@gravitee/ui-components 3.25.3-typescript-8a53edf → 3.25.3-typescript-e7256ca
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 +3 -4
- package/src/atoms/gv-autocomplete.d.ts +104 -0
- package/src/atoms/gv-autocomplete.js +1 -461
- package/src/atoms/gv-button.d.ts +109 -0
- package/src/atoms/gv-button.js +1 -410
- package/src/atoms/gv-checkbox.d.ts +114 -0
- package/src/atoms/gv-checkbox.js +1 -187
- package/src/atoms/gv-date-picker-calendar.d.ts +190 -0
- package/src/atoms/gv-date-picker-calendar.js +1 -894
- package/src/atoms/gv-date-picker-cell.d.ts +80 -0
- package/src/atoms/gv-date-picker-cell.js +1 -190
- package/src/atoms/gv-date-picker.d.ts +194 -0
- package/src/atoms/gv-date-picker.js +1 -671
- package/src/atoms/gv-file-upload.d.ts +64 -0
- package/src/atoms/gv-file-upload.js +1 -367
- package/src/atoms/gv-icon.d.ts +26 -0
- package/src/atoms/gv-icon.js +1 -103
- package/src/atoms/gv-image.d.ts +45 -0
- package/src/atoms/gv-image.js +1 -144
- package/src/atoms/gv-input-message.d.ts +20 -0
- package/src/atoms/gv-input-message.js +1 -84
- package/src/atoms/gv-input.d.ts +246 -0
- package/src/atoms/gv-input.js +1 -561
- package/src/atoms/gv-link.d.ts +67 -0
- package/src/atoms/gv-link.js +1 -210
- package/src/atoms/gv-message.d.ts +23 -0
- package/src/atoms/gv-message.js +1 -128
- package/src/atoms/gv-metric.d.ts +32 -0
- package/src/atoms/gv-metric.js +1 -117
- package/src/atoms/gv-relative-time.d.ts +45 -0
- package/src/atoms/gv-relative-time.js +1 -156
- package/src/atoms/gv-select-native.d.ts +174 -0
- package/src/atoms/gv-select-native.js +1 -388
- package/src/atoms/gv-select.d.ts +71 -0
- package/src/atoms/gv-select.js +1 -437
- package/src/atoms/gv-spinner.d.ts +10 -0
- package/src/atoms/gv-spinner.js +1 -57
- package/src/atoms/gv-state.d.ts +50 -0
- package/src/atoms/gv-state.js +1 -130
- package/src/atoms/gv-switch.d.ts +60 -0
- package/src/atoms/gv-switch.js +1 -243
- package/src/atoms/gv-tag.d.ts +69 -0
- package/src/atoms/gv-tag.js +1 -168
- package/src/atoms/gv-text.d.ts +110 -0
- package/src/atoms/gv-text.js +1 -168
- package/src/charts/gv-chart-bar.d.ts +50 -0
- package/src/charts/gv-chart-bar.js +1 -103
- package/src/charts/gv-chart-gauge.d.ts +58 -0
- package/src/charts/gv-chart-gauge.js +1 -100
- package/src/charts/gv-chart-histogram.d.ts +48 -0
- package/src/charts/gv-chart-histogram.js +1 -83
- package/src/charts/gv-chart-line.d.ts +52 -0
- package/src/charts/gv-chart-line.js +1 -224
- package/src/charts/gv-chart-map.d.ts +50 -0
- package/src/charts/gv-chart-map.js +1 -112
- package/src/charts/gv-chart-pie.d.ts +50 -0
- package/src/charts/gv-chart-pie.js +1 -91
- package/src/index.d.ts +77 -0
- package/src/index.js +1 -77
- package/src/lib/cron-expression.d.ts +1 -0
- package/src/lib/cron-expression.js +1 -205
- package/src/lib/date.d.ts +1 -0
- package/src/lib/date.js +1 -44
- package/src/lib/events.d.ts +1 -0
- package/src/lib/events.js +1 -26
- package/src/lib/http-client-schema-form.d.ts +68 -0
- package/src/lib/http-client-schema-form.js +1 -67
- package/src/lib/http.d.ts +222 -0
- package/src/lib/http.js +1 -237
- package/src/lib/i18n.d.ts +30 -0
- package/src/lib/i18n.js +1 -103
- package/src/lib/item.d.ts +12 -0
- package/src/lib/item.js +1 -118
- package/src/lib/properties.d.ts +42 -0
- package/src/lib/properties.js +1 -189
- package/src/lib/schema-form.d.ts +5 -0
- package/src/lib/schema-form.js +1 -44
- package/src/lib/studio.d.ts +2 -0
- package/src/lib/studio.js +1 -141
- package/src/lib/style.d.ts +6 -0
- package/src/lib/style.js +1 -41
- package/src/lib/text-format.d.ts +6 -0
- package/src/lib/text-format.js +1 -69
- package/src/lib/theme.d.ts +4 -0
- package/src/lib/theme.js +1 -63
- package/src/lib/utils.d.ts +9 -0
- package/src/lib/utils.js +1 -111
- package/src/mixins/chart-element.d.ts +39 -0
- package/src/mixins/chart-element.js +1 -165
- package/src/mixins/input-element.d.ts +64 -0
- package/src/mixins/input-element.js +1 -144
- package/src/mixins/item-resource.d.ts +56 -0
- package/src/mixins/item-resource.js +1 -120
- package/src/mixins/keyboard-element.d.ts +25 -0
- package/src/mixins/keyboard-element.js +1 -69
- package/src/mixins/update-after-browser.d.ts +11 -0
- package/src/mixins/update-after-browser.js +1 -30
- package/src/mixins/with-resize-observer.d.ts +12 -0
- package/src/mixins/with-resize-observer.js +1 -68
- package/src/mixins/with-skeleton-attribute.d.ts +35 -0
- package/src/mixins/with-skeleton-attribute.js +1 -112
- package/src/molecules/gv-card-full.d.ts +78 -0
- package/src/molecules/gv-card-full.js +1 -218
- package/src/molecules/gv-card-list.d.ts +33 -0
- package/src/molecules/gv-card-list.js +1 -113
- package/src/molecules/gv-card.d.ts +65 -0
- package/src/molecules/gv-card.js +1 -133
- package/src/molecules/gv-category-list.d.ts +17 -0
- package/src/molecules/gv-category-list.js +1 -60
- package/src/molecules/gv-category.d.ts +64 -0
- package/src/molecules/gv-category.js +1 -170
- package/src/molecules/gv-code.d.ts +192 -0
- package/src/molecules/gv-code.js +1 -359
- package/src/molecules/gv-confirm.d.ts +60 -0
- package/src/molecules/gv-confirm.js +1 -188
- package/src/molecules/gv-cron-editor.d.ts +115 -0
- package/src/molecules/gv-cron-editor.js +1 -710
- package/src/molecules/gv-dropdown-menu.d.ts +28 -0
- package/src/molecules/gv-dropdown-menu.js +1 -116
- package/src/molecules/gv-expandable.d.ts +37 -0
- package/src/molecules/gv-expandable.js +1 -122
- package/src/molecules/gv-expression-language.d.ts +150 -0
- package/src/molecules/gv-expression-language.js +1 -270
- package/src/molecules/gv-identity-picture.d.ts +44 -0
- package/src/molecules/gv-identity-picture.js +1 -148
- package/src/molecules/gv-list.d.ts +123 -0
- package/src/molecules/gv-list.js +1 -227
- package/src/molecules/gv-metrics.d.ts +65 -0
- package/src/molecules/gv-metrics.js +1 -162
- package/src/molecules/gv-modal.d.ts +64 -0
- package/src/molecules/gv-modal.js +1 -213
- package/src/molecules/gv-nav.d.ts +41 -0
- package/src/molecules/gv-nav.js +1 -196
- package/src/molecules/gv-option.d.ts +65 -0
- package/src/molecules/gv-option.js +1 -242
- package/src/molecules/gv-plans.d.ts +73 -0
- package/src/molecules/gv-plans.js +1 -429
- package/src/molecules/gv-popover.d.ts +91 -0
- package/src/molecules/gv-popover.js +1 -351
- package/src/molecules/gv-promote.d.ts +108 -0
- package/src/molecules/gv-promote.js +1 -209
- package/src/molecules/gv-rating-list.d.ts +77 -0
- package/src/molecules/gv-rating-list.js +1 -365
- package/src/molecules/gv-rating.d.ts +55 -0
- package/src/molecules/gv-rating.js +1 -253
- package/src/molecules/gv-row-expandable.d.ts +8 -0
- package/src/molecules/gv-row-expandable.js +1 -45
- package/src/molecules/gv-row.d.ts +37 -0
- package/src/molecules/gv-row.js +1 -210
- package/src/molecules/gv-stats.d.ts +53 -0
- package/src/molecules/gv-stats.js +1 -121
- package/src/molecules/gv-stepper.d.ts +46 -0
- package/src/molecules/gv-stepper.js +1 -288
- package/src/molecules/gv-table.d.ts +159 -0
- package/src/molecules/gv-table.js +1 -685
- package/src/molecules/gv-tree.d.ts +44 -0
- package/src/molecules/gv-tree.js +1 -250
- package/src/organisms/gv-documentation.d.ts +52 -0
- package/src/organisms/gv-documentation.js +1 -215
- package/src/organisms/gv-header.d.ts +60 -0
- package/src/organisms/gv-header.js +1 -288
- package/src/organisms/gv-http-client.d.ts +57 -0
- package/src/organisms/gv-http-client.js +1 -275
- package/src/organisms/gv-menu.d.ts +74 -0
- package/src/organisms/gv-menu.js +1 -263
- package/src/organisms/gv-newsletter-subscription.d.ts +82 -0
- package/src/organisms/gv-newsletter-subscription.js +1 -271
- package/src/organisms/gv-pagination.d.ts +63 -0
- package/src/organisms/gv-pagination.js +1 -198
- package/src/organisms/gv-properties.d.ts +229 -0
- package/src/organisms/gv-properties.js +1 -920
- package/src/organisms/gv-resizable-views.d.ts +33 -0
- package/src/organisms/gv-resizable-views.js +1 -396
- package/src/organisms/gv-resources.d.ts +125 -0
- package/src/organisms/gv-resources.js +1 -535
- package/src/organisms/gv-schema-form-array.d.ts +55 -0
- package/src/organisms/gv-schema-form-array.js +1 -250
- package/src/organisms/gv-schema-form-control-object.d.ts +64 -0
- package/src/organisms/gv-schema-form-control-object.js +1 -154
- package/src/organisms/gv-schema-form-control.d.ts +90 -0
- package/src/organisms/gv-schema-form-control.js +1 -443
- package/src/organisms/gv-schema-form.d.ts +156 -0
- package/src/organisms/gv-schema-form.js +1 -751
- package/src/organisms/gv-tabs.d.ts +56 -0
- package/src/organisms/gv-tabs.js +1 -210
- package/src/organisms/gv-user-menu.d.ts +56 -0
- package/src/organisms/gv-user-menu.js +1 -314
- package/src/organisms/gv-vertical-menu.d.ts +28 -0
- package/src/organisms/gv-vertical-menu.js +1 -123
- package/src/policy-studio/gv-flow-step.d.ts +142 -0
- package/src/policy-studio/gv-flow-step.js +1 -464
- package/src/policy-studio/gv-flow.d.ts +89 -0
- package/src/policy-studio/gv-flow.js +1 -621
- package/src/policy-studio/gv-policy-studio-menu.d.ts +94 -0
- package/src/policy-studio/gv-policy-studio-menu.js +1 -750
- package/src/policy-studio/gv-policy-studio.d.ts +464 -0
- package/src/policy-studio/gv-policy-studio.js +1 -1842
- package/src/styles/empty.d.ts +1 -0
- package/src/styles/empty.js +1 -36
- package/src/styles/input.d.ts +1 -0
- package/src/styles/input.js +1 -263
- package/src/styles/link.d.ts +1 -0
- package/src/styles/link.js +1 -32
- package/src/styles/shapes.d.ts +2 -0
- package/src/styles/shapes.js +1 -17
- package/src/styles/skeleton.d.ts +1 -0
- package/src/styles/skeleton.js +1 -53
- package/src/styles/zoom.d.ts +1 -0
- package/src/styles/zoom.js +1 -40
- package/src/theme/gv-theme.d.ts +81 -0
- package/src/theme/gv-theme.js +1 -203
- package/wc/gv-autocomplete.d.ts +1 -0
- package/wc/gv-autocomplete.js +1 -1
- package/wc/gv-button.d.ts +1 -0
- package/wc/gv-button.js +1 -1
- package/wc/gv-card-full.d.ts +1 -0
- package/wc/gv-card-full.js +1 -1
- package/wc/gv-card-list.d.ts +1 -0
- package/wc/gv-card-list.js +1 -1
- package/wc/gv-card.d.ts +1 -0
- package/wc/gv-card.js +1 -1
- package/wc/gv-category-list.d.ts +1 -0
- package/wc/gv-category-list.js +1 -1
- package/wc/gv-category.d.ts +1 -0
- package/wc/gv-category.js +1 -1
- package/wc/gv-chart-bar.d.ts +1 -0
- package/wc/gv-chart-bar.js +1 -1
- package/wc/gv-chart-gauge.d.ts +1 -0
- package/wc/gv-chart-gauge.js +1 -1
- package/wc/gv-chart-histogram.d.ts +1 -0
- package/wc/gv-chart-histogram.js +1 -1
- package/wc/gv-chart-line.d.ts +1 -0
- package/wc/gv-chart-line.js +1 -1
- package/wc/gv-chart-map.d.ts +1 -0
- package/wc/gv-chart-map.js +1 -1
- package/wc/gv-chart-pie.d.ts +1 -0
- package/wc/gv-chart-pie.js +1 -1
- package/wc/gv-checkbox.d.ts +1 -0
- package/wc/gv-checkbox.js +1 -1
- package/wc/gv-code.d.ts +1 -0
- package/wc/gv-code.js +1 -1
- package/wc/gv-confirm.d.ts +1 -0
- package/wc/gv-confirm.js +1 -1
- package/wc/gv-cron-editor.d.ts +1 -0
- package/wc/gv-cron-editor.js +1 -1
- package/wc/gv-date-picker-calendar.d.ts +1 -0
- package/wc/gv-date-picker-calendar.js +1 -1
- package/wc/gv-date-picker-cell.d.ts +1 -0
- package/wc/gv-date-picker-cell.js +1 -1
- package/wc/gv-date-picker.d.ts +1 -0
- package/wc/gv-date-picker.js +1 -1
- package/wc/gv-documentation.d.ts +1 -0
- package/wc/gv-documentation.js +1 -1
- package/wc/gv-dropdown-menu.d.ts +1 -0
- package/wc/gv-dropdown-menu.js +1 -1
- package/wc/gv-expandable.d.ts +1 -0
- package/wc/gv-expandable.js +1 -1
- package/wc/gv-expression-language.d.ts +1 -0
- package/wc/gv-expression-language.js +1 -1
- package/wc/gv-file-upload.d.ts +1 -0
- package/wc/gv-file-upload.js +1 -1
- package/wc/gv-flow-step.d.ts +1 -0
- package/wc/gv-flow-step.js +1 -1
- package/wc/gv-flow.d.ts +1 -0
- package/wc/gv-flow.js +1 -1
- package/wc/gv-header.d.ts +1 -0
- package/wc/gv-header.js +1 -1
- package/wc/gv-http-client.d.ts +1 -0
- package/wc/gv-http-client.js +1 -1
- package/wc/gv-icon.d.ts +1 -0
- package/wc/gv-icon.js +1 -1
- package/wc/gv-identity-picture.d.ts +1 -0
- package/wc/gv-identity-picture.js +1 -1
- package/wc/gv-image.d.ts +1 -0
- package/wc/gv-image.js +1 -1
- package/wc/gv-input-message.d.ts +1 -0
- package/wc/gv-input-message.js +1 -1
- package/wc/gv-input.d.ts +1 -0
- package/wc/gv-input.js +1 -1
- package/wc/gv-link.d.ts +1 -0
- package/wc/gv-link.js +1 -1
- package/wc/gv-list.d.ts +1 -0
- package/wc/gv-list.js +1 -1
- package/wc/gv-menu.d.ts +1 -0
- package/wc/gv-menu.js +1 -1
- package/wc/gv-message.d.ts +1 -0
- package/wc/gv-message.js +1 -1
- package/wc/gv-metric.d.ts +1 -0
- package/wc/gv-metric.js +1 -1
- package/wc/gv-metrics.d.ts +1 -0
- package/wc/gv-metrics.js +1 -1
- package/wc/gv-modal.d.ts +1 -0
- package/wc/gv-modal.js +1 -1
- package/wc/gv-nav.d.ts +1 -0
- package/wc/gv-nav.js +1 -1
- package/wc/gv-newsletter-subscription.d.ts +1 -0
- package/wc/gv-newsletter-subscription.js +1 -1
- package/wc/gv-option.d.ts +1 -0
- package/wc/gv-option.js +1 -1
- package/wc/gv-pagination.d.ts +1 -0
- package/wc/gv-pagination.js +1 -1
- package/wc/gv-plans.d.ts +1 -0
- package/wc/gv-plans.js +1 -1
- package/wc/gv-policy-studio-menu.d.ts +1 -0
- package/wc/gv-policy-studio-menu.js +1 -1
- package/wc/gv-policy-studio.d.ts +1 -0
- package/wc/gv-policy-studio.js +1 -1
- package/wc/gv-popover.d.ts +1 -0
- package/wc/gv-popover.js +1 -1
- package/wc/gv-promote.d.ts +1 -0
- package/wc/gv-promote.js +1 -1
- package/wc/gv-properties.d.ts +1 -0
- package/wc/gv-properties.js +1 -1
- package/wc/gv-rating-list.d.ts +1 -0
- package/wc/gv-rating-list.js +1 -1
- package/wc/gv-rating.d.ts +1 -0
- package/wc/gv-rating.js +1 -1
- package/wc/gv-relative-time.d.ts +1 -0
- package/wc/gv-relative-time.js +1 -1
- package/wc/gv-resizable-views.d.ts +1 -0
- package/wc/gv-resizable-views.js +1 -1
- package/wc/gv-resources.d.ts +1 -0
- package/wc/gv-resources.js +1 -1
- package/wc/gv-row-expandable.d.ts +1 -0
- package/wc/gv-row-expandable.js +1 -1
- package/wc/gv-row.d.ts +1 -0
- package/wc/gv-row.js +1 -1
- package/wc/gv-schema-form-array.d.ts +1 -0
- package/wc/gv-schema-form-array.js +1 -1
- package/wc/gv-schema-form-control-object.d.ts +1 -0
- package/wc/gv-schema-form-control-object.js +1 -1
- package/wc/gv-schema-form-control.d.ts +1 -0
- package/wc/gv-schema-form-control.js +1 -1
- package/wc/gv-schema-form.d.ts +1 -0
- package/wc/gv-schema-form.js +1 -1
- package/wc/gv-select-native.d.ts +1 -0
- package/wc/gv-select-native.js +1 -1
- package/wc/gv-select.d.ts +1 -0
- package/wc/gv-select.js +1 -1
- package/wc/gv-spinner.d.ts +1 -0
- package/wc/gv-spinner.js +1 -1
- package/wc/gv-state.d.ts +1 -0
- package/wc/gv-state.js +1 -1
- package/wc/gv-stats.d.ts +1 -0
- package/wc/gv-stats.js +1 -1
- package/wc/gv-stepper.d.ts +1 -0
- package/wc/gv-stepper.js +1 -1
- package/wc/gv-switch.d.ts +1 -0
- package/wc/gv-switch.js +1 -1
- package/wc/gv-table.d.ts +1 -0
- package/wc/gv-table.js +1 -1
- package/wc/gv-tabs.d.ts +1 -0
- package/wc/gv-tabs.js +1 -1
- package/wc/gv-tag.d.ts +1 -0
- package/wc/gv-tag.js +1 -1
- package/wc/gv-text.d.ts +1 -0
- package/wc/gv-text.js +1 -1
- package/wc/gv-theme.d.ts +1 -0
- package/wc/gv-theme.js +1 -1
- package/wc/gv-tree.d.ts +1 -0
- package/wc/gv-tree.js +1 -1
- package/wc/gv-user-menu.d.ts +1 -0
- package/wc/gv-user-menu.js +1 -1
- package/wc/gv-vertical-menu.d.ts +1 -0
- package/wc/gv-vertical-menu.js +1 -1
- package/CHANGELOG.md +0 -1292
- package/LICENSE.txt +0 -202
- package/README.md +0 -195
- package/src/.eslintrc.js +0 -19
- package/src/theme/definition.json +0 -1762
package/src/molecules/gv-code.js
CHANGED
|
@@ -1,359 +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 } from 'lit';
|
|
17
|
-
|
|
18
|
-
import { EditorView, basicSetup } from '@codemirror/basic-setup';
|
|
19
|
-
import { EditorState, Compartment } from '@codemirror/state';
|
|
20
|
-
import { autocompletion } from '@codemirror/autocomplete';
|
|
21
|
-
import { json } from '@codemirror/lang-json';
|
|
22
|
-
import { languages } from '@codemirror/language-data';
|
|
23
|
-
import { placeholder } from '@codemirror/view';
|
|
24
|
-
|
|
25
|
-
import { shapeClipboard } from '../styles/shapes';
|
|
26
|
-
import { dispatchCustomEvent } from '../lib/events';
|
|
27
|
-
import { uuid } from '../lib/utils';
|
|
28
|
-
import { classMap } from 'lit/directives/class-map';
|
|
29
|
-
import { GvInput } from '../atoms/gv-input';
|
|
30
|
-
import { skeleton } from '../styles/skeleton';
|
|
31
|
-
import { empty } from '../styles/empty';
|
|
32
|
-
import { input } from '../styles/input';
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Code component
|
|
36
|
-
*
|
|
37
|
-
* ## Details
|
|
38
|
-
* * has @theme facet
|
|
39
|
-
*
|
|
40
|
-
* @fires gv-code:input - input events with the `value` on `detail`
|
|
41
|
-
* @fires gv-code:ready - event dispatch when component is ready
|
|
42
|
-
* @fires gv-code:clipboard-copy - event dispatch when component the `value` has been copied to clipboard
|
|
43
|
-
*
|
|
44
|
-
* @attr {String} label - code language
|
|
45
|
-
* @attr {String} value - code content to be highlighted
|
|
46
|
-
* @attr {options} Object - options based on codemirror
|
|
47
|
-
* @attr {String} placeholder - an example value to display in the input when empty
|
|
48
|
-
* @attr {Number} rows - number of rows of the text element
|
|
49
|
-
* @attr {Boolean} large - for a large input (only if the field has one row)
|
|
50
|
-
* @attr {Boolean} medium - for a medium input (only if the field has one row) (Default)
|
|
51
|
-
* @attr {Boolean} small - for a small input (only if the field has one row)
|
|
52
|
-
*
|
|
53
|
-
* @attr {Boolean} [clipboard=false]- true if field has clipboard button
|
|
54
|
-
* @attr {Boolean} [autofocus=false] - true to put the focus on the input
|
|
55
|
-
* @attr {Boolean} [readonly=false] - true if field is readonly mode
|
|
56
|
-
*/
|
|
57
|
-
export class GvCode extends GvInput {
|
|
58
|
-
static get properties() {
|
|
59
|
-
return {
|
|
60
|
-
...super.properties,
|
|
61
|
-
options: { type: Object },
|
|
62
|
-
rows: { type: Number },
|
|
63
|
-
_error: { type: String, attribute: false },
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
constructor() {
|
|
68
|
-
super();
|
|
69
|
-
this._id = `gv-code-${uuid()}`;
|
|
70
|
-
this.value = '';
|
|
71
|
-
this.readonly = false;
|
|
72
|
-
this.autofocus = false;
|
|
73
|
-
this.clipboard = false;
|
|
74
|
-
this._clipboardIcon = shapeClipboard;
|
|
75
|
-
this.languageCompartment = new Compartment();
|
|
76
|
-
this.readonlyCompartment = new Compartment();
|
|
77
|
-
this.placeholderCompartment = new Compartment();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
render() {
|
|
81
|
-
const classes = {
|
|
82
|
-
box: true,
|
|
83
|
-
'box-invisible': this.skeleton,
|
|
84
|
-
large: this.large,
|
|
85
|
-
medium: this.medium || (!this.large && !this.small),
|
|
86
|
-
small: this.small,
|
|
87
|
-
copied: this.hasClipboard && this._copied,
|
|
88
|
-
};
|
|
89
|
-
const inputClasses = {
|
|
90
|
-
content: true,
|
|
91
|
-
code: !this.hasInputStyle,
|
|
92
|
-
input: this.hasInputStyle,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return html`
|
|
96
|
-
<div class="${classMap(classes)}">
|
|
97
|
-
${this.label ? html`<label for="code">${this.label}</label>` : ''}
|
|
98
|
-
<div id="${this._id}" class="${classMap(inputClasses)}">
|
|
99
|
-
<!-- No format please -->
|
|
100
|
-
${this.renderIcon()}
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
${this.description != null ? html`<div class="description" .innerHTML="${this.description}"></div>` : ''}
|
|
104
|
-
`;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
bindInputEvents() {
|
|
108
|
-
dispatchCustomEvent(this, 'ready', { currentTarget: this });
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get hasInputStyle() {
|
|
112
|
-
return this.rows === 1;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_autocomplete(completionContext) {
|
|
116
|
-
const { handler, match } = this.findBestAutocompleteHandler(completionContext);
|
|
117
|
-
return handler.run.call(this, completionContext, match);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
findBestAutocompleteHandler(completionContext) {
|
|
121
|
-
return { handler: this.defaultCompletionHandler, match: true };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
get defaultCompletionHandler() {
|
|
125
|
-
return {
|
|
126
|
-
run(completionContext) {
|
|
127
|
-
const language = completionContext.state.languageDataAt('autocomplete', completionContext.pos);
|
|
128
|
-
if (language.length > 0) {
|
|
129
|
-
return language[0](completionContext);
|
|
130
|
-
}
|
|
131
|
-
return { from: completionContext.pos, options: [] };
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
_getExtensions() {
|
|
137
|
-
return [
|
|
138
|
-
basicSetup,
|
|
139
|
-
GvCode.codemirrorTheme,
|
|
140
|
-
this.languageCompartment.of(json()),
|
|
141
|
-
this.placeholderCompartment.of(placeholder(this.placeholder || '')),
|
|
142
|
-
EditorState.transactionFilter.of((tr) => (this.hasInputStyle && tr.newDoc.lines > 1 ? [] : tr)),
|
|
143
|
-
this.readonlyCompartment.of(EditorView.editable.of(!this.readonly && !this.disabled)),
|
|
144
|
-
EditorView.updateListener.of((viewUpdate) => {
|
|
145
|
-
if (viewUpdate.docChanged) {
|
|
146
|
-
this.value = this._editorView.state.doc.toString();
|
|
147
|
-
dispatchCustomEvent(this, 'input', this.value);
|
|
148
|
-
}
|
|
149
|
-
}),
|
|
150
|
-
autocompletion({
|
|
151
|
-
activateOnTyping: true,
|
|
152
|
-
override: [this._autocomplete.bind(this)],
|
|
153
|
-
}),
|
|
154
|
-
...this.getExtensions(),
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
getExtensions() {
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
getInputElement() {
|
|
163
|
-
return this.shadowRoot.querySelector(`[id=${this._id}]`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
firstUpdated() {
|
|
167
|
-
super.firstUpdated();
|
|
168
|
-
this._editorState = EditorState.create({
|
|
169
|
-
doc: this.value,
|
|
170
|
-
extensions: this._getExtensions(),
|
|
171
|
-
});
|
|
172
|
-
const parent = this.getInputElement();
|
|
173
|
-
this._editorView = new EditorView({
|
|
174
|
-
root: this.shadowRoot,
|
|
175
|
-
parent,
|
|
176
|
-
state: this._editorState,
|
|
177
|
-
dispatch: (transaction) => {
|
|
178
|
-
try {
|
|
179
|
-
this._editorView.update([transaction]);
|
|
180
|
-
} catch (e) {
|
|
181
|
-
// Sometimes the default dispatch fn throws an NS_ERROR_FAILURE at runtime.
|
|
182
|
-
// It's so strange but with this catch everything is okay
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
parent.appendChild(this._editorView.dom);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async updated(properties) {
|
|
190
|
-
super.updated(properties);
|
|
191
|
-
if (properties.has('placeholder')) {
|
|
192
|
-
this._reflectPlaceholder();
|
|
193
|
-
}
|
|
194
|
-
if (properties.has('value')) {
|
|
195
|
-
this._reflectValue();
|
|
196
|
-
}
|
|
197
|
-
if (properties.has('readonly') || properties.has('disabled')) {
|
|
198
|
-
this._reflectReadonlyDisabled();
|
|
199
|
-
}
|
|
200
|
-
if (properties.has('options') && this.options) {
|
|
201
|
-
await this._reflectOptions();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
_reflectPlaceholder() {
|
|
206
|
-
this._editorView.dispatch({
|
|
207
|
-
effects: this.placeholderCompartment.reconfigure(placeholder(this.placeholder)),
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
_reflectValue() {
|
|
212
|
-
const transaction = this._editorState.update({
|
|
213
|
-
changes: {
|
|
214
|
-
from: 0,
|
|
215
|
-
to: this._editorState.doc.length,
|
|
216
|
-
insert: this.value,
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
this._editorState = transaction.state;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
_reflectReadonlyDisabled() {
|
|
223
|
-
this._editorView.dispatch({
|
|
224
|
-
effects: this.readonlyCompartment.reconfigure(EditorView.editable.of(!this.readonly && !this.disabled)),
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
static async findLanguage(mode) {
|
|
229
|
-
if (mode) {
|
|
230
|
-
const modeOnly = mode.split('/').pop();
|
|
231
|
-
if (modeOnly === 'asciidoc') {
|
|
232
|
-
const [{ asciidoc }, { StreamLanguage }] = await Promise.all([
|
|
233
|
-
import('codemirror-asciidoc/lib/asciidoc'),
|
|
234
|
-
import('@codemirror/stream-parser'),
|
|
235
|
-
]);
|
|
236
|
-
return {
|
|
237
|
-
name: 'asciidoc',
|
|
238
|
-
support: {
|
|
239
|
-
extension: StreamLanguage.define(asciidoc),
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
} else {
|
|
243
|
-
const language = languages.find((languageDescription) => {
|
|
244
|
-
return languageDescription.name.toUpperCase() === modeOnly.toUpperCase() || languageDescription.alias.includes(modeOnly);
|
|
245
|
-
});
|
|
246
|
-
if (language == null) {
|
|
247
|
-
console.warn(
|
|
248
|
-
`Cannot find language ${mode}, please use language supported by CodeMirror 6`,
|
|
249
|
-
languages.map((l) => l.name),
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
return language;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
async _reflectOptions() {
|
|
259
|
-
const language = await GvCode.findLanguage(this.options.mode);
|
|
260
|
-
if (language != null) {
|
|
261
|
-
if (language.support == null) {
|
|
262
|
-
await language.load();
|
|
263
|
-
}
|
|
264
|
-
this._editorView.dispatch({
|
|
265
|
-
effects: this.languageCompartment.reconfigure(language.support.extension),
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
static get codemirrorTheme() {
|
|
271
|
-
return EditorView.theme({
|
|
272
|
-
'&.cm-editor.cm-focused': {
|
|
273
|
-
outline: 'none',
|
|
274
|
-
},
|
|
275
|
-
'.cm-gutters': {
|
|
276
|
-
backgroundColor: 'var(--gv-input-icon--bgc, var(--gv-theme-neutral-color, #f5f5f5))',
|
|
277
|
-
color: 'var(--gv-theme-font-color-dark, #262626)',
|
|
278
|
-
borderLeft: '5px solid',
|
|
279
|
-
borderColor: 'var(--gv-input--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9))',
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
static get styles() {
|
|
285
|
-
return [
|
|
286
|
-
...super.styles,
|
|
287
|
-
skeleton,
|
|
288
|
-
empty,
|
|
289
|
-
input,
|
|
290
|
-
// language=CSS
|
|
291
|
-
css`
|
|
292
|
-
:host {
|
|
293
|
-
box-sizing: border-box;
|
|
294
|
-
display: block;
|
|
295
|
-
margin: 0 0.2rem 0.2rem 0.2rem;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.content {
|
|
299
|
-
position: relative;
|
|
300
|
-
border: var(--gv-input--bdw, 1px) var(--gv-input--bds, solid) var(--gv-input--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9));
|
|
301
|
-
box-sizing: border-box;
|
|
302
|
-
border-radius: 4px;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.btn_copy {
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.box-icon {
|
|
309
|
-
bottom: -1px;
|
|
310
|
-
right: -1px;
|
|
311
|
-
z-index: 1;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.code .box-icon {
|
|
315
|
-
border-radius: 3px;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.code .cm-content,
|
|
319
|
-
.code .cm-gutters {
|
|
320
|
-
height: var(--input-medium--h);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
.large .code .cm-content,
|
|
324
|
-
.large .code .cm-gutters {
|
|
325
|
-
height: var(--input-large--h);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.small .code .cm-content,
|
|
329
|
-
.small .code .cm-gutters {
|
|
330
|
-
height: var(--input-small--h);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/** Override Codemirror theme */
|
|
334
|
-
.input .cm-gutters {
|
|
335
|
-
display: none;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.input .cm-scroller {
|
|
339
|
-
overflow: hidden;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
.input .cm-activeLine,
|
|
343
|
-
:host([readonly]) .cm-activeLine {
|
|
344
|
-
background-color: transparent;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.input .cm-content {
|
|
348
|
-
padding: 0;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
:host([invalid]) .cm-gutters {
|
|
352
|
-
border-color: var(--gv-theme-color-error, #da1a1b);
|
|
353
|
-
}
|
|
354
|
-
`,
|
|
355
|
-
];
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
window.customElements.define('gv-code', GvCode);
|
|
1
|
+
var e=Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]},t=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},r=function(r){if(r&&r.__esModule)return r;var i={};if(null!=r)for(var o in r)"default"!==o&&Object.prototype.hasOwnProperty.call(r,o)&&e(i,r,o);return t(i,r),i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvCode=void 0;const i=require("lit"),o=require("@codemirror/basic-setup"),s=require("@codemirror/state"),a=require("@codemirror/autocomplete"),n=require("@codemirror/lang-json"),d=require("@codemirror/language-data"),l=require("@codemirror/view"),c=require("../styles/shapes"),u=require("../lib/events"),p=require("../lib/utils"),h=require("lit/directives/class-map"),m=require("../atoms/gv-input"),g=require("../styles/skeleton"),v=require("../styles/empty"),f=require("../styles/input");class b extends m.GvInput{static get properties(){return{...super.properties,options:{type:Object},rows:{type:Number},_error:{type:String,attribute:!1}}}constructor(){super(),this._id=`gv-code-${(0,p.uuid)()}`,this.value="",this.readonly=!1,this.autofocus=!1,this.clipboard=!1,this._clipboardIcon=c.shapeClipboard,this.languageCompartment=new s.Compartment,this.readonlyCompartment=new s.Compartment,this.placeholderCompartment=new s.Compartment}render(){const e={box:!0,"box-invisible":this.skeleton,large:this.large,medium:this.medium||!this.large&&!this.small,small:this.small,copied:this.hasClipboard&&this._copied},t={content:!0,code:!this.hasInputStyle,input:this.hasInputStyle};return i.html`<div class="${(0,h.classMap)(e)}">${this.label?i.html`<label for="code">${this.label}</label>`:""}<div id="${this._id}" class="${(0,h.classMap)(t)}">${this.renderIcon()}</div></div>${null!=this.description?i.html`<div class="description" .innerHTML="${this.description}"></div>`:""}`}bindInputEvents(){(0,u.dispatchCustomEvent)(this,"ready",{currentTarget:this})}get hasInputStyle(){return 1===this.rows}_autocomplete(e){const{handler:t,match:r}=this.findBestAutocompleteHandler(e);return t.run.call(this,e,r)}findBestAutocompleteHandler(e){return{handler:this.defaultCompletionHandler,match:!0}}get defaultCompletionHandler(){return{run(e){const t=e.state.languageDataAt("autocomplete",e.pos);return t.length>0?t[0](e):{from:e.pos,options:[]}}}}_getExtensions(){return[o.basicSetup,b.codemirrorTheme,this.languageCompartment.of((0,n.json)()),this.placeholderCompartment.of((0,l.placeholder)(this.placeholder||"")),s.EditorState.transactionFilter.of((e=>this.hasInputStyle&&e.newDoc.lines>1?[]:e)),this.readonlyCompartment.of(o.EditorView.editable.of(!this.readonly&&!this.disabled)),o.EditorView.updateListener.of((e=>{e.docChanged&&(this.value=this._editorView.state.doc.toString(),(0,u.dispatchCustomEvent)(this,"input",this.value))})),(0,a.autocompletion)({activateOnTyping:!0,override:[this._autocomplete.bind(this)]}),...this.getExtensions()]}getExtensions(){return[]}getInputElement(){return this.shadowRoot.querySelector(`[id=${this._id}]`)}firstUpdated(){super.firstUpdated(),this._editorState=s.EditorState.create({doc:this.value,extensions:this._getExtensions()});const e=this.getInputElement();this._editorView=new o.EditorView({root:this.shadowRoot,parent:e,state:this._editorState,dispatch:e=>{try{this._editorView.update([e])}catch(e){}}}),e.appendChild(this._editorView.dom)}async updated(e){super.updated(e),e.has("placeholder")&&this._reflectPlaceholder(),e.has("value")&&this._reflectValue(),(e.has("readonly")||e.has("disabled"))&&this._reflectReadonlyDisabled(),e.has("options")&&this.options&&await this._reflectOptions()}_reflectPlaceholder(){this._editorView.dispatch({effects:this.placeholderCompartment.reconfigure((0,l.placeholder)(this.placeholder))})}_reflectValue(){const e=this._editorState.update({changes:{from:0,to:this._editorState.doc.length,insert:this.value}});this._editorState=e.state}_reflectReadonlyDisabled(){this._editorView.dispatch({effects:this.readonlyCompartment.reconfigure(o.EditorView.editable.of(!this.readonly&&!this.disabled))})}static async findLanguage(e){if(e){const t=e.split("/").pop();if("asciidoc"===t){const[{asciidoc:e},{StreamLanguage:t}]=await Promise.all([Promise.resolve().then((()=>r(require("codemirror-asciidoc/lib/asciidoc")))),Promise.resolve().then((()=>r(require("@codemirror/stream-parser"))))]);return{name:"asciidoc",support:{extension:t.define(e)}}}{const r=d.languages.find((e=>e.name.toUpperCase()===t.toUpperCase()||e.alias.includes(t)));return null==r&&console.warn(`Cannot find language ${e}, please use language supported by CodeMirror 6`,d.languages.map((e=>e.name))),r}}return null}async _reflectOptions(){const e=await b.findLanguage(this.options.mode);null!=e&&(null==e.support&&await e.load(),this._editorView.dispatch({effects:this.languageCompartment.reconfigure(e.support.extension)}))}static get codemirrorTheme(){return o.EditorView.theme({"&.cm-editor.cm-focused":{outline:"none"},".cm-gutters":{backgroundColor:"var(--gv-input-icon--bgc, var(--gv-theme-neutral-color, #f5f5f5))",color:"var(--gv-theme-font-color-dark, #262626)",borderLeft:"5px solid",borderColor:"var(--gv-input--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9))"}})}static get styles(){return[...super.styles,g.skeleton,v.empty,f.input,i.css`:host{box-sizing:border-box;display:block;margin:0 .2rem .2rem .2rem}.content{position:relative;border:var(--gv-input--bdw,1px) var(--gv-input--bds,solid) var(--gv-input--bdc,var(--gv-theme-neutral-color-dark,#d9d9d9));box-sizing:border-box;border-radius:4px}.box-icon{bottom:-1px;right:-1px;z-index:1}.code .box-icon{border-radius:3px}.code .cm-content,.code .cm-gutters{height:var(--input-medium--h)}.large .code .cm-content,.large .code .cm-gutters{height:var(--input-large--h)}.small .code .cm-content,.small .code .cm-gutters{height:var(--input-small--h)}.input .cm-gutters{display:none}.input .cm-scroller{overflow:hidden}.input .cm-activeLine,:host([readonly]) .cm-activeLine{background-color:transparent}.input .cm-content{padding:0}:host([invalid]) .cm-gutters{border-color:var(--gv-theme-color-error,#da1a1b)}`]}}exports.GvCode=b,window.customElements.define("gv-code",b);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm component
|
|
3
|
+
*
|
|
4
|
+
* ## Details
|
|
5
|
+
* * has @theme facet
|
|
6
|
+
*
|
|
7
|
+
* @extends GvPopover
|
|
8
|
+
*
|
|
9
|
+
* @attr {String} event - the event that triggers the opening
|
|
10
|
+
* @attr {String} okLabel - the label of ok btn
|
|
11
|
+
* @attr {String} cancelLabel - the label of cancel btn
|
|
12
|
+
* @attr {String} icon - the icon before message
|
|
13
|
+
* @attr {String} message - the message
|
|
14
|
+
* @attr {Boolean} disabled - same as native button element `disabled` attribute
|
|
15
|
+
*
|
|
16
|
+
* @cssprop {Color} [--gv-confirm--bgc=var(--gv-theme-neutral-color-lighter, #fafafa)] - Background color
|
|
17
|
+
* @cssprop {Length} [--gv-confirm--maw=350px] - Max width
|
|
18
|
+
*/
|
|
19
|
+
export class GvConfirm extends GvPopover {
|
|
20
|
+
static get properties(): {
|
|
21
|
+
/**
|
|
22
|
+
* @default i18n: gv-confirm.cancel
|
|
23
|
+
*/
|
|
24
|
+
cancelLabel: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @default i18n: gv-confirm.ok
|
|
29
|
+
*/
|
|
30
|
+
okLabel: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
};
|
|
33
|
+
message: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
};
|
|
36
|
+
icon: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
};
|
|
39
|
+
danger: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
reflect: boolean;
|
|
42
|
+
};
|
|
43
|
+
disabled: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
};
|
|
46
|
+
_disabled: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
static get styles(): (import("lit").CSSResult | import("lit").CSSResult[])[];
|
|
51
|
+
icon: string;
|
|
52
|
+
cancelLabel: string;
|
|
53
|
+
okLabel: string;
|
|
54
|
+
_onCancel(): void;
|
|
55
|
+
_onOk(): void;
|
|
56
|
+
_disabled: any;
|
|
57
|
+
_reflectDisabledOnSlot(): void;
|
|
58
|
+
_calculateIsDisabled(): any;
|
|
59
|
+
}
|
|
60
|
+
import { GvPopover } from "./gv-popover";
|
|
@@ -1,188 +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 } from 'lit';
|
|
17
|
-
import '../atoms/gv-button';
|
|
18
|
-
import '../atoms/gv-icon';
|
|
19
|
-
import { i18n } from '../lib/i18n';
|
|
20
|
-
import { GvPopover } from './gv-popover';
|
|
21
|
-
import { dispatchCustomEvent } from '../lib/events';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Confirm component
|
|
25
|
-
*
|
|
26
|
-
* ## Details
|
|
27
|
-
* * has @theme facet
|
|
28
|
-
*
|
|
29
|
-
* @extends GvPopover
|
|
30
|
-
*
|
|
31
|
-
* @attr {String} event - the event that triggers the opening
|
|
32
|
-
* @attr {String} okLabel - the label of ok btn
|
|
33
|
-
* @attr {String} cancelLabel - the label of cancel btn
|
|
34
|
-
* @attr {String} icon - the icon before message
|
|
35
|
-
* @attr {String} message - the message
|
|
36
|
-
* @attr {Boolean} disabled - same as native button element `disabled` attribute
|
|
37
|
-
*
|
|
38
|
-
* @cssprop {Color} [--gv-confirm--bgc=var(--gv-theme-neutral-color-lighter, #fafafa)] - Background color
|
|
39
|
-
* @cssprop {Length} [--gv-confirm--maw=350px] - Max width
|
|
40
|
-
*/
|
|
41
|
-
export class GvConfirm extends GvPopover {
|
|
42
|
-
static get properties() {
|
|
43
|
-
return {
|
|
44
|
-
/**
|
|
45
|
-
* @default i18n: gv-confirm.cancel
|
|
46
|
-
*/
|
|
47
|
-
cancelLabel: { type: String },
|
|
48
|
-
/**
|
|
49
|
-
* @default i18n: gv-confirm.ok
|
|
50
|
-
*/
|
|
51
|
-
okLabel: { type: String },
|
|
52
|
-
message: { type: String },
|
|
53
|
-
icon: { type: String },
|
|
54
|
-
danger: { type: Boolean, reflect: true },
|
|
55
|
-
disabled: { type: Boolean },
|
|
56
|
-
_disabled: { type: Boolean },
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static get styles() {
|
|
61
|
-
return [
|
|
62
|
-
GvPopover.styles,
|
|
63
|
-
// language=CSS
|
|
64
|
-
css`
|
|
65
|
-
:host {
|
|
66
|
-
--gv-icon--s: 24px;
|
|
67
|
-
margin: 0.2rem;
|
|
68
|
-
box-sizing: border-box;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
:host([danger]) .message gv-icon {
|
|
72
|
-
--gv-icon--c: var(--gv-theme-color-danger, #ff5722);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.popover {
|
|
76
|
-
--bgc: var(--gv-confirm--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));
|
|
77
|
-
--maw: var(--gv-confirm--maw, 350px);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.message {
|
|
81
|
-
display: flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
margin: 1rem 0.5rem;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.message gv-icon {
|
|
87
|
-
margin-right: 0.5rem;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.text {
|
|
91
|
-
text-align: center;
|
|
92
|
-
line-height: 24px;
|
|
93
|
-
width: 100%;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.actions {
|
|
97
|
-
text-align: right;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
::slotted(*) {
|
|
101
|
-
margin: 0;
|
|
102
|
-
width: 100%;
|
|
103
|
-
}
|
|
104
|
-
`,
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
constructor() {
|
|
109
|
-
super();
|
|
110
|
-
this.event = 'click';
|
|
111
|
-
this.arrow = true;
|
|
112
|
-
this.auto = true;
|
|
113
|
-
this.icon = 'code:info';
|
|
114
|
-
this.cancelLabel = i18n('gv-confirm.cancel');
|
|
115
|
-
this.okLabel = i18n('gv-confirm.ok');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
connectedCallback() {
|
|
119
|
-
super.connectedCallback();
|
|
120
|
-
window.addEventListener('resize', this._closeHandler);
|
|
121
|
-
window.addEventListener('scroll', this._closeHandler);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
disconnectedCallback() {
|
|
125
|
-
window.removeEventListener('resize', this._closeHandler);
|
|
126
|
-
window.removeEventListener('scroll', this._closeHandler);
|
|
127
|
-
super.disconnectedCallback();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
_onCancel() {
|
|
131
|
-
this.close();
|
|
132
|
-
dispatchCustomEvent(this, 'cancel');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
_onOk() {
|
|
136
|
-
this.close();
|
|
137
|
-
dispatchCustomEvent(this, 'ok');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
_open(e) {
|
|
141
|
-
if (!this._disabled) {
|
|
142
|
-
super._open(e);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
renderContent() {
|
|
147
|
-
return html`
|
|
148
|
-
<div class="message">
|
|
149
|
-
${this.icon ? html`<gv-icon shape="${this.icon}"></gv-icon>` : ''}
|
|
150
|
-
<div class="text" .innerHTML="${this.message}"></div>
|
|
151
|
-
</div>
|
|
152
|
-
<div class="actions">
|
|
153
|
-
<gv-button primary small outlined @click="${this._onCancel}">${this.cancelLabel}</gv-button>
|
|
154
|
-
<gv-button primary small @click="${this._onOk}">${this.okLabel}</gv-button>
|
|
155
|
-
</div>
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
firstUpdated(changedProperties) {
|
|
160
|
-
super.firstUpdated(changedProperties);
|
|
161
|
-
if (this.danger) {
|
|
162
|
-
this.shadowRoot.querySelectorAll('gv-button').forEach((btn) => btn.setAttribute('danger', ''));
|
|
163
|
-
}
|
|
164
|
-
this._disabled = this._calculateIsDisabled();
|
|
165
|
-
if (this.disabled) {
|
|
166
|
-
this._reflectDisabledOnSlot();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
_reflectDisabledOnSlot() {
|
|
171
|
-
const slot = this.shadowRoot.querySelector('slot');
|
|
172
|
-
const childNodes = slot.assignedNodes({ flatten: true });
|
|
173
|
-
childNodes.forEach((node) => {
|
|
174
|
-
node.disabled = true;
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
_calculateIsDisabled() {
|
|
179
|
-
const slot = this.shadowRoot.querySelector('slot');
|
|
180
|
-
const childNodes = slot.assignedNodes({ flatten: true });
|
|
181
|
-
const isSlotButtonDisabled = childNodes
|
|
182
|
-
.filter((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
183
|
-
.some((node) => Boolean(node.getAttribute('disabled')) === true);
|
|
184
|
-
return this.disabled || isSlotButtonDisabled;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
window.customElements.define('gv-confirm', GvConfirm);
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvConfirm=void 0;const e=require("lit");require("../atoms/gv-button"),require("../atoms/gv-icon");const t=require("../lib/i18n"),s=require("./gv-popover"),i=require("../lib/events");class o extends s.GvPopover{static get properties(){return{cancelLabel:{type:String},okLabel:{type:String},message:{type:String},icon:{type:String},danger:{type:Boolean,reflect:!0},disabled:{type:Boolean},_disabled:{type:Boolean}}}static get styles(){return[s.GvPopover.styles,e.css`:host{--gv-icon--s:24px;margin:.2rem;box-sizing:border-box}:host([danger]) .message gv-icon{--gv-icon--c:var(--gv-theme-color-danger, #ff5722)}.popover{--bgc:var(--gv-confirm--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));--maw:var(--gv-confirm--maw, 350px)}.message{display:flex;align-items:center;margin:1rem .5rem}.message gv-icon{margin-right:.5rem}.text{text-align:center;line-height:24px;width:100%}.actions{text-align:right}::slotted(*){margin:0;width:100%}`]}constructor(){super(),this.event="click",this.arrow=!0,this.auto=!0,this.icon="code:info",this.cancelLabel=(0,t.i18n)("gv-confirm.cancel"),this.okLabel=(0,t.i18n)("gv-confirm.ok")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._closeHandler),window.addEventListener("scroll",this._closeHandler)}disconnectedCallback(){window.removeEventListener("resize",this._closeHandler),window.removeEventListener("scroll",this._closeHandler),super.disconnectedCallback()}_onCancel(){this.close(),(0,i.dispatchCustomEvent)(this,"cancel")}_onOk(){this.close(),(0,i.dispatchCustomEvent)(this,"ok")}_open(e){this._disabled||super._open(e)}renderContent(){return e.html`<div class="message">${this.icon?e.html`<gv-icon shape="${this.icon}"></gv-icon>`:""}<div class="text" .innerHTML="${this.message}"></div></div><div class="actions"><gv-button primary small outlined @click="${this._onCancel}">${this.cancelLabel}</gv-button><gv-button primary small @click="${this._onOk}">${this.okLabel}</gv-button></div>`}firstUpdated(e){super.firstUpdated(e),this.danger&&this.shadowRoot.querySelectorAll("gv-button").forEach((e=>e.setAttribute("danger",""))),this._disabled=this._calculateIsDisabled(),this.disabled&&this._reflectDisabledOnSlot()}_reflectDisabledOnSlot(){this.shadowRoot.querySelector("slot").assignedNodes({flatten:!0}).forEach((e=>{e.disabled=!0}))}_calculateIsDisabled(){const e=this.shadowRoot.querySelector("slot").assignedNodes({flatten:!0}).filter((e=>e.nodeType===Node.ELEMENT_NODE)).some((e=>!0===Boolean(e.getAttribute("disabled"))));return this.disabled||e}}exports.GvConfirm=o,window.customElements.define("gv-confirm",o);
|