@gravitee/ui-components 3.25.3-typescript-8a53edf → 3.25.3-typescript-9a4271f

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 (188) hide show
  1. package/package.json +1 -1
  2. package/src/atoms/gv-autocomplete.js +1 -461
  3. package/src/atoms/gv-button.js +1 -410
  4. package/src/atoms/gv-checkbox.js +1 -187
  5. package/src/atoms/gv-date-picker-calendar.js +1 -894
  6. package/src/atoms/gv-date-picker-cell.js +1 -190
  7. package/src/atoms/gv-date-picker.js +1 -671
  8. package/src/atoms/gv-file-upload.js +1 -367
  9. package/src/atoms/gv-icon.js +1 -103
  10. package/src/atoms/gv-image.js +1 -144
  11. package/src/atoms/gv-input-message.js +1 -84
  12. package/src/atoms/gv-input.js +1 -561
  13. package/src/atoms/gv-link.js +1 -210
  14. package/src/atoms/gv-message.js +1 -128
  15. package/src/atoms/gv-metric.js +1 -117
  16. package/src/atoms/gv-relative-time.js +1 -156
  17. package/src/atoms/gv-select-native.js +1 -388
  18. package/src/atoms/gv-select.js +1 -437
  19. package/src/atoms/gv-spinner.js +1 -57
  20. package/src/atoms/gv-state.js +1 -130
  21. package/src/atoms/gv-switch.js +1 -243
  22. package/src/atoms/gv-tag.js +1 -168
  23. package/src/atoms/gv-text.js +1 -168
  24. package/src/charts/gv-chart-bar.js +1 -103
  25. package/src/charts/gv-chart-gauge.js +1 -100
  26. package/src/charts/gv-chart-histogram.js +1 -83
  27. package/src/charts/gv-chart-line.js +1 -224
  28. package/src/charts/gv-chart-map.js +1 -112
  29. package/src/charts/gv-chart-pie.js +1 -91
  30. package/src/index.js +1 -77
  31. package/src/lib/cron-expression.js +1 -205
  32. package/src/lib/date.js +1 -44
  33. package/src/lib/events.js +1 -26
  34. package/src/lib/http-client-schema-form.js +1 -67
  35. package/src/lib/http.js +1 -237
  36. package/src/lib/i18n.js +1 -103
  37. package/src/lib/item.js +1 -118
  38. package/src/lib/properties.js +1 -189
  39. package/src/lib/schema-form.js +1 -44
  40. package/src/lib/studio.js +1 -141
  41. package/src/lib/style.js +1 -41
  42. package/src/lib/text-format.js +1 -69
  43. package/src/lib/theme.js +1 -63
  44. package/src/lib/utils.js +1 -111
  45. package/src/mixins/chart-element.js +1 -165
  46. package/src/mixins/input-element.js +1 -144
  47. package/src/mixins/item-resource.js +1 -120
  48. package/src/mixins/keyboard-element.js +1 -69
  49. package/src/mixins/update-after-browser.js +1 -30
  50. package/src/mixins/with-resize-observer.js +1 -68
  51. package/src/mixins/with-skeleton-attribute.js +1 -112
  52. package/src/molecules/gv-card-full.js +1 -218
  53. package/src/molecules/gv-card-list.js +1 -113
  54. package/src/molecules/gv-card.js +1 -133
  55. package/src/molecules/gv-category-list.js +1 -60
  56. package/src/molecules/gv-category.js +1 -170
  57. package/src/molecules/gv-code.js +1 -359
  58. package/src/molecules/gv-confirm.js +1 -188
  59. package/src/molecules/gv-cron-editor.js +1 -710
  60. package/src/molecules/gv-dropdown-menu.js +1 -116
  61. package/src/molecules/gv-expandable.js +1 -122
  62. package/src/molecules/gv-expression-language.js +1 -270
  63. package/src/molecules/gv-identity-picture.js +1 -148
  64. package/src/molecules/gv-list.js +1 -227
  65. package/src/molecules/gv-metrics.js +1 -162
  66. package/src/molecules/gv-modal.js +1 -213
  67. package/src/molecules/gv-nav.js +1 -196
  68. package/src/molecules/gv-option.js +1 -242
  69. package/src/molecules/gv-plans.js +1 -429
  70. package/src/molecules/gv-popover.js +1 -351
  71. package/src/molecules/gv-promote.js +1 -209
  72. package/src/molecules/gv-rating-list.js +1 -365
  73. package/src/molecules/gv-rating.js +1 -253
  74. package/src/molecules/gv-row-expandable.js +1 -45
  75. package/src/molecules/gv-row.js +1 -210
  76. package/src/molecules/gv-stats.js +1 -121
  77. package/src/molecules/gv-stepper.js +1 -288
  78. package/src/molecules/gv-table.js +1 -685
  79. package/src/molecules/gv-tree.js +1 -250
  80. package/src/organisms/gv-documentation.js +1 -215
  81. package/src/organisms/gv-header.js +1 -288
  82. package/src/organisms/gv-http-client.js +1 -275
  83. package/src/organisms/gv-menu.js +1 -263
  84. package/src/organisms/gv-newsletter-subscription.js +1 -271
  85. package/src/organisms/gv-pagination.js +1 -198
  86. package/src/organisms/gv-properties.js +1 -920
  87. package/src/organisms/gv-resizable-views.js +1 -396
  88. package/src/organisms/gv-resources.js +1 -535
  89. package/src/organisms/gv-schema-form-array.js +1 -250
  90. package/src/organisms/gv-schema-form-control-object.js +1 -154
  91. package/src/organisms/gv-schema-form-control.js +1 -443
  92. package/src/organisms/gv-schema-form.js +1 -751
  93. package/src/organisms/gv-tabs.js +1 -210
  94. package/src/organisms/gv-user-menu.js +1 -314
  95. package/src/organisms/gv-vertical-menu.js +1 -123
  96. package/src/policy-studio/gv-flow-step.js +1 -464
  97. package/src/policy-studio/gv-flow.js +1 -621
  98. package/src/policy-studio/gv-policy-studio-menu.js +1 -750
  99. package/src/policy-studio/gv-policy-studio.js +1 -1842
  100. package/src/styles/empty.js +1 -36
  101. package/src/styles/input.js +1 -263
  102. package/src/styles/link.js +1 -32
  103. package/src/styles/shapes.js +1 -17
  104. package/src/styles/skeleton.js +1 -53
  105. package/src/styles/zoom.js +1 -40
  106. package/src/theme/gv-theme.js +1 -203
  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
  184. package/CHANGELOG.md +0 -1292
  185. package/LICENSE.txt +0 -202
  186. package/README.md +0 -195
  187. package/src/.eslintrc.js +0 -19
  188. package/src/theme/definition.json +0 -1762
