@gravitee/ui-components 3.25.3-typescript-e7256ca → 3.25.3-typescript-9cbc31e

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,348 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvFileUpload=void 0;const e=require("lit"),i=require("../styles/link"),t=require("../lib/events"),r=require("lit/directives/if-defined"),s=require("../lib/i18n"),l=require("lit/directives/class-map");class o extends e.LitElement{static get properties(){return{label:{type:String},accept:{type:String},except:{type:String},limit:{type:Number},value:{type:Array,reflect:!0},_preview:{type:String,attribute:!1},_files:{type:Array,attribute:!1},_errors:{type:Array,attribute:!1}}}static get styles(){return[i.link,e.css`:host{box-sizing:border-box;display:block;width:100%;color:var(--gv-theme-color-dark,#28444f)}.box{font-size:1.25rem;background-color:var(--gv-theme-neutral-color-lighter,#fafafa);position:relative;padding:2rem;text-align:center;display:block;border:1px dashed #28444f;border-radius:4px;transition:outline-offset .15s ease-in-out,background-color .15s linear;height:100%}.box .box__icon{width:100%;height:80px;display:block;margin-bottom:40px;--gv-icon--s:5rem;--gv-icon--c:var(--gv-theme-color-dark, #28444f)}.box__file{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.box__file+label{max-width:80%;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;display:inline-block;overflow:hidden}.box.is-dragover{background-color:var(--gv-theme-color-light,#28444f);border:none;outline:1px dashed #28444f;outline-offset:-10px}.box .box__dragndrop{display:inline}.files{box-sizing:border-box;display:flex;align-items:center;--gv-icon--s:16px;padding:1rem .5rem 0}.filename{flex:1;padding:.2rem;word-break:break-all}.error{font-style:italic;--gv-icon--c:red}gv-image{position:absolute}.preview{transition:all .3s ease-in-out}.box__input{position:relative;display:flex;flex-direction:column;justify-content:center;height:100%;z-index:10}.preview .box__input{visibility:hidden}.preview:hover .box__input{visibility:visible}.preview:hover gv-image{opacity:.3}`]}constructor(){super(),this.reader=new FileReader,this._files=[],this._errors=[],this._counter=0}_onDragOver(e){e.preventDefault(),e.stopPropagation(),this._counter++;this.shadowRoot.querySelector(".box").classList.add("is-dragover")}_onDragEnd(e){if(e.preventDefault(),e.stopPropagation(),0==--this._counter){this.shadowRoot.querySelector(".box").classList.remove("is-dragover")}}_onDrop(e){e.preventDefault(),e.stopPropagation(),this.setFiles(e.dataTransfer.files)}_getRegex(e){return`(${e.toString().replace(" ","").replace(/,/g,".+|").replace(/\*/g,".+").replace(".+.+",".+")})`}setFiles(e){const i=[];this._files=[...e].filter((e=>this.accept&&null==e.type.match(this._getRegex(this.accept))||this.except&&null!=e.type.match(this._getRegex(this.except))?(i.push({file:e,error:(0,s.i18n)("gv-file-upload.error.typeNotAllowed")}),!1):!(this.limit&&e.size>parseInt(this.limit,10))||(i.push({file:e,error:(0,s.i18n)("gv-file-upload.error.maxSize")}),!1))),this._errors=i,this._errors.length>0&&((0,t.dispatchCustomEvent)(this,"error",{errors:this._errors}),this.dispatchEvent(new Event("invalid",{bubbles:!0,cancelable:!0})));this.shadowRoot.querySelector(".box").classList.remove("is-dragover"),this._files.length>0&&(this.reader.readAsDataURL(this._files[0]),this.reader.onload=e=>{this._files[0].type.match(this._getRegex("image/*"))?this._preview=e.target.result:this._preview=null,this.value=e.target.result,this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),(0,t.dispatchCustomEvent)(this,"drop",{files:[this.value]})})}_cancelEvent(e){e.preventDefault(),e.stopPropagation()}_removeFile(){this._errors=[],this._files=[],this._preview=null,this.value=null,this.shadowRoot.querySelector("#file").value=null,this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0}))}_onChange(e){this.setFiles(e.target.files)}get icon(){return this._files.length>0?"general:clip":"general:upload"}render(){const i=this._errors.length>0||this._files.length>0?(0,s.i18n)("gv-file-upload.chooseAnotherFile"):(0,s.i18n)("gv-file-upload.chooseFile"),t={box:!0,preview:null!=this._preview};return e.html`<label for="file">${this.label}</label><div class="${(0,l.classMap)(t)}" @drop="${this._onDrop}" @ondrop="${this._onDrop}" @drag="${this._cancelEvent}" @dragstart="${this._cancelEvent}" @dragover="${this._onDragOver}" @dragenter="${this._onDragOver}" @dragleave="${this._onDragEnd}" @dragend="${this._onDragEnd}">${null!=this._preview?e.html`<gv-image .src="${this._preview}" @error="${this._onPreviewError}"></gv-image>`:""}<div class="box__input"><gv-icon class="box__icon" shape="${this.icon}"></gv-icon><label for="file" class="link"><strong>${i}</strong> <span class="box__dragndrop">${(0,s.i18n)("gv-file-upload.orDragIt")}</span></label> <input class="box__file" type="file" name="files[]" id="file" files="${this.files}" accept="${(0,r.ifDefined)(this.accept)}" @change="${this._onChange}"></div></div>${this._files.length>0?e.html`<div class="files"><gv-icon shape="general:clip"></gv-icon><div class="filename">${this._files[0].name}</div><gv-icon class="link" @click="${this._removeFile.bind(this,0)}" shape="general:trash"></gv-icon></div>`:""} ${this._errors.length>0?e.html`<div class="files"><gv-icon class="error" shape="code:stop"></gv-icon><div class="filename">${this._errors[0].file.name} <span class="error">(${this._errors[0].error})</span></div></div>`:""} ${this.value&&0===this._files.length&&0===this._errors.length?e.html`<div class="files"><div class="filename"></div><gv-button link @click="${this._removeFile.bind(this,0)}">${(0,s.i18n)("gv-file-upload.removePicture")}</gv-button></div>`:""}`}_onPreviewError(){this.value=null}updated(e){e.has("value")&&(this.value?(this._preview=this.value,this._files&&this._files[0]&&(this.reader.readAsDataURL(this._files[0]),this.reader.onload=e=>{this.value!==e.target.result&&(this._files=[])})):(this._preview=null,this._files=[]));const i=this.shadowRoot.querySelector(".preview");if(i){const{width:e,height:t}=i.getBoundingClientRect(),r=this.shadowRoot.querySelector("gv-image");r.style.width=e-20+"px",r.style.height=t-20+"px",r.style.left="10px",r.style.top="10px"}}}exports.GvFileUpload=o,window.customElements.define("gv-file-upload",o);
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, LitElement, html } from 'lit';
17
+ import { link } from '../styles/link';
18
+ import { dispatchCustomEvent } from '../lib/events';
19
+ import { ifDefined } from 'lit/directives/if-defined';
20
+ import { i18n } from '../lib/i18n';
21
+ import { classMap } from 'lit/directives/class-map';
22
+ /**
23
+ * File upload
24
+ *
25
+ * ## Details
26
+ * * has @theme facet
27
+ *
28
+ * @fires gv-file-upload:drop - Custom event when user drop file
29
+ *
30
+ * @attr {String} label - Label
31
+ * @attr {String} accept - One or more file type identifiers describing the authorized file types.
32
+ * @attr {String} except - One or more file type identifiers describing unauthorized file types.
33
+ * @attr {Number} limit - Max size limit in bytes.
34
+ * @attr {String} value - Reflected value of uploaded file
35
+ **/
36
+ export class GvFileUpload extends LitElement {
37
+ static get properties() {
38
+ return {
39
+ label: { type: String },
40
+ accept: { type: String },
41
+ except: { type: String },
42
+ limit: { type: Number },
43
+ value: { type: Array, reflect: true },
44
+ _preview: { type: String, attribute: false },
45
+ _files: { type: Array, attribute: false },
46
+ _errors: { type: Array, attribute: false },
47
+ };
48
+ }
49
+ static get styles() {
50
+ return [
51
+ link,
52
+ // language=CSS
53
+ css `
54
+ :host {
55
+ box-sizing: border-box;
56
+ display: block;
57
+ width: 100%;
58
+ color: var(--gv-theme-color-dark, #28444f);
59
+ }
60
+
61
+ .box {
62
+ font-size: 1.25rem;
63
+ background-color: var(--gv-theme-neutral-color-lighter, #fafafa);
64
+ position: relative;
65
+ padding: 2rem;
66
+ text-align: center;
67
+ display: block;
68
+ border: 1px dashed #28444f;
69
+ border-radius: 4px;
70
+ transition: outline-offset 0.15s ease-in-out, background-color 0.15s linear;
71
+ height: 100%;
72
+ }
73
+
74
+ .box .box__icon {
75
+ width: 100%;
76
+ height: 80px;
77
+ display: block;
78
+ margin-bottom: 40px;
79
+ --gv-icon--s: 5rem;
80
+ --gv-icon--c: var(--gv-theme-color-dark, #28444f);
81
+ }
82
+
83
+ .box__file {
84
+ width: 0.1px;
85
+ height: 0.1px;
86
+ opacity: 0;
87
+ overflow: hidden;
88
+ position: absolute;
89
+ z-index: -1;
90
+ }
91
+
92
+ .box__file + label {
93
+ max-width: 80%;
94
+ text-overflow: ellipsis;
95
+ white-space: nowrap;
96
+ cursor: pointer;
97
+ display: inline-block;
98
+ overflow: hidden;
99
+ }
100
+
101
+ .box.is-dragover {
102
+ background-color: var(--gv-theme-color-light, #28444f);
103
+ border: none;
104
+ outline: 1px dashed #28444f;
105
+ outline-offset: -10px;
106
+ }
107
+
108
+ .box .box__dragndrop {
109
+ display: inline;
110
+ }
111
+
112
+ .files {
113
+ box-sizing: border-box;
114
+ display: flex;
115
+ align-items: center;
116
+ --gv-icon--s: 16px;
117
+ padding: 1rem 0.5rem 0;
118
+ }
119
+
120
+ .filename {
121
+ flex: 1;
122
+ padding: 0.2rem;
123
+ word-break: break-all;
124
+ }
125
+
126
+ .error {
127
+ font-style: italic;
128
+ --gv-icon--c: red;
129
+ }
130
+
131
+ gv-image {
132
+ position: absolute;
133
+ }
134
+
135
+ .preview {
136
+ transition: all 300ms ease-in-out;
137
+ }
138
+
139
+ .box__input {
140
+ position: relative;
141
+ display: flex;
142
+ flex-direction: column;
143
+ justify-content: center;
144
+ height: 100%;
145
+ z-index: 10;
146
+ }
147
+
148
+ .preview .box__input {
149
+ visibility: hidden;
150
+ }
151
+
152
+ .preview:hover .box__input {
153
+ visibility: visible;
154
+ }
155
+
156
+ .preview:hover gv-image {
157
+ opacity: 0.3;
158
+ }
159
+ `,
160
+ ];
161
+ }
162
+ constructor() {
163
+ super();
164
+ this.reader = new FileReader();
165
+ this._files = [];
166
+ this._errors = [];
167
+ this._counter = 0;
168
+ }
169
+ _onDragOver(e) {
170
+ e.preventDefault();
171
+ e.stopPropagation();
172
+ this._counter++;
173
+ const box = this.shadowRoot.querySelector('.box');
174
+ box.classList.add('is-dragover');
175
+ }
176
+ _onDragEnd(e) {
177
+ e.preventDefault();
178
+ e.stopPropagation();
179
+ if (--this._counter === 0) {
180
+ const box = this.shadowRoot.querySelector('.box');
181
+ box.classList.remove('is-dragover');
182
+ }
183
+ }
184
+ _onDrop(e) {
185
+ e.preventDefault();
186
+ e.stopPropagation();
187
+ this.setFiles(e.dataTransfer.files);
188
+ }
189
+ _getRegex(mimeTypes) {
190
+ return `(${mimeTypes.toString().replace(' ', '').replace(/,/g, '.+|').replace(/\*/g, '.+').replace('.+.+', '.+')})`;
191
+ }
192
+ setFiles(files) {
193
+ const errors = [];
194
+ this._files = [...files].filter((file) => {
195
+ if (this.accept && file.type.match(this._getRegex(this.accept)) == null) {
196
+ errors.push({ file, error: i18n('gv-file-upload.error.typeNotAllowed') });
197
+ return false;
198
+ }
199
+ if (this.except && file.type.match(this._getRegex(this.except)) != null) {
200
+ errors.push({ file, error: i18n('gv-file-upload.error.typeNotAllowed') });
201
+ return false;
202
+ }
203
+ if (this.limit && file.size > parseInt(this.limit, 10)) {
204
+ errors.push({ file, error: i18n('gv-file-upload.error.maxSize') });
205
+ return false;
206
+ }
207
+ return true;
208
+ });
209
+ this._errors = errors;
210
+ if (this._errors.length > 0) {
211
+ dispatchCustomEvent(this, 'error', { errors: this._errors });
212
+ this.dispatchEvent(new Event('invalid', { bubbles: true, cancelable: true }));
213
+ }
214
+ const box = this.shadowRoot.querySelector('.box');
215
+ box.classList.remove('is-dragover');
216
+ if (this._files.length > 0) {
217
+ this.reader.readAsDataURL(this._files[0]);
218
+ this.reader.onload = (event) => {
219
+ if (this._files[0].type.match(this._getRegex('image/*'))) {
220
+ this._preview = event.target.result;
221
+ }
222
+ else {
223
+ this._preview = null;
224
+ }
225
+ this.value = event.target.result;
226
+ this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
227
+ dispatchCustomEvent(this, 'drop', { files: [this.value] });
228
+ };
229
+ }
230
+ }
231
+ _cancelEvent(e) {
232
+ e.preventDefault();
233
+ e.stopPropagation();
234
+ }
235
+ _removeFile() {
236
+ this._errors = [];
237
+ this._files = [];
238
+ this._preview = null;
239
+ this.value = null;
240
+ this.shadowRoot.querySelector('#file').value = null;
241
+ this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
242
+ }
243
+ _onChange(e) {
244
+ this.setFiles(e.target.files);
245
+ }
246
+ get icon() {
247
+ if (this._files.length > 0) {
248
+ return 'general:clip';
249
+ }
250
+ return 'general:upload';
251
+ }
252
+ render() {
253
+ const label = this._errors.length > 0 || this._files.length > 0 ? i18n('gv-file-upload.chooseAnotherFile') : i18n('gv-file-upload.chooseFile');
254
+ const classes = {
255
+ box: true,
256
+ preview: this._preview != null,
257
+ };
258
+ return html `
259
+ <label for="file">${this.label}</label>
260
+ <div
261
+ class="${classMap(classes)}"
262
+ @drop="${this._onDrop}"
263
+ @ondrop="${this._onDrop}"
264
+ @drag="${this._cancelEvent}"
265
+ @dragstart="${this._cancelEvent}"
266
+ @dragover="${this._onDragOver}"
267
+ @dragenter="${this._onDragOver}"
268
+ @dragleave="${this._onDragEnd}"
269
+ @dragend="${this._onDragEnd}"
270
+ >
271
+ ${this._preview != null ? html `<gv-image .src="${this._preview}" @error="${this._onPreviewError}"></gv-image>` : ''}
272
+ <div class="box__input">
273
+ <gv-icon class="box__icon" shape="${this.icon}"></gv-icon>
274
+ <label for="file" class="link">
275
+ <strong>${label}</strong>
276
+ <span class="box__dragndrop">${i18n('gv-file-upload.orDragIt')}</span>
277
+ </label>
278
+ <input
279
+ class="box__file"
280
+ type="file"
281
+ name="files[]"
282
+ id="file"
283
+ files="${this.files}"
284
+ accept="${ifDefined(this.accept)}"
285
+ @change="${this._onChange}"
286
+ />
287
+ </div>
288
+ </div>
289
+ ${this._files.length > 0
290
+ ? html `
291
+ <div class="files">
292
+ <gv-icon shape="general:clip"></gv-icon>
293
+ <div class="filename">${this._files[0].name}</div>
294
+ <gv-icon class="link" @click="${this._removeFile.bind(this, 0)}" shape="general:trash"></gv-icon>
295
+ </div>
296
+ `
297
+ : ''}
298
+ ${this._errors.length > 0
299
+ ? html `
300
+ <div class="files">
301
+ <gv-icon class="error" shape="code:stop"></gv-icon>
302
+ <div class="filename">${this._errors[0].file.name} <span class="error">(${this._errors[0].error})</span></div>
303
+ </div>
304
+ `
305
+ : ''}
306
+ ${this.value && this._files.length === 0 && this._errors.length === 0
307
+ ? html `
308
+ <div class="files">
309
+ <div class="filename"></div>
310
+ <gv-button link @click="${this._removeFile.bind(this, 0)}">${i18n('gv-file-upload.removePicture')}</gv-button>
311
+ </div>
312
+ `
313
+ : ''}
314
+ `;
315
+ }
316
+ _onPreviewError() {
317
+ this.value = null;
318
+ }
319
+ updated(changedProperties) {
320
+ if (changedProperties.has('value')) {
321
+ if (this.value) {
322
+ this._preview = this.value;
323
+ if (this._files && this._files[0]) {
324
+ this.reader.readAsDataURL(this._files[0]);
325
+ this.reader.onload = (event) => {
326
+ if (this.value !== event.target.result) {
327
+ this._files = [];
328
+ }
329
+ };
330
+ }
331
+ }
332
+ else {
333
+ this._preview = null;
334
+ this._files = [];
335
+ }
336
+ }
337
+ const preview = this.shadowRoot.querySelector('.preview');
338
+ if (preview) {
339
+ const { width, height } = preview.getBoundingClientRect();
340
+ const img = this.shadowRoot.querySelector('gv-image');
341
+ img.style.width = width - 20 + 'px';
342
+ img.style.height = height - 20 + 'px';
343
+ img.style.left = '10px';
344
+ img.style.top = '10px';
345
+ }
346
+ }
347
+ }
348
+ window.customElements.define('gv-file-upload', GvFileUpload);
@@ -1 +1,93 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvIcon=void 0;const e=require("lit"),t=require("lit/directive"),r=require("lit/directives/class-map");class i extends t.Directive{update(t,[r,i]){return t.element.setAttributeNS(r,t.name,i),e.noChange}}const s=(0,t.directive)(i);class o extends e.LitElement{static get properties(){return{shape:{type:String}}}static get excludedShapes(){return["thirdparty:google","thirdparty:graviteeio_am"]}canCustomize(){return!["thirdparty:google","thirdparty:graviteeio_am","thirdparty:http","thirdparty:jdbc","thirdparty:microsoft","thirdparty:mongodb"].includes(this.shape)}static get styles(){return[e.css`:host{box-sizing:border-box;display:inline-flex;vertical-align:middle;--color:var(--gv-icon--c, var(--gv-theme-font-color-dark, #262626));--opacity:var(--gv-icon-opacity--c, var(--gv-theme-font-color-dark, #262626));--size:var(--gv-icon--s, 32px)}svg{height:var(--size);width:var(--size);fill:var(--color)}`]}static getHref(e){const[t,r]=e.split(":");return`./icons/${t}.svg#${r}`}render(){return e.html`<svg class="${(0,r.classMap)({"no-color":!this.canCustomize()})}"><use xlink:href="${s("http://www.w3.org/1999/xlink",o.getHref(this.shape))}"/></svg>`}}exports.GvIcon=o,window.customElements.define("gv-icon",o);
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, LitElement, html, noChange } from 'lit';
17
+ import { Directive, directive } from 'lit/directive';
18
+ import { classMap } from 'lit/directives/class-map';
19
+ class Namespaced extends Directive {
20
+ update(part, [namespace, value]) {
21
+ part.element.setAttributeNS(namespace, part.name, value);
22
+ return noChange;
23
+ }
24
+ }
25
+ const namespaced = directive(Namespaced);
26
+ /**
27
+ * An icon
28
+ *
29
+ * ## Details
30
+ * * has @theme facet
31
+ *
32
+ * @cssprop {Color} [--gv-icon--c=var(--gv-theme-font-color-dark, #262626)] - Color
33
+ * @cssprop {Color} [--gv-icon-opacity--c=var(--gv-theme-font-color-dark, #262626)] - Opacity color
34
+ * @cssprop {Length} [--gv-icon--s=32px] - Height and width
35
+ */
36
+ export class GvIcon extends LitElement {
37
+ static get properties() {
38
+ return {
39
+ /**
40
+ * This is a shape, an concatenation of category name and icon name.
41
+ * @type {"{category}:{iconName}"}
42
+ * @attr
43
+ * @required
44
+ */
45
+ shape: { type: String },
46
+ };
47
+ }
48
+ static get excludedShapes() {
49
+ return ['thirdparty:google', 'thirdparty:graviteeio_am'];
50
+ }
51
+ canCustomize() {
52
+ return ![
53
+ 'thirdparty:google',
54
+ 'thirdparty:graviteeio_am',
55
+ 'thirdparty:http',
56
+ 'thirdparty:jdbc',
57
+ 'thirdparty:microsoft',
58
+ 'thirdparty:mongodb',
59
+ ].includes(this.shape);
60
+ }
61
+ static get styles() {
62
+ return [
63
+ // language=CSS
64
+ css `
65
+ :host {
66
+ box-sizing: border-box;
67
+ display: inline-flex;
68
+ vertical-align: middle;
69
+ --color: var(--gv-icon--c, var(--gv-theme-font-color-dark, #262626));
70
+ --opacity: var(--gv-icon-opacity--c, var(--gv-theme-font-color-dark, #262626));
71
+ --size: var(--gv-icon--s, 32px);
72
+ }
73
+
74
+ svg {
75
+ height: var(--size);
76
+ width: var(--size);
77
+ fill: var(--color);
78
+ }
79
+ `,
80
+ ];
81
+ }
82
+ static getHref(shape) {
83
+ const [category, icon] = shape.split(':');
84
+ return `./icons/${category}.svg#${icon}`;
85
+ }
86
+ render() {
87
+ const xlinkNamespace = 'http://www.w3.org/1999/xlink';
88
+ return html `<svg class="${classMap({ 'no-color': !this.canCustomize() })}">
89
+ <use xlink:href="${namespaced(xlinkNamespace, GvIcon.getHref(this.shape))}" />
90
+ </svg>`;
91
+ }
92
+ }
93
+ window.customElements.define('gv-icon', GvIcon);
@@ -1 +1,135 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvImage=void 0;const e=require("lit"),t=require("../lib/events"),r=require("lit/directives/class-map"),s=require("lit/directives/if-defined"),i=require("../styles/skeleton");class o extends e.LitElement{static get properties(){return{src:{type:String},skeleton:{type:Boolean,reflect:!0},alt:{type:String},_loaded:{type:Boolean,reflect:!0},_error:{type:Boolean}}}static get styles(){return[e.css`:host{display:inline-block;overflow:hidden}.wrapper,img{height:100%;width:100%;transition:opacity .3s ease-in-out}.wrapper{align-items:center;display:flex;justify-content:center;position:relative}.wrapper.text:not('.skeleton'){background-color:var(--gv-theme-neutral-color)}img{display:block;object-fit:var(--gv-image--of,cover);object-position:center center;opacity:0;position:absolute;top:0;transition:opacity 150ms ease-in-out;left:0}.wrapper.loaded img{opacity:1}.error-msg{font-size:.9rem;overflow:hidden;padding:.25rem;text-align:center;text-overflow:ellipsis;white-space:nowrap}`,i.skeleton]}constructor(){super(),this.skeleton=!1,this._error=!1,this._loaded=!1}set src(e){const t=this._src;this._src=e,this.requestUpdate("src",t),this._error=!1,this._loaded=!1}get src(){return this._src}_onLoad(e){this._loaded=!0,this.skeleton=!1,(0,t.dispatchCustomEvent)(this,"loaded",{src:this.src,alt:this.alt})}_onError(e){this._error=!0,this.skeleton=!1,this.dispatchEvent(new Event("error"),e)}render(){const t=null==this.src||this._error;return e.html`<div class="wrapper ${(0,r.classMap)({skeleton:this.skeleton,loaded:this._loaded,text:t})}"><img src="${(0,s.ifDefined)(this.src)}" @load="${this._onLoad}" @error="${this._onError}" alt=""> ${t?e.html`<div class="error-msg">${this.alt}</div>`:""}</div>`}}exports.GvImage=o,window.customElements.define("gv-image",o);
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 { dispatchCustomEvent } from '../lib/events';
18
+ import { classMap } from 'lit/directives/class-map';
19
+ import { ifDefined } from 'lit/directives/if-defined';
20
+ import { skeleton } from '../styles/skeleton';
21
+ /**
22
+ * An image
23
+ *
24
+ * ## Details
25
+ * * has @theme facet
26
+ *
27
+ * @fires gv-image:loaded - When image is loaded
28
+ *
29
+ * @attr {String} src - Source of img
30
+ * @attr {String} alt - Alternative text of img
31
+ * @attr {Boolean} skeleton - enable skeleton screen UI pattern (loading hint)
32
+ *
33
+ * @cssprop {String} [--gv-image--of=cover] - set the object-fit of image
34
+ */
35
+ export class GvImage extends LitElement {
36
+ static get properties() {
37
+ return {
38
+ src: { type: String },
39
+ skeleton: { type: Boolean, reflect: true },
40
+ alt: { type: String },
41
+ _loaded: { type: Boolean, reflect: true },
42
+ _error: { type: Boolean },
43
+ };
44
+ }
45
+ static get styles() {
46
+ return [
47
+ // language=CSS
48
+ css `
49
+ :host {
50
+ display: inline-block;
51
+ overflow: hidden;
52
+ }
53
+
54
+ .wrapper,
55
+ img {
56
+ height: 100%;
57
+ width: 100%;
58
+ transition: opacity 0.3s ease-in-out;
59
+ }
60
+
61
+ .wrapper {
62
+ align-items: center;
63
+ display: flex;
64
+ justify-content: center;
65
+ position: relative;
66
+ }
67
+
68
+ .wrapper.text:not('.skeleton') {
69
+ background-color: var(--gv-theme-neutral-color);
70
+ }
71
+
72
+ img {
73
+ display: block;
74
+ object-fit: var(--gv-image--of, cover);
75
+ object-position: center center;
76
+ opacity: 0;
77
+ position: absolute;
78
+ top: 0;
79
+ transition: opacity 150ms ease-in-out;
80
+ left: 0;
81
+ }
82
+
83
+ .wrapper.loaded img {
84
+ opacity: 1;
85
+ }
86
+
87
+ .error-msg {
88
+ font-size: 0.9rem;
89
+ overflow: hidden;
90
+ padding: 0.25rem;
91
+ text-align: center;
92
+ text-overflow: ellipsis;
93
+ white-space: nowrap;
94
+ }
95
+ `,
96
+ skeleton,
97
+ ];
98
+ }
99
+ constructor() {
100
+ super();
101
+ this.skeleton = false;
102
+ this._error = false;
103
+ this._loaded = false;
104
+ }
105
+ set src(newVal) {
106
+ const oldVal = this._src;
107
+ this._src = newVal;
108
+ this.requestUpdate('src', oldVal);
109
+ this._error = false;
110
+ this._loaded = false;
111
+ }
112
+ get src() {
113
+ return this._src;
114
+ }
115
+ _onLoad(e) {
116
+ this._loaded = true;
117
+ this.skeleton = false;
118
+ dispatchCustomEvent(this, 'loaded', { src: this.src, alt: this.alt });
119
+ }
120
+ _onError(e) {
121
+ this._error = true;
122
+ this.skeleton = false;
123
+ this.dispatchEvent(new Event('error'), e);
124
+ }
125
+ render() {
126
+ const displayText = this.src == null || this._error;
127
+ return html `
128
+ <div class="wrapper ${classMap({ skeleton: this.skeleton, loaded: this._loaded, text: displayText })}">
129
+ <img src=${ifDefined(this.src)} @load=${this._onLoad} @error=${this._onError} alt="" />
130
+ ${displayText ? html ` <div class="error-msg">${this.alt}</div> ` : ''}
131
+ </div>
132
+ `;
133
+ }
134
+ }
135
+ window.customElements.define('gv-image', GvImage);
@@ -1 +1,78 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvInputMessage=void 0;const e=require("lit");require("../atoms/gv-icon");class t extends e.LitElement{static get properties(){return{level:{type:String},_level:{type:String,attribute:!1}}}constructor(){super(),this._level="warning"}set level(e){["error","info","warning"].includes(e)&&(this._level=e)}render(){return e.html`<div class="box"><gv-icon class="${this._level}" shape="code:${this._level}"></gv-icon><slot></slot></div>`}static get styles(){return[e.css`:host{box-sizing:border-box;display:block;margin:.2rem}.box{display:flex;align-items:center;white-space:normal}gv-icon{margin:0 .2rem;--gv-icon--s:24px}gv-icon.warning{--gv-icon-opacity--c:var(--gv-theme-color-warning, #ff9800)}gv-icon.error{--gv-icon-opacity--c:var(--gv-theme-color-error, #f44336)}gv-icon.info{--gv-icon-opacity--c:var(--gv-theme-color-info, #2196f3)}`]}}exports.GvInputMessage=t,window.customElements.define("gv-input-message",t);
1
+ /*
2
+ * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { css, LitElement, html } from 'lit';
17
+ import '../atoms/gv-icon';
18
+ /**
19
+ * Input message component
20
+ *
21
+ * @attr {String} level - level of message ['info', 'error', 'warning']
22
+ */
23
+ export class GvInputMessage extends LitElement {
24
+ static get properties() {
25
+ return {
26
+ level: { type: String },
27
+ _level: { type: String, attribute: false },
28
+ };
29
+ }
30
+ constructor() {
31
+ super();
32
+ this._level = 'warning';
33
+ }
34
+ set level(level) {
35
+ if (['error', 'info', 'warning'].includes(level)) {
36
+ this._level = level;
37
+ }
38
+ }
39
+ render() {
40
+ return html `<div class="box"><gv-icon class="${this._level}" shape="code:${this._level}"></gv-icon><slot></slot></div>`;
41
+ }
42
+ static get styles() {
43
+ return [
44
+ // language=CSS
45
+ css `
46
+ :host {
47
+ box-sizing: border-box;
48
+ display: block;
49
+ margin: 0.2rem;
50
+ }
51
+
52
+ .box {
53
+ display: flex;
54
+ align-items: center;
55
+ white-space: normal;
56
+ }
57
+
58
+ gv-icon {
59
+ margin: 0 0.2rem;
60
+ --gv-icon--s: 24px;
61
+ }
62
+
63
+ gv-icon.warning {
64
+ --gv-icon-opacity--c: var(--gv-theme-color-warning, #ff9800);
65
+ }
66
+
67
+ gv-icon.error {
68
+ --gv-icon-opacity--c: var(--gv-theme-color-error, #f44336);
69
+ }
70
+
71
+ gv-icon.info {
72
+ --gv-icon-opacity--c: var(--gv-theme-color-info, #2196f3);
73
+ }
74
+ `,
75
+ ];
76
+ }
77
+ }
78
+ window.customElements.define('gv-input-message', GvInputMessage);