@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
|
@@ -1,621 +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 { LitElement, html, css } from 'lit';
|
|
17
|
-
import { classMap } from 'lit/directives/class-map';
|
|
18
|
-
import { dispatchCustomEvent } from '../lib/events';
|
|
19
|
-
import '../atoms/gv-image';
|
|
20
|
-
import { appendDraggableImage, uuid } from '../lib/utils';
|
|
21
|
-
import { PolicyDraggable } from './gv-flow-step';
|
|
22
|
-
import { getFlowName, methods } from '../lib/studio';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Flow component
|
|
26
|
-
*
|
|
27
|
-
* @fires gv-flow:drop - Drop event
|
|
28
|
-
* @fires gv-flow:edit - Edit event
|
|
29
|
-
* @fires gv-flow:delete - Delete event
|
|
30
|
-
*
|
|
31
|
-
* @attr {Object} flow - the flow to display
|
|
32
|
-
* @attr {String} selectedStepId - the selected step id
|
|
33
|
-
* @attr {Object} targetedPolicy - true, if flow is targeted for drop action
|
|
34
|
-
* @attr {Boolean} has-policy-filter - true if policies have onRequest/onResponse properties
|
|
35
|
-
* @attr {String} flowsTitle - flows menu title
|
|
36
|
-
* @attr {Boolean} disabled - true for disabled
|
|
37
|
-
* @attr {Boolean} readonly - true if readonly
|
|
38
|
-
*/
|
|
39
|
-
export class GvFlow extends LitElement {
|
|
40
|
-
static get properties() {
|
|
41
|
-
return {
|
|
42
|
-
flow: { type: Object },
|
|
43
|
-
plan: { type: Object },
|
|
44
|
-
policies: { type: Object },
|
|
45
|
-
selectedStepId: { type: String },
|
|
46
|
-
dragPolicy: { type: Object },
|
|
47
|
-
dropPolicy: { type: Object },
|
|
48
|
-
disabled: { type: Boolean, reflect: true },
|
|
49
|
-
hasPolicyFilter: { type: Boolean, attribute: 'has-policy-filter' },
|
|
50
|
-
flowsTitle: { type: String, attribute: 'flows-title' },
|
|
51
|
-
readonly: { type: Boolean, reflect: true },
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
constructor() {
|
|
56
|
-
super();
|
|
57
|
-
this.flowsTitle = 'Flows';
|
|
58
|
-
this.addEventListener('mouseleave', this._onMouseLeave);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
_onMouseLeave() {
|
|
62
|
-
this.dragPolicy = null;
|
|
63
|
-
this.dropPolicy = null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getCandidate() {
|
|
67
|
-
return this.shadowRoot.querySelector('gv-flow-step[empty]');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getFlowSteps() {
|
|
71
|
-
return Array.from(this.shadowRoot.querySelectorAll('gv-flow-step'));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getOrCreateCandidate() {
|
|
75
|
-
let candidate = this.getCandidate();
|
|
76
|
-
if (!candidate) {
|
|
77
|
-
candidate = document.createElement('gv-flow-step');
|
|
78
|
-
candidate.setAttribute('empty', true);
|
|
79
|
-
}
|
|
80
|
-
return candidate;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
removeCandidate() {
|
|
84
|
-
const candidate = this.getCandidate();
|
|
85
|
-
if (candidate) {
|
|
86
|
-
candidate.remove();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_canDropPolicy(flowKey, policy) {
|
|
91
|
-
if (this.disabled || this.readonly) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
if (policy != null) {
|
|
95
|
-
if (flowKey === 'pre') {
|
|
96
|
-
return this.hasPolicyFilter !== true || policy.onRequest === true;
|
|
97
|
-
} else if (flowKey === 'post') {
|
|
98
|
-
return this.hasPolicyFilter !== true || policy.onResponse === true;
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error(`The flowkey [${flowKey}] parameter must be "pre" or "post"`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_onDragOver(flowKey, e) {
|
|
107
|
-
if (!this.disabled && !this.readonly) {
|
|
108
|
-
if (e.dataTransfer.items.length > 0) {
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
e.stopPropagation();
|
|
111
|
-
if (this.dropPolicy == null) {
|
|
112
|
-
this.dropPolicy = this.dragPolicy;
|
|
113
|
-
} else {
|
|
114
|
-
this.dragPolicy = this.dropPolicy;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
this.dropPolicy != null &&
|
|
119
|
-
this._canDropPolicy(flowKey, this.dropPolicy.policy) &&
|
|
120
|
-
!e.target.classList.contains('candidate') &&
|
|
121
|
-
!e.target.hasAttribute('dragging')
|
|
122
|
-
) {
|
|
123
|
-
if (e.target.tagName.toLowerCase() === 'gv-flow-step') {
|
|
124
|
-
const { x, width } = e.target.getBoundingClientRect();
|
|
125
|
-
const condition = flowKey === 'post' ? e.clientX - x <= width / 2 : e.clientX - x >= width / 2;
|
|
126
|
-
if (condition && !(e.target.nextElementSibling && e.target.nextElementSibling.hasAttribute('dragging'))) {
|
|
127
|
-
e.target.insertAdjacentElement('afterend', this.getOrCreateCandidate());
|
|
128
|
-
} else if (!(e.target.previousElementSibling && e.target.previousElementSibling.hasAttribute('dragging'))) {
|
|
129
|
-
e.target.insertAdjacentElement('beforebegin', this.getOrCreateCandidate());
|
|
130
|
-
}
|
|
131
|
-
} else if (e.target.classList && e.target.classList.contains('drop-area-grid')) {
|
|
132
|
-
const dropAreas = e.target.querySelectorAll('gv-flow-step');
|
|
133
|
-
if (dropAreas.length === 0) {
|
|
134
|
-
e.target.prepend(this.getOrCreateCandidate());
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
this.removeCandidate();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
_onDragEnd() {
|
|
145
|
-
if (!this.disabled && !this.readonly) {
|
|
146
|
-
if (this._draggablePolicyImage) {
|
|
147
|
-
this._draggablePolicyImage.remove();
|
|
148
|
-
this._draggablePolicyImage = null;
|
|
149
|
-
}
|
|
150
|
-
this.dragPolicy = null;
|
|
151
|
-
this.dropPolicy = null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
_onDragStart(sourceFlowKey, flowStep, sourcePosition, e) {
|
|
156
|
-
if (!this.disabled && !this.readonly) {
|
|
157
|
-
const policy = this.findPolicy(flowStep.policy);
|
|
158
|
-
if (policy != null) {
|
|
159
|
-
// Simulate click on window for close all dropdown menu
|
|
160
|
-
const windowClick = document.createEvent('Events');
|
|
161
|
-
windowClick.initEvent('click', true, false);
|
|
162
|
-
window.dispatchEvent(windowClick);
|
|
163
|
-
e.target.setAttribute('dragging', true);
|
|
164
|
-
this.shadowRoot.querySelector('.drop-area-grid').classList.add('dragging');
|
|
165
|
-
|
|
166
|
-
this.dropPolicy = new PolicyDraggable(policy, sourcePosition, sourceFlowKey, this.flow._id, flowStep);
|
|
167
|
-
e.dataTransfer.setData('text/plain', this.dropPolicy.toString());
|
|
168
|
-
if (policy) {
|
|
169
|
-
const size = 100;
|
|
170
|
-
this._draggablePolicyImage = appendDraggableImage(policy.icon, size);
|
|
171
|
-
e.dataTransfer.setDragImage(this._draggablePolicyImage, size / 2, size / 2);
|
|
172
|
-
}
|
|
173
|
-
dispatchCustomEvent(this, 'drag-start', this.dropPolicy);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async performUpdate() {
|
|
179
|
-
this.getFlowSteps().forEach((s) => {
|
|
180
|
-
s.requestUpdate();
|
|
181
|
-
});
|
|
182
|
-
super.performUpdate();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get draggingArea() {
|
|
186
|
-
return this.shadowRoot.querySelector('gv-flow-step[dragging]');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
_onDrop(flowKey, e) {
|
|
190
|
-
this.shadowRoot.querySelectorAll('gv-flow-step').forEach((step) => step.resetConfirm());
|
|
191
|
-
e.preventDefault();
|
|
192
|
-
e.stopPropagation();
|
|
193
|
-
const box = e.target.closest('.drop-area-grid');
|
|
194
|
-
const candidate = this.getCandidate();
|
|
195
|
-
const draggingArea = this.draggingArea;
|
|
196
|
-
if (candidate) {
|
|
197
|
-
let position = 0;
|
|
198
|
-
[...box.querySelectorAll('gv-flow-step')].some((area) => {
|
|
199
|
-
if (!area.hasAttribute('empty')) {
|
|
200
|
-
position++;
|
|
201
|
-
}
|
|
202
|
-
return area.hasAttribute('empty');
|
|
203
|
-
});
|
|
204
|
-
const { policy, sourceFlowKey, sourceFlowId, sourcePosition, flowStep } = this.dropPolicy;
|
|
205
|
-
const move = () => {
|
|
206
|
-
if (draggingArea) {
|
|
207
|
-
draggingArea.removeAttribute('dragging');
|
|
208
|
-
}
|
|
209
|
-
candidate.remove();
|
|
210
|
-
dispatchCustomEvent(this, 'drop', {
|
|
211
|
-
flowId: this.flow._id,
|
|
212
|
-
flowKey,
|
|
213
|
-
position,
|
|
214
|
-
flowStep,
|
|
215
|
-
policy,
|
|
216
|
-
sourcePosition,
|
|
217
|
-
sourceFlowKey,
|
|
218
|
-
sourceFlowId,
|
|
219
|
-
});
|
|
220
|
-
this.dragPolicy = null;
|
|
221
|
-
this.dropPolicy = null;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
if (sourceFlowId != null && this.flow._id !== sourceFlowId) {
|
|
225
|
-
candidate.setAttribute('confirm', true);
|
|
226
|
-
candidate.addEventListener('gv-flow-step:copy', () => {
|
|
227
|
-
candidate.remove();
|
|
228
|
-
this.dragPolicy = null;
|
|
229
|
-
this.dropPolicy = null;
|
|
230
|
-
dispatchCustomEvent(this, 'drop', {
|
|
231
|
-
flowId: this.flow._id,
|
|
232
|
-
flowKey,
|
|
233
|
-
position,
|
|
234
|
-
policy,
|
|
235
|
-
flowStep,
|
|
236
|
-
cancelEdit: true,
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
candidate.addEventListener('gv-flow-step:move', () => {
|
|
241
|
-
candidate.remove();
|
|
242
|
-
move();
|
|
243
|
-
});
|
|
244
|
-
} else {
|
|
245
|
-
move();
|
|
246
|
-
}
|
|
247
|
-
} else if (draggingArea) {
|
|
248
|
-
draggingArea.removeAttribute('dragging');
|
|
249
|
-
this.dragPolicy = null;
|
|
250
|
-
this.dropPolicy = null;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
getFlowStep(flowKey, position) {
|
|
255
|
-
return this.flow[flowKey][position];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
_onEditStep({ detail: { step, policy, group } }) {
|
|
259
|
-
dispatchCustomEvent(this, 'edit', { flow: this.flow, step, policy, group });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
_onDuplicateStep(flowKey, position) {
|
|
263
|
-
const step = this.getFlowStep(flowKey, position);
|
|
264
|
-
const duplicatePosition = position + 1;
|
|
265
|
-
const policy = this.findPolicy(step.policy);
|
|
266
|
-
const duplicateStep = { ...step, _id: uuid() };
|
|
267
|
-
dispatchCustomEvent(this, 'drop', {
|
|
268
|
-
flowId: this.flow._id,
|
|
269
|
-
flowKey,
|
|
270
|
-
position: duplicatePosition,
|
|
271
|
-
flowStep: duplicateStep,
|
|
272
|
-
policy,
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
_isEditable(step) {
|
|
277
|
-
return this.selectedStepId && this.selectedStepId === step._id;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
_onDeleteStep(flowKey, position, e) {
|
|
281
|
-
dispatchCustomEvent(this, 'delete', { flowKey, position, flowId: this.flow._id, target: e.target });
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
_onChangeStepState(flowKey, position, { detail }) {
|
|
285
|
-
dispatchCustomEvent(this, 'change-state', { flowKey, position, flowId: this.flow._id, ...detail });
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
_renderDropStep(group, step, position) {
|
|
289
|
-
if (step) {
|
|
290
|
-
return html`<gv-flow-step
|
|
291
|
-
.step="${step}"
|
|
292
|
-
.policy="${this.findPolicy(step.policy)}"
|
|
293
|
-
.id="${step._id}"
|
|
294
|
-
.group="${group}"
|
|
295
|
-
.parent="${this.flow._id}"
|
|
296
|
-
?disabled="${this.disabled}"
|
|
297
|
-
?readonly="${this.readonly}"
|
|
298
|
-
.draggable="${!this.disabled && !this.readonly}"
|
|
299
|
-
?editing="${this._isEditable(step)}"
|
|
300
|
-
@dragstart="${this._onDragStart.bind(this, group, step, position)}"
|
|
301
|
-
@dragend="${this._onDragEnd}"
|
|
302
|
-
@gv-flow-step:edit="${this._onEditStep}"
|
|
303
|
-
@gv-flow-step:change-state="${this._onChangeStepState.bind(this, group, position)}"
|
|
304
|
-
@gv-flow-step:delete="${this._onDeleteStep.bind(this, group, position)}"
|
|
305
|
-
@gv-flow-step:duplicate="${this._onDuplicateStep.bind(this, group, position)}"
|
|
306
|
-
></gv-flow-step>`;
|
|
307
|
-
} else {
|
|
308
|
-
return html``;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
async getUpdateComplete() {
|
|
313
|
-
await super.getUpdateComplete();
|
|
314
|
-
await Promise.all(this.getFlowSteps().map((e) => e.updateComplete));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
updated(properties) {
|
|
318
|
-
if (properties.has('data')) {
|
|
319
|
-
this.onDragEnd();
|
|
320
|
-
}
|
|
321
|
-
if (properties.has('dropPolicy') || properties.has('dragPolicy')) {
|
|
322
|
-
if (this.dropPolicy == null && this.dragPolicy == null) {
|
|
323
|
-
this.removeCandidate();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
onDragEnd() {
|
|
329
|
-
setTimeout(() => {
|
|
330
|
-
this.shadowRoot.querySelector('.drop-area-grid').classList.remove('dragging');
|
|
331
|
-
this.removeCandidate();
|
|
332
|
-
const draggingArea = this.draggingArea;
|
|
333
|
-
if (draggingArea) {
|
|
334
|
-
draggingArea.removeAttribute('dragging');
|
|
335
|
-
}
|
|
336
|
-
}, 0);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
_getLabel(flowKey) {
|
|
340
|
-
if (this.flow.type) {
|
|
341
|
-
return html`
|
|
342
|
-
<div class="drop-box-type">${flowKey}</div>
|
|
343
|
-
<div>${this.flow.type.toUpperCase() === 'ROOT' ? 'flow' : this.flow.type}</div>
|
|
344
|
-
`;
|
|
345
|
-
} else if (flowKey === 'pre') {
|
|
346
|
-
return 'request';
|
|
347
|
-
} else if (flowKey === 'post') {
|
|
348
|
-
return 'response';
|
|
349
|
-
}
|
|
350
|
-
return '';
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
get collectionName() {
|
|
354
|
-
return this.plan != null ? this.plan.name : this.flowsTitle;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
render() {
|
|
358
|
-
const preTarget = this.dragPolicy && (this.hasPolicyFilter !== true || this.dragPolicy.policy.onRequest);
|
|
359
|
-
const postTarget = this.dragPolicy && (this.hasPolicyFilter !== true || this.dragPolicy.policy.onResponse);
|
|
360
|
-
|
|
361
|
-
const preForbidden = this.dragPolicy && this.hasPolicyFilter === true && !this.dragPolicy.policy.onRequest;
|
|
362
|
-
const postForbidden = this.dragPolicy && this.hasPolicyFilter === true && !this.dragPolicy.policy.onResponse;
|
|
363
|
-
const hasPost = this.flow.type == null || (this.flow.type && this.flow.type.toLowerCase() !== 'root');
|
|
364
|
-
return html`<div class="box">
|
|
365
|
-
<div class="container">
|
|
366
|
-
<div class="header">
|
|
367
|
-
<div class="title">${getFlowName(this.flow, this.collectionName)}</div>
|
|
368
|
-
</div>
|
|
369
|
-
<div class="content">
|
|
370
|
-
<div class="flow">
|
|
371
|
-
<div class="${classMap({ pre: true, targeted: preTarget, forbidden: preForbidden })}">
|
|
372
|
-
<div class="arrow arrow-right"></div>
|
|
373
|
-
<div
|
|
374
|
-
class="drop-box"
|
|
375
|
-
@drop="${this._onDrop.bind(this, 'pre')}"
|
|
376
|
-
@dragend="${this.onDragEnd}"
|
|
377
|
-
@dragover="${this._onDragOver.bind(this, 'pre')}"
|
|
378
|
-
>
|
|
379
|
-
<div class="drop-box-title">${preTarget ? 'drop here' : this._getLabel('pre')}</div>
|
|
380
|
-
<div class="drop-area-grid">${this.flow.pre.map((flowStep, i) => this._renderDropStep('pre', flowStep, i))}</div>
|
|
381
|
-
</div>
|
|
382
|
-
</div>
|
|
383
|
-
|
|
384
|
-
${hasPost
|
|
385
|
-
? html`
|
|
386
|
-
<div class="${classMap({ post: true, targeted: postTarget, forbidden: postForbidden })}">
|
|
387
|
-
<div class='arrow arrow-left'> </div>
|
|
388
|
-
<div class="drop-box"
|
|
389
|
-
@drop="${this._onDrop.bind(this, 'post')}"
|
|
390
|
-
@dragend="${this.onDragEnd}"
|
|
391
|
-
@dragover="${this._onDragOver.bind(this, 'post')}">
|
|
392
|
-
<div class="drop-area-grid drop-area-grid-reverse">
|
|
393
|
-
${this.flow.post.map((flowStep, i) => this._renderDropStep('post', flowStep, i))}
|
|
394
|
-
</div>
|
|
395
|
-
<div class="drop-box-title">${postTarget ? 'drop here' : this._getLabel('post')}</div>
|
|
396
|
-
</div>
|
|
397
|
-
</div>
|
|
398
|
-
</div>`
|
|
399
|
-
: ''}
|
|
400
|
-
</div>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
</div>`;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
findPolicy(policyId) {
|
|
407
|
-
const policy = this.policies.find((p) => p.id === policyId);
|
|
408
|
-
if (policy == null) {
|
|
409
|
-
// throw new Error(`Policy ${policyId} not found`);
|
|
410
|
-
}
|
|
411
|
-
return policy;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
static get styles() {
|
|
415
|
-
return [
|
|
416
|
-
methods,
|
|
417
|
-
// language=CSS
|
|
418
|
-
css`
|
|
419
|
-
:host {
|
|
420
|
-
box-sizing: border-box;
|
|
421
|
-
position: relative;
|
|
422
|
-
display: block;
|
|
423
|
-
height: 100%;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
.flow {
|
|
427
|
-
padding-left: 20px;
|
|
428
|
-
display: flex;
|
|
429
|
-
height: 100%;
|
|
430
|
-
flex-direction: column;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
.drop-area-grid {
|
|
434
|
-
flex: 1;
|
|
435
|
-
border: 1px dashed transparent;
|
|
436
|
-
transition: all 350ms ease-in-out;
|
|
437
|
-
position: relative;
|
|
438
|
-
display: flex;
|
|
439
|
-
flex-wrap: wrap;
|
|
440
|
-
max-width: calc(100% - 40px);
|
|
441
|
-
align-items: center;
|
|
442
|
-
min-height: 150px;
|
|
443
|
-
box-sizing: border-box;
|
|
444
|
-
padding: 0 30px;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
.targeted .drop-area-grid {
|
|
448
|
-
border: 1px dashed #d9d9d9;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
.forbidden .drop-area-grid {
|
|
452
|
-
background-color: #efefef;
|
|
453
|
-
opacity: 0.2;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
gv-flow-step {
|
|
457
|
-
flex: 1;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
.message {
|
|
461
|
-
text-transform: uppercase;
|
|
462
|
-
color: #d9d9d9;
|
|
463
|
-
opacity: 0;
|
|
464
|
-
transition: opacity 350ms ease-in-out;
|
|
465
|
-
font-size: 18px;
|
|
466
|
-
text-align: center;
|
|
467
|
-
align-self: center;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
.message {
|
|
471
|
-
width: 100%;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
.targeted .message {
|
|
475
|
-
opacity: 1;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
.targeted .drop-area-empty {
|
|
479
|
-
opacity: 0;
|
|
480
|
-
transition: all 350ms ease-in-out;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
.pre,
|
|
484
|
-
.post {
|
|
485
|
-
position: relative;
|
|
486
|
-
flex: 1;
|
|
487
|
-
display: flex;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
.arrow {
|
|
491
|
-
background-color: #d9d9d9;
|
|
492
|
-
width: calc(100% - 50px * 2 - 1px);
|
|
493
|
-
text-align: center;
|
|
494
|
-
position: absolute;
|
|
495
|
-
margin: 0 30px;
|
|
496
|
-
color: #262626;
|
|
497
|
-
top: calc(50% - 20px);
|
|
498
|
-
height: 40px;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
.arrow-right::after {
|
|
502
|
-
width: 0;
|
|
503
|
-
height: 0;
|
|
504
|
-
border-top: 40px solid transparent;
|
|
505
|
-
border-bottom: 40px solid transparent;
|
|
506
|
-
border-left: 40px solid #d9d9d9;
|
|
507
|
-
content: ' ';
|
|
508
|
-
position: absolute;
|
|
509
|
-
right: -20px;
|
|
510
|
-
top: -20px;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
.drop-box-type {
|
|
514
|
-
position: relative;
|
|
515
|
-
writing-mode: horizontal-tb;
|
|
516
|
-
margin-bottom: 10px;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
.drop-box-title {
|
|
520
|
-
position: relative;
|
|
521
|
-
writing-mode: vertical-lr;
|
|
522
|
-
text-orientation: upright;
|
|
523
|
-
text-transform: uppercase;
|
|
524
|
-
color: #bfbfbf;
|
|
525
|
-
font-size: 13px;
|
|
526
|
-
font-weight: 500;
|
|
527
|
-
text-align: center;
|
|
528
|
-
max-height: 145px;
|
|
529
|
-
line-height: 13px;
|
|
530
|
-
display: flex;
|
|
531
|
-
align-items: center;
|
|
532
|
-
min-width: 30px;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
.pre .drop-box-title {
|
|
536
|
-
position: absolute;
|
|
537
|
-
left: -30px;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
.arrow-left::after {
|
|
541
|
-
width: 0;
|
|
542
|
-
height: 0;
|
|
543
|
-
border-top: 40px solid transparent;
|
|
544
|
-
border-bottom: 40px solid transparent;
|
|
545
|
-
border-right: 40px solid #d9d9d9;
|
|
546
|
-
content: ' ';
|
|
547
|
-
position: absolute;
|
|
548
|
-
left: -20px;
|
|
549
|
-
top: -20px;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
.drop-box {
|
|
553
|
-
display: flex;
|
|
554
|
-
border: 1px solid transparent;
|
|
555
|
-
margin: 0 30px;
|
|
556
|
-
align-items: center;
|
|
557
|
-
position: relative;
|
|
558
|
-
width: 100%;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
.drop-area-grid-reverse {
|
|
562
|
-
flex-direction: row-reverse;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
.header {
|
|
566
|
-
border-bottom: 1px solid #d9d9d9;
|
|
567
|
-
display: flex;
|
|
568
|
-
min-height: 45px;
|
|
569
|
-
margin-bottom: 0.5rem;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
.header .title {
|
|
573
|
-
color: #28444f;
|
|
574
|
-
font-size: 18px;
|
|
575
|
-
display: flex;
|
|
576
|
-
align-items: center;
|
|
577
|
-
margin: 0 0.5rem;
|
|
578
|
-
width: 100%;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
.header .title .flow-path {
|
|
582
|
-
flex: 1;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
.box {
|
|
586
|
-
position: absolute;
|
|
587
|
-
display: flex;
|
|
588
|
-
flex-direction: column;
|
|
589
|
-
width: 100%;
|
|
590
|
-
top: 0;
|
|
591
|
-
bottom: 0;
|
|
592
|
-
left: 0;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
.container {
|
|
596
|
-
flex-grow: 1;
|
|
597
|
-
|
|
598
|
-
display: flex;
|
|
599
|
-
flex-direction: column;
|
|
600
|
-
|
|
601
|
-
/* for Firefox */
|
|
602
|
-
min-height: 0;
|
|
603
|
-
height: 100%;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
.content {
|
|
607
|
-
background: white;
|
|
608
|
-
flex-grow: 1;
|
|
609
|
-
|
|
610
|
-
overflow: auto;
|
|
611
|
-
|
|
612
|
-
/* for Firefox */
|
|
613
|
-
min-height: 0;
|
|
614
|
-
padding: 0.5rem;
|
|
615
|
-
}
|
|
616
|
-
`,
|
|
617
|
-
];
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
window.customElements.define('gv-flow', GvFlow);
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvFlow=void 0;const t=require("lit"),e=require("lit/directives/class-map"),i=require("../lib/events");require("../atoms/gv-image");const o=require("../lib/utils"),r=require("./gv-flow-step"),s=require("../lib/studio");class l extends t.LitElement{static get properties(){return{flow:{type:Object},plan:{type:Object},policies:{type:Object},selectedStepId:{type:String},dragPolicy:{type:Object},dropPolicy:{type:Object},disabled:{type:Boolean,reflect:!0},hasPolicyFilter:{type:Boolean,attribute:"has-policy-filter"},flowsTitle:{type:String,attribute:"flows-title"},readonly:{type:Boolean,reflect:!0}}}constructor(){super(),this.flowsTitle="Flows",this.addEventListener("mouseleave",this._onMouseLeave)}_onMouseLeave(){this.dragPolicy=null,this.dropPolicy=null}getCandidate(){return this.shadowRoot.querySelector("gv-flow-step[empty]")}getFlowSteps(){return Array.from(this.shadowRoot.querySelectorAll("gv-flow-step"))}getOrCreateCandidate(){let t=this.getCandidate();return t||(t=document.createElement("gv-flow-step"),t.setAttribute("empty",!0)),t}removeCandidate(){const t=this.getCandidate();t&&t.remove()}_canDropPolicy(t,e){if(this.disabled||this.readonly)return!1;if(null!=e){if("pre"===t)return!0!==this.hasPolicyFilter||!0===e.onRequest;if("post"===t)return!0!==this.hasPolicyFilter||!0===e.onResponse;throw new Error(`The flowkey [${t}] parameter must be "pre" or "post"`)}return!1}_onDragOver(t,e){if(!this.disabled&&!this.readonly&&e.dataTransfer.items.length>0&&(e.preventDefault(),e.stopPropagation(),null==this.dropPolicy?this.dropPolicy=this.dragPolicy:this.dragPolicy=this.dropPolicy,null!=this.dropPolicy&&this._canDropPolicy(t,this.dropPolicy.policy)&&!e.target.classList.contains("candidate")&&!e.target.hasAttribute("dragging")))if("gv-flow-step"===e.target.tagName.toLowerCase()){const{x:i,width:o}=e.target.getBoundingClientRect();!("post"===t?e.clientX-i<=o/2:e.clientX-i>=o/2)||e.target.nextElementSibling&&e.target.nextElementSibling.hasAttribute("dragging")?e.target.previousElementSibling&&e.target.previousElementSibling.hasAttribute("dragging")||e.target.insertAdjacentElement("beforebegin",this.getOrCreateCandidate()):e.target.insertAdjacentElement("afterend",this.getOrCreateCandidate())}else if(e.target.classList&&e.target.classList.contains("drop-area-grid")){0===e.target.querySelectorAll("gv-flow-step").length&&e.target.prepend(this.getOrCreateCandidate())}else this.removeCandidate()}_onDragEnd(){this.disabled||this.readonly||(this._draggablePolicyImage&&(this._draggablePolicyImage.remove(),this._draggablePolicyImage=null),this.dragPolicy=null,this.dropPolicy=null)}_onDragStart(t,e,s,l){if(!this.disabled&&!this.readonly){const a=this.findPolicy(e.policy);if(null!=a){const d=document.createEvent("Events");if(d.initEvent("click",!0,!1),window.dispatchEvent(d),l.target.setAttribute("dragging",!0),this.shadowRoot.querySelector(".drop-area-grid").classList.add("dragging"),this.dropPolicy=new r.PolicyDraggable(a,s,t,this.flow._id,e),l.dataTransfer.setData("text/plain",this.dropPolicy.toString()),a){const t=100;this._draggablePolicyImage=(0,o.appendDraggableImage)(a.icon,t),l.dataTransfer.setDragImage(this._draggablePolicyImage,t/2,t/2)}(0,i.dispatchCustomEvent)(this,"drag-start",this.dropPolicy)}}}async performUpdate(){this.getFlowSteps().forEach((t=>{t.requestUpdate()})),super.performUpdate()}get draggingArea(){return this.shadowRoot.querySelector("gv-flow-step[dragging]")}_onDrop(t,e){this.shadowRoot.querySelectorAll("gv-flow-step").forEach((t=>t.resetConfirm())),e.preventDefault(),e.stopPropagation();const o=e.target.closest(".drop-area-grid"),r=this.getCandidate(),s=this.draggingArea;if(r){let e=0;[...o.querySelectorAll("gv-flow-step")].some((t=>(t.hasAttribute("empty")||e++,t.hasAttribute("empty"))));const{policy:l,sourceFlowKey:a,sourceFlowId:d,sourcePosition:n,flowStep:p}=this.dropPolicy,g=()=>{s&&s.removeAttribute("dragging"),r.remove(),(0,i.dispatchCustomEvent)(this,"drop",{flowId:this.flow._id,flowKey:t,position:e,flowStep:p,policy:l,sourcePosition:n,sourceFlowKey:a,sourceFlowId:d}),this.dragPolicy=null,this.dropPolicy=null};null!=d&&this.flow._id!==d?(r.setAttribute("confirm",!0),r.addEventListener("gv-flow-step:copy",(()=>{r.remove(),this.dragPolicy=null,this.dropPolicy=null,(0,i.dispatchCustomEvent)(this,"drop",{flowId:this.flow._id,flowKey:t,position:e,policy:l,flowStep:p,cancelEdit:!0})})),r.addEventListener("gv-flow-step:move",(()=>{r.remove(),g()}))):g()}else s&&(s.removeAttribute("dragging"),this.dragPolicy=null,this.dropPolicy=null)}getFlowStep(t,e){return this.flow[t][e]}_onEditStep({detail:{step:t,policy:e,group:o}}){(0,i.dispatchCustomEvent)(this,"edit",{flow:this.flow,step:t,policy:e,group:o})}_onDuplicateStep(t,e){const r=this.getFlowStep(t,e),s=e+1,l=this.findPolicy(r.policy),a={...r,_id:(0,o.uuid)()};(0,i.dispatchCustomEvent)(this,"drop",{flowId:this.flow._id,flowKey:t,position:s,flowStep:a,policy:l})}_isEditable(t){return this.selectedStepId&&this.selectedStepId===t._id}_onDeleteStep(t,e,o){(0,i.dispatchCustomEvent)(this,"delete",{flowKey:t,position:e,flowId:this.flow._id,target:o.target})}_onChangeStepState(t,e,{detail:o}){(0,i.dispatchCustomEvent)(this,"change-state",{flowKey:t,position:e,flowId:this.flow._id,...o})}_renderDropStep(e,i,o){return i?t.html`<gv-flow-step .step="${i}" .policy="${this.findPolicy(i.policy)}" .id="${i._id}" .group="${e}" .parent="${this.flow._id}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" .draggable="${!this.disabled&&!this.readonly}" ?editing="${this._isEditable(i)}" @dragstart="${this._onDragStart.bind(this,e,i,o)}" @dragend="${this._onDragEnd}" @gv-flow-step:edit="${this._onEditStep}" @gv-flow-step:change-state="${this._onChangeStepState.bind(this,e,o)}" @gv-flow-step:delete="${this._onDeleteStep.bind(this,e,o)}" @gv-flow-step:duplicate="${this._onDuplicateStep.bind(this,e,o)}"></gv-flow-step>`:t.html``}async getUpdateComplete(){await super.getUpdateComplete(),await Promise.all(this.getFlowSteps().map((t=>t.updateComplete)))}updated(t){t.has("data")&&this.onDragEnd(),(t.has("dropPolicy")||t.has("dragPolicy"))&&null==this.dropPolicy&&null==this.dragPolicy&&this.removeCandidate()}onDragEnd(){setTimeout((()=>{this.shadowRoot.querySelector(".drop-area-grid").classList.remove("dragging"),this.removeCandidate();const t=this.draggingArea;t&&t.removeAttribute("dragging")}),0)}_getLabel(e){return this.flow.type?t.html`<div class="drop-box-type">${e}</div><div>${"ROOT"===this.flow.type.toUpperCase()?"flow":this.flow.type}</div>`:"pre"===e?"request":"post"===e?"response":""}get collectionName(){return null!=this.plan?this.plan.name:this.flowsTitle}render(){const i=this.dragPolicy&&(!0!==this.hasPolicyFilter||this.dragPolicy.policy.onRequest),o=this.dragPolicy&&(!0!==this.hasPolicyFilter||this.dragPolicy.policy.onResponse),r=this.dragPolicy&&!0===this.hasPolicyFilter&&!this.dragPolicy.policy.onRequest,l=this.dragPolicy&&!0===this.hasPolicyFilter&&!this.dragPolicy.policy.onResponse,a=null==this.flow.type||this.flow.type&&"root"!==this.flow.type.toLowerCase();return t.html`<div class="box"><div class="container"><div class="header"><div class="title">${(0,s.getFlowName)(this.flow,this.collectionName)}</div></div><div class="content"><div class="flow"><div class="${(0,e.classMap)({pre:!0,targeted:i,forbidden:r})}"><div class="arrow arrow-right"></div><div class="drop-box" @drop="${this._onDrop.bind(this,"pre")}" @dragend="${this.onDragEnd}" @dragover="${this._onDragOver.bind(this,"pre")}"><div class="drop-box-title">${i?"drop here":this._getLabel("pre")}</div><div class="drop-area-grid">${this.flow.pre.map(((t,e)=>this._renderDropStep("pre",t,e)))}</div></div></div>${a?t.html`<div class="${(0,e.classMap)({post:!0,targeted:o,forbidden:l})}"><div class="arrow arrow-left"></div><div class="drop-box" @drop="${this._onDrop.bind(this,"post")}" @dragend="${this.onDragEnd}" @dragover="${this._onDragOver.bind(this,"post")}"><div class="drop-area-grid drop-area-grid-reverse">${this.flow.post.map(((t,e)=>this._renderDropStep("post",t,e)))}</div><div class="drop-box-title">${o?"drop here":this._getLabel("post")}</div></div></div>`:""}</div></div></div></div>`}findPolicy(t){return this.policies.find((e=>e.id===t))}static get styles(){return[s.methods,t.css`:host{box-sizing:border-box;position:relative;display:block;height:100%}.flow{padding-left:20px;display:flex;height:100%;flex-direction:column}.drop-area-grid{flex:1;border:1px dashed transparent;transition:all 350ms ease-in-out;position:relative;display:flex;flex-wrap:wrap;max-width:calc(100% - 40px);align-items:center;min-height:150px;box-sizing:border-box;padding:0 30px}.targeted .drop-area-grid{border:1px dashed #d9d9d9}.forbidden .drop-area-grid{background-color:#efefef;opacity:.2}gv-flow-step{flex:1}.message{text-transform:uppercase;color:#d9d9d9;opacity:0;transition:opacity 350ms ease-in-out;font-size:18px;text-align:center;align-self:center}.message{width:100%}.targeted .message{opacity:1}.targeted .drop-area-empty{opacity:0;transition:all 350ms ease-in-out}.post,.pre{position:relative;flex:1;display:flex}.arrow{background-color:#d9d9d9;width:calc(100% - 50px * 2 - 1px);text-align:center;position:absolute;margin:0 30px;color:#262626;top:calc(50% - 20px);height:40px}.arrow-right::after{width:0;height:0;border-top:40px solid transparent;border-bottom:40px solid transparent;border-left:40px solid #d9d9d9;content:' ';position:absolute;right:-20px;top:-20px}.drop-box-type{position:relative;writing-mode:horizontal-tb;margin-bottom:10px}.drop-box-title{position:relative;writing-mode:vertical-lr;text-orientation:upright;text-transform:uppercase;color:#bfbfbf;font-size:13px;font-weight:500;text-align:center;max-height:145px;line-height:13px;display:flex;align-items:center;min-width:30px}.pre .drop-box-title{position:absolute;left:-30px}.arrow-left::after{width:0;height:0;border-top:40px solid transparent;border-bottom:40px solid transparent;border-right:40px solid #d9d9d9;content:' ';position:absolute;left:-20px;top:-20px}.drop-box{display:flex;border:1px solid transparent;margin:0 30px;align-items:center;position:relative;width:100%}.drop-area-grid-reverse{flex-direction:row-reverse}.header{border-bottom:1px solid #d9d9d9;display:flex;min-height:45px;margin-bottom:.5rem}.header .title{color:#28444f;font-size:18px;display:flex;align-items:center;margin:0 .5rem;width:100%}.header .title .flow-path{flex:1}.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}`]}}exports.GvFlow=l,window.customElements.define("gv-flow",l);
|