@gravitee/ui-components 3.25.3-typescript-50960c3 → 3.25.3-typescript-9d19b68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/package.json +5 -13
  2. package/src/atoms/gv-autocomplete.js +422 -1
  3. package/src/atoms/gv-button.js +397 -1
  4. package/src/atoms/gv-checkbox.js +178 -1
  5. package/src/atoms/gv-date-picker-calendar.js +812 -1
  6. package/src/atoms/gv-date-picker-cell.js +174 -1
  7. package/src/atoms/gv-date-picker.js +638 -1
  8. package/src/atoms/gv-file-upload.js +348 -1
  9. package/src/atoms/gv-icon.js +93 -1
  10. package/src/atoms/gv-image.js +135 -1
  11. package/src/atoms/gv-input-message.js +78 -1
  12. package/src/atoms/gv-input.js +508 -1
  13. package/src/atoms/gv-link.js +204 -1
  14. package/src/atoms/gv-message.js +133 -1
  15. package/src/atoms/gv-metric.js +112 -1
  16. package/src/atoms/gv-relative-time.js +143 -1
  17. package/src/atoms/gv-select-native.js +363 -1
  18. package/src/atoms/gv-select.js +413 -1
  19. package/src/atoms/gv-spinner.js +54 -1
  20. package/src/atoms/gv-state.js +125 -1
  21. package/src/atoms/gv-switch.js +235 -1
  22. package/src/atoms/gv-tag.js +162 -1
  23. package/src/atoms/gv-text.js +160 -1
  24. package/src/charts/gv-chart-bar.js +101 -1
  25. package/src/charts/gv-chart-gauge.js +92 -1
  26. package/src/charts/gv-chart-histogram.js +78 -1
  27. package/src/charts/gv-chart-line.js +218 -1
  28. package/src/charts/gv-chart-map.js +111 -1
  29. package/src/charts/gv-chart-pie.js +89 -1
  30. package/src/index.js +77 -1
  31. package/src/lib/cron-expression.js +176 -1
  32. package/src/lib/date.js +43 -1
  33. package/src/lib/events.js +26 -1
  34. package/src/lib/http-client-schema-form.js +67 -1
  35. package/src/lib/http.js +237 -1
  36. package/src/lib/i18n.js +93 -1
  37. package/src/lib/item.js +110 -1
  38. package/src/lib/properties.js +171 -1
  39. package/src/lib/schema-form.js +39 -1
  40. package/src/lib/studio.js +144 -1
  41. package/src/lib/style.js +39 -1
  42. package/src/lib/text-format.js +65 -1
  43. package/src/lib/theme.js +60 -1
  44. package/src/lib/utils.js +106 -1
  45. package/src/mixins/chart-element.js +153 -1
  46. package/src/mixins/input-element.js +136 -1
  47. package/src/mixins/item-resource.js +102 -1
  48. package/src/mixins/keyboard-element.js +62 -1
  49. package/src/mixins/update-after-browser.js +30 -1
  50. package/src/mixins/with-resize-observer.js +62 -1
  51. package/src/mixins/with-skeleton-attribute.js +109 -1
  52. package/src/molecules/gv-card-full.js +209 -1
  53. package/src/molecules/gv-card-list.js +101 -1
  54. package/src/molecules/gv-card.js +130 -1
  55. package/src/molecules/gv-category-list.js +56 -1
  56. package/src/molecules/gv-category.js +163 -1
  57. package/src/molecules/gv-code.js +334 -1
  58. package/src/molecules/gv-confirm.js +175 -1
  59. package/src/molecules/gv-cron-editor.js +685 -1
  60. package/src/molecules/gv-dropdown-menu.js +108 -1
  61. package/src/molecules/gv-expandable.js +116 -1
  62. package/src/molecules/gv-expression-language.js +263 -1
  63. package/src/molecules/gv-identity-picture.js +139 -1
  64. package/src/molecules/gv-list.js +214 -1
  65. package/src/molecules/gv-metrics.js +147 -1
  66. package/src/molecules/gv-modal.js +203 -1
  67. package/src/molecules/gv-nav.js +180 -1
  68. package/src/molecules/gv-option.js +230 -1
  69. package/src/molecules/gv-plans.js +400 -1
  70. package/src/molecules/gv-popover.js +323 -1
  71. package/src/molecules/gv-promote.js +203 -1
  72. package/src/molecules/gv-rating-list.js +341 -1
  73. package/src/molecules/gv-rating.js +234 -1
  74. package/src/molecules/gv-row-expandable.js +42 -1
  75. package/src/molecules/gv-row.js +205 -1
  76. package/src/molecules/gv-stats.js +110 -1
  77. package/src/molecules/gv-stepper.js +274 -1
  78. package/src/molecules/gv-table.js +644 -1
  79. package/src/molecules/gv-tree.js +238 -1
  80. package/src/organisms/gv-documentation.js +205 -1
  81. package/src/organisms/gv-header.js +276 -1
  82. package/src/organisms/gv-http-client.js +258 -1
  83. package/src/organisms/gv-menu.js +258 -1
  84. package/src/organisms/gv-newsletter-subscription.js +258 -1
  85. package/src/organisms/gv-pagination.js +179 -1
  86. package/src/organisms/gv-properties.js +860 -1
  87. package/src/organisms/gv-resizable-views.js +371 -1
  88. package/src/organisms/gv-resources.js +496 -1
  89. package/src/organisms/gv-schema-form-array.js +237 -1
  90. package/src/organisms/gv-schema-form-control-object.js +141 -1
  91. package/src/organisms/gv-schema-form-control.js +419 -1
  92. package/src/organisms/gv-schema-form.js +700 -1
  93. package/src/organisms/gv-tabs.js +201 -1
  94. package/src/organisms/gv-user-menu.js +298 -1
  95. package/src/organisms/gv-vertical-menu.js +119 -1
  96. package/src/policy-studio/gv-flow-step.js +443 -1
  97. package/src/policy-studio/gv-flow.js +595 -1
  98. package/src/policy-studio/gv-policy-studio-menu.js +689 -1
  99. package/src/policy-studio/gv-policy-studio.js +1712 -1
  100. package/src/styles/empty.js +35 -1
  101. package/src/styles/input.js +262 -1
  102. package/src/styles/link.js +31 -1
  103. package/src/styles/shapes.js +17 -1
  104. package/src/styles/skeleton.js +52 -1
  105. package/src/styles/zoom.js +39 -1
  106. package/src/theme/gv-theme.js +197 -1
  107. package/wc/gv-autocomplete.js +1 -1
  108. package/wc/gv-button.js +1 -1
  109. package/wc/gv-card-full.js +1 -1
  110. package/wc/gv-card-list.js +1 -1
  111. package/wc/gv-card.js +1 -1
  112. package/wc/gv-category-list.js +1 -1
  113. package/wc/gv-category.js +1 -1
  114. package/wc/gv-chart-bar.js +1 -1
  115. package/wc/gv-chart-gauge.js +1 -1
  116. package/wc/gv-chart-histogram.js +1 -1
  117. package/wc/gv-chart-line.js +1 -1
  118. package/wc/gv-chart-map.js +1 -1
  119. package/wc/gv-chart-pie.js +1 -1
  120. package/wc/gv-checkbox.js +1 -1
  121. package/wc/gv-code.js +1 -1
  122. package/wc/gv-confirm.js +1 -1
  123. package/wc/gv-cron-editor.js +1 -1
  124. package/wc/gv-date-picker-calendar.js +1 -1
  125. package/wc/gv-date-picker-cell.js +1 -1
  126. package/wc/gv-date-picker.js +1 -1
  127. package/wc/gv-documentation.js +1 -1
  128. package/wc/gv-dropdown-menu.js +1 -1
  129. package/wc/gv-expandable.js +1 -1
  130. package/wc/gv-expression-language.js +1 -1
  131. package/wc/gv-file-upload.js +1 -1
  132. package/wc/gv-flow-step.js +1 -1
  133. package/wc/gv-flow.js +1 -1
  134. package/wc/gv-header.js +1 -1
  135. package/wc/gv-http-client.js +1 -1
  136. package/wc/gv-icon.js +1 -1
  137. package/wc/gv-identity-picture.js +1 -1
  138. package/wc/gv-image.js +1 -1
  139. package/wc/gv-input-message.js +1 -1
  140. package/wc/gv-input.js +1 -1
  141. package/wc/gv-link.js +1 -1
  142. package/wc/gv-list.js +1 -1
  143. package/wc/gv-menu.js +1 -1
  144. package/wc/gv-message.js +1 -1
  145. package/wc/gv-metric.js +1 -1
  146. package/wc/gv-metrics.js +1 -1
  147. package/wc/gv-modal.js +1 -1
  148. package/wc/gv-nav.js +1 -1
  149. package/wc/gv-newsletter-subscription.js +1 -1
  150. package/wc/gv-option.js +1 -1
  151. package/wc/gv-pagination.js +1 -1
  152. package/wc/gv-plans.js +1 -1
  153. package/wc/gv-policy-studio-menu.js +1 -1
  154. package/wc/gv-policy-studio.js +1 -1
  155. package/wc/gv-popover.js +1 -1
  156. package/wc/gv-promote.js +1 -1
  157. package/wc/gv-properties.js +1 -1
  158. package/wc/gv-rating-list.js +1 -1
  159. package/wc/gv-rating.js +1 -1
  160. package/wc/gv-relative-time.js +1 -1
  161. package/wc/gv-resizable-views.js +1 -1
  162. package/wc/gv-resources.js +1 -1
  163. package/wc/gv-row-expandable.js +1 -1
  164. package/wc/gv-row.js +1 -1
  165. package/wc/gv-schema-form-array.js +1 -1
  166. package/wc/gv-schema-form-control-object.js +1 -1
  167. package/wc/gv-schema-form-control.js +1 -1
  168. package/wc/gv-schema-form.js +1 -1
  169. package/wc/gv-select-native.js +1 -1
  170. package/wc/gv-select.js +1 -1
  171. package/wc/gv-spinner.js +1 -1
  172. package/wc/gv-state.js +1 -1
  173. package/wc/gv-stats.js +1 -1
  174. package/wc/gv-stepper.js +1 -1
  175. package/wc/gv-switch.js +1 -1
  176. package/wc/gv-table.js +1 -1
  177. package/wc/gv-tabs.js +1 -1
  178. package/wc/gv-tag.js +1 -1
  179. package/wc/gv-text.js +1 -1
  180. package/wc/gv-theme.js +1 -1
  181. package/wc/gv-tree.js +1 -1
  182. package/wc/gv-user-menu.js +1 -1
  183. package/wc/gv-vertical-menu.js +1 -1
