@navservice/web-components 1.0.0

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.
@@ -0,0 +1,421 @@
1
+ import "./rslib-runtime.js";
2
+ import { LitElement, html } from "lit";
3
+ import { property } from "lit/decorators.js";
4
+ function applyDecs2203RFactory() {
5
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
6
+ return function(initializer) {
7
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
8
+ assertCallable(initializer, "An initializer");
9
+ initializers.push(initializer);
10
+ };
11
+ }
12
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
13
+ var kindStr;
14
+ switch(kind){
15
+ case 1:
16
+ kindStr = "accessor";
17
+ break;
18
+ case 2:
19
+ kindStr = "method";
20
+ break;
21
+ case 3:
22
+ kindStr = "getter";
23
+ break;
24
+ case 4:
25
+ kindStr = "setter";
26
+ break;
27
+ default:
28
+ kindStr = "field";
29
+ }
30
+ var ctx = {
31
+ kind: kindStr,
32
+ name: isPrivate ? "#" + name : name,
33
+ static: isStatic,
34
+ private: isPrivate,
35
+ metadata: metadata
36
+ };
37
+ var decoratorFinishedRef = {
38
+ v: false
39
+ };
40
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
41
+ var get, set;
42
+ if (0 === kind) if (isPrivate) {
43
+ get = desc.get;
44
+ set = desc.set;
45
+ } else {
46
+ get = function() {
47
+ return this[name];
48
+ };
49
+ set = function(v) {
50
+ this[name] = v;
51
+ };
52
+ }
53
+ else if (2 === kind) get = function() {
54
+ return desc.value;
55
+ };
56
+ else {
57
+ if (1 === kind || 3 === kind) get = function() {
58
+ return desc.get.call(this);
59
+ };
60
+ if (1 === kind || 4 === kind) set = function(v) {
61
+ desc.set.call(this, v);
62
+ };
63
+ }
64
+ ctx.access = get && set ? {
65
+ get: get,
66
+ set: set
67
+ } : get ? {
68
+ get: get
69
+ } : {
70
+ set: set
71
+ };
72
+ try {
73
+ return dec(value, ctx);
74
+ } finally{
75
+ decoratorFinishedRef.v = true;
76
+ }
77
+ }
78
+ function assertNotFinished(decoratorFinishedRef, fnName) {
79
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
80
+ }
81
+ function assertCallable(fn, hint) {
82
+ if ("function" != typeof fn) throw new TypeError(hint + " must be a function");
83
+ }
84
+ function assertValidReturnValue(kind, value) {
85
+ var type = typeof value;
86
+ if (1 === kind) {
87
+ if ("object" !== type || null === value) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
88
+ if (void 0 !== value.get) assertCallable(value.get, "accessor.get");
89
+ if (void 0 !== value.set) assertCallable(value.set, "accessor.set");
90
+ if (void 0 !== value.init) assertCallable(value.init, "accessor.init");
91
+ } else if ("function" !== type) {
92
+ var hint;
93
+ hint = 0 === kind ? "field" : 10 === kind ? "class" : "method";
94
+ throw new TypeError(hint + " decorators must return a function or void 0");
95
+ }
96
+ }
97
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
98
+ var decs = decInfo[0];
99
+ var desc, init, value;
100
+ if (isPrivate) desc = 0 === kind || 1 === kind ? {
101
+ get: decInfo[3],
102
+ set: decInfo[4]
103
+ } : 3 === kind ? {
104
+ get: decInfo[3]
105
+ } : 4 === kind ? {
106
+ set: decInfo[3]
107
+ } : {
108
+ value: decInfo[3]
109
+ };
110
+ else if (0 !== kind) desc = Object.getOwnPropertyDescriptor(base, name);
111
+ if (1 === kind) value = {
112
+ get: desc.get,
113
+ set: desc.set
114
+ };
115
+ else if (2 === kind) value = desc.value;
116
+ else if (3 === kind) value = desc.get;
117
+ else if (4 === kind) value = desc.set;
118
+ var newValue, get, set;
119
+ if ("function" == typeof decs) {
120
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
121
+ if (void 0 !== newValue) {
122
+ assertValidReturnValue(kind, newValue);
123
+ if (0 === kind) init = newValue;
124
+ else if (1 === kind) {
125
+ init = newValue.init;
126
+ get = newValue.get || value.get;
127
+ set = newValue.set || value.set;
128
+ value = {
129
+ get: get,
130
+ set: set
131
+ };
132
+ } else value = newValue;
133
+ }
134
+ } else for(var i = decs.length - 1; i >= 0; i--){
135
+ var dec = decs[i];
136
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
137
+ if (void 0 !== newValue) {
138
+ assertValidReturnValue(kind, newValue);
139
+ var newInit;
140
+ if (0 === kind) newInit = newValue;
141
+ else if (1 === kind) {
142
+ newInit = newValue.init;
143
+ get = newValue.get || value.get;
144
+ set = newValue.set || value.set;
145
+ value = {
146
+ get: get,
147
+ set: set
148
+ };
149
+ } else value = newValue;
150
+ if (void 0 !== newInit) if (void 0 === init) init = newInit;
151
+ else if ("function" == typeof init) init = [
152
+ init,
153
+ newInit
154
+ ];
155
+ else init.push(newInit);
156
+ }
157
+ }
158
+ if (0 === kind || 1 === kind) {
159
+ if (void 0 === init) init = function(instance, init) {
160
+ return init;
161
+ };
162
+ else if ("function" != typeof init) {
163
+ var ownInitializers = init;
164
+ init = function(instance, init) {
165
+ var value = init;
166
+ for(var i = 0; i < ownInitializers.length; i++)value = ownInitializers[i].call(instance, value);
167
+ return value;
168
+ };
169
+ } else {
170
+ var originalInitializer = init;
171
+ init = function(instance, init) {
172
+ return originalInitializer.call(instance, init);
173
+ };
174
+ }
175
+ ret.push(init);
176
+ }
177
+ if (0 !== kind) {
178
+ if (1 === kind) {
179
+ desc.get = value.get;
180
+ desc.set = value.set;
181
+ } else if (2 === kind) desc.value = value;
182
+ else if (3 === kind) desc.get = value;
183
+ else if (4 === kind) desc.set = value;
184
+ if (isPrivate) if (1 === kind) {
185
+ ret.push(function(instance, args) {
186
+ return value.get.call(instance, args);
187
+ });
188
+ ret.push(function(instance, args) {
189
+ return value.set.call(instance, args);
190
+ });
191
+ } else if (2 === kind) ret.push(value);
192
+ else ret.push(function(instance, args) {
193
+ return value.call(instance, args);
194
+ });
195
+ else Object.defineProperty(base, name, desc);
196
+ }
197
+ }
198
+ function applyMemberDecs(Class, decInfos, metadata) {
199
+ var ret = [];
200
+ var protoInitializers;
201
+ var staticInitializers;
202
+ var existingProtoNonFields = new Map();
203
+ var existingStaticNonFields = new Map();
204
+ for(var i = 0; i < decInfos.length; i++){
205
+ var decInfo = decInfos[i];
206
+ if (Array.isArray(decInfo)) {
207
+ var kind = decInfo[1];
208
+ var name = decInfo[2];
209
+ var isPrivate = decInfo.length > 3;
210
+ var isStatic = kind >= 5;
211
+ var base;
212
+ var initializers;
213
+ if (isStatic) {
214
+ base = Class;
215
+ kind -= 5;
216
+ staticInitializers = staticInitializers || [];
217
+ initializers = staticInitializers;
218
+ } else {
219
+ base = Class.prototype;
220
+ protoInitializers = protoInitializers || [];
221
+ initializers = protoInitializers;
222
+ }
223
+ if (0 !== kind && !isPrivate) {
224
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
225
+ var existingKind = existingNonFields.get(name) || 0;
226
+ if (true === existingKind || 3 === existingKind && 4 !== kind || 4 === existingKind && 3 !== kind) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
227
+ if (!existingKind && kind > 2) existingNonFields.set(name, kind);
228
+ else existingNonFields.set(name, true);
229
+ }
230
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
231
+ }
232
+ }
233
+ pushInitializers(ret, protoInitializers);
234
+ pushInitializers(ret, staticInitializers);
235
+ return ret;
236
+ }
237
+ function pushInitializers(ret, initializers) {
238
+ if (initializers) ret.push(function(instance) {
239
+ for(var i = 0; i < initializers.length; i++)initializers[i].call(instance);
240
+ return instance;
241
+ });
242
+ }
243
+ function applyClassDecs(targetClass, classDecs, metadata) {
244
+ if (classDecs.length > 0) {
245
+ var initializers = [];
246
+ var newClass = targetClass;
247
+ var name = targetClass.name;
248
+ for(var i = classDecs.length - 1; i >= 0; i--){
249
+ var decoratorFinishedRef = {
250
+ v: false
251
+ };
252
+ try {
253
+ var nextNewClass = classDecs[i](newClass, {
254
+ kind: "class",
255
+ name: name,
256
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
257
+ metadata
258
+ });
259
+ } finally{
260
+ decoratorFinishedRef.v = true;
261
+ }
262
+ if (void 0 !== nextNewClass) {
263
+ assertValidReturnValue(10, nextNewClass);
264
+ newClass = nextNewClass;
265
+ }
266
+ }
267
+ return [
268
+ defineMetadata(newClass, metadata),
269
+ function() {
270
+ for(var i = 0; i < initializers.length; i++)initializers[i].call(newClass);
271
+ }
272
+ ];
273
+ }
274
+ }
275
+ function defineMetadata(Class, metadata) {
276
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
277
+ configurable: true,
278
+ enumerable: true,
279
+ value: metadata
280
+ });
281
+ }
282
+ return function(targetClass, memberDecs, classDecs, parentClass) {
283
+ if (void 0 !== parentClass) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
284
+ var metadata = Object.create(void 0 === parentMetadata ? null : parentMetadata);
285
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
286
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
287
+ return {
288
+ e: e,
289
+ get c () {
290
+ return applyClassDecs(targetClass, classDecs, metadata);
291
+ }
292
+ };
293
+ };
294
+ }
295
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
296
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
297
+ }
298
+ var _dec, _dec1, _init_open, _init_setOnEscClose, _initProto;
299
+ _dec = property({
300
+ type: Boolean
301
+ }), _dec1 = property({
302
+ type: Boolean
303
+ });
304
+ class MyElement extends LitElement {
305
+ static{
306
+ ({ e: [_init_open, _init_setOnEscClose, _initProto] } = _apply_decs_2203_r(this, [
307
+ [
308
+ _dec,
309
+ 1,
310
+ "open"
311
+ ],
312
+ [
313
+ _dec1,
314
+ 1,
315
+ "setOnEscClose"
316
+ ]
317
+ ], []));
318
+ }
319
+ #___private_open_1 = (_initProto(this), _init_open(this, false));
320
+ get open() {
321
+ return this.#___private_open_1;
322
+ }
323
+ set open(_v) {
324
+ this.#___private_open_1 = _v;
325
+ }
326
+ #___private_setOnEscClose_2 = _init_setOnEscClose(this, true);
327
+ get setOnEscClose() {
328
+ return this.#___private_setOnEscClose_2;
329
+ }
330
+ set setOnEscClose(_v) {
331
+ this.#___private_setOnEscClose_2 = _v;
332
+ }
333
+ createRenderRoot() {
334
+ return this;
335
+ }
336
+ connectedCallback() {
337
+ super.connectedCallback();
338
+ window.addEventListener('keydown', this.handleKeydown);
339
+ }
340
+ disconnectedCallback() {
341
+ window.removeEventListener('keydown', this.handleKeydown);
342
+ super.disconnectedCallback();
343
+ }
344
+ handleKeydown = (event)=>{
345
+ if (this.setOnEscClose && 'Escape' === event.key && this.open) this.closeModal();
346
+ };
347
+ openModal = ()=>{
348
+ this.open = true;
349
+ };
350
+ closeModal = ()=>{
351
+ this.open = false;
352
+ };
353
+ clearAndClose = ()=>{
354
+ console.log('Clear acionado');
355
+ this.open = false;
356
+ };
357
+ render() {
358
+ return html`
359
+ <div class="min-h-screen flex flex-col items-center justify-center gap-3 bg-gradient-to-br from-gray-50 to-gray-100">
360
+ <h1 class="text-3xl font-semibold tracking-tight text-gray-900">
361
+ Rsbuild + Lit
362
+ </h1>
363
+ <p class="text-sm text-gray-500">
364
+ Interface minimalista, rápida e moderna.
365
+ </p>
366
+
367
+ <button
368
+ class="mt-4 inline-flex items-center justify-center rounded-lg border border-gray-300 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 shadow-sm transition hover:bg-gray-50 hover:shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-500"
369
+ @click=${this.openModal}
370
+ >
371
+ Abrir modal lateral
372
+ </button>
373
+ </div>
374
+
375
+ <!-- Overlay -->
376
+ <div
377
+ class="fixed inset-0 z-40 bg-black/40 backdrop-blur-sm transition-opacity duration-300
378
+ ${this.open ? 'opacity-100 pointer-events-auto' : 'opacity-0 pointer-events-none'}"
379
+ @click=${this.closeModal}
380
+ ></div>
381
+
382
+ <!-- Drawer -->
383
+ <aside
384
+ class="fixed right-0 top-0 z-50 h-full w-full max-w-md bg-white shadow-2xl
385
+ transition-transform duration-300 ease-out
386
+ ${this.open ? 'translate-x-0' : 'translate-x-full'}"
387
+ >
388
+ <div class="flex h-full flex-col p-6">
389
+ <div class="mb-4">
390
+ <h2 class="text-lg font-semibold text-gray-900">
391
+ Confirmação
392
+ </h2>
393
+ <p class="mt-1 text-sm text-gray-500">
394
+ Este é um modal lateral com UX inspirada em Vercel e Cloudflare.
395
+ </p>
396
+ </div>
397
+
398
+ <div class="flex-1"></div>
399
+
400
+ <div class="flex justify-end gap-3 border-t pt-4">
401
+ <button
402
+ class="rounded-md px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 transition"
403
+ @click=${this.clearAndClose}
404
+ >
405
+ Cancelar
406
+ </button>
407
+
408
+ <button
409
+ class="rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 transition"
410
+ @click=${this.closeModal}
411
+ >
412
+ Confirmar
413
+ </button>
414
+ </div>
415
+ </div>
416
+ </aside>
417
+ `;
418
+ }
419
+ }
420
+ customElements.define('my-element', MyElement);
421
+ export { MyElement };
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class MyElement extends LitElement {
3
+ accessor open: boolean;
4
+ accessor setOnEscClose: boolean;
5
+ createRenderRoot(): this;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ handleKeydown: (event: KeyboardEvent) => void;
9
+ openModal: () => void;
10
+ closeModal: () => void;
11
+ clearAndClose: () => void;
12
+ render(): import("lit-html").TemplateResult<1>;
13
+ }
@@ -0,0 +1,18 @@
1
+ var __webpack_modules__ = {};
2
+ var __webpack_module_cache__ = {};
3
+ function __webpack_require__(moduleId) {
4
+ var cachedModule = __webpack_module_cache__[moduleId];
5
+ if (void 0 !== cachedModule) return cachedModule.exports;
6
+ var module = __webpack_module_cache__[moduleId] = {
7
+ exports: {}
8
+ };
9
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
+ return module.exports;
11
+ }
12
+ __webpack_require__.m = __webpack_modules__;
13
+ (()=>{
14
+ __webpack_require__.add = function(modules) {
15
+ Object.assign(__webpack_require__.m, modules);
16
+ };
17
+ })();
18
+ export { __webpack_require__ };
Binary file