@politiet/sheriff-web-components 2.1.3 → 2.3.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.
- package/dist/frameworks/preact.d.ts +7 -1
- package/dist/frameworks/preact.d.ts.map +1 -1
- package/dist/frameworks/react.d.ts +7 -1
- package/dist/frameworks/react.d.ts.map +1 -1
- package/dist/frameworks/solidjs.d.ts +2 -0
- package/dist/frameworks/solidjs.d.ts.map +1 -1
- package/dist/frameworks/svelte.d.ts +2 -0
- package/dist/frameworks/svelte.d.ts.map +1 -1
- package/dist/frameworks/vue.d.ts +2 -0
- package/dist/frameworks/vue.d.ts.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/react-wrappers/SDSDialogWrapper.d.ts +6 -0
- package/dist/react-wrappers/SDSDialogWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSDialogWrapper.js +12 -0
- package/dist/react-wrappers/SDSDialogWrapper.js.map +1 -0
- package/dist/react-wrappers/SDSSelectWrapper.d.ts +8 -0
- package/dist/react-wrappers/SDSSelectWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSSelectWrapper.js +14 -0
- package/dist/react-wrappers/SDSSelectWrapper.js.map +1 -0
- package/dist/react-wrappers/index.d.ts +2 -0
- package/dist/react-wrappers/index.d.ts.map +1 -1
- package/dist/react-wrappers/index.js +2 -0
- package/dist/react-wrappers/index.js.map +1 -1
- package/dist/sds-alert/sds-alert.component.d.ts +25 -0
- package/dist/sds-alert/sds-alert.component.d.ts.map +1 -0
- package/dist/sds-alert/sds-alert.component.js +73 -0
- package/dist/sds-alert/sds-alert.component.js.map +1 -0
- package/dist/sds-alert/sds-alert.d.ts +3 -19
- package/dist/sds-alert/sds-alert.d.ts.map +1 -1
- package/dist/sds-alert/sds-alert.js +2 -55
- package/dist/sds-alert/sds-alert.js.map +1 -1
- package/dist/sds-alert/sds-alert.styles.d.ts.map +1 -1
- package/dist/sds-alert/sds-alert.styles.js +12 -7
- package/dist/sds-alert/sds-alert.styles.js.map +1 -1
- package/dist/sds-button/sds-button.component.d.ts +45 -0
- package/dist/sds-button/sds-button.component.d.ts.map +1 -0
- package/dist/sds-button/sds-button.component.js +162 -0
- package/dist/sds-button/sds-button.component.js.map +1 -0
- package/dist/sds-button/sds-button.d.ts +2 -42
- package/dist/sds-button/sds-button.d.ts.map +1 -1
- package/dist/sds-button/sds-button.js +2 -151
- package/dist/sds-button/sds-button.js.map +1 -1
- package/dist/sds-card/sds-card.d.ts +4 -0
- package/dist/sds-card/sds-card.d.ts.map +1 -1
- package/dist/sds-card/sds-card.js +18 -15
- package/dist/sds-card/sds-card.js.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.d.ts +1 -0
- package/dist/sds-checkbox/sds-checkbox.d.ts.map +1 -1
- package/dist/sds-checkbox/sds-checkbox.js +4 -1
- package/dist/sds-checkbox/sds-checkbox.js.map +1 -1
- package/dist/sds-chip/sds-chip.d.ts +1 -0
- package/dist/sds-chip/sds-chip.d.ts.map +1 -1
- package/dist/sds-chip/sds-chip.js +4 -1
- package/dist/sds-chip/sds-chip.js.map +1 -1
- package/dist/sds-chip/sds-chip.styles.d.ts.map +1 -1
- package/dist/sds-chip/sds-chip.styles.js +2 -1
- package/dist/sds-chip/sds-chip.styles.js.map +1 -1
- package/dist/sds-dialog/sds-dialog.d.ts +61 -0
- package/dist/sds-dialog/sds-dialog.d.ts.map +1 -0
- package/dist/sds-dialog/sds-dialog.js +162 -0
- package/dist/sds-dialog/sds-dialog.js.map +1 -0
- package/dist/sds-dialog/sds-dialog.styles.d.ts +2 -0
- package/dist/sds-dialog/sds-dialog.styles.d.ts.map +1 -0
- package/dist/sds-dialog/sds-dialog.styles.js +115 -0
- package/dist/sds-dialog/sds-dialog.styles.js.map +1 -0
- package/dist/sds-heading/sds-heading.component.d.ts +16 -0
- package/dist/sds-heading/sds-heading.component.d.ts.map +1 -0
- package/dist/sds-heading/sds-heading.component.js +50 -0
- package/dist/sds-heading/sds-heading.component.js.map +1 -0
- package/dist/sds-heading/sds-heading.d.ts +2 -14
- package/dist/sds-heading/sds-heading.d.ts.map +1 -1
- package/dist/sds-heading/sds-heading.js +2 -42
- package/dist/sds-heading/sds-heading.js.map +1 -1
- package/dist/sds-icon/sds-icon.component.d.ts +31 -0
- package/dist/sds-icon/sds-icon.component.d.ts.map +1 -0
- package/dist/sds-icon/sds-icon.component.js +73 -0
- package/dist/sds-icon/sds-icon.component.js.map +1 -0
- package/dist/sds-icon/sds-icon.d.ts +2 -29
- package/dist/sds-icon/sds-icon.d.ts.map +1 -1
- package/dist/sds-icon/sds-icon.js +3 -67
- package/dist/sds-icon/sds-icon.js.map +1 -1
- package/dist/sds-radio/sds-radio.d.ts +1 -0
- package/dist/sds-radio/sds-radio.d.ts.map +1 -1
- package/dist/sds-radio/sds-radio.js +4 -1
- package/dist/sds-radio/sds-radio.js.map +1 -1
- package/dist/sds-select/sds-select.d.ts +72 -0
- package/dist/sds-select/sds-select.d.ts.map +1 -0
- package/dist/sds-select/sds-select.js +324 -0
- package/dist/sds-select/sds-select.js.map +1 -0
- package/dist/sds-select/sds-select.styles.d.ts +2 -0
- package/dist/sds-select/sds-select.styles.d.ts.map +1 -0
- package/dist/sds-select/sds-select.styles.js +179 -0
- package/dist/sds-select/sds-select.styles.js.map +1 -0
- package/dist/sds-switch/sds-switch.d.ts +1 -0
- package/dist/sds-switch/sds-switch.d.ts.map +1 -1
- package/dist/sds-switch/sds-switch.js +4 -1
- package/dist/sds-switch/sds-switch.js.map +1 -1
- package/dist/sds-text/sds-text.component.d.ts +17 -0
- package/dist/sds-text/sds-text.component.d.ts.map +1 -0
- package/dist/sds-text/sds-text.component.js +33 -0
- package/dist/sds-text/sds-text.component.js.map +1 -0
- package/dist/sds-text/sds-text.d.ts +2 -15
- package/dist/sds-text/sds-text.d.ts.map +1 -1
- package/dist/sds-text/sds-text.js +2 -25
- package/dist/sds-text/sds-text.js.map +1 -1
- package/dist/sds-textarea/sds-textarea.d.ts +1 -0
- package/dist/sds-textarea/sds-textarea.d.ts.map +1 -1
- package/dist/sds-textarea/sds-textarea.js +4 -1
- package/dist/sds-textarea/sds-textarea.js.map +1 -1
- package/dist/sds-textfield/sds-textfield.d.ts +1 -0
- package/dist/sds-textfield/sds-textfield.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.js +4 -1
- package/dist/sds-textfield/sds-textfield.js.map +1 -1
- package/dist/sheriff-web-components.js +461 -120
- package/dist/utils/slot-validator.js +2 -2
- package/dist/utils/slot-validator.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,65 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
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;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { LitElement, html, nothing } from 'lit';
|
|
8
|
-
import { property } from 'lit/decorators.js';
|
|
9
7
|
import { guardedCustomElement } from '../utils/guarded-custom-element';
|
|
10
|
-
import {
|
|
8
|
+
import { SDSAlertComponent } from './sds-alert.component';
|
|
11
9
|
import '../sds-icon/sds-icon';
|
|
12
10
|
import '../sds-button/sds-button';
|
|
13
|
-
|
|
14
|
-
info: 'InformationSquareFill-aksel-filled',
|
|
15
|
-
success: 'check_circle-material-filled',
|
|
16
|
-
attention: 'warning-material-filled',
|
|
17
|
-
danger: 'dangerous-material-filled',
|
|
11
|
+
let SDSAlert = class SDSAlert extends SDSAlertComponent {
|
|
18
12
|
};
|
|
19
|
-
let SDSAlert = class SDSAlert extends LitElement {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.variant = 'primary';
|
|
23
|
-
this.size = 'md';
|
|
24
|
-
this.palette = 'info';
|
|
25
|
-
this._remove = () => {
|
|
26
|
-
this.dispatchEvent(new CustomEvent('sds-remove', {
|
|
27
|
-
bubbles: true,
|
|
28
|
-
composed: true,
|
|
29
|
-
}));
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
render() {
|
|
33
|
-
const iconSize = this.variant === 'primary' ? 'md' : this.size ?? 'md';
|
|
34
|
-
const iconName = alertIcons[this.palette] ?? alertIcons['info'];
|
|
35
|
-
return html `<div class="sds-alert">
|
|
36
|
-
<div class="sds-alert__type">
|
|
37
|
-
<sds-icon class="sds-alert__icon" name="${iconName}" size="${iconSize}"></sds-icon>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="sds-alert__content">
|
|
40
|
-
<slot name="title"></slot>
|
|
41
|
-
<slot name="message"></slot>
|
|
42
|
-
</div>
|
|
43
|
-
${this.removableLabel && this.variant === 'primary'
|
|
44
|
-
? html `<div class="sds-alert__actions">
|
|
45
|
-
<sds-button icon variant="tertiary" size="sm" @click=${this._remove} aria-label="${this.removableLabel}">
|
|
46
|
-
<sds-icon name="close-material-outlined" size="sm"></sds-icon>
|
|
47
|
-
</sds-button>
|
|
48
|
-
</div>`
|
|
49
|
-
: nothing}
|
|
50
|
-
</div>`;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
SDSAlert.styles = [styles];
|
|
54
|
-
__decorate([
|
|
55
|
-
property({ type: String, reflect: true })
|
|
56
|
-
], SDSAlert.prototype, "variant", void 0);
|
|
57
|
-
__decorate([
|
|
58
|
-
property({ type: String, reflect: true })
|
|
59
|
-
], SDSAlert.prototype, "size", void 0);
|
|
60
|
-
__decorate([
|
|
61
|
-
property({ type: String, attribute: 'removable-label', reflect: true })
|
|
62
|
-
], SDSAlert.prototype, "removableLabel", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
property({ type: String, attribute: 'data-palette', reflect: true })
|
|
65
|
-
], SDSAlert.prototype, "palette", void 0);
|
|
66
13
|
SDSAlert = __decorate([
|
|
67
14
|
guardedCustomElement('sds-alert')
|
|
68
15
|
], SDSAlert);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-alert.js","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sds-alert.js","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAG3B,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,iBAAiB;CAAG,CAAA;AAArC,QAAQ;IADpB,oBAAoB,CAAC,WAAW,CAAC;GACrB,QAAQ,CAA6B","sourcesContent":["import { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { SheriffEvent } from '../types';\nimport { SDSAlertComponent } from './sds-alert.component';\n\nimport '../sds-icon/sds-icon';\nimport '../sds-button/sds-button';\n\n@guardedCustomElement('sds-alert')\nexport class SDSAlert extends SDSAlertComponent {}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-alert': SDSAlert;\n\t}\n\tinterface GlobalEventHandlersEventMap {\n\t\t'sds-remove': SheriffEvent;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-alert.styles.d.ts","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"sds-alert.styles.d.ts","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAmLlB,CAAC"}
|
|
@@ -96,8 +96,8 @@ export const styles = css `
|
|
|
96
96
|
:host([variant='secondary']) {
|
|
97
97
|
--_sds-alert-background-color: var(--sds-alert-background-color, transparent);
|
|
98
98
|
--_sds-alert-border-color: var(--sds-alert-border-color, transparent);
|
|
99
|
-
|
|
100
|
-
--_sds-alert-padding: var(--sds-alert-padding,
|
|
99
|
+
--_sds-alert-border-width: var(--sds-alert-border-width, 0);
|
|
100
|
+
--_sds-alert-padding: var(--sds-alert-padding, 0);
|
|
101
101
|
--_sds-alert-column-gap: var(--sds-alert-column-gap, var(--sds-spacing-3xs));
|
|
102
102
|
--_sds-alert-content-gap: var(--sds-alert-content-gap, var(--sds-spacing-4xs));
|
|
103
103
|
|
|
@@ -109,22 +109,27 @@ export const styles = css `
|
|
|
109
109
|
&::after {
|
|
110
110
|
content: '';
|
|
111
111
|
position: absolute;
|
|
112
|
-
top:
|
|
113
|
-
left:
|
|
112
|
+
top: 4px;
|
|
113
|
+
left: 4px;
|
|
114
114
|
width: 16px;
|
|
115
115
|
height: 16px;
|
|
116
116
|
background-color: var(--_sds-alert-icon-color-background);
|
|
117
|
-
z-index:
|
|
117
|
+
z-index: -1;
|
|
118
118
|
clip-path: circle(50%);
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
&:host([size='sm'])::after {
|
|
122
|
+
width: 10px;
|
|
123
|
+
height: 10px;
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
:host([variant='secondary']):host([data-palette='attention']) {
|
|
123
128
|
--sds-icon-color: var(--sds-alert-icon-color, var(--sds-color-action-default));
|
|
124
129
|
|
|
125
130
|
&::after {
|
|
126
|
-
top:
|
|
127
|
-
left:
|
|
131
|
+
top: 4px;
|
|
132
|
+
left: 2px;
|
|
128
133
|
width: 20px;
|
|
129
134
|
height: 16px;
|
|
130
135
|
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-alert.styles.js","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"sds-alert.styles.js","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmLxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n\t:host {\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, var(--sds-color-alert-info-surface-tinted));\n\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, var(--sds-color-alert-info-border-default));\n\t\t--_sds-alert-border-radius: var(--sds-alert-border-radius, var(--sds-radius-sm));\n\t\t--_sds-alert-border-width: var(--sds-alert-border-width, var(--sds-border-sm));\n\n\t\t--_sds-alert-column-gap: var(--sds-alert-column-gap, var(--sds-spacing-2xs));\n\t\t--_sds-alert-content-gap: var(--sds-alert-content-gap, var(--sds-spacing-3xs));\n\n\t\t--_sds-alert-font-family: var(--sds-alert-font-family, var(--sds-typography-font-family-roboto));\n\t\t--_sds-alert-text-color: var(--sds-alert-text-color, var(--sds-color-alert-info-text-default));\n\n\t\t--_sds-alert-font-size: var(--sds-alert-font-size, var(--sds-components-font-size-content-md));\n\t\t--_sds-alert-font-weight: var(--sds-alert-font-weight, var(--sds-typography-body-md-desktop-font-weight));\n\t\t--_sds-alert-line-height: var(--sds-alert-line-height, var(--sds-components-line-height-tall-content-md));\n\n\t\t--_sds-alert-title-font-size: var(--sds-alert-title-font-size, var(--sds-components-font-size-title-md));\n\t\t--_sds-alert-title-font-weight: var(--sds-alert-title-font-weight, var(--sds-typography-body-lg-strong-tall-desktop-font-weight));\n\t\t--_sds-alert-title-line-height: var(--sds-alert-title-line-height, var(--sds-components-line-height-tall-title-md));\n\n\t\t--_sds-alert-icon-color: var(--sds-alert-icon-color, var(--sds-color-alert-info-text-subtle));\n\t\t--_sds-alert-icon-color-background: var(--sds-alert-icon-color-background, var(--sds-color-action-contrast-default, white));\n\t\t--_sds-alert-max-line-width: var(--sds-alert-max-line-width, var(--sds-typography-max-line-width));\n\t\t--_sds-alert-padding: var(--sds-alert-padding, var(--sds-spacing-sm));\n\n\t\t--sds-icon-color: var(--sds-alert-icon-color, var(--_sds-alert-icon-color));\n\n\t\tdisplay: block;\n\t}\n\n\t.sds-alert {\n\t\tdisplay: flex;\n\t\tgap: var(--_sds-alert-column-gap);\n\t\tpadding: var(--_sds-alert-padding);\n\t\tbackground-color: var(--_sds-alert-background-color);\n\t\tborder: var(--_sds-alert-border-width) solid var(--_sds-alert-border-color);\n\t\tborder-radius: var(--_sds-alert-border-radius);\n\t\tcolor: var(--_sds-alert-text-color);\n\t\tfont-family: var(--_sds-alert-font-family);\n\t\ttext-align: left;\n\t}\n\n\t:host([data-palette='success']) {\n\t\t--_sds-alert-icon-color: var(--sds-alert-icon-color, var(--sds-color-alert-success-text-subtle));\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, var(--sds-color-alert-success-border-default));\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, var(--sds-color-alert-success-surface-tinted));\n\t\t--_sds-alert-text-color: var(--sds-alert-text-color, var(--sds-color-alert-success-text-default));\n\t}\n\n\t:host([data-palette='danger']) {\n\t\t--_sds-alert-icon-color: var(--sds-alert-icon-color, var(--sds-color-alert-danger-text-subtle));\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, var(--sds-color-alert-danger-border-default));\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, var(--sds-color-alert-danger-surface-tinted));\n\t\t--_sds-alert-text-color: var(--sds-alert-text-color, var(--sds-color-alert-danger-text-default));\n\t}\n\n\t:host([data-palette='attention']) {\n\t\t--_sds-alert-icon-color: var(--sds-alert-icon-color, var(--sds-color-alert-attention-text-subtle));\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, var(--sds-color-alert-attention-border-default));\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, var(--sds-color-alert-attention-surface-tinted));\n\t\t--_sds-alert-text-color: var(--sds-alert-text-color, var(--sds-color-alert-attention-text-default));\n\t}\n\n\t:host([data-palette='warning']) {\n\t\t--_sds-alert-icon-color: var(--sds-alert-icon-color, var(--sds-color-alert-warning-text-subtle));\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, var(--sds-color-alert-warning-border-default));\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, var(--sds-color-alert-warning-surface-tinted));\n\t\t--_sds-alert-text-color: var(--sds-alert-text-color, var(--sds-color-alert-warning-text-default));\n\t}\n\n\t.sds-alert__type {\n\t\tcolor: var(--_sds-alert-icon-color);\n\t}\n\n\t.sds-alert__content {\n\t\talign-self: center;\n\t\tdisplay: flex;\n\t\tflex: 1;\n\t\tflex-direction: column;\n\t}\n\n\t.sds-alert__actions {\n\t\t--sds-button-padding-inline: 0;\n\t\t--sds-button-text-color: var(--sds-color-action-default);\n\t}\n\n\t.sds-alert__icon {\n\t\tdisplay: block;\n\t\tposition: relative;\n\t\tz-index: 1;\n\t}\n\n\t:host([variant='secondary']) {\n\t\t--_sds-alert-background-color: var(--sds-alert-background-color, transparent);\n\t\t--_sds-alert-border-color: var(--sds-alert-border-color, transparent);\n\t\t--_sds-alert-border-width: var(--sds-alert-border-width, 0);\n\t\t--_sds-alert-padding: var(--sds-alert-padding, 0);\n\t\t--_sds-alert-column-gap: var(--sds-alert-column-gap, var(--sds-spacing-3xs));\n\t\t--_sds-alert-content-gap: var(--sds-alert-content-gap, var(--sds-spacing-4xs));\n\n\t\t--_sds-alert-line-height: var(--sds-alert-line-height, var(--sds-components-line-height-tall-content-md));\n\t\t--_sds-alert-font-weight: var(--sds-alert-font-weight, var(--sds-typography-body-md-tall-desktop-font-weight));\n\n\t\tposition: relative;\n\n\t\t&::after {\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\ttop: 4px;\n\t\t\tleft: 4px;\n\t\t\twidth: 16px;\n\t\t\theight: 16px;\n\t\t\tbackground-color: var(--_sds-alert-icon-color-background);\n\t\t\tz-index: -1;\n\t\t\tclip-path: circle(50%);\n\t\t}\n\n\t\t&:host([size='sm'])::after {\n\t\t\twidth: 10px;\n\t\t\theight: 10px;\n\t\t}\n\t}\n\n\t:host([variant='secondary']):host([data-palette='attention']) {\n\t\t--sds-icon-color: var(--sds-alert-icon-color, var(--sds-color-action-default));\n\n\t\t&::after {\n\t\t\ttop: 4px;\n\t\t\tleft: 2px;\n\t\t\twidth: 20px;\n\t\t\theight: 16px;\n\t\t\tclip-path: polygon(50% 0%, 0% 100%, 100% 100%);\n\t\t}\n\t}\n\n\t:host([variant='secondary']):host([size='sm']) {\n\t\t--_sds-alert-font-size: var(--sds-alert-font-size, var(--sds-components-font-size-content-sm));\n\t\t--_sds-alert-line-height: var(--sds-alert-line-height, var(--sds-components-line-height-tall-content-sm));\n\t\t--_sds-alert-title-font-size: var(--sds-alert-title-font-size, var(--sds-components-font-size-title-sm));\n\t\t--_sds-alert-title-line-height: var(--sds-alert-title-line-height, var(--sds-components-line-height-tall-title-sm));\n\t}\n\n\t:host([variant='secondary']):host([size='md']) {\n\t\t--_sds-alert-font-size: var(--sds-alert-font-size, var(--sds-components-font-size-content-md));\n\t\t--_sds-alert-line-height: var(--sds-alert-line-height, var(--sds-components-line-height-tall-content-md));\n\t\t--_sds-alert-title-font-size: var(--sds-alert-title-font-size, var(--sds-components-font-size-title-md));\n\t\t--_sds-alert-title-line-height: var(--sds-alert-title-line-height, var(--sds-components-line-height-tall-title-md));\n\t}\n\n\t:host([variant='secondary']):host([size='lg']) {\n\t\t--_sds-alert-font-size: var(--sds-alert-font-size, var(--sds-components-font-size-content-lg));\n\t\t--_sds-alert-line-height: var(--sds-alert-line-height, var(--sds-components-line-height-tall-content-lg));\n\t\t--_sds-alert-title-font-size: var(--sds-alert-title-font-size, var(--sds-components-font-size-title-lg));\n\t\t--_sds-alert-title-line-height: var(--sds-alert-title-line-height, var(--sds-components-line-height-tall-title-lg));\n\t}\n\n\t::slotted([slot='title']),\n\t::slotted(:is(h1, h2, h3, h4, h5, h6)) {\n\t\tcolor: var(--_sds-alert-text-color) !important;\n\t\tfont-size: var(--_sds-alert-title-font-size) !important;\n\t\tfont-style: normal !important;\n\t\tfont-weight: var(--_sds-alert-title-font-weight) !important;\n\t\tline-height: var(--_sds-alert-title-line-height) !important;\n\t\tmargin: 0 !important;\n\t\tmax-width: var(--_sds-alert-max-line-width) !important;\n\t}\n\n\t::slotted([slot='message']),\n\t::slotted(:is(p)) {\n\t\tcolor: var(--_sds-alert-text-color) !important;\n\t\tfont-size: var(--_sds-alert-font-size) !important;\n\t\tfont-style: normal !important;\n\t\tfont-weight: var(--_sds-alert-font-weight) !important;\n\t\tline-height: var(--_sds-alert-line-height) !important;\n\t\tmargin: 0 !important;\n\t\tmax-width: var(--_sds-alert-max-line-width) !important;\n\t}\n`;\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { SDS_SIZES, SDS_VARIANTS } from '../types';
|
|
3
|
+
type ButtonType = 'button' | 'submit' | 'reset';
|
|
4
|
+
type ButtonVariant = SDS_VARIANTS | 'critical';
|
|
5
|
+
type ButtonSize = 'large' | 'medium' | 'small' | Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
6
|
+
type TargetTypes = '_self' | '_blank' | '_parent' | '_top';
|
|
7
|
+
export interface SDSButtonProps {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
form?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
icon?: boolean;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
name?: string;
|
|
14
|
+
size?: ButtonSize;
|
|
15
|
+
target?: TargetTypes;
|
|
16
|
+
type?: ButtonType;
|
|
17
|
+
value?: string;
|
|
18
|
+
variant?: ButtonVariant;
|
|
19
|
+
}
|
|
20
|
+
export declare class SDSButtonComponent extends LitElement {
|
|
21
|
+
static styles: import("lit").CSSResult[];
|
|
22
|
+
static formAssociated: boolean;
|
|
23
|
+
readonly internals: ElementInternals;
|
|
24
|
+
static shadowRootOptions: ShadowRootInit;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
icon: boolean;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
form?: string;
|
|
29
|
+
href?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
size: ButtonSize;
|
|
32
|
+
target?: TargetTypes;
|
|
33
|
+
type: ButtonType;
|
|
34
|
+
value: string;
|
|
35
|
+
variant: ButtonVariant;
|
|
36
|
+
constructor();
|
|
37
|
+
updated(changed: PropertyValues): void;
|
|
38
|
+
private readonly _handleClick;
|
|
39
|
+
focus(): void;
|
|
40
|
+
blur(): void;
|
|
41
|
+
click(): void;
|
|
42
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=sds-button.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-button.component.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAiB,MAAM,KAAK,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGnD,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAChD,KAAK,aAAa,GAAG,YAAY,GAAG,UAAU,CAAC;AAC/C,KAAK,UAAU,GAAG,OAAO,GAAG,QAAQ,GAA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,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAIb,MAAM;CA+Bf"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, nothing } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { styles } from './sds-button.styles';
|
|
12
|
+
export class SDSButtonComponent extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.disabled = false;
|
|
16
|
+
this.icon = false;
|
|
17
|
+
this.loading = false;
|
|
18
|
+
this.size = 'lg';
|
|
19
|
+
this.type = 'button';
|
|
20
|
+
this.value = '';
|
|
21
|
+
this.variant = 'primary';
|
|
22
|
+
this._handleClick = (event) => {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
event.stopImmediatePropagation();
|
|
25
|
+
if (!this.disabled) {
|
|
26
|
+
switch (this.type) {
|
|
27
|
+
case 'submit': {
|
|
28
|
+
const submitEvent = new CustomEvent('submit', {
|
|
29
|
+
bubbles: true,
|
|
30
|
+
composed: true,
|
|
31
|
+
cancelable: true,
|
|
32
|
+
});
|
|
33
|
+
const shouldSubmit = this.dispatchEvent(submitEvent);
|
|
34
|
+
if (shouldSubmit) {
|
|
35
|
+
if (this.form) {
|
|
36
|
+
const root = this.getRootNode();
|
|
37
|
+
const formElement = root.querySelector(`form#${this.form}`);
|
|
38
|
+
formElement?.requestSubmit();
|
|
39
|
+
}
|
|
40
|
+
else if (this.internals.form) {
|
|
41
|
+
this.internals.form.requestSubmit();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'reset': {
|
|
47
|
+
const resetEvent = new CustomEvent('reset', {
|
|
48
|
+
bubbles: true,
|
|
49
|
+
composed: true,
|
|
50
|
+
cancelable: true,
|
|
51
|
+
});
|
|
52
|
+
const shouldReset = this.dispatchEvent(resetEvent);
|
|
53
|
+
if (shouldReset) {
|
|
54
|
+
if (this.form) {
|
|
55
|
+
const root = this.getRootNode();
|
|
56
|
+
const formElement = root.querySelector(`form#${this.form}`);
|
|
57
|
+
formElement?.reset();
|
|
58
|
+
}
|
|
59
|
+
else if (this.internals.form) {
|
|
60
|
+
this.internals.form.reset();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
default:
|
|
66
|
+
this.dispatchEvent(new CustomEvent('click', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
this.internals = this.attachInternals();
|
|
74
|
+
}
|
|
75
|
+
updated(changed) {
|
|
76
|
+
// Cast critical variant to danger palette to prevent breaking changes
|
|
77
|
+
if (changed.has('variant') && this.variant === 'critical') {
|
|
78
|
+
this.setAttribute('data-palette', 'danger');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
focus() {
|
|
82
|
+
if (!this.disabled)
|
|
83
|
+
this.shadowRoot?.querySelector('button')?.focus();
|
|
84
|
+
}
|
|
85
|
+
blur() {
|
|
86
|
+
if (!this.disabled)
|
|
87
|
+
this.shadowRoot?.querySelector('button')?.blur();
|
|
88
|
+
}
|
|
89
|
+
click() {
|
|
90
|
+
if (!this.disabled)
|
|
91
|
+
this.shadowRoot?.querySelector('button')?.click();
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
const buttonClasses = {
|
|
95
|
+
'sds-button': true,
|
|
96
|
+
'sds-button--as-link': !!this.href,
|
|
97
|
+
};
|
|
98
|
+
if (this.href) {
|
|
99
|
+
return html ` <a id="link" class="${classMap(buttonClasses)}" href="${this.href}" target="${ifDefined(this.target)}">
|
|
100
|
+
<slot name="before"></slot>
|
|
101
|
+
<slot></slot>
|
|
102
|
+
<slot name="after"></slot>
|
|
103
|
+
</a>`;
|
|
104
|
+
}
|
|
105
|
+
return html `
|
|
106
|
+
<button
|
|
107
|
+
id="control"
|
|
108
|
+
form="${ifDefined(this.form)}"
|
|
109
|
+
class="${classMap(buttonClasses)}"
|
|
110
|
+
type="${this.type}"
|
|
111
|
+
name="${ifDefined(this.name)}"
|
|
112
|
+
value="${ifDefined(this.value)}"
|
|
113
|
+
?disabled="${this.disabled}"
|
|
114
|
+
@click="${this._handleClick}"
|
|
115
|
+
>
|
|
116
|
+
${this.loading ? html `<sds-loader slot="before" ?contrast="${this.variant !== 'primary'}"></sds-loader>` : nothing} ${this.loading ? nothing : html `<slot name="before"></slot>`}
|
|
117
|
+
<slot></slot>
|
|
118
|
+
${this.loading ? nothing : html `<slot name="after"></slot>`}
|
|
119
|
+
</button>
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
SDSButtonComponent.styles = [styles];
|
|
124
|
+
SDSButtonComponent.formAssociated = true;
|
|
125
|
+
SDSButtonComponent.shadowRootOptions = {
|
|
126
|
+
...LitElement.shadowRootOptions,
|
|
127
|
+
delegatesFocus: true,
|
|
128
|
+
};
|
|
129
|
+
__decorate([
|
|
130
|
+
property({ type: Boolean, reflect: true })
|
|
131
|
+
], SDSButtonComponent.prototype, "disabled", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
property({ type: Boolean, reflect: true })
|
|
134
|
+
], SDSButtonComponent.prototype, "icon", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: Boolean, reflect: true })
|
|
137
|
+
], SDSButtonComponent.prototype, "loading", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
property({ type: String, reflect: true })
|
|
140
|
+
], SDSButtonComponent.prototype, "form", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ type: String, reflect: true })
|
|
143
|
+
], SDSButtonComponent.prototype, "href", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property({ type: String, reflect: true })
|
|
146
|
+
], SDSButtonComponent.prototype, "name", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ type: String, reflect: true })
|
|
149
|
+
], SDSButtonComponent.prototype, "size", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: String, reflect: true })
|
|
152
|
+
], SDSButtonComponent.prototype, "target", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: String, reflect: true })
|
|
155
|
+
], SDSButtonComponent.prototype, "type", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: String, reflect: true })
|
|
158
|
+
], SDSButtonComponent.prototype, "value", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: String, reflect: true })
|
|
161
|
+
], SDSButtonComponent.prototype, "variant", void 0);
|
|
162
|
+
//# sourceMappingURL=sds-button.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-button.component.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAA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,EAAE,CAAC;mDAAoC","sourcesContent":["import { LitElement, PropertyValues, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { SDS_SIZES, SDS_VARIANTS } from '../types';\nimport { styles } from './sds-button.styles';\n\ntype ButtonType = 'button' | 'submit' | 'reset';\ntype ButtonVariant = SDS_VARIANTS | 'critical';\ntype ButtonSize = 'large' | 'medium' | 'small' | Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\ntype TargetTypes = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface SDSButtonProps {\n\tdisabled?: boolean;\n\tform?: string;\n\thref?: string;\n\ticon?: boolean;\n\tloading?: boolean;\n\tname?: string;\n\tsize?: ButtonSize;\n\ttarget?: TargetTypes;\n\ttype?: ButtonType;\n\tvalue?: string;\n\tvariant?: ButtonVariant;\n}\n\nexport class SDSButtonComponent extends LitElement {\n\tstatic override styles = [styles];\n\n\tstatic formAssociated = true;\n\tpublic readonly internals: ElementInternals;\n\n\tstatic override shadowRootOptions: ShadowRootInit = {\n\t\t...LitElement.shadowRootOptions,\n\t\tdelegatesFocus: true,\n\t};\n\n\t@property({ type: Boolean, reflect: true }) disabled: boolean = false;\n\t@property({ type: Boolean, reflect: true }) icon: boolean = false;\n\t@property({ type: Boolean, reflect: true }) loading: boolean = false;\n\t@property({ type: String, reflect: true }) form?: string;\n\t@property({ type: String, reflect: true }) href?: string;\n\t@property({ type: String, reflect: true }) name?: string;\n\t@property({ type: String, reflect: true }) size: ButtonSize = 'lg';\n\t@property({ type: String, reflect: true }) target?: TargetTypes;\n\t@property({ type: String, reflect: true }) type: ButtonType = 'button';\n\t@property({ type: String, reflect: true }) value: string = '';\n\t@property({ type: String, reflect: true }) variant: ButtonVariant = 'primary';\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t}\n\n\toverride updated(changed: PropertyValues) {\n\t\t// Cast critical variant to danger palette to prevent breaking changes\n\t\tif (changed.has('variant') && this.variant === 'critical') {\n\t\t\tthis.setAttribute('data-palette', 'danger');\n\t\t}\n\t}\n\n\tprivate readonly _handleClick = (event: MouseEvent) => {\n\t\tevent.preventDefault();\n\t\tevent.stopImmediatePropagation();\n\n\t\tif (!this.disabled) {\n\t\t\tswitch (this.type) {\n\t\t\t\tcase 'submit': {\n\t\t\t\t\tconst submitEvent = new CustomEvent('submit', {\n\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\tcancelable: true,\n\t\t\t\t\t});\n\t\t\t\t\tconst shouldSubmit = this.dispatchEvent(submitEvent);\n\n\t\t\t\t\tif (shouldSubmit) {\n\t\t\t\t\t\tif (this.form) {\n\t\t\t\t\t\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\t\t\t\t\t\tconst formElement: HTMLFormElement | null = root.querySelector(`form#${this.form}`);\n\t\t\t\t\t\t\tformElement?.requestSubmit();\n\t\t\t\t\t\t} else if (this.internals.form) {\n\t\t\t\t\t\t\tthis.internals.form.requestSubmit();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'reset': {\n\t\t\t\t\tconst resetEvent = new CustomEvent('reset', {\n\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\tcancelable: true,\n\t\t\t\t\t});\n\t\t\t\t\tconst shouldReset = this.dispatchEvent(resetEvent);\n\n\t\t\t\t\tif (shouldReset) {\n\t\t\t\t\t\tif (this.form) {\n\t\t\t\t\t\t\tconst root = this.getRootNode() as Document | ShadowRoot;\n\t\t\t\t\t\t\tconst formElement: HTMLFormElement | null = root.querySelector(`form#${this.form}`);\n\t\t\t\t\t\t\tformElement?.reset();\n\t\t\t\t\t\t} else if (this.internals.form) {\n\t\t\t\t\t\t\tthis.internals.form.reset();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent('click', {\n\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\toverride focus(): void {\n\t\tif (!this.disabled) this.shadowRoot?.querySelector('button')?.focus();\n\t}\n\n\toverride blur(): void {\n\t\tif (!this.disabled) this.shadowRoot?.querySelector('button')?.blur();\n\t}\n\n\toverride click(): void {\n\t\tif (!this.disabled) this.shadowRoot?.querySelector('button')?.click();\n\t}\n\n\toverride render() {\n\t\tconst buttonClasses = {\n\t\t\t'sds-button': true,\n\t\t\t'sds-button--as-link': !!this.href,\n\t\t};\n\n\t\tif (this.href) {\n\t\t\treturn html` <a id=\"link\" class=\"${classMap(buttonClasses)}\" href=\"${this.href}\" target=\"${ifDefined(this.target)}\">\n\t\t\t\t<slot name=\"before\"></slot>\n\t\t\t\t<slot></slot>\n\t\t\t\t<slot name=\"after\"></slot>\n\t\t\t</a>`;\n\t\t}\n\n\t\treturn html`\n\t\t\t<button\n\t\t\t\tid=\"control\"\n\t\t\t\tform=\"${ifDefined(this.form)}\"\n\t\t\t\tclass=\"${classMap(buttonClasses)}\"\n\t\t\t\ttype=\"${this.type}\"\n\t\t\t\tname=\"${ifDefined(this.name)}\"\n\t\t\t\tvalue=\"${ifDefined(this.value)}\"\n\t\t\t\t?disabled=\"${this.disabled}\"\n\t\t\t\t@click=\"${this._handleClick}\"\n\t\t\t>\n\t\t\t\t${this.loading ? html`<sds-loader slot=\"before\" ?contrast=\"${this.variant !== 'primary'}\"></sds-loader>` : nothing} ${this.loading ? nothing : html`<slot name=\"before\"></slot>`}\n\t\t\t\t<slot></slot>\n\t\t\t\t${this.loading ? nothing : html`<slot name=\"after\"></slot>`}\n\t\t\t</button>\n\t\t`;\n\t}\n}\n"]}
|
|
@@ -1,49 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ButtonType = 'button' | 'submit' | 'reset';
|
|
4
|
-
type ButtonVariant = SDS_VARIANTS | 'critical';
|
|
5
|
-
type ButtonSize = 'large' | 'medium' | 'small' | Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
6
|
-
type TargetTypes = '_self' | '_blank' | '_parent' | '_top';
|
|
7
|
-
export interface SDSButtonProps {
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
form?: string;
|
|
10
|
-
href?: string;
|
|
11
|
-
icon?: boolean;
|
|
12
|
-
loading?: boolean;
|
|
13
|
-
name?: string;
|
|
14
|
-
size?: ButtonSize;
|
|
15
|
-
target?: TargetTypes;
|
|
16
|
-
type?: ButtonType;
|
|
17
|
-
value?: string;
|
|
18
|
-
variant?: ButtonVariant;
|
|
19
|
-
}
|
|
20
|
-
export declare class SDSButton extends LitElement {
|
|
21
|
-
static styles: import("lit").CSSResult[];
|
|
22
|
-
static formAssociated: boolean;
|
|
23
|
-
readonly internals: ElementInternals;
|
|
24
|
-
disabled: boolean;
|
|
25
|
-
icon: boolean;
|
|
26
|
-
loading: boolean;
|
|
27
|
-
form?: string;
|
|
28
|
-
href?: string;
|
|
29
|
-
name?: string;
|
|
30
|
-
size: ButtonSize;
|
|
31
|
-
target?: TargetTypes;
|
|
32
|
-
type: ButtonType;
|
|
33
|
-
value: string;
|
|
34
|
-
variant: ButtonVariant;
|
|
35
|
-
constructor();
|
|
36
|
-
updated(changed: PropertyValues): void;
|
|
37
|
-
private readonly _handleClick;
|
|
38
|
-
focus(): void;
|
|
39
|
-
blur(): void;
|
|
40
|
-
click(): void;
|
|
41
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
1
|
+
import { SDSButtonComponent } from './sds-button.component';
|
|
2
|
+
export declare class SDSButton extends SDSButtonComponent {
|
|
42
3
|
}
|
|
43
4
|
declare global {
|
|
44
5
|
interface HTMLElementTagNameMap {
|
|
45
6
|
'sds-button': SDSButton;
|
|
46
7
|
}
|
|
47
8
|
}
|
|
48
|
-
export {};
|
|
49
9
|
//# sourceMappingURL=sds-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-button.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sds-button.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,qBACa,SAAU,SAAQ,kBAAkB;CAAG;AAEpD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD"}
|
|
@@ -4,159 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
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;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { LitElement, html, nothing } from 'lit';
|
|
8
|
-
import { property } from 'lit/decorators.js';
|
|
9
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
7
|
import { guardedCustomElement } from '../utils/guarded-custom-element';
|
|
12
|
-
import {
|
|
13
|
-
let SDSButton = class SDSButton extends
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
this.disabled = false;
|
|
17
|
-
this.icon = false;
|
|
18
|
-
this.loading = false;
|
|
19
|
-
this.size = 'lg';
|
|
20
|
-
this.type = 'button';
|
|
21
|
-
this.value = '';
|
|
22
|
-
this.variant = 'primary';
|
|
23
|
-
this._handleClick = (event) => {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
event.stopImmediatePropagation();
|
|
26
|
-
if (!this.disabled) {
|
|
27
|
-
switch (this.type) {
|
|
28
|
-
case 'submit': {
|
|
29
|
-
const submitEvent = new CustomEvent('submit', {
|
|
30
|
-
bubbles: true,
|
|
31
|
-
composed: true,
|
|
32
|
-
cancelable: true,
|
|
33
|
-
});
|
|
34
|
-
const shouldSubmit = this.dispatchEvent(submitEvent);
|
|
35
|
-
if (shouldSubmit) {
|
|
36
|
-
if (this.form) {
|
|
37
|
-
const root = this.getRootNode();
|
|
38
|
-
const formElement = root.querySelector(`form#${this.form}`);
|
|
39
|
-
formElement?.requestSubmit();
|
|
40
|
-
}
|
|
41
|
-
else if (this.internals.form) {
|
|
42
|
-
this.internals.form.requestSubmit();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case 'reset': {
|
|
48
|
-
const resetEvent = new CustomEvent('reset', {
|
|
49
|
-
bubbles: true,
|
|
50
|
-
composed: true,
|
|
51
|
-
cancelable: true,
|
|
52
|
-
});
|
|
53
|
-
const shouldReset = this.dispatchEvent(resetEvent);
|
|
54
|
-
if (shouldReset) {
|
|
55
|
-
if (this.form) {
|
|
56
|
-
const root = this.getRootNode();
|
|
57
|
-
const formElement = root.querySelector(`form#${this.form}`);
|
|
58
|
-
formElement?.reset();
|
|
59
|
-
}
|
|
60
|
-
else if (this.internals.form) {
|
|
61
|
-
this.internals.form.reset();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
default:
|
|
67
|
-
this.dispatchEvent(new CustomEvent('click', {
|
|
68
|
-
bubbles: true,
|
|
69
|
-
composed: true,
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
this.internals = this.attachInternals();
|
|
75
|
-
this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
76
|
-
}
|
|
77
|
-
updated(changed) {
|
|
78
|
-
// Cast critical variant to danger palette to prevent breaking changes
|
|
79
|
-
if (changed.has('variant') && this.variant === 'critical') {
|
|
80
|
-
this.setAttribute('data-palette', 'danger');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
focus() {
|
|
84
|
-
if (!this.disabled)
|
|
85
|
-
this.shadowRoot?.querySelector('button')?.focus();
|
|
86
|
-
}
|
|
87
|
-
blur() {
|
|
88
|
-
if (!this.disabled)
|
|
89
|
-
this.shadowRoot?.querySelector('button')?.blur();
|
|
90
|
-
}
|
|
91
|
-
click() {
|
|
92
|
-
if (!this.disabled)
|
|
93
|
-
this.shadowRoot?.querySelector('button')?.click();
|
|
94
|
-
}
|
|
95
|
-
render() {
|
|
96
|
-
const buttonClasses = {
|
|
97
|
-
'sds-button': true,
|
|
98
|
-
'sds-button--as-link': !!this.href,
|
|
99
|
-
};
|
|
100
|
-
if (this.href) {
|
|
101
|
-
return html ` <a id="link" class="${classMap(buttonClasses)}" href="${this.href}" target="${ifDefined(this.target)}">
|
|
102
|
-
<slot name="before"></slot>
|
|
103
|
-
<slot></slot>
|
|
104
|
-
<slot name="after"></slot>
|
|
105
|
-
</a>`;
|
|
106
|
-
}
|
|
107
|
-
return html `
|
|
108
|
-
<button
|
|
109
|
-
id="control"
|
|
110
|
-
form="${ifDefined(this.form)}"
|
|
111
|
-
class="${classMap(buttonClasses)}"
|
|
112
|
-
type="${this.type}"
|
|
113
|
-
name="${ifDefined(this.name)}"
|
|
114
|
-
value="${ifDefined(this.value)}"
|
|
115
|
-
?disabled="${this.disabled}"
|
|
116
|
-
@click="${this._handleClick}"
|
|
117
|
-
>
|
|
118
|
-
${this.loading ? html `<sds-loader slot="before" ?contrast="${this.variant !== 'primary'}"></sds-loader>` : nothing} ${this.loading ? nothing : html `<slot name="before"></slot>`}
|
|
119
|
-
<slot></slot>
|
|
120
|
-
${this.loading ? nothing : html `<slot name="after"></slot>`}
|
|
121
|
-
</button>
|
|
122
|
-
`;
|
|
123
|
-
}
|
|
8
|
+
import { SDSButtonComponent } from './sds-button.component';
|
|
9
|
+
let SDSButton = class SDSButton extends SDSButtonComponent {
|
|
124
10
|
};
|
|
125
|
-
SDSButton.styles = [styles];
|
|
126
|
-
SDSButton.formAssociated = true;
|
|
127
|
-
__decorate([
|
|
128
|
-
property({ type: Boolean, reflect: true })
|
|
129
|
-
], SDSButton.prototype, "disabled", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
property({ type: Boolean, reflect: true })
|
|
132
|
-
], SDSButton.prototype, "icon", void 0);
|
|
133
|
-
__decorate([
|
|
134
|
-
property({ type: Boolean, reflect: true })
|
|
135
|
-
], SDSButton.prototype, "loading", void 0);
|
|
136
|
-
__decorate([
|
|
137
|
-
property({ type: String, reflect: true })
|
|
138
|
-
], SDSButton.prototype, "form", void 0);
|
|
139
|
-
__decorate([
|
|
140
|
-
property({ type: String, reflect: true })
|
|
141
|
-
], SDSButton.prototype, "href", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
property({ type: String, reflect: true })
|
|
144
|
-
], SDSButton.prototype, "name", void 0);
|
|
145
|
-
__decorate([
|
|
146
|
-
property({ type: String, reflect: true })
|
|
147
|
-
], SDSButton.prototype, "size", void 0);
|
|
148
|
-
__decorate([
|
|
149
|
-
property({ type: String, reflect: true })
|
|
150
|
-
], SDSButton.prototype, "target", void 0);
|
|
151
|
-
__decorate([
|
|
152
|
-
property({ type: String, reflect: true })
|
|
153
|
-
], SDSButton.prototype, "type", void 0);
|
|
154
|
-
__decorate([
|
|
155
|
-
property({ type: String, reflect: true })
|
|
156
|
-
], SDSButton.prototype, "value", void 0);
|
|
157
|
-
__decorate([
|
|
158
|
-
property({ type: String, reflect: true })
|
|
159
|
-
], SDSButton.prototype, "variant", void 0);
|
|
160
11
|
SDSButton = __decorate([
|
|
161
12
|
guardedCustomElement('sds-button')
|
|
162
13
|
], SDSButton);
|