@italia/button 0.0.1-alpha.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,681 @@
1
+ import { directive, Directive } from 'lit/directive.js';
2
+ import { LitElement, css, html } from 'lit';
3
+ import { property, customElement } from 'lit/decorators.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
+
6
+ /******************************************************************************
7
+ Copyright (c) Microsoft Corporation.
8
+
9
+ Permission to use, copy, modify, and/or distribute this software for any
10
+ purpose with or without fee is hereby granted.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.
19
+ ***************************************************************************** */
20
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
+
22
+
23
+ function __decorate(decorators, target, key, desc) {
24
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
26
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
27
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
28
+ }
29
+
30
+ function __metadata(metadataKey, metadataValue) {
31
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
32
+ }
33
+
34
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
35
+ var e = new Error(message);
36
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
37
+ };
38
+
39
+ /**
40
+ * @license
41
+ *
42
+ * Copyright IBM Corp. 2020, 2022
43
+ *
44
+ * This source code is licensed under the Apache-2.0 license found in the
45
+ * LICENSE file in the root directory of this source tree.
46
+ */
47
+ /**
48
+ * Form validation status.
49
+ */
50
+ var VALIDATION_STATUS;
51
+ (function (VALIDATION_STATUS) {
52
+ /**
53
+ * One indicating no validation error.
54
+ */
55
+ VALIDATION_STATUS["NO_ERROR"] = "";
56
+ /**
57
+ * One indicating missing required value.
58
+ */
59
+ VALIDATION_STATUS["ERROR_REQUIRED"] = "required";
60
+ })(VALIDATION_STATUS || (VALIDATION_STATUS = {}));
61
+
62
+ class SetAttributesDirective extends Directive {
63
+ update(part, [attributes]) {
64
+ const el = part.element;
65
+ for (const [name, value] of Object.entries(attributes)) {
66
+ if (value != null)
67
+ el.setAttribute(name, value);
68
+ else
69
+ el.removeAttribute(name);
70
+ }
71
+ return null;
72
+ }
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
+ render(_attributes) {
75
+ return null;
76
+ }
77
+ }
78
+ /* How to use:
79
+
80
+ <textarea ${setAttributes(this._ariaAttributes)} ... />
81
+ */
82
+ const setAttributes = directive(SetAttributesDirective);
83
+
84
+ const connectedElements = new Set();
85
+ if (window && !window.translations) {
86
+ window.translations = new Map();
87
+ }
88
+ const { translations } = window;
89
+ const isClient = typeof MutationObserver !== 'undefined' &&
90
+ typeof document !== 'undefined' &&
91
+ typeof document.documentElement !== 'undefined';
92
+ /** Updates all localized elements that are currently connected */
93
+ function update() {
94
+ if (isClient) {
95
+ document.documentElement.dir || 'ltr';
96
+ document.documentElement.lang || navigator.language;
97
+ }
98
+ [...connectedElements.keys()].forEach((el) => {
99
+ const litEl = el;
100
+ if (typeof litEl.requestUpdate === 'function') {
101
+ litEl.requestUpdate();
102
+ }
103
+ });
104
+ }
105
+ if (isClient) {
106
+ const documentElementObserver = new MutationObserver(update);
107
+ document.documentElement.dir || 'ltr';
108
+ document.documentElement.lang || navigator.language;
109
+ // Watch for changes on <html lang>
110
+ documentElementObserver.observe(document.documentElement, {
111
+ attributes: true,
112
+ attributeFilter: ['dir', 'lang'],
113
+ });
114
+ }
115
+ /** Registers one or more translations */
116
+ function registerTranslation(...translation) {
117
+ translation.forEach((t) => {
118
+ const code = t.$code.toLowerCase();
119
+ if (translations.has(code)) {
120
+ // Merge translations that share the same language code
121
+ translations.set(code, { ...translations.get(code), ...t });
122
+ }
123
+ else {
124
+ translations.set(code, t);
125
+ }
126
+ });
127
+ update();
128
+ }
129
+ window.registerTranslation = registerTranslation;
130
+
131
+ /* eslint-disable no-console */
132
+ class Logger {
133
+ constructor(tag) {
134
+ this.tag = tag;
135
+ }
136
+ format(level, msg) {
137
+ return [`[${this.tag}] ${msg}`];
138
+ }
139
+ warn(msg) {
140
+ console.warn(...this.format('warn', msg));
141
+ }
142
+ error(msg) {
143
+ console.error(...this.format('error', msg));
144
+ }
145
+ info(msg) {
146
+ console.info(...this.format('info', msg));
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Factory function per creare una base class estendibile
152
+ * con stili personalizzati.
153
+ */
154
+ class BaseComponent extends LitElement {
155
+ constructor() {
156
+ super();
157
+ this._ariaAttributes = {}; // tutti gli attributi aria-* passati al Web component
158
+ this.logger = new Logger(this.tagName.toLowerCase());
159
+ }
160
+ // eslint-disable-next-line class-methods-use-this
161
+ generateId(prefix) {
162
+ return `${prefix}-${Math.random().toString(36).slice(2)}`;
163
+ }
164
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
165
+ addFocus(element) {
166
+ // new TrackFocus(element); // per il momento è stato disattivato perchè ci sono le pseudo classi ::focus-visible per fare quello che fa TrackFocus. Si possono aggiungere regole css in bsi-italia 3 dato che stiamo facendo una breaking release di bsi.
167
+ }
168
+ // eslint-disable-next-line class-methods-use-this
169
+ composeClass(...classes) {
170
+ let composedClass = '';
171
+ classes
172
+ .filter((c) => c.length > 0)
173
+ .forEach((newClass) => {
174
+ composedClass += ` ${newClass}`;
175
+ });
176
+ return composedClass.trim();
177
+ }
178
+ getAriaAttributes() {
179
+ for (const attr of this.getAttributeNames()) {
180
+ if (attr.startsWith('aria-')) {
181
+ this._ariaAttributes[attr] = this.getAttribute(attr);
182
+ }
183
+ }
184
+ }
185
+ connectedCallback() {
186
+ super.connectedCallback?.();
187
+ this.getAriaAttributes();
188
+ // generate internal _id
189
+ const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
190
+ this._id = this.generateId(prefix);
191
+ }
192
+ }
193
+
194
+ var styles = css`/***************************** 1 ****************************************/
195
+ /***************************** 2 ****************************************/
196
+ /***************************** 1 ****************************************/
197
+ /***************************** 2 ****************************************/
198
+ /***************************** 1 ****************************************/
199
+ /***************************** 2 ****************************************/
200
+ /***************************** 3 ****************************************/
201
+ /***************************** 1 ****************************************/
202
+ /***************************** 2 ****************************************/
203
+ /***************************** 3 ****************************************/
204
+ /***************************** NEUTRAL 1 ****************************************/
205
+ /***************************** NEUTRAL 2 ****************************************/
206
+ /***************************** NEUTRAL 2 / 3 ****************************************/
207
+ button,
208
+ [type=button],
209
+ [type=reset],
210
+ [type=submit] {
211
+ -webkit-appearance: button;
212
+ }
213
+ button:not(:disabled),
214
+ [type=button]:not(:disabled),
215
+ [type=reset]:not(:disabled),
216
+ [type=submit]:not(:disabled) {
217
+ cursor: pointer;
218
+ }
219
+
220
+ .d-block {
221
+ display: block !important;
222
+ }
223
+
224
+ .w-100 {
225
+ width: 100% !important;
226
+ }
227
+
228
+ @media (min-width: 576px) {
229
+ .d-sm-block {
230
+ display: block !important;
231
+ }
232
+ }
233
+ @media (min-width: 768px) {
234
+ .d-md-block {
235
+ display: block !important;
236
+ }
237
+ }
238
+ @media (min-width: 992px) {
239
+ .d-lg-block {
240
+ display: block !important;
241
+ }
242
+ }
243
+ @media (min-width: 1200px) {
244
+ .d-xl-block {
245
+ display: block !important;
246
+ }
247
+ }
248
+ @media (min-width: 1400px) {
249
+ .d-xxl-block {
250
+ display: block !important;
251
+ }
252
+ }
253
+ @media print {
254
+ .d-print-block {
255
+ display: block !important;
256
+ }
257
+ }
258
+ .btn {
259
+ --bs-btn-padding-x: var(--bs-spacing-s);
260
+ --bs-btn-padding-y: var(--bs-spacing-xs);
261
+ --bs-btn-font-family: var(--bs-font-sans);
262
+ --bs-btn-font-weight: var(--bs-font-weight-solid);
263
+ --bs-btn-font-size: var(--bs-label-font-size);
264
+ --bs-btn-line-height: var(--bs-font-line-height-3);
265
+ --bs-btn-text-color: var(--bs-color-text-primary);
266
+ --bs-btn-background: transparent;
267
+ --bs-btn-border-size: 0;
268
+ --bs-btn-border-color: transparent;
269
+ --bs-btn-border-radius: var(--bs-radius-smooth);
270
+ --bs-btn-outline-border-size: 2px;
271
+ --bs-btn-outline-border-color: transparent;
272
+ --bs-btn-disabled-opacity: 0.5;
273
+ }
274
+
275
+ .btn {
276
+ display: inline-block;
277
+ padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);
278
+ border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);
279
+ border-radius: var(--bs-btn-border-radius);
280
+ background: var(--bs-btn-background);
281
+ box-shadow: var(--bs-btn-box-shadow, none);
282
+ color: var(--bs-btn-text-color);
283
+ font-family: var(--bs-btn-font-family);
284
+ font-size: var(--bs-btn-font-size);
285
+ font-weight: var(--bs-btn-font-weight);
286
+ line-height: var(--bs-btn-line-height);
287
+ text-align: center;
288
+ text-decoration: none;
289
+ vertical-align: middle;
290
+ white-space: initial;
291
+ width: auto;
292
+ transition: all var(--bs-transition-instant) ease-in-out;
293
+ user-select: none;
294
+ }
295
+ .btn:disabled, .btn.disabled {
296
+ opacity: var(--bs-btn-disabled-opacity);
297
+ cursor: not-allowed;
298
+ pointer-events: none;
299
+ }
300
+ .btn:focus-visible {
301
+ border-color: var(--bs-btn-hover-border-color);
302
+ outline: 0;
303
+ }
304
+ .btn-check:focus-visible + .btn {
305
+ border-color: var(--bs-btn-hover-border-color);
306
+ outline: 0;
307
+ }
308
+
309
+ .btn-link {
310
+ --bs-btn-background: transparent;
311
+ --bs-btn-border-color: transparent;
312
+ text-decoration: underline;
313
+ }
314
+ .btn-link:hover {
315
+ color: var(--bs-color-link-hover);
316
+ }
317
+
318
+ .btn-xs {
319
+ --bs-btn-padding-x: var(--bs-spacing-xs);
320
+ --bs-btn-padding-y: var(--bs-spacing-xs);
321
+ --bs-btn-font-size: var(--bs-label-font-size-s);
322
+ --bs-btn-line-height: var(--bs-font-line-height-1);
323
+ --bs-rounded-icon-size: 20px;
324
+ }
325
+
326
+ .btn-lg {
327
+ --bs-btn-padding-x: var(--bs-spacing-m);
328
+ --bs-btn-padding-y: var(--bs-spacing-s);
329
+ --bs-btn-font-size: var(--bs-label-font-size-m);
330
+ --bs-btn-line-height: var(--bs-font-line-height-5);
331
+ }
332
+
333
+ .btn-progress {
334
+ position: relative;
335
+ }
336
+
337
+ .btn-icon {
338
+ display: inline-flex;
339
+ flex-direction: row;
340
+ align-items: center;
341
+ justify-content: center;
342
+ gap: var(--bs-icon-spacing);
343
+ }
344
+
345
+ .btn-full {
346
+ align-self: stretch;
347
+ width: inherit;
348
+ border: none;
349
+ box-shadow: none;
350
+ }
351
+ @media (min-width: 992px) {
352
+ .btn-full {
353
+ display: flex;
354
+ flex: 1;
355
+ flex-direction: row;
356
+ align-items: center;
357
+ justify-content: center;
358
+ margin: 0;
359
+ }
360
+ }
361
+
362
+ .btn:disabled:hover,
363
+ .btn.disabled:hover {
364
+ cursor: not-allowed;
365
+ }
366
+
367
+ .btn-primary,
368
+ a.btn-primary {
369
+ --bs-btn-text-color: var(--bs-color-text-inverse);
370
+ --bs-btn-background: var(--bs-color-background-primary);
371
+ }
372
+ .btn-primary:hover,
373
+ a.btn-primary:hover {
374
+ --bs-btn-background: var(--bs-color-background-primary-hover);
375
+ }
376
+ .btn-primary:active,
377
+ a.btn-primary:active {
378
+ --bs-btn-background: var(--bs-color-background-primary-active);
379
+ }
380
+ .btn-primary.btn-progress,
381
+ a.btn-primary.btn-progress {
382
+ border-color: hsl(210, 76%, 67%);
383
+ opacity: 1;
384
+ background-color: hsl(210, 76%, 67%);
385
+ }
386
+
387
+ .btn-secondary,
388
+ a.btn-secondary {
389
+ --bs-btn-text-color: var(--bs-color-text-inverse);
390
+ --bs-btn-background: var(--bs-color-background-secondary);
391
+ }
392
+ .btn-secondary:hover,
393
+ a.btn-secondary:hover {
394
+ --bs-btn-background: var(--bs-color-background-secondary-hover);
395
+ }
396
+ .btn-secondary:active,
397
+ a.btn-secondary:active {
398
+ --bs-btn-background: var(--bs-color-background-secondary-active);
399
+ }
400
+ .btn-secondary:disabled.btn-progress, .btn-secondary.disabled.btn-progress,
401
+ a.btn-secondary:disabled.btn-progress,
402
+ a.btn-secondary.disabled.btn-progress {
403
+ border-color: hsl(210, 12%, 52%);
404
+ opacity: 1;
405
+ background-color: hsl(210, 12%, 52%);
406
+ }
407
+
408
+ .btn-success,
409
+ a.btn-success {
410
+ --bs-btn-text-color: var(--bs-color-text-inverse);
411
+ --bs-btn-background: var(--bs-color-background-success);
412
+ }
413
+ .btn-success:hover,
414
+ a.btn-success:hover {
415
+ --bs-btn-background: var(--bs-color-background-success-hover);
416
+ }
417
+ .btn-success:active,
418
+ a.btn-success:active {
419
+ --bs-btn-background: var(--bs-color-background-success-active);
420
+ }
421
+
422
+ .btn-warning,
423
+ a.btn-warning {
424
+ --bs-btn-text-color: var(--bs-color-text-inverse);
425
+ --bs-btn-background: var(--bs-color-background-warning);
426
+ }
427
+ .btn-warning:hover,
428
+ a.btn-warning:hover {
429
+ --bs-btn-background: var(--bs-color-background-warning-hover);
430
+ }
431
+ .btn-warning:active,
432
+ a.btn-warning:active {
433
+ --bs-btn-background: var(--bs-color-background-warning-active);
434
+ }
435
+
436
+ .btn-danger,
437
+ a.btn-danger {
438
+ --bs-btn-text-color: var(--bs-color-text-inverse);
439
+ --bs-btn-background: var(--bs-color-background-danger);
440
+ }
441
+ .btn-danger:hover,
442
+ a.btn-danger:hover {
443
+ --bs-btn-background: var(--bs-color-background-danger-hover);
444
+ }
445
+ .btn-danger:active,
446
+ a.btn-danger:active {
447
+ --bs-btn-background: var(--bs-color-background-danger-active);
448
+ }
449
+
450
+ .btn[class*=btn-outline-] {
451
+ --bs-btn-box-shadow: inset 0 0 0 var(--bs-btn-outline-border-size) var(--bs-btn-outline-border-color);
452
+ }
453
+
454
+ .btn-outline-primary,
455
+ a.btn-outline-primary {
456
+ --bs-btn-outline-border-color: var(--bs-color-border-primary);
457
+ --bs-btn-text-color: var(--bs-color-text-primary);
458
+ }
459
+ .btn-outline-primary:hover,
460
+ a.btn-outline-primary:hover {
461
+ --bs-btn-outline-border-color: var(--bs-color-border-primary-hover);
462
+ --bs-btn-text-color: var(--bs-color-link-hover);
463
+ }
464
+ .btn-outline-primary:active,
465
+ a.btn-outline-primary:active {
466
+ --bs-btn-outline-border-color: var(--bs-color-border-primary-active);
467
+ --bs-btn-text-color: var(--bs-color-link-active);
468
+ }
469
+ .btn-outline-secondary,
470
+ a.btn-outline-secondary {
471
+ --bs-btn-outline-border-color: var(--bs-color-border-secondary);
472
+ --bs-btn-text-color: var(--bs-color-text-secondary);
473
+ }
474
+ .btn-outline-secondary:hover,
475
+ a.btn-outline-secondary:hover {
476
+ --bs-btn-outline-border-color: var(--bs-color-border-secondary-hover);
477
+ --bs-btn-text-color: var(--bs-color-text-secondary-hover);
478
+ }
479
+ .btn-outline-secondary:active,
480
+ a.btn-outline-secondary:active {
481
+ --bs-btn-outline-border-color: var(--bs-color-border-secondary-active);
482
+ --bs-btn-text-color: var(--bs-color-text-secondary-active);
483
+ }
484
+ .btn-outline-success,
485
+ a.btn-outline-success {
486
+ --bs-btn-outline-border-color: var(--bs-color-border-success);
487
+ --bs-btn-text-color: var(--bs-color-text-success);
488
+ }
489
+ .btn-outline-success:hover,
490
+ a.btn-outline-success:hover {
491
+ --bs-btn-outline-border-color: var(--bs-color-border-success-hover);
492
+ --bs-btn-text-color: var(--bs-color-text-success-hover);
493
+ }
494
+ .btn-outline-success:active,
495
+ a.btn-outline-success:active {
496
+ --bs-btn-outline-border-color: var(--bs-color-border-success-active);
497
+ --bs-btn-text-color: var(--bs-color-text-success-active);
498
+ }
499
+ .btn-outline-warning,
500
+ a.btn-outline-warning {
501
+ --bs-btn-outline-border-color: var(--bs-color-border-warning);
502
+ --bs-btn-text-color: var(--bs-color-text-warning);
503
+ }
504
+ .btn-outline-warning:hover,
505
+ a.btn-outline-warning:hover {
506
+ --bs-btn-outline-border-color: var(--bs-color-border-warning-hover);
507
+ --bs-btn-text-color: var(--bs-color-text-warning-hover);
508
+ }
509
+ .btn-outline-warning:active,
510
+ a.btn-outline-warning:active {
511
+ --bs-btn-outline-border-color: var(--bs-color-border-warning-active);
512
+ --bs-btn-text-color: var(--bs-color-text-warning-active);
513
+ }
514
+ .btn-outline-danger,
515
+ a.btn-outline-danger {
516
+ --bs-btn-outline-border-color: var(--bs-color-border-danger);
517
+ --bs-btn-text-color: var(--bs-color-text-danger);
518
+ }
519
+ .btn-outline-danger:hover,
520
+ a.btn-outline-danger:hover {
521
+ --bs-btn-outline-border-color: var(--bs-color-border-danger-hover);
522
+ --bs-btn-text-color: var(--bs-color-text-danger-hover);
523
+ }
524
+ .btn-outline-danger:active,
525
+ a.btn-outline-danger:active {
526
+ --bs-btn-outline-border-color: var(--bs-color-border-danger-active);
527
+ --bs-btn-text-color: var(--bs-color-text-danger-active);
528
+ }
529
+
530
+ .bg-dark .btn-link {
531
+ --bs-btn-text-color: var(--bs-color-text-inverse);
532
+ }
533
+ .bg-dark .btn-outline-primary,
534
+ .bg-dark a.btn-outline-primary,
535
+ .bg-dark .btn-outline-secondary,
536
+ .bg-dark a.btn-outline-secondary {
537
+ --bs-btn-outline-border-color: var(--bs-color-border-inverse);
538
+ --bs-btn-text-color: var(--bs-color-text-inverse);
539
+ }
540
+
541
+ .btn-close {
542
+ position: relative;
543
+ box-sizing: content-box;
544
+ width: 2.5rem;
545
+ height: 2.5rem;
546
+ padding: 0;
547
+ border: 0;
548
+ opacity: 0.5;
549
+ background-color: transparent;
550
+ color: var(--bs-color-text-base);
551
+ }
552
+ .btn-close .icon {
553
+ position: absolute;
554
+ top: 50%;
555
+ left: 50%;
556
+ transform: translate(-50%, -50%);
557
+ }
558
+ .btn-close:hover {
559
+ opacity: 1;
560
+ text-decoration: none;
561
+ }
562
+ .btn-close:focus {
563
+ opacity: 1;
564
+ }
565
+ .btn-close:disabled, .btn-close.disabled {
566
+ opacity: var(--bs-btn-disabled-opacity);
567
+ pointer-events: none;
568
+ user-select: none;
569
+ }
570
+
571
+ .btn-close-white {
572
+ filter: invert(1) grayscale(100%) brightness(200%);
573
+ }`;
574
+
575
+ let ItButton = class ItButton extends BaseComponent {
576
+ constructor() {
577
+ super(...arguments);
578
+ this._buttonClasses = '';
579
+ this.type = 'button';
580
+ this.variant = '';
581
+ this.size = '';
582
+ this.outline = false;
583
+ this.block = false;
584
+ this.icon = false;
585
+ this.value = '';
586
+ this.internals = this.attachInternals();
587
+ }
588
+ static get formAssociated() {
589
+ return true;
590
+ }
591
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
592
+ firstUpdated(_changedProperties) {
593
+ const button = this.renderRoot.querySelector('button');
594
+ if (button) {
595
+ this.addFocus(button);
596
+ }
597
+ }
598
+ updated() {
599
+ this._buttonClasses = this.composeClass('btn', !this.outline && this.variant !== '' ? `btn-${this.variant}` : '', this.outline ? `${this.variant ? 'btn-outline-' : ''}${this.variant}` : '', 'aria-disabled' in this._ariaAttributes ? 'disabled' : '', this.size ? `btn-${this.size}` : '', this.block ? 'd-block w-100' : '', this.icon ? 'btn-icon' : '');
600
+ }
601
+ surfaceSubmitEvent(event) {
602
+ const disabled = 'aria-disabled' in this._ariaAttributes;
603
+ if (this.form && !disabled) {
604
+ event.preventDefault();
605
+ event.stopPropagation();
606
+ this.form.requestSubmit();
607
+ }
608
+ if (disabled) {
609
+ event.preventDefault();
610
+ event.stopPropagation();
611
+ }
612
+ }
613
+ get form() {
614
+ return this.internals ? this.internals.form : null;
615
+ }
616
+ connectedCallback() {
617
+ super.connectedCallback?.();
618
+ if (this.block) {
619
+ this.classList.add('d-block', 'w-100');
620
+ }
621
+ }
622
+ // Render the UI as a function of component state
623
+ render() {
624
+ const part = this.composeClass('button', this.variant?.length > 0 ? this.variant : '', this.outline ? 'outline' : '');
625
+ return html `
626
+ <button
627
+ part="${part}"
628
+ type="${this.type}"
629
+ class="${this._buttonClasses}"
630
+ @click="${this.type === 'submit' ? this.surfaceSubmitEvent : undefined}"
631
+ .value="${ifDefined(this.value ? this.value : undefined)}"
632
+ ${setAttributes(this._ariaAttributes)}
633
+ >
634
+ <slot></slot>
635
+ </button>
636
+ `;
637
+ }
638
+ };
639
+ ItButton.styles = styles;
640
+ __decorate([
641
+ property({ type: String }),
642
+ __metadata("design:type", Object)
643
+ ], ItButton.prototype, "_buttonClasses", void 0);
644
+ __decorate([
645
+ property({ type: String }),
646
+ __metadata("design:type", Object)
647
+ ], ItButton.prototype, "type", void 0);
648
+ __decorate([
649
+ property({ type: String }),
650
+ __metadata("design:type", String)
651
+ ], ItButton.prototype, "variant", void 0);
652
+ __decorate([
653
+ property({ type: String }),
654
+ __metadata("design:type", String)
655
+ ], ItButton.prototype, "size", void 0);
656
+ __decorate([
657
+ property({ type: Boolean }),
658
+ __metadata("design:type", Object)
659
+ ], ItButton.prototype, "outline", void 0);
660
+ __decorate([
661
+ property({ type: Boolean }),
662
+ __metadata("design:type", Object)
663
+ ], ItButton.prototype, "block", void 0);
664
+ __decorate([
665
+ property({ type: Boolean }),
666
+ __metadata("design:type", Object)
667
+ ], ItButton.prototype, "icon", void 0);
668
+ __decorate([
669
+ property({ type: String }),
670
+ __metadata("design:type", Object)
671
+ ], ItButton.prototype, "value", void 0);
672
+ __decorate([
673
+ property(),
674
+ __metadata("design:type", Object)
675
+ ], ItButton.prototype, "internals", void 0);
676
+ ItButton = __decorate([
677
+ customElement('it-button')
678
+ ], ItButton);
679
+
680
+ export { ItButton };
681
+ //# sourceMappingURL=it-button.js.map