@@ -1 +1,443 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.PolicyDraggable=exports.GvFlowStep=void 0;const t=require("lit"),e=require("../mixins/with-resize-observer"),o=require("lit/directives/class-map"),i=require("../lib/events");require("../atoms/gv-image"),require("../molecules/gv-dropdown-menu"),require("../atoms/gv-switch");class n extends((0,e.withResizeObserver)(t.LitElement)){static get properties(){return{id:{type:String,reflect:!0},group:{type:String,reflect:!0},parent:{type:String,reflect:!0},step:{type:Object},policy:{type:Object},editing:{type:Boolean,reflect:!0},dragging:{type:Boolean,reflect:!0},hover:{type:Boolean,reflect:!0},title:{type:String,reflect:!0},empty:{type:Boolean,reflect:!0},confirm:{type:Boolean,reflect:!0},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},_small:{type:Boolean,attribute:!1},_confirmDelete:{type:Boolean,reflect:!0},_confirmDuplicate:{type:Boolean,reflect:!0}}}constructor(){super(),this.empty=!0,this.breakpoints={width:[100,200]}}onResize({width:t}){this._small=t<=200}_onDuplicate(){this._confirmDuplicate=!0}_onConfirmDuplicate(){this._confirmDuplicate=!1,(0,i.dispatchCustomEvent)(this,"duplicate",{step:this.step,policy:this.policy,target:this})}_onCancelDuplicate(){this._confirmDuplicate=!1}_onClick(t){t.target.classList.contains("action")||this.editing||(t.preventDefault(),this._edit())}_edit(){this.policy&&!this.disabled&&(0,i.dispatchCustomEvent)(this,"edit",{step:this.step,policy:this.policy,group:this.group})}_onMouseEnter(){if(!this.disabled&&(this.hover=!0,!this.readonly)){this.shadowRoot.querySelector("gv-dropdown-menu").setAttribute("open",!0)}}_onMouseLeave(){if(!this.disabled&&(this.hover=!1,!this.readonly)){this.shadowRoot.querySelector("gv-dropdown-menu").removeAttribute("open")}}_onDelete(){this._confirmDelete=!0}_onConfirmDelete(){this._confirmDelete=!1,(0,i.dispatchCustomEvent)(this,"delete",{step:this.step})}_onCancelDelete(){this._confirmDelete=!1}updated(t){if(t.has("dragging")&&!0===this.dragging){this.shadowRoot.querySelector("gv-dropdown-menu").removeAttribute("open")}t.has("step")&&null!=this.step&&(this.empty=!1)}_onCancel(){this.remove()}_onCopy(){(0,i.dispatchCustomEvent)(this,"copy")}_onMove(){(0,i.dispatchCustomEvent)(this,"move")}_onChangeState({detail:t}){(0,i.dispatchCustomEvent)(this,"change-state",{step:this.step,enabled:t})}_renderDropdownMenu(){if(this.disabled||this.readonly)return t.html``;const e=!1!==this.step.enabled;return t.html`<gv-dropdown-menu right><gv-switch slot="action" class="action" small label="${e?"Enabled":"Disabled"}" title="${e?"Disable policy ?":"Enable policy ?"}" @gv-switch:input="${this._onChangeState}" .value="${e}"></gv-switch><gv-button slot="action" class="action" link small icon="general:duplicate" @gv-button:click="${this._onDuplicate}">Duplicate</gv-button><gv-button slot="action" class="action" link small icon="home:trash" @gv-button:click="${this._onDelete}">Delete</gv-button></gv-dropdown-menu>`}resetConfirm(){this.confirm=!1,this._confirmDelete=!1,this._confirmDuplicate=!1}render(){if(this.confirm)return t.html`<div class="drop-area drop-area-confirm"><gv-button small @gv-button:click="${this._onCopy}">Copy</gv-button><gv-button small @gv-button:click="${this._onMove}">Move</gv-button><gv-button link small @gv-button:click="${this._onCancel}">Cancel</gv-button></div>`;if(this._confirmDelete)return t.html`<div class="drop-area drop-area-confirm"><gv-button small danger @gv-button:click="${this._onConfirmDelete}">Delete</gv-button><gv-button link small @gv-button:click="${this._onCancelDelete}">Cancel</gv-button></div>`;if(this._confirmDuplicate)return t.html`<div class="drop-area drop-area-confirm"><gv-button small @gv-button:click="${this._onConfirmDuplicate}">Duplicate</gv-button><gv-button link small @gv-button:click="${this._onCancelDuplicate}">Cancel</gv-button></div>`;if(this.empty)return t.html`<div class="drop-area"></div>`;{const e=this.step?this.step.name:"",i=this.step&&this.step.description?this.step.description:"",n=this.step&&!!this.step.condition,s=this.step?this.policy&&this.policy.icon:null,r=this.step&&!1!==this.step.enabled,a=null==this.policy;this.title=a?"Warning: policy not found in plugins folder":i;const l={"drop-area":!0,"is-assigned":""!==e,"has-icon":null!=s,disabled:!r,"not-found":a};return t.html`<div class="${(0,o.classMap)(l)}" @click="${this._onClick}" @mouseenter="${this._onMouseEnter}" @mouseleave="${this._onMouseLeave}">${this._renderDropdownMenu()}<div class="content"><div class="content-icon">${n?t.html`<gv-icon class="content-icon-conditional" shape="design:conditional"></gv-icon>`:t.html``} ${s?t.html`<gv-image src="${s}"></gv-image>`:t.html``}</div>${null==s&&a?t.html`<gv-icon class="not-found__icon" shape="finance:folder-error"></gv-icon>`:""}<div><div class="name">${e}</div><div class="description">${i}</div></div></div></div>`}}static get styles(){return[t.css`:host{box-sizing:border-box;margin:.2rem;display:block}:host(:active){outline:0}:host([dragging]){opacity:.5}gv-dropdown-menu{position:absolute;right:0;display:flex;flex-wrap:wrap;justify-content:right;top:-1px;bottom:-1px;z-index:10;--gv-dropdown-menu--bdw:0 0 0 1px;--gv-dropdown-menu--p:0.1rem 0.3rem;--gv-dropdown-menu--gg:0}gv-switch{margin:.2rem 0}:host([hover]) .drop-area{transform:translateY(-4px);box-shadow:0 0 0 1px #5a7684,0 1px 3px #5a7684;border-color:transparent}:host([dragging]) .drop-area{transform:translateY(-4px)}:host([editing]) .drop-area{border-color:#5a7684;transform:translateY(-4px);box-shadow:0 0 0 1px #5a7684,0 1px 3px #5a7684;transition:all .2s}:host([w-lt-200]) gv-image{position:absolute;opacity:.1;width:100%}:host([w-lt-200]) .drop-area:hover gv-image{opacity:1}:host([w-lt-200]) .content-icon{position:absolute;width:100%;height:100%}:host([w-lt-100]) .description{display:none}:host([empty]) .drop-area{position:relative;background-color:transparent;border:2px dashed #bfbfbf;font-size:14px}.description{line-height:14px;font-size:12px;max-height:42px;overflow:hidden}.drop-area{position:relative;border:2px dashed #bfbfbf;border-radius:4px;height:80px;min-width:80px;margin:4px;padding:4px;word-break:break-word;display:flex;align-items:center;text-align:center;justify-content:center;flex-direction:column;--gv-button--fz:11px;flex:1;transition:color 150ms ease-in-out,transform .3s ease-in-out,box-shadow .3s ease-in-out,border .3s ease-in-out;background-color:#fff}.drop-area.disabled{text-decoration:line-through;font-style:italic}.drop-area.not-found{border-color:var(--gv-theme-color-warning-light,#ffb74d)}.drop-area.has-icon{padding-left:0;text-align:left}.drop-area.has-icon .content{justify-content:left}.drop-area.is-assigned{border-style:solid}:host([hover]) .drop-area.is-assigned:not(.not-found){cursor:grab}:host([hover]) .drop-area.is-assigned:not(.not-found):active{cursor:grabbing}:host([readonly]) .drop-area.is-assigned:not(.not-found),:host([readonly]) .drop-area.is-assigned:not(.not-found):active{cursor:pointer}.content{display:flex;align-items:center;justify-content:center;text-align:center;width:100%}.content>div,.content>mark{width:100%}.content-icon{flex:0 1 0%;display:flex;margin:.2rem}.content-icon-conditional{position:absolute;z-index:10;margin:.2rem}gv-image{height:80px;width:80px}.not-found__icon{--gv-icon--c:var(--gv-theme-color-warning-light, #ffb74d);height:60px;width:60px;margin:.2rem;justify-content:center;align-items:center}.drop-area-confirm{flex-direction:row;align-items:center;justify-content:center;background-color:#fff}`]}}exports.GvFlowStep=n;class s{static parse(t){const e=JSON.parse(t);return new s(e.policy,e.sourcePosition,e.sourceFlowKey,e.sourceFlowId,e.flowStep)}constructor(t,e,o,i,n){this.policy=t,this.sourcePosition=e,this.sourceFlowKey=o,this.sourceFlowId=i,this.flowStep=n}toString(){return JSON.stringify(this)}}exports.PolicyDraggable=s,window.customElements.define("gv-flow-step",n);
1
+ /*
2
+ * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { LitElement, html, css } from 'lit';
17
+ import { withResizeObserver } from '../mixins/with-resize-observer';
18
+ import { classMap } from 'lit/directives/class-map';
19
+ import { dispatchCustomEvent } from '../lib/events';
20
+ import '../atoms/gv-image';
21
+ import '../molecules/gv-dropdown-menu';
22
+ import '../atoms/gv-switch';
23
+ /**
24
+ * Flow area component
25
+ *
26
+ * @fires gv-flow-step:duplicate - Duplicate event from actions
27
+ * @fires gv-flow-step:delete - Delete event from actions
28
+ * @fires gv-flow-step:edit - Edit event
29
+ * @fires gv-flow-step:copy - Copy event
30
+ * @fires gv-flow-step:move - Move event
31
+ *
32
+ * @attr {Object<{name, icon, configuration:{description, ...}}>} step - the flow step, configuration contains form conf for gv-schema-form component
33
+ * @attr {Boolean} editing - true, if edition in progress
34
+ * @attr {Boolean} dragging - true, if dragging in progress
35
+ * @attr {Boolean} hover - true, if area is hover
36
+ * @attr {String} title - title of area, default is "content.configuration.description" if exist
37
+ * @attr {Boolean} empty - true, if render empty state
38
+ * @attr {Boolean} confirm - true, if render confirm state
39
+ * @attr {Boolean} disabled - true for disabled
40
+ * @attr {Boolean} readonly - true if readonly
41
+ */
42
+ export class GvFlowStep extends withResizeObserver(LitElement) {
43
+ static get properties() {
44
+ return {
45
+ id: { type: String, reflect: true },
46
+ group: { type: String, reflect: true },
47
+ parent: { type: String, reflect: true },
48
+ step: { type: Object },
49
+ policy: { type: Object },
50
+ editing: { type: Boolean, reflect: true },
51
+ dragging: { type: Boolean, reflect: true },
52
+ hover: { type: Boolean, reflect: true },
53
+ title: { type: String, reflect: true },
54
+ empty: { type: Boolean, reflect: true },
55
+ confirm: { type: Boolean, reflect: true },
56
+ disabled: { type: Boolean, reflect: true },
57
+ readonly: { type: Boolean, reflect: true },
58
+ _small: { type: Boolean, attribute: false },
59
+ _confirmDelete: { type: Boolean, reflect: true },
60
+ _confirmDuplicate: { type: Boolean, reflect: true },
61
+ };
62
+ }
63
+ constructor() {
64
+ super();
65
+ this.empty = true;
66
+ this.breakpoints = {
67
+ width: [100, 200],
68
+ };
69
+ }
70
+ onResize({ width }) {
71
+ this._small = width <= 200;
72
+ }
73
+ _onDuplicate() {
74
+ this._confirmDuplicate = true;
75
+ }
76
+ _onConfirmDuplicate() {
77
+ this._confirmDuplicate = false;
78
+ dispatchCustomEvent(this, 'duplicate', { step: this.step, policy: this.policy, target: this });
79
+ }
80
+ _onCancelDuplicate() {
81
+ this._confirmDuplicate = false;
82
+ }
83
+ _onClick(e) {
84
+ if (!e.target.classList.contains('action') && !this.editing) {
85
+ e.preventDefault();
86
+ this._edit();
87
+ }
88
+ }
89
+ _edit() {
90
+ if (this.policy && !this.disabled) {
91
+ dispatchCustomEvent(this, 'edit', { step: this.step, policy: this.policy, group: this.group });
92
+ }
93
+ }
94
+ _onMouseEnter() {
95
+ if (!this.disabled) {
96
+ this.hover = true;
97
+ if (!this.readonly) {
98
+ const dropdownMenu = this.shadowRoot.querySelector('gv-dropdown-menu');
99
+ dropdownMenu.setAttribute('open', true);
100
+ }
101
+ }
102
+ }
103
+ _onMouseLeave() {
104
+ if (!this.disabled) {
105
+ this.hover = false;
106
+ if (!this.readonly) {
107
+ const dropdownMenu = this.shadowRoot.querySelector('gv-dropdown-menu');
108
+ dropdownMenu.removeAttribute('open');
109
+ }
110
+ }
111
+ }
112
+ _onDelete() {
113
+ this._confirmDelete = true;
114
+ }
115
+ _onConfirmDelete() {
116
+ this._confirmDelete = false;
117
+ dispatchCustomEvent(this, 'delete', { step: this.step });
118
+ }
119
+ _onCancelDelete() {
120
+ this._confirmDelete = false;
121
+ }
122
+ updated(properties) {
123
+ if (properties.has('dragging') && this.dragging === true) {
124
+ const dropdownMenu = this.shadowRoot.querySelector('gv-dropdown-menu');
125
+ dropdownMenu.removeAttribute('open');
126
+ }
127
+ if (properties.has('step') && this.step != null) {
128
+ this.empty = false;
129
+ }
130
+ }
131
+ _onCancel() {
132
+ this.remove();
133
+ }
134
+ _onCopy() {
135
+ dispatchCustomEvent(this, 'copy');
136
+ }
137
+ _onMove() {
138
+ dispatchCustomEvent(this, 'move');
139
+ }
140
+ _onChangeState({ detail }) {
141
+ dispatchCustomEvent(this, 'change-state', { step: this.step, enabled: detail });
142
+ }
143
+ _renderDropdownMenu() {
144
+ if (this.disabled || this.readonly) {
145
+ return html ``;
146
+ }
147
+ const enabled = this.step.enabled !== false;
148
+ return html `<gv-dropdown-menu right>
149
+ <gv-switch
150
+ slot="action"
151
+ class="action"
152
+ small
153
+ label="${enabled ? 'Enabled' : 'Disabled'}"
154
+ title="${enabled ? 'Disable policy ?' : 'Enable policy ?'}"
155
+ @gv-switch:input="${this._onChangeState}"
156
+ .value="${enabled}"
157
+ ></gv-switch>
158
+ <gv-button slot="action" class="action" link small icon="general:duplicate" @gv-button:click="${this._onDuplicate}"
159
+ >Duplicate</gv-button
160
+ >
161
+ <gv-button slot="action" class="action" link small icon="home:trash" @gv-button:click="${this._onDelete}">Delete</gv-button>
162
+ </gv-dropdown-menu>`;
163
+ }
164
+ resetConfirm() {
165
+ this.confirm = false;
166
+ this._confirmDelete = false;
167
+ this._confirmDuplicate = false;
168
+ }
169
+ render() {
170
+ if (this.confirm) {
171
+ return html `<div class="drop-area drop-area-confirm">
172
+ <gv-button small @gv-button:click="${this._onCopy}">Copy</gv-button>
173
+ <gv-button small @gv-button:click="${this._onMove}">Move</gv-button>
174
+ <gv-button link small @gv-button:click="${this._onCancel}">Cancel</gv-button>
175
+ </div>`;
176
+ }
177
+ else if (this._confirmDelete) {
178
+ return html `<div class="drop-area drop-area-confirm">
179
+ <gv-button small danger @gv-button:click="${this._onConfirmDelete}">Delete</gv-button>
180
+ <gv-button link small @gv-button:click="${this._onCancelDelete}">Cancel</gv-button>
181
+ </div>`;
182
+ }
183
+ else if (this._confirmDuplicate) {
184
+ return html `<div class="drop-area drop-area-confirm">
185
+ <gv-button small @gv-button:click="${this._onConfirmDuplicate}">Duplicate</gv-button>
186
+ <gv-button link small @gv-button:click="${this._onCancelDuplicate}">Cancel</gv-button>
187
+ </div>`;
188
+ }
189
+ else if (!this.empty) {
190
+ const name = this.step ? this.step.name : '';
191
+ const description = this.step && this.step.description ? this.step.description : '';
192
+ const hasConditionalSteps = this.step && !!this.step.condition;
193
+ const icon = this.step ? this.policy && this.policy.icon : null;
194
+ const enabled = this.step && this.step.enabled !== false;
195
+ const notFound = this.policy == null;
196
+ if (notFound) {
197
+ this.title = 'Warning: policy not found in plugins folder';
198
+ }
199
+ else {
200
+ this.title = description;
201
+ }
202
+ const classes = {
203
+ 'drop-area': true,
204
+ 'is-assigned': name !== '',
205
+ 'has-icon': icon != null,
206
+ disabled: !enabled,
207
+ 'not-found': notFound,
208
+ };
209
+ return html `<div
210
+ class="${classMap(classes)}"
211
+ @click="${this._onClick}"
212
+ @mouseenter="${this._onMouseEnter}"
213
+ @mouseleave="${this._onMouseLeave}"
214
+ >
215
+ ${this._renderDropdownMenu()}
216
+ <div class="content">
217
+ <div class="content-icon">
218
+ ${hasConditionalSteps ? html `<gv-icon class="content-icon-conditional" shape="design:conditional"></gv-icon>` : html ``}
219
+ ${icon ? html `<gv-image src="${icon}"></gv-image>` : html ``}
220
+ </div>
221
+
222
+ ${icon == null && notFound ? html `<gv-icon class="not-found__icon" shape="finance:folder-error"></gv-icon>` : ''}
223
+ <div>
224
+ <div class="name">${name}</div>
225
+ <div class="description">${description}</div>
226
+ </div>
227
+ </div>
228
+ </div> `;
229
+ }
230
+ else {
231
+ return html `<div class="drop-area"></div>`;
232
+ }
233
+ }
234
+ static get styles() {
235
+ return [
236
+ // language=CSS
237
+ css `
238
+ :host {
239
+ box-sizing: border-box;
240
+ margin: 0.2rem;
241
+ display: block;
242
+ }
243
+
244
+ :host(:active) {
245
+ outline: none;
246
+ }
247
+
248
+ :host([dragging]) {
249
+ opacity: 0.5;
250
+ }
251
+
252
+ gv-dropdown-menu {
253
+ position: absolute;
254
+ right: 0;
255
+ display: flex;
256
+ flex-wrap: wrap;
257
+ justify-content: right;
258
+ top: -1px;
259
+ bottom: -1px;
260
+ z-index: 10;
261
+ --gv-dropdown-menu--bdw: 0 0 0 1px;
262
+ --gv-dropdown-menu--p: 0.1rem 0.3rem;
263
+ --gv-dropdown-menu--gg: 0;
264
+ }
265
+
266
+ gv-switch {
267
+ margin: 0.2rem 0;
268
+ }
269
+
270
+ :host([hover]) .drop-area {
271
+ transform: translateY(-4px);
272
+ box-shadow: 0 0 0 1px #5a7684, 0 1px 3px #5a7684;
273
+ border-color: transparent;
274
+ }
275
+
276
+ :host([dragging]) .drop-area {
277
+ transform: translateY(-4px);
278
+ }
279
+
280
+ :host([editing]) .drop-area {
281
+ border-color: #5a7684;
282
+ transform: translateY(-4px);
283
+ box-shadow: 0 0 0 1px #5a7684, 0 1px 3px #5a7684;
284
+ transition: all 0.2s;
285
+ }
286
+
287
+ :host([w-lt-200]) gv-image {
288
+ position: absolute;
289
+ opacity: 0.1;
290
+ width: 100%;
291
+ }
292
+
293
+ :host([w-lt-200]) .drop-area:hover gv-image {
294
+ opacity: 1;
295
+ }
296
+
297
+ :host([w-lt-200]) .content-icon {
298
+ position: absolute;
299
+ width: 100%;
300
+ height: 100%;
301
+ }
302
+
303
+ :host([w-lt-100]) .description {
304
+ display: none;
305
+ }
306
+
307
+ :host([empty]) .drop-area {
308
+ position: relative;
309
+ background-color: transparent;
310
+ border: 2px dashed #bfbfbf;
311
+ font-size: 14px;
312
+ }
313
+
314
+ .description {
315
+ line-height: 14px;
316
+ font-size: 12px;
317
+ max-height: 42px;
318
+ overflow: hidden;
319
+ }
320
+
321
+ .drop-area {
322
+ position: relative;
323
+ border: 2px dashed #bfbfbf;
324
+ border-radius: 4px;
325
+ height: 80px;
326
+ min-width: 80px;
327
+ margin: 4px;
328
+ padding: 4px;
329
+ word-break: break-word;
330
+ display: flex;
331
+ align-items: center;
332
+ text-align: center;
333
+ justify-content: center;
334
+ flex-direction: column;
335
+ --gv-button--fz: 11px;
336
+ flex: 1;
337
+ transition: color 150ms ease-in-out, transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out, border 0.3s ease-in-out;
338
+ background-color: white;
339
+ }
340
+
341
+ .drop-area.disabled {
342
+ /*opacity: 0.7;*/
343
+ /*background-color: #BFBFBF; !* fallback color if gradients are not supported *!*/
344
+ /*border-color: white;*/
345
+ text-decoration: line-through;
346
+ font-style: italic;
347
+ }
348
+
349
+ .drop-area.not-found {
350
+ border-color: var(--gv-theme-color-warning-light, #ffb74d);
351
+ }
352
+
353
+ .drop-area.has-icon {
354
+ padding-left: 0;
355
+ text-align: left;
356
+ }
357
+
358
+ .drop-area.has-icon .content {
359
+ justify-content: left;
360
+ }
361
+
362
+ .drop-area.is-assigned {
363
+ border-style: solid;
364
+ }
365
+
366
+ :host([hover]) .drop-area.is-assigned:not(.not-found) {
367
+ cursor: grab;
368
+ }
369
+
370
+ :host([hover]) .drop-area.is-assigned:not(.not-found):active {
371
+ cursor: grabbing;
372
+ }
373
+
374
+ :host([readonly]) .drop-area.is-assigned:not(.not-found),
375
+ :host([readonly]) .drop-area.is-assigned:not(.not-found):active {
376
+ cursor: pointer;
377
+ }
378
+
379
+ .content {
380
+ display: flex;
381
+ align-items: center;
382
+ justify-content: center;
383
+ text-align: center;
384
+ width: 100%;
385
+ }
386
+
387
+ .content > div,
388
+ .content > mark {
389
+ width: 100%;
390
+ }
391
+
392
+ .content-icon {
393
+ flex: 0 1 0%;
394
+ display: flex;
395
+ margin: 0.2rem;
396
+ }
397
+ .content-icon-conditional {
398
+ position: absolute;
399
+ z-index: 10;
400
+ margin: 0.2rem;
401
+ }
402
+
403
+ gv-image {
404
+ height: 80px;
405
+ width: 80px;
406
+ }
407
+
408
+ .not-found__icon {
409
+ --gv-icon--c: var(--gv-theme-color-warning-light, #ffb74d);
410
+ height: 60px;
411
+ width: 60px;
412
+ margin: 0.2rem;
413
+ justify-content: center;
414
+ align-items: center;
415
+ }
416
+
417
+ .drop-area-confirm {
418
+ flex-direction: row;
419
+ align-items: center;
420
+ justify-content: center;
421
+ background-color: white;
422
+ }
423
+ `,
424
+ ];
425
+ }
426
+ }
427
+ export class PolicyDraggable {
428
+ static parse(str) {
429
+ const data = JSON.parse(str);
430
+ return new PolicyDraggable(data.policy, data.sourcePosition, data.sourceFlowKey, data.sourceFlowId, data.flowStep);
431
+ }
432
+ constructor(policy, sourcePosition, sourceFlowKey, sourceFlowId, flowStep) {
433
+ this.policy = policy;
434
+ this.sourcePosition = sourcePosition;
435
+ this.sourceFlowKey = sourceFlowKey;
436
+ this.sourceFlowId = sourceFlowId;
437
+ this.flowStep = flowStep;
438
+ }
439
+ toString() {
440
+ return JSON.stringify(this);
441
+ }
442
+ }
443
+ window.customElements.define('gv-flow-step', GvFlowStep);