@descope/web-components-ui 1.0.35
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +191 -0
- package/dist/cjs/index.cjs.js +95 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/index.esm.js +703 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/umd/146.js +1 -0
- package/dist/umd/221.js +37 -0
- package/dist/umd/221.js.LICENSE.txt +11 -0
- package/dist/umd/511.js +573 -0
- package/dist/umd/511.js.LICENSE.txt +23 -0
- package/dist/umd/54.js +971 -0
- package/dist/umd/54.js.LICENSE.txt +33 -0
- package/dist/umd/599.js +1 -0
- package/dist/umd/729.js +1 -0
- package/dist/umd/840.js +356 -0
- package/dist/umd/840.js.LICENSE.txt +61 -0
- package/dist/umd/9.js +312 -0
- package/dist/umd/9.js.LICENSE.txt +21 -0
- package/dist/umd/descope-button-js.js +1 -0
- package/dist/umd/descope-combo-js.js +1 -0
- package/dist/umd/descope-date-picker-js.js +1 -0
- package/dist/umd/descope-text-field-js.js +1 -0
- package/dist/umd/index.js +1 -0
- package/package.json +45 -0
- package/src/components/descope-button.js +39 -0
- package/src/components/descope-combo.js +26 -0
- package/src/components/descope-date-picker.js +19 -0
- package/src/components/descope-text-field.js +36 -0
- package/src/componentsHelpers/createProxy/helpers.js +33 -0
- package/src/componentsHelpers/createProxy/index.js +82 -0
- package/src/componentsHelpers/createStyleMixin/helpers.js +66 -0
- package/src/componentsHelpers/createStyleMixin/index.js +22 -0
- package/src/componentsHelpers/draggableMixin.js +32 -0
- package/src/componentsHelpers/index.js +11 -0
- package/src/componentsHelpers/inputMixin.js +46 -0
- package/src/constants.js +1 -0
- package/src/dev/index.js +6 -0
- package/src/helpers.js +8 -0
- package/src/index.cjs.js +3 -0
- package/src/index.js +8 -0
- package/src/index.umd.js +7 -0
- package/src/theme/components/button.js +86 -0
- package/src/theme/components/index.js +7 -0
- package/src/theme/components/textField.js +50 -0
- package/src/theme/globals.js +66 -0
- package/src/theme/index.js +4 -0
- package/src/themeHelpers/index.js +76 -0
- package/src/themeHelpers/processColors.js +29 -0
package/dist/umd/9.js
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
/*! For license information please see 9.js.LICENSE.txt */
|
2
|
+
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[9],{9765:(t,e,o)=>{var n=o(4241),i=o(6155),r=o(1402),s=o(4463),a=o(5128);const c=o(9897).iv`
|
3
|
+
:host {
|
4
|
+
display: inline-block;
|
5
|
+
position: relative;
|
6
|
+
outline: none;
|
7
|
+
white-space: nowrap;
|
8
|
+
-webkit-user-select: none;
|
9
|
+
-moz-user-select: none;
|
10
|
+
user-select: none;
|
11
|
+
}
|
12
|
+
|
13
|
+
:host([hidden]) {
|
14
|
+
display: none !important;
|
15
|
+
}
|
16
|
+
|
17
|
+
/* Aligns the button with form fields when placed on the same line.
|
18
|
+
Note, to make it work, the form fields should have the same "::before" pseudo-element. */
|
19
|
+
.vaadin-button-container::before {
|
20
|
+
content: '\\2003';
|
21
|
+
display: inline-block;
|
22
|
+
width: 0;
|
23
|
+
max-height: 100%;
|
24
|
+
}
|
25
|
+
|
26
|
+
.vaadin-button-container {
|
27
|
+
display: inline-flex;
|
28
|
+
align-items: center;
|
29
|
+
justify-content: center;
|
30
|
+
text-align: center;
|
31
|
+
width: 100%;
|
32
|
+
height: 100%;
|
33
|
+
min-height: inherit;
|
34
|
+
text-shadow: inherit;
|
35
|
+
}
|
36
|
+
|
37
|
+
[part='prefix'],
|
38
|
+
[part='suffix'] {
|
39
|
+
flex: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
[part='label'] {
|
43
|
+
white-space: nowrap;
|
44
|
+
overflow: hidden;
|
45
|
+
text-overflow: ellipsis;
|
46
|
+
}
|
47
|
+
`;var l=o(1598),u=o(9109),h=o(602);const d=t=>class extends((0,l.f)((0,h.L)(t))){get _activeKeys(){return[" "]}ready(){super.ready(),(0,u.NH)(this,"down",(t=>{this._shouldSetActive(t)&&this._setActive(!0)})),(0,u.NH)(this,"up",(()=>{this._setActive(!1)}))}disconnectedCallback(){super.disconnectedCallback(),this._setActive(!1)}_shouldSetActive(t){return!this.disabled}_onKeyDown(t){super._onKeyDown(t),this._shouldSetActive(t)&&this._activeKeys.includes(t.key)&&(this._setActive(!0),document.addEventListener("keyup",(t=>{this._activeKeys.includes(t.key)&&this._setActive(!1)}),{once:!0}))}_setActive(t){this.toggleAttribute("active",t)}};var m=o(2527),f=o(4062);const p=t=>class extends(d((0,f.N)((0,m.W)(t)))){static get properties(){return{tabindex:{type:Number,value:0,reflectToAttribute:!0}}}get _activeKeys(){return["Enter"," "]}ready(){super.ready(),this.hasAttribute("role")||this.setAttribute("role","button")}_onKeyDown(t){super._onKeyDown(t),this._activeKeys.includes(t.key)&&(t.preventDefault(),this.click())}};(0,a.hC)("vaadin-button",c,{moduleId:"vaadin-button-styles"});class v extends(p((0,r.S)((0,a.Tb)((0,i.k)(n.H3))))){static get is(){return"vaadin-button"}static get template(){return n.dy`
|
48
|
+
<div class="vaadin-button-container">
|
49
|
+
<span part="prefix" aria-hidden="true">
|
50
|
+
<slot name="prefix"></slot>
|
51
|
+
</span>
|
52
|
+
<span part="label">
|
53
|
+
<slot></slot>
|
54
|
+
</span>
|
55
|
+
<span part="suffix" aria-hidden="true">
|
56
|
+
<slot name="suffix"></slot>
|
57
|
+
</span>
|
58
|
+
</div>
|
59
|
+
<slot name="tooltip"></slot>
|
60
|
+
`}ready(){super.ready(),this._tooltipController=new s.f(this),this.addController(this._tooltipController)}}customElements.define(v.is,v)},4599:(t,e,o)=>{o(1195),o(9098),o(9416),o(9849),o(4173);var n=o(5128);const i=n.iv`
|
61
|
+
:host {
|
62
|
+
/* Sizing */
|
63
|
+
--lumo-button-size: var(--lumo-size-m);
|
64
|
+
min-width: calc(var(--lumo-button-size) * 2);
|
65
|
+
height: var(--lumo-button-size);
|
66
|
+
padding: 0 calc(var(--lumo-button-size) / 3 + var(--lumo-border-radius-m) / 2);
|
67
|
+
margin: var(--lumo-space-xs) 0;
|
68
|
+
box-sizing: border-box;
|
69
|
+
/* Style */
|
70
|
+
font-family: var(--lumo-font-family);
|
71
|
+
font-size: var(--lumo-font-size-m);
|
72
|
+
font-weight: 500;
|
73
|
+
color: var(--_lumo-button-color, var(--lumo-primary-text-color));
|
74
|
+
background-color: var(--_lumo-button-background-color, var(--lumo-contrast-5pct));
|
75
|
+
border-radius: var(--lumo-border-radius-m);
|
76
|
+
cursor: var(--lumo-clickable-cursor);
|
77
|
+
-webkit-tap-highlight-color: transparent;
|
78
|
+
-webkit-font-smoothing: antialiased;
|
79
|
+
-moz-osx-font-smoothing: grayscale;
|
80
|
+
flex-shrink: 0;
|
81
|
+
}
|
82
|
+
|
83
|
+
/* Set only for the internal parts so we don't affect the host vertical alignment */
|
84
|
+
[part='label'],
|
85
|
+
[part='prefix'],
|
86
|
+
[part='suffix'] {
|
87
|
+
line-height: var(--lumo-line-height-xs);
|
88
|
+
}
|
89
|
+
|
90
|
+
[part='label'] {
|
91
|
+
padding: calc(var(--lumo-button-size) / 6) 0;
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([theme~='small']) {
|
95
|
+
font-size: var(--lumo-font-size-s);
|
96
|
+
--lumo-button-size: var(--lumo-size-s);
|
97
|
+
}
|
98
|
+
|
99
|
+
:host([theme~='large']) {
|
100
|
+
font-size: var(--lumo-font-size-l);
|
101
|
+
--lumo-button-size: var(--lumo-size-l);
|
102
|
+
}
|
103
|
+
|
104
|
+
/* For interaction states */
|
105
|
+
:host::before,
|
106
|
+
:host::after {
|
107
|
+
content: '';
|
108
|
+
/* We rely on the host always being relative */
|
109
|
+
position: absolute;
|
110
|
+
z-index: 1;
|
111
|
+
top: 0;
|
112
|
+
right: 0;
|
113
|
+
bottom: 0;
|
114
|
+
left: 0;
|
115
|
+
background-color: currentColor;
|
116
|
+
border-radius: inherit;
|
117
|
+
opacity: 0;
|
118
|
+
pointer-events: none;
|
119
|
+
}
|
120
|
+
|
121
|
+
/* Hover */
|
122
|
+
|
123
|
+
@media (any-hover: hover) {
|
124
|
+
:host(:hover)::before {
|
125
|
+
opacity: 0.02;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
/* Active */
|
130
|
+
|
131
|
+
:host::after {
|
132
|
+
transition: opacity 1.4s, transform 0.1s;
|
133
|
+
filter: blur(8px);
|
134
|
+
}
|
135
|
+
|
136
|
+
:host([active])::before {
|
137
|
+
opacity: 0.05;
|
138
|
+
transition-duration: 0s;
|
139
|
+
}
|
140
|
+
|
141
|
+
:host([active])::after {
|
142
|
+
opacity: 0.1;
|
143
|
+
transition-duration: 0s, 0s;
|
144
|
+
transform: scale(0);
|
145
|
+
}
|
146
|
+
|
147
|
+
/* Keyboard focus */
|
148
|
+
|
149
|
+
:host([focus-ring]) {
|
150
|
+
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
|
151
|
+
}
|
152
|
+
|
153
|
+
:host([theme~='primary'][focus-ring]) {
|
154
|
+
box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
|
155
|
+
}
|
156
|
+
|
157
|
+
/* Types (primary, tertiary, tertiary-inline */
|
158
|
+
|
159
|
+
:host([theme~='tertiary']),
|
160
|
+
:host([theme~='tertiary-inline']) {
|
161
|
+
background-color: transparent !important;
|
162
|
+
min-width: 0;
|
163
|
+
}
|
164
|
+
|
165
|
+
:host([theme~='tertiary']) {
|
166
|
+
padding: 0 calc(var(--lumo-button-size) / 6);
|
167
|
+
}
|
168
|
+
|
169
|
+
:host([theme~='tertiary-inline'])::before {
|
170
|
+
display: none;
|
171
|
+
}
|
172
|
+
|
173
|
+
:host([theme~='tertiary-inline']) {
|
174
|
+
margin: 0;
|
175
|
+
height: auto;
|
176
|
+
padding: 0;
|
177
|
+
line-height: inherit;
|
178
|
+
font-size: inherit;
|
179
|
+
}
|
180
|
+
|
181
|
+
:host([theme~='tertiary-inline']) [part='label'] {
|
182
|
+
padding: 0;
|
183
|
+
overflow: visible;
|
184
|
+
line-height: inherit;
|
185
|
+
}
|
186
|
+
|
187
|
+
:host([theme~='primary']) {
|
188
|
+
background-color: var(--_lumo-button-primary-background-color, var(--lumo-primary-color));
|
189
|
+
color: var(--_lumo-button-primary-color, var(--lumo-primary-contrast-color));
|
190
|
+
font-weight: 600;
|
191
|
+
min-width: calc(var(--lumo-button-size) * 2.5);
|
192
|
+
}
|
193
|
+
|
194
|
+
:host([theme~='primary'])::before {
|
195
|
+
background-color: black;
|
196
|
+
}
|
197
|
+
|
198
|
+
@media (any-hover: hover) {
|
199
|
+
:host([theme~='primary']:hover)::before {
|
200
|
+
opacity: 0.05;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
:host([theme~='primary'][active])::before {
|
205
|
+
opacity: 0.1;
|
206
|
+
}
|
207
|
+
|
208
|
+
:host([theme~='primary'][active])::after {
|
209
|
+
opacity: 0.2;
|
210
|
+
}
|
211
|
+
|
212
|
+
/* Colors (success, error, contrast) */
|
213
|
+
|
214
|
+
:host([theme~='success']) {
|
215
|
+
color: var(--lumo-success-text-color);
|
216
|
+
}
|
217
|
+
|
218
|
+
:host([theme~='success'][theme~='primary']) {
|
219
|
+
background-color: var(--lumo-success-color);
|
220
|
+
color: var(--lumo-success-contrast-color);
|
221
|
+
}
|
222
|
+
|
223
|
+
:host([theme~='error']) {
|
224
|
+
color: var(--lumo-error-text-color);
|
225
|
+
}
|
226
|
+
|
227
|
+
:host([theme~='error'][theme~='primary']) {
|
228
|
+
background-color: var(--lumo-error-color);
|
229
|
+
color: var(--lumo-error-contrast-color);
|
230
|
+
}
|
231
|
+
|
232
|
+
:host([theme~='contrast']) {
|
233
|
+
color: var(--lumo-contrast);
|
234
|
+
}
|
235
|
+
|
236
|
+
:host([theme~='contrast'][theme~='primary']) {
|
237
|
+
background-color: var(--lumo-contrast);
|
238
|
+
color: var(--lumo-base-color);
|
239
|
+
}
|
240
|
+
|
241
|
+
/* Disabled state. Keep selectors after other color variants. */
|
242
|
+
|
243
|
+
:host([disabled]) {
|
244
|
+
pointer-events: none;
|
245
|
+
color: var(--lumo-disabled-text-color);
|
246
|
+
}
|
247
|
+
|
248
|
+
:host([theme~='primary'][disabled]) {
|
249
|
+
background-color: var(--lumo-contrast-30pct);
|
250
|
+
color: var(--lumo-base-color);
|
251
|
+
}
|
252
|
+
|
253
|
+
:host([theme~='primary'][disabled]) [part] {
|
254
|
+
opacity: 0.7;
|
255
|
+
}
|
256
|
+
|
257
|
+
/* Icons */
|
258
|
+
|
259
|
+
[part] ::slotted(vaadin-icon) {
|
260
|
+
display: inline-block;
|
261
|
+
width: var(--lumo-icon-size-m);
|
262
|
+
height: var(--lumo-icon-size-m);
|
263
|
+
}
|
264
|
+
|
265
|
+
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
|
266
|
+
[part] ::slotted(vaadin-icon[icon^='vaadin:']) {
|
267
|
+
padding: 0.25em;
|
268
|
+
box-sizing: border-box !important;
|
269
|
+
}
|
270
|
+
|
271
|
+
[part='prefix'] {
|
272
|
+
margin-left: -0.25em;
|
273
|
+
margin-right: 0.25em;
|
274
|
+
}
|
275
|
+
|
276
|
+
[part='suffix'] {
|
277
|
+
margin-left: 0.25em;
|
278
|
+
margin-right: -0.25em;
|
279
|
+
}
|
280
|
+
|
281
|
+
/* Icon-only */
|
282
|
+
|
283
|
+
:host([theme~='icon']:not([theme~='tertiary-inline'])) {
|
284
|
+
min-width: var(--lumo-button-size);
|
285
|
+
padding-left: calc(var(--lumo-button-size) / 4);
|
286
|
+
padding-right: calc(var(--lumo-button-size) / 4);
|
287
|
+
}
|
288
|
+
|
289
|
+
:host([theme~='icon']) [part='prefix'],
|
290
|
+
:host([theme~='icon']) [part='suffix'] {
|
291
|
+
margin-left: 0;
|
292
|
+
margin-right: 0;
|
293
|
+
}
|
294
|
+
|
295
|
+
/* RTL specific styles */
|
296
|
+
|
297
|
+
:host([dir='rtl']) [part='prefix'] {
|
298
|
+
margin-left: 0.25em;
|
299
|
+
margin-right: -0.25em;
|
300
|
+
}
|
301
|
+
|
302
|
+
:host([dir='rtl']) [part='suffix'] {
|
303
|
+
margin-left: -0.25em;
|
304
|
+
margin-right: 0.25em;
|
305
|
+
}
|
306
|
+
|
307
|
+
:host([dir='rtl'][theme~='icon']) [part='prefix'],
|
308
|
+
:host([dir='rtl'][theme~='icon']) [part='suffix'] {
|
309
|
+
margin-left: 0;
|
310
|
+
margin-right: 0;
|
311
|
+
}
|
312
|
+
`;(0,n.hC)("vaadin-button",i,{moduleId:"lumo-button"}),o(9765)},9109:(t,e,o)=>{o.d(e,{BP:()=>M,NH:()=>N});var n=o(7913);const i=!1,r=t=>t,s="string"==typeof document.head.style.touchAction,a="__polymerGestures",c="__polymerGesturesHandled",l="__polymerGesturesTouchAction",u=["mousedown","mousemove","mouseup","click"],h=[0,1,4,2],d=function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}();function m(t){return u.indexOf(t)>-1}let f=!1;function p(t){if(!m(t)&&"touchend"!==t)return s&&f&&i?{passive:!0}:void 0}!function(){try{const t=Object.defineProperty({},"passive",{get(){f=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(t){}}();const v=navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/u),y={button:!0,command:!0,fieldset:!0,input:!0,keygen:!0,optgroup:!0,option:!0,select:!0,textarea:!0};function b(t){const e=t.type;if(!m(e))return!1;if("mousemove"===e){let e=void 0===t.buttons?1:t.buttons;return t instanceof window.MouseEvent&&!d&&(e=h[t.which]||0),Boolean(1&e)}return 0===(void 0===t.button?0:t.button)}const g={mouse:{target:null,mouseIgnoreJob:null},touch:{x:0,y:0,id:-1,scrollDecided:!1}};function x(t,e,o){t.movefn=e,t.upfn=o,document.addEventListener("mousemove",e),document.addEventListener("mouseup",o)}function w(t){document.removeEventListener("mousemove",t.movefn),document.removeEventListener("mouseup",t.upfn),t.movefn=null,t.upfn=null}const k=window.ShadyDOM&&window.ShadyDOM.noPatch?window.ShadyDOM.composedPath:t=>t.composedPath&&t.composedPath()||[],_={},z=[];function A(t){const e=k(t);return e.length>0?e[0]:t.target}function E(t){const e=t.type,o=t.currentTarget[a];if(!o)return;const n=o[e];if(!n)return;if(!t[c]&&(t[c]={},e.startsWith("touch"))){const o=t.changedTouches[0];if("touchstart"===e&&1===t.touches.length&&(g.touch.id=o.identifier),g.touch.id!==o.identifier)return;s||"touchstart"!==e&&"touchmove"!==e||function(t){const e=t.changedTouches[0],o=t.type;if("touchstart"===o)g.touch.x=e.clientX,g.touch.y=e.clientY,g.touch.scrollDecided=!1;else if("touchmove"===o){if(g.touch.scrollDecided)return;g.touch.scrollDecided=!0;const o=function(t){let e="auto";const o=k(t);for(let t,n=0;n<o.length;n++)if(t=o[n],t[l]){e=t[l];break}return e}(t);let n=!1;const i=Math.abs(g.touch.x-e.clientX),r=Math.abs(g.touch.y-e.clientY);t.cancelable&&("none"===o?n=!0:"pan-x"===o?n=r>i:"pan-y"===o&&(n=i>r)),n?t.preventDefault():Y("track")}}(t)}const i=t[c];if(!i.skip){for(let e,o=0;o<z.length;o++)e=z[o],n[e.name]&&!i[e.name]&&e.flow&&e.flow.start.indexOf(t.type)>-1&&e.reset&&e.reset();for(let o,r=0;r<z.length;r++)o=z[r],n[o.name]&&!i[o.name]&&(i[o.name]=!0,o[e](t))}}function N(t,e,o){return!!_[e]&&(function(t,e,o){const n=_[e],i=n.deps,r=n.name;let s=t[a];s||(t[a]=s={});for(let e,o,n=0;n<i.length;n++)e=i[n],v&&m(e)&&"click"!==e||(o=s[e],o||(s[e]=o={_count:0}),0===o._count&&t.addEventListener(e,E,p(e)),o[r]=(o[r]||0)+1,o._count=(o._count||0)+1);t.addEventListener(e,o),n.touchAction&&M(t,n.touchAction)}(t,e,o),!0)}function D(t){z.push(t),t.emits.forEach((e=>{_[e]=t}))}function M(t,e){s&&t instanceof HTMLElement&&n.YA.run((()=>{t.style.touchAction=e})),t[l]=e}function T(t,e,o){const n=new Event(e,{bubbles:!0,cancelable:!0,composed:!0});if(n.detail=o,r(t).dispatchEvent(n),n.defaultPrevented){const t=o.preventer||o.sourceEvent;t&&t.preventDefault&&t.preventDefault()}}function Y(t){const e=function(t){for(let e,o=0;o<z.length;o++){e=z[o];for(let o,n=0;n<e.emits.length;n++)if(o=e.emits[n],o===t)return e}return null}(t);e.info&&(e.info.prevent=!0)}function X(t,e,o,n){e&&T(e,t,{x:o.clientX,y:o.clientY,sourceEvent:o,preventer:n,prevent:t=>Y(t)})}function L(t,e,o){if(t.prevent)return!1;if(t.started)return!0;const n=Math.abs(t.x-e),i=Math.abs(t.y-o);return n>=5||i>=5}function C(t,e,o){if(!e)return;const n=t.moves[t.moves.length-2],i=t.moves[t.moves.length-1],r=i.x-t.x,s=i.y-t.y;let a,c=0;n&&(a=i.x-n.x,c=i.y-n.y),T(e,"track",{state:t.state,x:o.clientX,y:o.clientY,dx:r,dy:s,ddx:a,ddy:c,sourceEvent:o,hover:()=>function(t,e){let o=document.elementFromPoint(t,e),n=o;for(;n&&n.shadowRoot&&!window.ShadyDOM;){const i=n;if(n=n.shadowRoot.elementFromPoint(t,e),i===n)break;n&&(o=n)}return o}(o.clientX,o.clientY)})}function K(t,e,o){const n=Math.abs(e.clientX-t.x),i=Math.abs(e.clientY-t.y),r=A(o||e);!r||y[r.localName]&&r.hasAttribute("disabled")||(isNaN(n)||isNaN(i)||n<=25&&i<=25||function(t){if("click"===t.type){if(0===t.detail)return!0;const e=A(t);if(!e.nodeType||e.nodeType!==Node.ELEMENT_NODE)return!0;const o=e.getBoundingClientRect(),n=t.pageX,i=t.pageY;return!(n>=o.left&&n<=o.right&&i>=o.top&&i<=o.bottom)}return!1}(e))&&(t.prevent||T(r,"tap",{x:e.clientX,y:e.clientY,sourceEvent:e,preventer:o}))}D({name:"downup",deps:["mousedown","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["down","up"],info:{movefn:null,upfn:null},reset(){w(this.info)},mousedown(t){if(!b(t))return;const e=A(t),o=this;x(this.info,(t=>{b(t)||(X("up",e,t),w(o.info))}),(t=>{b(t)&&X("up",e,t),w(o.info)})),X("down",e,t)},touchstart(t){X("down",A(t),t.changedTouches[0],t)},touchend(t){X("up",A(t),t.changedTouches[0],t)}}),D({name:"track",touchAction:"none",deps:["mousedown","touchstart","touchmove","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["track"],info:{x:0,y:0,state:"start",started:!1,moves:[],addMove(t){this.moves.length>2&&this.moves.shift(),this.moves.push(t)},movefn:null,upfn:null,prevent:!1},reset(){this.info.state="start",this.info.started=!1,this.info.moves=[],this.info.x=0,this.info.y=0,this.info.prevent=!1,w(this.info)},mousedown(t){if(!b(t))return;const e=A(t),o=this,n=t=>{const n=t.clientX,i=t.clientY;L(o.info,n,i)&&(o.info.state=o.info.started?"mouseup"===t.type?"end":"track":"start","start"===o.info.state&&Y("tap"),o.info.addMove({x:n,y:i}),b(t)||(o.info.state="end",w(o.info)),e&&C(o.info,e,t),o.info.started=!0)};x(this.info,n,(t=>{o.info.started&&n(t),w(o.info)})),this.info.x=t.clientX,this.info.y=t.clientY},touchstart(t){const e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchmove(t){const e=A(t),o=t.changedTouches[0],n=o.clientX,i=o.clientY;L(this.info,n,i)&&("start"===this.info.state&&Y("tap"),this.info.addMove({x:n,y:i}),C(this.info,e,o),this.info.state="track",this.info.started=!0)},touchend(t){const e=A(t),o=t.changedTouches[0];this.info.started&&(this.info.state="end",this.info.addMove({x:o.clientX,y:o.clientY}),C(this.info,e,o))}}),D({name:"tap",deps:["mousedown","click","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["click","touchend"]},emits:["tap"],info:{x:NaN,y:NaN,prevent:!1},reset(){this.info.x=NaN,this.info.y=NaN,this.info.prevent=!1},mousedown(t){b(t)&&(this.info.x=t.clientX,this.info.y=t.clientY)},click(t){b(t)&&K(this.info,t)},touchstart(t){const e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchend(t){K(this.info,t.changedTouches[0],t)}})}}]);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @license
|
9
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
10
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
@license
|
15
|
+
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
16
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
17
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
18
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
19
|
+
Code distributed by Google as part of the polymer project is also
|
20
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
21
|
+
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[155],{3146:(e,t,o)=>{o.r(t),o.d(t,{Button:()=>l}),o(729);var r=o(2788),n=o(9893),s=o(2089),a=o(3097),d=o(3535);const i=(0,r.iY)("button"),l=(0,r.qC)((0,n.y)({mappings:{backgroundColor:{},borderRadius:{},color:{selector:"::part(label)"},borderColor:{},borderStyle:{},borderWidth:{},fontSize:{},height:{},width:(0,d.zy)({}),cursor:{},padding:{}}}),s.e)((0,a.D)({slots:["prefix","suffix"],wrappedEleName:"vaadin-button",style:"vaadin-button::part(label) { pointer-events: none; }",excludeAttrsSync:["tabindex"],componentName:i}));customElements.define(i,l)}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[559],{5319:(e,t,o)=>{o.r(t),o.d(t,{Combo:()=>d});var n=o(2788);o(3146),o(2320);const c=document.createElement("template"),s=(0,n.iY)("combo");c.innerHTML="\n <descope-button></descope-button>\n <descope-text-field></descope-text-field>\n";class d extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}).appendChild(c.content.cloneNode(!0))}}customElements.define(s,d)}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[938],{3450:(e,s,a)=>{a.r(s),a.d(s,{DatePicker:()=>n}),a(3054);var c=a(2788),p=a(2089),t=a(3097);const i=(0,c.iY)("date-picker"),n=(0,c.qC)(p.e)((0,t.D)({componentName:i,slots:["prefix","suffix"],wrappedEleName:"vaadin-date-picker",style:""}));customElements.define(i,n)}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[117],{2320:(t,e,i)=>{i.r(e),i.d(e,{TextField:()=>d}),i(6221);var r=i(2788),l=i(9893),s=i(2089),a=i(3097);const o=(0,r.iY)("text-field"),d=(0,r.qC)((0,l.y)({mappings:{placeholderColor:{selector:"> input:placeholder-shown",property:"color"},color:{},borderColor:{selector:"::part(input-field)"},borderWidth:{selector:"::part(input-field)"},borderStyle:{selector:"::part(input-field)"},borderRadius:{selector:"::part(input-field)"},boxShadow:{selector:"::part(input-field)"},height:{selector:"::part(input-field)"},padding:{selector:"::part(input-field)"},backgroundColor:{selector:"::part(input-field)"},labelColor:{selector:"::part(label)",property:"color"}}}),s.e,(t=>class extends t{static get formAssociated(){return!0}#t;constructor(){super(),this.#t=this.attachInternals(),this.hasAttribute("tabindex")||this.setAttribute("tabindex",0)}formAssociatedCallback(){this.setValidity?.()}connectedCallback(){super.connectedCallback();const t=this.proxyElement.querySelector("input");if(!t)throw Error("no input was found");this.checkValidity=()=>t.checkValidity(),this.reportValidity=()=>t.reportValidity(),this.validity=t.validity,this.setValidity=()=>{this.#t.setValidity(t.validity,t.validationMessage)},t.oninput=()=>{this.value=t.value,this.setValidity()}}}))((0,a.D)({slots:["prefix","suffix"],wrappedEleName:"vaadin-text-field",style:"",excludeAttrsSync:["tabindex"],componentName:o}));customElements.define(o,d)}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.DescopeUI=r():e.DescopeUI=r()}(self,(()=>(()=>{var e,r,t,o={2181:(e,r,t)=>{var o={"./descope-button.js":[3146,840,9,729,146,599,155],"./descope-combo.js":[5319,840,511,9,221,729,146,599,117,155,559],"./descope-date-picker.js":[3450,840,511,9,54,146,938],"./descope-text-field.js":[2320,840,511,221,146,599,117]};function n(e){if(!t.o(o,e))return Promise.resolve().then((()=>{var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}));var r=o[e],n=r[0];return Promise.all(r.slice(1).map(t.e)).then((()=>t(n)))}n.keys=()=>Object.keys(o),n.id=2181,e.exports=n},7507:(e,r,t)=>{const o=t(2181);e.exports=o.keys().reduce(((e,r)=>(e[r.replace(/.*?([^\/]+)\.js$/,"$1")]=()=>o(r),e)),{})}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var t=n[e]={exports:{}};return o[e](t,t.exports,i),t.exports}i.m=o,e=[],i.O=(r,t,o,n)=>{if(!t){var a=1/0;for(l=0;l<e.length;l++){for(var[t,o,n]=e[l],c=!0,s=0;s<t.length;s++)(!1&n||a>=n)&&Object.keys(i.O).every((e=>i.O[e](t[s])))?t.splice(s--,1):(c=!1,n<a&&(a=n));if(c){e.splice(l--,1);var p=o();void 0!==p&&(r=p)}}return r}n=n||0;for(var l=e.length;l>0&&e[l-1][2]>n;l--)e[l]=e[l-1];e[l]=[t,o,n]},i.F={},i.E=e=>{Object.keys(i.F).map((r=>{i.F[r](e)}))},i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((r,t)=>(i.f[t](e,r),r)),[])),i.u=e=>(({117:"descope-text-field-js",155:"descope-button-js",559:"descope-combo-js",938:"descope-date-picker-js"}[e]||e)+".js"),i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="DescopeUI:",i.l=(e,o,n,a)=>{if(r[e])r[e].push(o);else{var c,s;if(void 0!==n)for(var p=document.getElementsByTagName("script"),l=0;l<p.length;l++){var d=p[l];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==t+n){c=d;break}}c||(s=!0,(c=document.createElement("script")).charset="utf-8",c.timeout=120,i.nc&&c.setAttribute("nonce",i.nc),c.setAttribute("data-webpack",t+n),c.src=e),r[e]=[o];var u=(t,o)=>{c.onerror=c.onload=null,clearTimeout(f);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach((e=>e(o))),t)return t(o)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=u.bind(null,c.onerror),c.onload=u.bind(null,c.onload),s&&document.head.appendChild(c)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var r=i.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");t.length&&(e=t[t.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={826:0};i.f.j=(r,t)=>{var o=i.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var n=new Promise(((t,n)=>o=e[r]=[t,n]));t.push(o[2]=n);var a=i.p+i.u(r),c=new Error;i.l(a,(t=>{if(i.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var n=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;c.message="Loading chunk "+r+" failed.\n("+n+": "+a+")",c.name="ChunkLoadError",c.type=n,c.request=a,o[1](c)}}),"chunk-"+r,r)}},i.F.j=r=>{if(!i.o(e,r)||void 0===e[r]){e[r]=null;var t=document.createElement("link");i.nc&&t.setAttribute("nonce",i.nc),t.rel="prefetch",t.as="script",t.href=i.p+i.u(r),document.head.appendChild(t)}},i.O.j=r=>0===e[r];var r=(r,t)=>{var o,n,[a,c,s]=t,p=0;if(a.some((r=>0!==e[r]))){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(s)var l=s(i)}for(r&&r(t);p<a.length;p++)n=a[p],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return i.O(l)},t=self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),i.O(0,[826],(()=>{[840,9,729,146,599,155,511,221,117,559,54,938].map(i.E)}),5);var a=i(7507);return i.O(a)})()));
|
package/package.json
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"name": "@descope/web-components-ui",
|
3
|
+
"version": "1.0.35",
|
4
|
+
"description": "",
|
5
|
+
"main": "dist/cjs/index.cjs.js",
|
6
|
+
"module": "dist/index.esm.js",
|
7
|
+
"types": "dist/index.d.ts",
|
8
|
+
"exports": {
|
9
|
+
"require": "./dist/cjs/index.cjs.js",
|
10
|
+
"import": "./dist/index.esm.js"
|
11
|
+
},
|
12
|
+
"scripts": {
|
13
|
+
"test": "jest",
|
14
|
+
"lint": "echo \"Error: no lint specified\" && exit 0",
|
15
|
+
"build:umd": "webpack -c webpack.prod.js",
|
16
|
+
"build:lib": "rollup -c",
|
17
|
+
"build": "npm run build:umd && npm run build:lib",
|
18
|
+
"start": "webpack serve -c webpack.dev.js --port=8888"
|
19
|
+
},
|
20
|
+
"files": [
|
21
|
+
"dist",
|
22
|
+
"src"
|
23
|
+
],
|
24
|
+
"license": "UNLICENSED",
|
25
|
+
"devDependencies": {
|
26
|
+
"@babel/preset-env": "^7.22.2",
|
27
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
28
|
+
"html-webpack-plugin": "^5.5.1",
|
29
|
+
"jest": "^29.5.0",
|
30
|
+
"jest-environment-jsdom": "^29.5.0",
|
31
|
+
"rollup": "^3.21.4",
|
32
|
+
"webpack": "^5.79.0",
|
33
|
+
"webpack-cli": "^5.0.1",
|
34
|
+
"webpack-dev-server": "^4.13.3"
|
35
|
+
},
|
36
|
+
"dependencies": {
|
37
|
+
"@vaadin/button": "24.0.4",
|
38
|
+
"@vaadin/date-picker": "24.0.4",
|
39
|
+
"@vaadin/text-field": "24.0.4",
|
40
|
+
"color": "^4.2.3",
|
41
|
+
"lodash.merge": "4.6.2",
|
42
|
+
"lodash.set": "4.3.2",
|
43
|
+
"rollup-plugin-import-css": "^3.2.1"
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import "@vaadin/button";
|
2
|
+
import { getComponentName, createStyleMixin, draggableMixin, createProxy, compose } from "../componentsHelpers";
|
3
|
+
import { matchHostStyle } from "../componentsHelpers/createStyleMixin/helpers";
|
4
|
+
|
5
|
+
const editorOverrides = `vaadin-button::part(label) { pointer-events: none; }`;
|
6
|
+
|
7
|
+
const componentName = getComponentName("button");
|
8
|
+
|
9
|
+
const Button = compose(
|
10
|
+
createStyleMixin({
|
11
|
+
// todo: do we want to change the mapping structure to this? ['aa', 'aaa', {'color': [{ selector: '::part(label)' }]}],
|
12
|
+
mappings: {
|
13
|
+
'backgroundColor': {},
|
14
|
+
'borderRadius': {},
|
15
|
+
'color': { selector: '::part(label)' },
|
16
|
+
'borderColor': {},
|
17
|
+
'borderStyle': {},
|
18
|
+
'borderWidth': {},
|
19
|
+
'fontSize': {},
|
20
|
+
'height': {},
|
21
|
+
'width': matchHostStyle({}),
|
22
|
+
'cursor': {},
|
23
|
+
'padding': {},
|
24
|
+
},
|
25
|
+
}),
|
26
|
+
draggableMixin,
|
27
|
+
)(
|
28
|
+
createProxy({
|
29
|
+
slots: ["prefix", "suffix"],
|
30
|
+
wrappedEleName: "vaadin-button",
|
31
|
+
style: `${editorOverrides}`,
|
32
|
+
excludeAttrsSync: ['tabindex'],
|
33
|
+
componentName
|
34
|
+
})
|
35
|
+
)
|
36
|
+
|
37
|
+
customElements.define(componentName, Button);
|
38
|
+
|
39
|
+
export { Button }
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { getComponentName } from '../componentsHelpers/index.js';
|
2
|
+
import './descope-button.js'
|
3
|
+
import './descope-text-field.js'
|
4
|
+
|
5
|
+
const template = document.createElement('template')
|
6
|
+
|
7
|
+
const componentName = getComponentName("combo");
|
8
|
+
|
9
|
+
template.innerHTML = `
|
10
|
+
<descope-button></descope-button>
|
11
|
+
<descope-text-field></descope-text-field>
|
12
|
+
`
|
13
|
+
|
14
|
+
class Combo extends HTMLElement {
|
15
|
+
constructor() {
|
16
|
+
super();
|
17
|
+
|
18
|
+
this.attachShadow({ mode: 'open' }).appendChild(
|
19
|
+
template.content.cloneNode(true)
|
20
|
+
);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
customElements.define(componentName, Combo);
|
25
|
+
|
26
|
+
export { Combo }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import "@vaadin/date-picker";
|
2
|
+
import { getComponentName, draggableMixin, createProxy, compose } from "../componentsHelpers";
|
3
|
+
|
4
|
+
const componentName = getComponentName("date-picker");
|
5
|
+
|
6
|
+
const DatePicker = compose(
|
7
|
+
draggableMixin
|
8
|
+
)(
|
9
|
+
createProxy({
|
10
|
+
componentName,
|
11
|
+
slots: ["prefix", "suffix"],
|
12
|
+
wrappedEleName: "vaadin-date-picker",
|
13
|
+
style: ``,
|
14
|
+
})
|
15
|
+
);
|
16
|
+
|
17
|
+
customElements.define(componentName, DatePicker);
|
18
|
+
|
19
|
+
export { DatePicker }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import "@vaadin/text-field";
|
2
|
+
import { getComponentName, createStyleMixin, draggableMixin, createProxy, inputMixin, compose } from "../componentsHelpers";
|
3
|
+
|
4
|
+
const componentName = getComponentName("text-field")
|
5
|
+
|
6
|
+
const TextField = compose(
|
7
|
+
createStyleMixin({
|
8
|
+
mappings: {
|
9
|
+
'placeholderColor': { selector: '> input:placeholder-shown', property: 'color' },
|
10
|
+
'color': {},
|
11
|
+
'borderColor': { selector: '::part(input-field)' },
|
12
|
+
'borderWidth': { selector: '::part(input-field)' },
|
13
|
+
'borderStyle': { selector: '::part(input-field)' },
|
14
|
+
'borderRadius': { selector: '::part(input-field)' },
|
15
|
+
'boxShadow': { selector: '::part(input-field)' },
|
16
|
+
'height': { selector: '::part(input-field)' },
|
17
|
+
'padding': { selector: '::part(input-field)' },
|
18
|
+
'backgroundColor': { selector: '::part(input-field)' },
|
19
|
+
'labelColor': { selector: '::part(label)', property: 'color' },
|
20
|
+
},
|
21
|
+
}),
|
22
|
+
draggableMixin,
|
23
|
+
inputMixin
|
24
|
+
)(
|
25
|
+
createProxy({
|
26
|
+
slots: ["prefix", "suffix"],
|
27
|
+
wrappedEleName: "vaadin-text-field",
|
28
|
+
style: ``,
|
29
|
+
excludeAttrsSync: ['tabindex'],
|
30
|
+
componentName
|
31
|
+
})
|
32
|
+
);
|
33
|
+
|
34
|
+
customElements.define(componentName, TextField);
|
35
|
+
|
36
|
+
export { TextField }
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
const observeAttributes = (ele, callback, excludeAttrs) => {
|
3
|
+
// sync all attrs on init
|
4
|
+
callback(...Array.from(ele.attributes).map(attr => attr.name));
|
5
|
+
|
6
|
+
const observer = new MutationObserver((mutationsList) => {
|
7
|
+
for (const mutation of mutationsList) {
|
8
|
+
if (mutation.type === "attributes" && !excludeAttrs.includes(mutation.attributeName)) {
|
9
|
+
callback(mutation.attributeName);
|
10
|
+
}
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
observer.observe(ele, { attributes: true });
|
15
|
+
}
|
16
|
+
|
17
|
+
const createSyncAttrsCb = (srcEle, targetEle) => (...attrNames) => {
|
18
|
+
attrNames.forEach(attrName => {
|
19
|
+
const srcAttrVal = srcEle.getAttribute(attrName);
|
20
|
+
if (srcAttrVal !== null) {
|
21
|
+
if (targetEle.getAttribute(attrName) !== srcAttrVal) {
|
22
|
+
targetEle.setAttribute(attrName, srcAttrVal);
|
23
|
+
}
|
24
|
+
} else {
|
25
|
+
targetEle.removeAttribute(attrName);
|
26
|
+
}
|
27
|
+
})
|
28
|
+
}
|
29
|
+
|
30
|
+
export const syncAttrs = (ele1, ele2, excludeAttrs) => {
|
31
|
+
observeAttributes(ele1, createSyncAttrsCb(ele1, ele2), excludeAttrs)
|
32
|
+
observeAttributes(ele2, createSyncAttrsCb(ele2, ele1), excludeAttrs)
|
33
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { syncAttrs } from "./helpers";
|
2
|
+
|
3
|
+
export const createProxy = ({ componentName, wrappedEleName, slots = [], style, excludeAttrsSync = [] }) => {
|
4
|
+
|
5
|
+
const template = `
|
6
|
+
${style ? `<style id="create-proxy">${style}</style>` : ''}
|
7
|
+
<${wrappedEleName}>
|
8
|
+
<slot></slot>
|
9
|
+
${slots.map((slot) => `<slot name="${slot}" slot="${slot}"></slot>`).join("")}
|
10
|
+
</${wrappedEleName}>
|
11
|
+
`;
|
12
|
+
|
13
|
+
class ProxyElement extends HTMLElement {
|
14
|
+
static get componentName() {
|
15
|
+
return componentName;
|
16
|
+
}
|
17
|
+
|
18
|
+
constructor() {
|
19
|
+
super().attachShadow({ mode: "open" }).innerHTML = template;
|
20
|
+
this.hostElement = this.shadowRoot.host;
|
21
|
+
this.componentName = this.hostElement.tagName.toLowerCase()
|
22
|
+
this.wrappedComponentName = wrappedEleName
|
23
|
+
}
|
24
|
+
|
25
|
+
#checkComponentName() {
|
26
|
+
if (this.componentName !== componentName) {
|
27
|
+
throw Error(`component name mismatch, expected "${componentName}", current "${actualComponentName}"`)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
connectedCallback() {
|
32
|
+
if (this.shadowRoot.isConnected) {
|
33
|
+
this.#checkComponentName()
|
34
|
+
|
35
|
+
this.proxyElement = this.shadowRoot.querySelector(wrappedEleName);
|
36
|
+
this.setAttribute('tabindex', '0');
|
37
|
+
|
38
|
+
// we want to focus on the proxy element when focusing our WC
|
39
|
+
this.onfocus = (e) => {
|
40
|
+
this.proxyElement.focus()
|
41
|
+
}
|
42
|
+
|
43
|
+
// `onkeydown` is set on `proxyElement` support proper tab-index navigation
|
44
|
+
// this support is needed since both proxy host and element catch `focus`/`blur` event
|
45
|
+
// which causes faulty behaviour.
|
46
|
+
this.proxyElement.onkeydown = (e) => {
|
47
|
+
if (e.shiftKey && e.keyCode === 9) {
|
48
|
+
this.removeAttribute('tabindex');
|
49
|
+
// We want to defer the action of setting the tab index back
|
50
|
+
// so it will happen after focusing the previous element
|
51
|
+
setTimeout(() => this.setAttribute('tabindex', '0'), 0)
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
this.mouseoverCbRef = () => {
|
56
|
+
this.proxyElement.setAttribute('hover', '');
|
57
|
+
this.proxyElement.addEventListener('mouseleave', () =>
|
58
|
+
this.proxyElement.removeAttribute('hover'), { once: true })
|
59
|
+
}
|
60
|
+
|
61
|
+
this.proxyElement.addEventListener('mouseover', this.mouseoverCbRef);
|
62
|
+
|
63
|
+
// sync events
|
64
|
+
this.addEventListener = this.proxyElement.addEventListener;
|
65
|
+
|
66
|
+
syncAttrs(this.proxyElement, this.hostElement, excludeAttrsSync);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
disconnectedCallback() {
|
71
|
+
this.proxyElement.removeEventListener('mouseover', this.mouseoverCbRef)
|
72
|
+
}
|
73
|
+
|
74
|
+
attributeChangedCallback() {
|
75
|
+
if (!this.proxyElement) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
return ProxyElement;
|
82
|
+
};
|