@@ -1,920 +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 { css, html, LitElement } from 'lit';
17
-
18
- import './gv-schema-form';
19
- import './gv-resizable-views';
20
- import '../molecules/gv-table';
21
- import '../atoms/gv-button';
22
- import '../atoms/gv-input';
23
- import '../atoms/gv-icon';
24
- import '../atoms/gv-text';
25
- import '../atoms/gv-input-message';
26
- import '../atoms/gv-select';
27
- import { dispatchCustomEvent } from '../lib/events';
28
- import { ERROR_TYPES, parseRaw, toNameEqualsValueString } from '../lib/properties';
29
- import { i18n } from '../lib/i18n';
30
- import { classMap } from 'lit/directives/class-map';
31
- import { KeyboardElement, KEYS } from '../mixins/keyboard-element';
32
- import { empty } from '../styles/empty';
33
-
34
- /**
35
- * A component to manage properties
36
- *
37
- * @fires gv-properties:change - When list of properties change
38
- * @fires gv-properties:save-provider - When user validates provider configuration
39
- * @fires gv-properties:switch-encrypted - When user switches encryption toggle
40
- *
41
- * @attr {Array} properties - Array of Properties {key, value, dynamic?}
42
- * @attr {Object} provider - Configuration of provider
43
- * @attr {Array} providers - List of available providers (only http for the moment)
44
- * @attr {Boolean} expert - For display expert mode by default
45
- * @attr {Boolean} encryptable - To display the 'encrypted' toggle on each property
46
- *
47
- * @cssprop {Length} [--gv-properties-table--colmg=0.2rem] - Table cells margin
48
- */
49
- export class GvProperties extends KeyboardElement(LitElement) {
50
- static get properties() {
51
- return {
52
- dynamicPropertySchema: { type: Object },
53
- properties: { type: Array },
54
- _properties: { type: Array, attribute: false },
55
- provider: { type: Object },
56
- providers: { type: Array },
57
- _propertySchemaForm: { type: Object, attribute: false },
58
- expert: { type: Boolean },
59
- _formattedErrors: { type: Array, attributes: false },
60
- _filter: { type: String },
61
- _paginationData: { type: Object, attribute: false },
62
- _pageSize: { type: Number, attribute: false },
63
- _newItem: { type: Object, attribute: false },
64
- _providerDocumentation: { type: Boolean, attribute: false },
65
- _showDocumentation: { type: Boolean, attribute: false },
66
- _textRows: { type: Number, attribute: false },
67
- readonly: { type: Boolean, reflect: true },
68
- encryptable: { type: Boolean, reflect: true },
69
- };
70
- }
71
-
72
- constructor() {
73
- super();
74
- this.properties = [];
75
- this.types = [];
76
- this.provider = {};
77
- this._currentResource = null;
78
- this._formattedErrors = [];
79
- this._showDocumentation = true;
80
- this._newItem = { key: '', value: '', _new: true };
81
- this._pageSize = 10;
82
- this._textRows = 10;
83
- this._pageSizes = [5, 10, 25, 50, 100];
84
- this._errors = [];
85
- }
86
-
87
- onKeyboard() {
88
- if (this.isPressed(KEYS.Esc)) {
89
- this._onClosePropertySchemaForm();
90
- }
91
- if (this.isPressed(KEYS.Shift, KEYS.Ctrl, KEYS.Space)) {
92
- const search = this.shadowRoot.querySelector('#search-property');
93
- if (search) {
94
- search.focus();
95
- }
96
- }
97
- }
98
-
99
- set properties(properties) {
100
- this._properties = properties
101
- .sort((a, b) => a.key.localeCompare(b.key))
102
- .map((property) => {
103
- if (property.encrypted) {
104
- property.encryptable = true;
105
- }
106
- return property;
107
- });
108
- }
109
-
110
- get properties() {
111
- return this._properties;
112
- }
113
-
114
- _getResizableViews() {
115
- return this.shadowRoot.querySelector('gv-resizable-views');
116
- }
117
-
118
- _maximizeTopView() {
119
- const views = this._getResizableViews();
120
- if (views) {
121
- views.maximizeTop(95, 5);
122
- }
123
- }
124
-
125
- _maximizeBottomView() {
126
- const views = this._getResizableViews();
127
- if (views) {
128
- views.resize(30, 70);
129
- }
130
- }
131
-
132
- _splitMainViews() {
133
- const views = this._getResizableViews();
134
- if (views) {
135
- views.split();
136
- }
137
- }
138
-
139
- _isNewLineTable(line) {
140
- return line._new === true;
141
- }
142
-
143
- _onInputNew(name, event) {
144
- const target = event.target;
145
- this._newItem[name] = event.detail;
146
- const { errors } = parseRaw(toNameEqualsValueString([...this.properties, this._newItem]));
147
- this._errors = errors;
148
- setTimeout(() => {
149
- const btn = this.shadowRoot.querySelector('gv-button#add-property');
150
- if (errors.length > 0 || this._disabledNewLine(this._newItem)) {
151
- btn.setAttribute('disabled', true);
152
- } else {
153
- btn.removeAttribute('disabled');
154
- }
155
- if (name === 'key') {
156
- if (errors.length === 0) {
157
- target.removeAttribute('invalid');
158
- target.setAttribute('valid', true);
159
- } else {
160
- target.removeAttribute('valid');
161
- target.setAttribute('invalid', true);
162
- }
163
- }
164
- }, 0);
165
- }
166
-
167
- _onInput() {
168
- dispatchCustomEvent(this, 'change', { properties: this.properties });
169
- }
170
-
171
- _onSwitchEncrypted(item) {
172
- if (item.encrypted === true) {
173
- item.value = '';
174
- item.encrypted = false;
175
- item.encryptionWarning = i18n('gv-properties.infos.overwrite-encryption');
176
- this.requestUpdate();
177
- }
178
- dispatchCustomEvent(this, 'switch-encrypted', { properties: this.properties });
179
- }
180
-
181
- _addProperty(item) {
182
- delete item._new;
183
- this.properties = [item, ...this._properties];
184
- this._newItem = { key: '', value: '', _new: true, encryptable: false, encrypted: false };
185
- dispatchCustomEvent(this, 'change', { properties: this.properties });
186
- }
187
-
188
- _removeProperty(item) {
189
- this._properties = this._properties.filter((property) => property.key !== item.key);
190
- dispatchCustomEvent(this, 'change', { properties: this.properties });
191
- }
192
-
193
- _disabledNewLine(item) {
194
- return item.key == null || item.value == null || item.key.trim() === '' || item.value.trim() === '';
195
- }
196
-
197
- _submitExpertMode() {
198
- if (this.expert) {
199
- this.properties = this._handleExpertModeInput(this.shadowRoot.querySelector('#expert-input').value);
200
- }
201
- }
202
-
203
- _onExpertModeTextInput({ detail }) {
204
- this._handleExpertModeInput(detail);
205
- }
206
-
207
- _handleExpertModeInput(expertModeInputString) {
208
- let allProperties = this._properties;
209
- const providerEnabled = this.provider && this.provider.enabled;
210
- const dynamicProperties = allProperties.filter((prop) => providerEnabled && prop.dynamic);
211
- const encryptedProperties = allProperties.filter((prop) => prop.encrypted);
212
-
213
- const allPropertiesString = `${expertModeInputString}\n${toNameEqualsValueString(dynamicProperties)}\n${toNameEqualsValueString(
214
- encryptedProperties,
215
- )}`;
216
- const { errors } = parseRaw(allPropertiesString);
217
- this._errors = errors;
218
- if (errors.length === 0) {
219
- const { variables } = parseRaw(expertModeInputString);
220
- allProperties = [...variables, ...dynamicProperties, ...encryptedProperties];
221
- dispatchCustomEvent(this, 'change', { properties: allProperties });
222
- }
223
-
224
- return allProperties;
225
- }
226
-
227
- _onSubmitPropertyForm({ detail }) {
228
- const provider = detail.values;
229
- dispatchCustomEvent(this, 'save-provider', { provider });
230
- this.requestUpdate();
231
- }
232
-
233
- submit() {
234
- if (this.expert) {
235
- this._submitExpertMode();
236
- } else {
237
- this._onSubmit();
238
- }
239
- }
240
-
241
- _onSubmit() {
242
- const invalidControls = [...this.shadowRoot.querySelectorAll('form .control')].find((control) => control.invalid);
243
- if (invalidControls == null) {
244
- this._addProperty(this._newItem);
245
- }
246
- }
247
-
248
- _onConfigureDynamicProperties() {
249
- if (this.dynamicPropertySchema == null) {
250
- // dynamicPropertySchema has been introduced to ensure backward compatibility with old versions. If no schema is provided a default schema will be used.
251
- const providersTitleMap = this.providers.reduce((map, provider) => {
252
- map[provider.id] = provider.key;
253
- return map;
254
- }, {});
255
-
256
- const providersEnum = Object.keys(providersTitleMap);
257
- this.dynamicPropertySchema = {
258
- properties: {
259
- enabled: {
260
- type: 'boolean',
261
- title: 'Enabled',
262
- description: ' This service is requiring an API deployment. Do not forget to deploy API to start dynamic-properties service.',
263
- },
264
- schedule: {
265
- type: 'string',
266
- title: 'Schedule',
267
- 'x-schema-form': {
268
- 'cron-expression': true,
269
- },
270
- },
271
- provider: {
272
- type: 'string',
273
- title: 'Provider type',
274
- enum: providersEnum,
275
- default: providersEnum[0],
276
- 'x-schema-form': {
277
- titleMap: providersTitleMap,
278
- },
279
- },
280
- },
281
- required: ['schedule', 'provider'],
282
- };
283
- }
284
-
285
- const defaultProvider = this.providers[0];
286
-
287
- this._propertySchemaForm = {
288
- properties: { ...this.dynamicPropertySchema.properties, configuration: defaultProvider.schema },
289
- required: this.dynamicPropertySchema.required,
290
- };
291
- this._providerDocumentation = defaultProvider.documentation;
292
- this._maximizeBottomView();
293
- }
294
-
295
- _onClosePropertySchemaForm() {
296
- this._propertySchemaForm = null;
297
- this._maximizeTopView();
298
- }
299
-
300
- _onSearchProperty({ detail }) {
301
- this._filter = detail;
302
- this._onClosePropertySchemaForm();
303
- }
304
-
305
- _onClearProperty() {
306
- this._filter = null;
307
- this._onClosePropertySchemaForm();
308
- }
309
-
310
- get _errors() {
311
- return this._formattedErrors;
312
- }
313
-
314
- set _errors(rawErrors) {
315
- this._formattedErrors = rawErrors.map(({ type, key, pos }) => {
316
- if (type === ERROR_TYPES.INVALID_NAME) {
317
- return {
318
- line: pos.line,
319
- msg: i18n('gv-properties.errors.invalid-key', { key }),
320
- };
321
- }
322
- if (type === ERROR_TYPES.DUPLICATED_NAME) {
323
- return {
324
- line: pos.line,
325
- msg: i18n('gv-properties.errors.duplicated-key', { key }),
326
- };
327
- }
328
- if (type === ERROR_TYPES.INVALID_LINE) {
329
- return {
330
- line: pos.line,
331
- msg: i18n('gv-properties.errors.invalid-line'),
332
- };
333
- }
334
- if (type === ERROR_TYPES.INVALID_VALUE) {
335
- return {
336
- line: pos.line,
337
- msg: i18n('gv-properties.errors.invalid-value'),
338
- };
339
- }
340
- return { line: '?', msg: i18n('gv-properties.errors.unknown') };
341
- });
342
- }
343
-
344
- _renderErrors(withLine = false) {
345
- if (this._formattedErrors.length > 0) {
346
- return html`<div class="${classMap({ 'add-form-error': true, 'add-form-error_expert': this.expert })}">
347
- <div></div>
348
- <div class="error-list">
349
- ${this._formattedErrors.map(
350
- ({ line, msg }) => html`
351
- <gv-input-message
352
- >${withLine ? html`<strong .innerHTML="${i18n('gv-properties.errors.line')} ${line}:&nbsp;"></strong>` : ''}
353
- <span .innerHTML="${msg}"></span
354
- ></gv-input-message>
355
- `,
356
- )}
357
- </div>
358
- </div>`;
359
- }
360
- return html``;
361
- }
362
-
363
- _renderTable() {
364
- const providerEnabled = this.provider && this.provider.enabled;
365
- if (this.expert) {
366
- this._computeTextRows();
367
-
368
- const staticProperties = providerEnabled ? this._properties.filter((prop) => !(providerEnabled && prop.dynamic)) : this._properties;
369
- const expertProperties = staticProperties.filter((prop) => !prop.encrypted);
370
- const content = expertProperties.map((prop) => `${prop.key}="${prop.value}"`).join('\n');
371
-
372
- return html`<gv-text
373
- id="expert-input"
374
- placeholder="${i18n('gv-properties.placeholder.input')}"
375
- @gv-text:input="${this._onExpertModeTextInput}"
376
- .value="${content}"
377
- ?readonly="${this.readonly}"
378
- .rows="${this._textRows}"
379
- ></gv-text>
380
- ${this._renderErrors(true)}`;
381
- } else {
382
- const options = {
383
- data: [
384
- {
385
- field: 'dynamic',
386
- label: 'Dynamic',
387
- width: '40px',
388
- type: (item) => (item.dynamic && providerEnabled ? 'gv-icon' : 'div'),
389
- attributes: {
390
- shape: (item) => (item.dynamic && providerEnabled ? 'code:time-schedule' : ''),
391
- title: (item) => (item.dynamic && providerEnabled ? 'Dynamic properties service is actually in running' : ''),
392
- style: 'justify-content: center; align-items: center; height: 100%;',
393
- },
394
- },
395
- {
396
- field: 'key',
397
- label: 'Key',
398
- type: 'gv-input',
399
- attributes: {
400
- clipboard: true,
401
- placeholder: i18n('gv-properties.placeholder.key'),
402
- name: 'key',
403
- required: true,
404
- readonly: this.readonly,
405
- },
406
- },
407
- {
408
- field: 'value',
409
- label: 'Value',
410
- type: 'gv-input',
411
- attributes: {
412
- name: 'value',
413
- placeholder: 'Property value',
414
- required: true,
415
- readonly: this.readonly,
416
- disabled: (item) => (item.dynamic && providerEnabled) || item.encrypted,
417
- type: (item) => (item.encrypted ? 'password' : 'text'),
418
- title: (item) => (item.encrypted ? i18n('gv-properties.infos.encrypted-value') : ''),
419
- description: (item) => item.encryptionWarning,
420
- icon: null,
421
- 'ongv-input:input': this._onInput.bind(this),
422
- },
423
- },
424
- ],
425
- };
426
-
427
- if (this.encryptable === true) {
428
- options.data.push({
429
- field: 'encryptable',
430
- type: 'gv-switch',
431
- style: '--gv-switch--ta: right;',
432
- width: '105px',
433
- attributes: {
434
- description: i18n('gv-properties.encrypted-toggle'),
435
- required: true,
436
- readonly: this.readonly,
437
- disabled: (item) => item.dynamic && providerEnabled,
438
- 'ongv-switch:input': this._onSwitchEncrypted.bind(this),
439
- style: 'display: inline-flex; font-size: 12px; height: 40px;',
440
- },
441
- });
442
- }
443
-
444
- if (this.readonly !== true) {
445
- options.data.push({
446
- type: 'gv-button',
447
- width: '40px',
448
- attributes: {
449
- 'ongv-button:click': (item, event, target) => this._removeProperty(item, target),
450
- title: 'Remove',
451
- disabled: (item) => item.dynamic && providerEnabled,
452
- danger: true,
453
- outlined: true,
454
- icon: 'home:trash',
455
- },
456
- });
457
- }
458
-
459
- const filteredProperties =
460
- this._filter != null
461
- ? this._properties.filter((prop) => {
462
- return (prop.key.toLowerCase() + prop.value.toLowerCase()).includes(this._filter);
463
- })
464
- : this._properties;
465
- let properties = [...filteredProperties];
466
- if (this._paginationData) {
467
- this._paginationData.last = Math.ceil(filteredProperties.length / this._pageSize);
468
- this._paginationData.total = filteredProperties.length;
469
- this._paginationData.total_pages = Math.ceil(filteredProperties.length / this._pageSize);
470
- const index = (this._paginationData.current_page - 1) * this._pageSize;
471
- properties = [...filteredProperties].splice(index, this._pageSize);
472
- }
473
-
474
- const addPropertyFormGridClass = this.encryptable ? 'add-form-grid-with-encrypted-toggle' : 'add-form-grid';
475
-
476
- const addPropertyForm =
477
- this.readonly !== true
478
- ? html`<form id="add-property-form" class="add-form ${addPropertyFormGridClass}" @submit="${this._onSubmit}">
479
- <div></div>
480
- <gv-input
481
- class="control"
482
- placeholder="${i18n('gv-properties.placeholder.key')}"
483
- required
484
- @gv-input:input="${this._onInputNew.bind(this, 'key')}"
485
- value="${this._newItem.key}"
486
- ></gv-input>
487
- <gv-input
488
- class="control"
489
- placeholder="${i18n('gv-properties.placeholder.value')}"
490
- required
491
- @gv-input:input="${this._onInputNew.bind(this, 'value')}"
492
- .value="${this._newItem.value}"
493
- ></gv-input>
494
- ${this.encryptable
495
- ? html` <gv-switch
496
- class="control"
497
- required
498
- description="${i18n('gv-properties.encrypted-toggle')}"
499
- @gv-switch:input="${this._onInputNew.bind(this, 'encryptable')}"
500
- .value="${this._newItem.encryptable}"
501
- ></gv-switch>`
502
- : ''}
503
- <gv-button
504
- id="add-property"
505
- icon="code:plus"
506
- outlined
507
- disabled
508
- @gv-button:click="${this._addProperty.bind(this, this._newItem)}"
509
- title="${i18n('gv-properties.add')}"
510
- ></gv-button>
511
- </form>
512
- ${this._renderErrors()}
513
- <hr />`
514
- : '';
515
-
516
- return html` ${addPropertyForm}
517
- <gv-table .options="${options}" .items="${properties}" noheader nosort order="key" rowheight="57px"></gv-table>`;
518
- }
519
- }
520
-
521
- _onChangeMode({ detail }) {
522
- this._submitExpertMode();
523
- this.expert = detail;
524
- this._errors = [];
525
- this._newItem = { key: '', value: '', _new: true };
526
- this._onClosePropertySchemaForm();
527
- }
528
-
529
- _onPaginate({ detail }) {
530
- this._paginationData.current_page = detail.page;
531
- this._onClosePropertySchemaForm();
532
- this.requestUpdate();
533
- }
534
-
535
- updated(props) {
536
- if (props.has('_properties') || props.has('_pageSize')) {
537
- this._paginationData = {
538
- first: 1,
539
- last: Math.ceil(this._properties.length / this._pageSize),
540
- total: this._properties.length,
541
- current_page: 1,
542
- total_pages: Math.ceil(this._properties.length / this._pageSize),
543
- };
544
- }
545
- }
546
-
547
- _onChangePageSize({ detail }) {
548
- this._pageSize = Number(detail).valueOf();
549
- this._onClosePropertySchemaForm();
550
- }
551
-
552
- _renderTableForm() {
553
- return html`<div class="container">
554
- <div class="header">
555
- <div class="title">Manage global properties <span>(${this._properties ? this._properties.length : 0})</span></div>
556
- <gv-switch
557
- small
558
- .description="${this.expert ? 'Expert' : 'Simple'}"
559
- .value="${this.expert}"
560
- @gv-switch:input="${this._onChangeMode}"
561
- ></gv-switch>
562
- <gv-input
563
- id="search-property"
564
- placeholder="Filter properties (Shift + Ctrl + Space)"
565
- type="search"
566
- small
567
- class="search-input"
568
- .disabled="${this.expert}"
569
- @gv-input:input="${this._onSearchProperty}"
570
- @gv-input:clear="${this._onClearProperty}"
571
- ></gv-input>
572
- <gv-select
573
- class="page-size__select"
574
- @gv-select:input="${this._onChangePageSize}"
575
- small
576
- .options="${this._pageSizes}"
577
- .value="${this._pageSize}"
578
- .disabled="${this.expert || this._paginationData == null}"
579
- ></gv-select>
580
- <gv-pagination
581
- @gv-pagination:paginate="${this._onPaginate}"
582
- .disabled="${this.expert || this._paginationData == null}"
583
- .data="${this._paginationData}"
584
- widget
585
- ></gv-pagination>
586
- </div>
587
- <div class="content"><div class="form-content">${this._renderTable()}</div></div>
588
- </div>`;
589
- }
590
-
591
- _fetchDocumentation() {
592
- this._showDocumentation = true;
593
- }
594
-
595
- _hideDocumentation() {
596
- this._showDocumentation = false;
597
- }
598
-
599
- get dirty() {
600
- const form = this.shadowRoot.querySelector('gv-schema-form');
601
- return form && form.dirty;
602
- }
603
-
604
- confirm() {
605
- const form = this.shadowRoot.querySelector('gv-schema-form');
606
- if (form) {
607
- return form.confirm().then(() => this._onClosePropertySchemaForm());
608
- }
609
- return Promise.resolve();
610
- }
611
-
612
- _renderForm() {
613
- return html`<gv-schema-form
614
- slot="top"
615
- scrollable
616
- .schema="${this._propertySchemaForm}"
617
- .values="${this.provider}"
618
- .icon="design:edit"
619
- has-header
620
- ?readonly="${this.readonly}"
621
- @gv-schema-form:submit="${this._onSubmitPropertyForm}"
622
- >
623
- <div slot="title" class="properties-title">Configure dynamic properties</div>
624
- <gv-button
625
- slot="header-left"
626
- icon="general:close"
627
- outlined
628
- small
629
- @gv-button:click="${this._onClosePropertySchemaForm}"
630
- title="Close (esc)"
631
- ></gv-button>
632
- <gv-button
633
- slot="header-left"
634
- icon="home:book"
635
- ?disabled="${this._showDocumentation}"
636
- outlined
637
- small
638
- @gv-button:click="${this._fetchDocumentation}"
639
- title="Open documentation"
640
- ></gv-button>
641
- </gv-schema-form>`;
642
- }
643
-
644
- _renderBottom() {
645
- if (this._propertySchemaForm && this._showDocumentation) {
646
- return html`<gv-resizable-views no-overflow direction="horizontal">
647
- ${this._renderForm()}
648
- <gv-documentation
649
- slot="bottom"
650
- .text="${this._providerDocumentation}"
651
- @gv-documentation:close="${this._hideDocumentation}"
652
- ></gv-documentation>
653
- </gv-resizable-views>`;
654
- } else if (this._propertySchemaForm) {
655
- return this._renderForm();
656
- } else {
657
- return html`<div class="properties-bottom-container">${this._renderDynamicConfiguration()}</div>`;
658
- }
659
- }
660
-
661
- _renderDynamicConfiguration() {
662
- const hasDynamicConfiguration = this.provider && this.provider.enabled;
663
-
664
- let configureAction = '';
665
- if (hasDynamicConfiguration || this.readonly !== true) {
666
- configureAction = html`<gv-button
667
- icon="tools:tools"
668
- @gv-button:click="${this._onConfigureDynamicProperties}"
669
- outlined
670
- .disabled="${this.expert}"
671
- >Configure dynamic properties</gv-button
672
- >`;
673
- }
674
-
675
- if (hasDynamicConfiguration) {
676
- return html`<div class="properties-message">
677
- Dynamic properties service is actually in <code>running</code> state and run with cron expression
678
- <code>${this.provider.schedule}</code> using <code>${this.provider.provider}</code> provider.
679
- </div>
680
- ${configureAction}`;
681
- } else if (this.readonly) {
682
- return html`<div class="empty">No dynamic properties service configured</div>`;
683
- } else {
684
- return configureAction;
685
- }
686
- }
687
-
688
- _onMove() {
689
- this._computeTextRows();
690
- }
691
-
692
- _computeTextRows() {
693
- const parent = this.shadowRoot.querySelector('.content');
694
- if (parent) {
695
- const { height } = parent.getBoundingClientRect();
696
- // --gv-text--lh=30px
697
- this._textRows = Math.round(Math.round(height - 20) / 30) - 2;
698
- }
699
- }
700
-
701
- render() {
702
- if (this.providers && this.providers.length > 0) {
703
- return html`<div class="properties">
704
- <gv-resizable-views no-overflow @gv-resizable-views:move="${this._onMove}" @gv-resizable-views:resize="${this._onMove}">
705
- <div slot="top" class="box">${this._renderTableForm()}</div>
706
- <div slot="bottom">${this._renderBottom()}</div>
707
- </gv-resizable-views>
708
- </div>`;
709
- } else {
710
- return html`<div class="properties">
711
- <div class="table-box">${this._renderTableForm()}</div>
712
- </div>`;
713
- }
714
- }
715
-
716
- static get styles() {
717
- return [
718
- empty,
719
- // language=CSS
720
- css`
721
- :host {
722
- box-sizing: border-box;
723
- height: 100%;
724
- width: 100%;
725
- display: block;
726
- }
727
-
728
- .properties {
729
- display: flex;
730
- height: 100%;
731
- width: 100%;
732
- }
733
-
734
- gv-resizable-views {
735
- height: 100%;
736
- width: 100%;
737
- }
738
-
739
- gv-schema-form {
740
- margin: 0;
741
- }
742
-
743
- .table-box {
744
- width: 100%;
745
- border-left: 1px solid #bfbfbf;
746
- display: flex;
747
- }
748
-
749
- gv-table {
750
- height: auto;
751
- flex: 1;
752
- margin-top: 10px;
753
- margin-right: 50px;
754
- --gv-table-rows--ov: none;
755
- --gv-table--colmg: var(--gv-properties-table--colmg, 0.2rem);
756
- --gv-table-cell--d: inline;
757
- --gv-table-row--ai: flex-start;
758
- --gv-table-row--ac: flex-start;
759
- --gv-table-hover--bgc: var(--gv-theme-neutral-color-lightest);
760
- }
761
-
762
- .properties-title {
763
- text-transform: uppercase;
764
- letter-spacing: 0.2rem;
765
- }
766
-
767
- .properties-bottom-container {
768
- display: flex;
769
- justify-content: center;
770
- align-items: center;
771
- height: 100%;
772
- flex-direction: column;
773
- }
774
-
775
- .header {
776
- border-bottom: 1px solid #d9d9d9;
777
- display: flex;
778
- min-height: 45px;
779
- align-items: center;
780
- margin-bottom: 0.5rem;
781
- padding: 0 0.5rem;
782
- }
783
-
784
- .header .title {
785
- color: #28444f;
786
- font-size: 18px;
787
- display: flex;
788
- align-items: flex-end;
789
- flex: 1;
790
- }
791
-
792
- .header .title span {
793
- font-size: 12px;
794
- margin-left: 8px;
795
- opacity: 0.7;
796
- }
797
-
798
- .box {
799
- position: absolute;
800
- display: flex;
801
- flex-direction: column;
802
- width: 100%;
803
- top: 0;
804
- bottom: 0;
805
- left: 0;
806
- }
807
-
808
- .container {
809
- flex-grow: 1;
810
-
811
- display: flex;
812
- flex-direction: column;
813
-
814
- /* for Firefox */
815
- min-height: 0;
816
- height: 100%;
817
- }
818
-
819
- .content {
820
- background: white;
821
- flex-grow: 1;
822
-
823
- overflow: auto;
824
-
825
- /* for Firefox */
826
- min-height: 0;
827
- padding: 0.5rem;
828
-
829
- display: flex;
830
- flex-direction: column;
831
- align-items: center;
832
- }
833
-
834
- gv-text {
835
- --gv-text--fz: 20px;
836
- --gv-text--lh: 25px;
837
- }
838
-
839
- gv-switch {
840
- --gv-switch--ta: right;
841
- }
842
-
843
- .header gv-input {
844
- margin: 0 1rem;
845
- }
846
-
847
- .add-form,
848
- .add-form-error {
849
- display: grid;
850
- margin: auto 50px auto 0;
851
- box-sizing: border-box;
852
- }
853
-
854
- .add-form {
855
- column-gap: var(--gv-properties-table--colmg, 0.2rem);
856
- border-right: solid thick transparent;
857
- height: 50px;
858
- }
859
-
860
- .add-form gv-input,
861
- gv-button,
862
- gv-switch {
863
- margin: auto 0;
864
- }
865
-
866
- .add-form gv-switch {
867
- font-size: 12px;
868
- }
869
-
870
- .add-form-grid {
871
- grid-template-columns: 40px auto auto 40px;
872
- }
873
-
874
- .add-form-grid-with-encrypted-toggle {
875
- grid-template-columns: 40px auto auto 105px 40px;
876
- }
877
-
878
- .add-form-error_expert {
879
- display: flex;
880
- }
881
-
882
- .add-form-error {
883
- grid-template-columns: 40px 1fr;
884
- }
885
-
886
- code {
887
- color: var(--gv-theme-color-warning-dark, #f57c00);
888
- }
889
-
890
- .form-content {
891
- display: flex;
892
- flex-direction: column;
893
- width: 100%;
894
- }
895
-
896
- .properties-message {
897
- margin-bottom: 0.5rem;
898
- font-size: 14px;
899
- }
900
-
901
- .page-size__select {
902
- max-width: 50px;
903
- }
904
-
905
- .search-input {
906
- width: 300px;
907
- }
908
-
909
- hr {
910
- background-color: var(--gv-theme-neutral-color);
911
- border: 0;
912
- width: 100%;
913
- height: 2px;
914
- }
915
- `,
916
- ];
917
- }
918
- }
919
-
920
- window.customElements.define('gv-properties', GvProperties);
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvProperties=void 0;const e=require("lit");require("./gv-schema-form"),require("./gv-resizable-views"),require("../molecules/gv-table"),require("../atoms/gv-button"),require("../atoms/gv-input"),require("../atoms/gv-icon"),require("../atoms/gv-text"),require("../atoms/gv-input-message"),require("../atoms/gv-select");const t=require("../lib/events"),i=require("../lib/properties"),r=require("../lib/i18n"),o=require("lit/directives/class-map"),s=require("../mixins/keyboard-element"),n=require("../styles/empty");class a extends((0,s.KeyboardElement)(e.LitElement)){static get properties(){return{dynamicPropertySchema:{type:Object},properties:{type:Array},_properties:{type:Array,attribute:!1},provider:{type:Object},providers:{type:Array},_propertySchemaForm:{type:Object,attribute:!1},expert:{type:Boolean},_formattedErrors:{type:Array,attributes:!1},_filter:{type:String},_paginationData:{type:Object,attribute:!1},_pageSize:{type:Number,attribute:!1},_newItem:{type:Object,attribute:!1},_providerDocumentation:{type:Boolean,attribute:!1},_showDocumentation:{type:Boolean,attribute:!1},_textRows:{type:Number,attribute:!1},readonly:{type:Boolean,reflect:!0},encryptable:{type:Boolean,reflect:!0}}}constructor(){super(),this.properties=[],this.types=[],this.provider={},this._currentResource=null,this._formattedErrors=[],this._showDocumentation=!0,this._newItem={key:"",value:"",_new:!0},this._pageSize=10,this._textRows=10,this._pageSizes=[5,10,25,50,100],this._errors=[]}onKeyboard(){if(this.isPressed(s.KEYS.Esc)&&this._onClosePropertySchemaForm(),this.isPressed(s.KEYS.Shift,s.KEYS.Ctrl,s.KEYS.Space)){const e=this.shadowRoot.querySelector("#search-property");e&&e.focus()}}set properties(e){this._properties=e.sort(((e,t)=>e.key.localeCompare(t.key))).map((e=>(e.encrypted&&(e.encryptable=!0),e)))}get properties(){return this._properties}_getResizableViews(){return this.shadowRoot.querySelector("gv-resizable-views")}_maximizeTopView(){const e=this._getResizableViews();e&&e.maximizeTop(95,5)}_maximizeBottomView(){const e=this._getResizableViews();e&&e.resize(30,70)}_splitMainViews(){const e=this._getResizableViews();e&&e.split()}_isNewLineTable(e){return!0===e._new}_onInputNew(e,t){const r=t.target;this._newItem[e]=t.detail;const{errors:o}=(0,i.parseRaw)((0,i.toNameEqualsValueString)([...this.properties,this._newItem]));this._errors=o,setTimeout((()=>{const t=this.shadowRoot.querySelector("gv-button#add-property");o.length>0||this._disabledNewLine(this._newItem)?t.setAttribute("disabled",!0):t.removeAttribute("disabled"),"key"===e&&(0===o.length?(r.removeAttribute("invalid"),r.setAttribute("valid",!0)):(r.removeAttribute("valid"),r.setAttribute("invalid",!0)))}),0)}_onInput(){(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_onSwitchEncrypted(e){!0===e.encrypted&&(e.value="",e.encrypted=!1,e.encryptionWarning=(0,r.i18n)("gv-properties.infos.overwrite-encryption"),this.requestUpdate()),(0,t.dispatchCustomEvent)(this,"switch-encrypted",{properties:this.properties})}_addProperty(e){delete e._new,this.properties=[e,...this._properties],this._newItem={key:"",value:"",_new:!0,encryptable:!1,encrypted:!1},(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_removeProperty(e){this._properties=this._properties.filter((t=>t.key!==e.key)),(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_disabledNewLine(e){return null==e.key||null==e.value||""===e.key.trim()||""===e.value.trim()}_submitExpertMode(){this.expert&&(this.properties=this._handleExpertModeInput(this.shadowRoot.querySelector("#expert-input").value))}_onExpertModeTextInput({detail:e}){this._handleExpertModeInput(e)}_handleExpertModeInput(e){let r=this._properties;const o=this.provider&&this.provider.enabled,s=r.filter((e=>o&&e.dynamic)),n=r.filter((e=>e.encrypted)),a=`${e}\n${(0,i.toNameEqualsValueString)(s)}\n${(0,i.toNameEqualsValueString)(n)}`,{errors:p}=(0,i.parseRaw)(a);if(this._errors=p,0===p.length){const{variables:o}=(0,i.parseRaw)(e);r=[...o,...s,...n],(0,t.dispatchCustomEvent)(this,"change",{properties:r})}return r}_onSubmitPropertyForm({detail:e}){const i=e.values;(0,t.dispatchCustomEvent)(this,"save-provider",{provider:i}),this.requestUpdate()}submit(){this.expert?this._submitExpertMode():this._onSubmit()}_onSubmit(){null==[...this.shadowRoot.querySelectorAll("form .control")].find((e=>e.invalid))&&this._addProperty(this._newItem)}_onConfigureDynamicProperties(){if(null==this.dynamicPropertySchema){const e=this.providers.reduce(((e,t)=>(e[t.id]=t.key,e)),{}),t=Object.keys(e);this.dynamicPropertySchema={properties:{enabled:{type:"boolean",title:"Enabled",description:" This service is requiring an API deployment. Do not forget to deploy API to start dynamic-properties service."},schedule:{type:"string",title:"Schedule","x-schema-form":{"cron-expression":!0}},provider:{type:"string",title:"Provider type",enum:t,default:t[0],"x-schema-form":{titleMap:e}}},required:["schedule","provider"]}}const e=this.providers[0];this._propertySchemaForm={properties:{...this.dynamicPropertySchema.properties,configuration:e.schema},required:this.dynamicPropertySchema.required},this._providerDocumentation=e.documentation,this._maximizeBottomView()}_onClosePropertySchemaForm(){this._propertySchemaForm=null,this._maximizeTopView()}_onSearchProperty({detail:e}){this._filter=e,this._onClosePropertySchemaForm()}_onClearProperty(){this._filter=null,this._onClosePropertySchemaForm()}get _errors(){return this._formattedErrors}set _errors(e){this._formattedErrors=e.map((({type:e,key:t,pos:o})=>e===i.ERROR_TYPES.INVALID_NAME?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-key",{key:t})}:e===i.ERROR_TYPES.DUPLICATED_NAME?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.duplicated-key",{key:t})}:e===i.ERROR_TYPES.INVALID_LINE?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-line")}:e===i.ERROR_TYPES.INVALID_VALUE?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-value")}:{line:"?",msg:(0,r.i18n)("gv-properties.errors.unknown")}))}_renderErrors(t=!1){return this._formattedErrors.length>0?e.html`<div class="${(0,o.classMap)({"add-form-error":!0,"add-form-error_expert":this.expert})}"><div></div><div class="error-list">${this._formattedErrors.map((({line:i,msg:o})=>e.html`<gv-input-message>${t?e.html`<strong .innerHTML="${(0,r.i18n)("gv-properties.errors.line")} ${i}: "></strong>`:""} <span .innerHTML="${o}"></span></gv-input-message>`))}</div></div>`:e.html``}_renderTable(){const t=this.provider&&this.provider.enabled;if(this.expert){this._computeTextRows();const i=(t?this._properties.filter((e=>!(t&&e.dynamic))):this._properties).filter((e=>!e.encrypted)).map((e=>`${e.key}="${e.value}"`)).join("\n");return e.html`<gv-text id="expert-input" placeholder="${(0,r.i18n)("gv-properties.placeholder.input")}" @gv-text:input="${this._onExpertModeTextInput}" .value="${i}" ?readonly="${this.readonly}" .rows="${this._textRows}"></gv-text>${this._renderErrors(!0)}`}{const i={data:[{field:"dynamic",label:"Dynamic",width:"40px",type:e=>e.dynamic&&t?"gv-icon":"div",attributes:{shape:e=>e.dynamic&&t?"code:time-schedule":"",title:e=>e.dynamic&&t?"Dynamic properties service is actually in running":"",style:"justify-content: center; align-items: center; height: 100%;"}},{field:"key",label:"Key",type:"gv-input",attributes:{clipboard:!0,placeholder:(0,r.i18n)("gv-properties.placeholder.key"),name:"key",required:!0,readonly:this.readonly}},{field:"value",label:"Value",type:"gv-input",attributes:{name:"value",placeholder:"Property value",required:!0,readonly:this.readonly,disabled:e=>e.dynamic&&t||e.encrypted,type:e=>e.encrypted?"password":"text",title:e=>e.encrypted?(0,r.i18n)("gv-properties.infos.encrypted-value"):"",description:e=>e.encryptionWarning,icon:null,"ongv-input:input":this._onInput.bind(this)}}]};!0===this.encryptable&&i.data.push({field:"encryptable",type:"gv-switch",style:"--gv-switch--ta: right;",width:"105px",attributes:{description:(0,r.i18n)("gv-properties.encrypted-toggle"),required:!0,readonly:this.readonly,disabled:e=>e.dynamic&&t,"ongv-switch:input":this._onSwitchEncrypted.bind(this),style:"display: inline-flex; font-size: 12px; height: 40px;"}}),!0!==this.readonly&&i.data.push({type:"gv-button",width:"40px",attributes:{"ongv-button:click":(e,t,i)=>this._removeProperty(e,i),title:"Remove",disabled:e=>e.dynamic&&t,danger:!0,outlined:!0,icon:"home:trash"}});const o=null!=this._filter?this._properties.filter((e=>(e.key.toLowerCase()+e.value.toLowerCase()).includes(this._filter))):this._properties;let s=[...o];if(this._paginationData){this._paginationData.last=Math.ceil(o.length/this._pageSize),this._paginationData.total=o.length,this._paginationData.total_pages=Math.ceil(o.length/this._pageSize);const e=(this._paginationData.current_page-1)*this._pageSize;s=[...o].splice(e,this._pageSize)}const n=this.encryptable?"add-form-grid-with-encrypted-toggle":"add-form-grid",a=!0!==this.readonly?e.html`<form id="add-property-form" class="add-form ${n}" @submit="${this._onSubmit}"><div></div><gv-input class="control" placeholder="${(0,r.i18n)("gv-properties.placeholder.key")}" required @gv-input:input="${this._onInputNew.bind(this,"key")}" value="${this._newItem.key}"></gv-input><gv-input class="control" placeholder="${(0,r.i18n)("gv-properties.placeholder.value")}" required @gv-input:input="${this._onInputNew.bind(this,"value")}" .value="${this._newItem.value}"></gv-input>${this.encryptable?e.html`<gv-switch class="control" required description="${(0,r.i18n)("gv-properties.encrypted-toggle")}" @gv-switch:input="${this._onInputNew.bind(this,"encryptable")}" .value="${this._newItem.encryptable}"></gv-switch>`:""}<gv-button id="add-property" icon="code:plus" outlined disabled="disabled" @gv-button:click="${this._addProperty.bind(this,this._newItem)}" title="${(0,r.i18n)("gv-properties.add")}"></gv-button></form>${this._renderErrors()}<hr>`:"";return e.html`${a}<gv-table .options="${i}" .items="${s}" noheader nosort order="key" rowheight="57px"></gv-table>`}}_onChangeMode({detail:e}){this._submitExpertMode(),this.expert=e,this._errors=[],this._newItem={key:"",value:"",_new:!0},this._onClosePropertySchemaForm()}_onPaginate({detail:e}){this._paginationData.current_page=e.page,this._onClosePropertySchemaForm(),this.requestUpdate()}updated(e){(e.has("_properties")||e.has("_pageSize"))&&(this._paginationData={first:1,last:Math.ceil(this._properties.length/this._pageSize),total:this._properties.length,current_page:1,total_pages:Math.ceil(this._properties.length/this._pageSize)})}_onChangePageSize({detail:e}){this._pageSize=Number(e).valueOf(),this._onClosePropertySchemaForm()}_renderTableForm(){return e.html`<div class="container"><div class="header"><div class="title">Manage global properties <span>(${this._properties?this._properties.length:0})</span></div><gv-switch small .description="${this.expert?"Expert":"Simple"}" .value="${this.expert}" @gv-switch:input="${this._onChangeMode}"></gv-switch><gv-input id="search-property" placeholder="Filter properties (Shift + Ctrl + Space)" type="search" small class="search-input" .disabled="${this.expert}" @gv-input:input="${this._onSearchProperty}" @gv-input:clear="${this._onClearProperty}"></gv-input><gv-select class="page-size__select" @gv-select:input="${this._onChangePageSize}" small .options="${this._pageSizes}" .value="${this._pageSize}" .disabled="${this.expert||null==this._paginationData}"></gv-select><gv-pagination @gv-pagination:paginate="${this._onPaginate}" .disabled="${this.expert||null==this._paginationData}" .data="${this._paginationData}" widget></gv-pagination></div><div class="content"><div class="form-content">${this._renderTable()}</div></div></div>`}_fetchDocumentation(){this._showDocumentation=!0}_hideDocumentation(){this._showDocumentation=!1}get dirty(){const e=this.shadowRoot.querySelector("gv-schema-form");return e&&e.dirty}confirm(){const e=this.shadowRoot.querySelector("gv-schema-form");return e?e.confirm().then((()=>this._onClosePropertySchemaForm())):Promise.resolve()}_renderForm(){return e.html`<gv-schema-form slot="top" scrollable .schema="${this._propertySchemaForm}" .values="${this.provider}" .icon="design:edit" has-header ?readonly="${this.readonly}" @gv-schema-form:submit="${this._onSubmitPropertyForm}"><div slot="title" class="properties-title">Configure dynamic properties</div><gv-button slot="header-left" icon="general:close" outlined small @gv-button:click="${this._onClosePropertySchemaForm}" title="Close (esc)"></gv-button><gv-button slot="header-left" icon="home:book" ?disabled="${this._showDocumentation}" outlined small @gv-button:click="${this._fetchDocumentation}" title="Open documentation"></gv-button></gv-schema-form>`}_renderBottom(){return this._propertySchemaForm&&this._showDocumentation?e.html`<gv-resizable-views no-overflow direction="horizontal">${this._renderForm()}<gv-documentation slot="bottom" .text="${this._providerDocumentation}" @gv-documentation:close="${this._hideDocumentation}"></gv-documentation></gv-resizable-views>`:this._propertySchemaForm?this._renderForm():e.html`<div class="properties-bottom-container">${this._renderDynamicConfiguration()}</div>`}_renderDynamicConfiguration(){const t=this.provider&&this.provider.enabled;let i="";return(t||!0!==this.readonly)&&(i=e.html`<gv-button icon="tools:tools" @gv-button:click="${this._onConfigureDynamicProperties}" outlined .disabled="${this.expert}">Configure dynamic properties</gv-button>`),t?e.html`<div class="properties-message">Dynamic properties service is actually in <code>running</code> state and run with cron expression <code>${this.provider.schedule}</code> using <code>${this.provider.provider}</code> provider.</div>${i}`:this.readonly?e.html`<div class="empty">No dynamic properties service configured</div>`:i}_onMove(){this._computeTextRows()}_computeTextRows(){const e=this.shadowRoot.querySelector(".content");if(e){const{height:t}=e.getBoundingClientRect();this._textRows=Math.round(Math.round(t-20)/30)-2}}render(){return this.providers&&this.providers.length>0?e.html`<div class="properties"><gv-resizable-views no-overflow @gv-resizable-views:move="${this._onMove}" @gv-resizable-views:resize="${this._onMove}"><div slot="top" class="box">${this._renderTableForm()}</div><div slot="bottom">${this._renderBottom()}</div></gv-resizable-views></div>`:e.html`<div class="properties"><div class="table-box">${this._renderTableForm()}</div></div>`}static get styles(){return[n.empty,e.css`:host{box-sizing:border-box;height:100%;width:100%;display:block}.properties{display:flex;height:100%;width:100%}gv-resizable-views{height:100%;width:100%}gv-schema-form{margin:0}.table-box{width:100%;border-left:1px solid #bfbfbf;display:flex}gv-table{height:auto;flex:1;margin-top:10px;margin-right:50px;--gv-table-rows--ov:none;--gv-table--colmg:var(--gv-properties-table--colmg, 0.2rem);--gv-table-cell--d:inline;--gv-table-row--ai:flex-start;--gv-table-row--ac:flex-start;--gv-table-hover--bgc:var(--gv-theme-neutral-color-lightest)}.properties-title{text-transform:uppercase;letter-spacing:.2rem}.properties-bottom-container{display:flex;justify-content:center;align-items:center;height:100%;flex-direction:column}.header{border-bottom:1px solid #d9d9d9;display:flex;min-height:45px;align-items:center;margin-bottom:.5rem;padding:0 .5rem}.header .title{color:#28444f;font-size:18px;display:flex;align-items:flex-end;flex:1}.header .title span{font-size:12px;margin-left:8px;opacity:.7}.box{position:absolute;display:flex;flex-direction:column;width:100%;top:0;bottom:0;left:0}.container{flex-grow:1;display:flex;flex-direction:column;min-height:0;height:100%}.content{background:#fff;flex-grow:1;overflow:auto;min-height:0;padding:.5rem;display:flex;flex-direction:column;align-items:center}gv-text{--gv-text--fz:20px;--gv-text--lh:25px}gv-switch{--gv-switch--ta:right}.header gv-input{margin:0 1rem}.add-form,.add-form-error{display:grid;margin:auto 50px auto 0;box-sizing:border-box}.add-form{column-gap:var(--gv-properties-table--colmg,.2rem);border-right:solid thick transparent;height:50px}.add-form gv-input,gv-button,gv-switch{margin:auto 0}.add-form gv-switch{font-size:12px}.add-form-grid{grid-template-columns:40px auto auto 40px}.add-form-grid-with-encrypted-toggle{grid-template-columns:40px auto auto 105px 40px}.add-form-error_expert{display:flex}.add-form-error{grid-template-columns:40px 1fr}code{color:var(--gv-theme-color-warning-dark,#f57c00)}.form-content{display:flex;flex-direction:column;width:100%}.properties-message{margin-bottom:.5rem;font-size:14px}.page-size__select{max-width:50px}.search-input{width:300px}hr{background-color:var(--gv-theme-neutral-color);border:0;width:100%;height:2px}`]}}exports.GvProperties=a,window.customElements.define("gv-properties",a);