@politiet/sheriff-web-components 2.1.3 → 2.2.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/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/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 +5 -4
- package/dist/sds-alert/sds-alert.styles.js.map +1 -1
- package/dist/sds-button/sds-button.component.d.ts +44 -0
- package/dist/sds-button/sds-button.component.d.ts.map +1 -0
- package/dist/sds-button/sds-button.component.js +159 -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-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-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/sheriff-web-components.js +118 -114
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SDSAlert } from './sds-alert/sds-alert';
|
|
2
|
-
export type { SDSAlertProps } from './sds-alert/sds-alert';
|
|
2
|
+
export type { SDSAlertProps } from './sds-alert/sds-alert.component';
|
|
3
3
|
export { SDSButton } from './sds-button/sds-button';
|
|
4
|
-
export type { SDSButtonProps } from './sds-button/sds-button';
|
|
4
|
+
export type { SDSButtonProps } from './sds-button/sds-button.component';
|
|
5
5
|
export { SDSCard } from './sds-card/sds-card';
|
|
6
6
|
export type { SDSCardProps } from './sds-card/sds-card';
|
|
7
7
|
export { SDSCheckbox } from './sds-checkbox/sds-checkbox';
|
|
@@ -13,9 +13,9 @@ export type { SDSChipProps } from './sds-chip/sds-chip';
|
|
|
13
13
|
export { SDSDetails } from './sds-details/sds-details';
|
|
14
14
|
export type { SDSDetailsProps as SDSDetailProps } from './sds-details/sds-details';
|
|
15
15
|
export { SDSHeading } from './sds-heading/sds-heading';
|
|
16
|
-
export type { SDSHeadingProps } from './sds-heading/sds-heading';
|
|
16
|
+
export type { SDSHeadingProps } from './sds-heading/sds-heading.component';
|
|
17
17
|
export { SDSIcon } from './sds-icon/sds-icon';
|
|
18
|
-
export type { SDSIconProps } from './sds-icon/sds-icon';
|
|
18
|
+
export type { SDSIconProps } from './sds-icon/sds-icon.component';
|
|
19
19
|
export { SDSLoader } from './sds-loader/sds-loader';
|
|
20
20
|
export type { SDSLoaderProps } from './sds-loader/sds-loader';
|
|
21
21
|
export { SDSNotification } from './sds-notification/sds-notification';
|
|
@@ -29,7 +29,7 @@ export type { SDSSwitchProps } from './sds-switch/sds-switch';
|
|
|
29
29
|
export { SDSTag } from './sds-tag/sds-tag';
|
|
30
30
|
export type { SDSTagProps } from './sds-tag/sds-tag';
|
|
31
31
|
export { SDSText } from './sds-text/sds-text';
|
|
32
|
-
export type { SDSTextProps } from './sds-text/sds-text';
|
|
32
|
+
export type { SDSTextProps } from './sds-text/sds-text.component';
|
|
33
33
|
export { SDSTextField } from './sds-textfield/sds-textfield';
|
|
34
34
|
export type { SDSTextFieldProps } from './sds-textfield/sds-textfield';
|
|
35
35
|
export { SDSTextArea } from './sds-textarea/sds-textarea';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAE,gBA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AAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { SDSAlert } from './sds-alert/sds-alert';\nexport type { SDSAlertProps } from './sds-alert/sds-alert';\n\nexport { SDSButton } from './sds-button/sds-button';\nexport type { SDSButtonProps } from './sds-button/sds-button';\n\nexport { SDSCard } from './sds-card/sds-card';\nexport type { SDSCardProps } from './sds-card/sds-card';\n\nexport { SDSCheckbox } from './sds-checkbox/sds-checkbox';\nexport type { SDSCheckboxProps } from './sds-checkbox/sds-checkbox';\n\nexport { SDSCheckboxGroup } from './sds-checkbox-group/sds-checkbox-group';\nexport type { SDSCheckboxGroupProps } from './sds-checkbox-group/sds-checkbox-group';\n\nexport { SDSChip } from './sds-chip/sds-chip';\nexport type { SDSChipProps } from './sds-chip/sds-chip';\n\nexport { SDSDetails } from './sds-details/sds-details';\nexport type { SDSDetailsProps as SDSDetailProps } from './sds-details/sds-details';\n\nexport { SDSHeading } from './sds-heading/sds-heading';\nexport type { SDSHeadingProps } from './sds-heading/sds-heading';\n\nexport { SDSIcon } from './sds-icon/sds-icon';\nexport type { SDSIconProps } from './sds-icon/sds-icon';\n\nexport { SDSLoader } from './sds-loader/sds-loader';\nexport type { SDSLoaderProps } from './sds-loader/sds-loader';\n\nexport { SDSNotification } from './sds-notification/sds-notification';\nexport type { SDSNotificationProps } from './sds-notification/sds-notification';\n\nexport { SDSRadio } from './sds-radio/sds-radio';\nexport type { SDSRadioProps } from './sds-radio/sds-radio';\n\nexport { SDSRadioGroup } from './sds-radio-group/sds-radio-group';\nexport type { SDSRadioGroupProps } from './sds-radio-group/sds-radio-group';\n\nexport { SDSSwitch } from './sds-switch/sds-switch';\nexport type { SDSSwitchProps } from './sds-switch/sds-switch';\n\nexport { SDSTag } from './sds-tag/sds-tag';\nexport type { SDSTagProps } from './sds-tag/sds-tag';\n\nexport { SDSText } from './sds-text/sds-text';\nexport type { SDSTextProps } from './sds-text/sds-text';\n\nexport { SDSTextField } from './sds-textfield/sds-textfield';\nexport type { SDSTextFieldProps } from './sds-textfield/sds-textfield';\n\nexport { SDSTextArea } from './sds-textarea/sds-textarea';\nexport type { SDSTextAreaProps } from './sds-textarea/sds-textarea';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { SDSAlert } from './sds-alert/sds-alert';\nexport type { SDSAlertProps } from './sds-alert/sds-alert.component';\n\nexport { SDSButton } from './sds-button/sds-button';\nexport type { SDSButtonProps } from './sds-button/sds-button.component';\n\nexport { SDSCard } from './sds-card/sds-card';\nexport type { SDSCardProps } from './sds-card/sds-card';\n\nexport { SDSCheckbox } from './sds-checkbox/sds-checkbox';\nexport type { SDSCheckboxProps } from './sds-checkbox/sds-checkbox';\n\nexport { SDSCheckboxGroup } from './sds-checkbox-group/sds-checkbox-group';\nexport type { SDSCheckboxGroupProps } from './sds-checkbox-group/sds-checkbox-group';\n\nexport { SDSChip } from './sds-chip/sds-chip';\nexport type { SDSChipProps } from './sds-chip/sds-chip';\n\nexport { SDSDetails } from './sds-details/sds-details';\nexport type { SDSDetailsProps as SDSDetailProps } from './sds-details/sds-details';\n\nexport { SDSHeading } from './sds-heading/sds-heading';\nexport type { SDSHeadingProps } from './sds-heading/sds-heading.component';\n\nexport { SDSIcon } from './sds-icon/sds-icon';\nexport type { SDSIconProps } from './sds-icon/sds-icon.component';\n\nexport { SDSLoader } from './sds-loader/sds-loader';\nexport type { SDSLoaderProps } from './sds-loader/sds-loader';\n\nexport { SDSNotification } from './sds-notification/sds-notification';\nexport type { SDSNotificationProps } from './sds-notification/sds-notification';\n\nexport { SDSRadio } from './sds-radio/sds-radio';\nexport type { SDSRadioProps } from './sds-radio/sds-radio';\n\nexport { SDSRadioGroup } from './sds-radio-group/sds-radio-group';\nexport type { SDSRadioGroupProps } from './sds-radio-group/sds-radio-group';\n\nexport { SDSSwitch } from './sds-switch/sds-switch';\nexport type { SDSSwitchProps } from './sds-switch/sds-switch';\n\nexport { SDSTag } from './sds-tag/sds-tag';\nexport type { SDSTagProps } from './sds-tag/sds-tag';\n\nexport { SDSText } from './sds-text/sds-text';\nexport type { SDSTextProps } from './sds-text/sds-text.component';\n\nexport { SDSTextField } from './sds-textfield/sds-textfield';\nexport type { SDSTextFieldProps } from './sds-textfield/sds-textfield';\n\nexport { SDSTextArea } from './sds-textarea/sds-textarea';\nexport type { SDSTextAreaProps } from './sds-textarea/sds-textarea';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { SDS_VARIANTS, SDS_SIZES } from '../types';
|
|
3
|
+
type ColorPalette = 'info' | 'success' | 'attention' | 'danger';
|
|
4
|
+
type Variants = Extract<SDS_VARIANTS, 'primary' | 'secondary'>;
|
|
5
|
+
type AlertSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
6
|
+
export interface SDSAlertProps {
|
|
7
|
+
variant?: Variants;
|
|
8
|
+
size?: AlertSize;
|
|
9
|
+
'removable-label'?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class SDSAlertComponent extends LitElement {
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
variant: Variants;
|
|
14
|
+
size: AlertSize;
|
|
15
|
+
removableLabel?: string;
|
|
16
|
+
palette: ColorPalette;
|
|
17
|
+
protected iconTag: import("lit-html/static").StaticValue;
|
|
18
|
+
protected buttonTag: import("lit-html/static").StaticValue;
|
|
19
|
+
private readonly _remove;
|
|
20
|
+
private readonly _renderIcon;
|
|
21
|
+
private readonly _renderRemoveButton;
|
|
22
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=sds-alert.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-alert.component.d.ts","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnD,KAAK,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAChE,KAAK,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;AAC/D,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AASxD,MAAM,WAAW,aAAa;IAC7B,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,OAAgB,MAAM,4BAAY;IAES,OAAO,EAAE,QAAQ,CAAa;IAC9B,IAAI,EAAE,SAAS,CAAQ;IACO,cAAc,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,YAAY,CAAU;IAErG,SAAS,CAAC,OAAO,wCAAqB;IACtC,SAAS,CAAC,SAAS,wCAAuB;IAE1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAOtB;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAE1B;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAWlC;IAEO,MAAM;CAaf"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { html as staticHtml, literal } from 'lit/static-html.js';
|
|
10
|
+
import { styles } from './sds-alert.styles';
|
|
11
|
+
const alertIcons = {
|
|
12
|
+
info: 'InformationSquareFill-aksel-filled',
|
|
13
|
+
success: 'check_circle-material-filled',
|
|
14
|
+
attention: 'warning-material-filled',
|
|
15
|
+
danger: 'dangerous-material-filled',
|
|
16
|
+
};
|
|
17
|
+
export class SDSAlertComponent extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.variant = 'primary';
|
|
21
|
+
this.size = 'md';
|
|
22
|
+
this.palette = 'info';
|
|
23
|
+
this.iconTag = literal `sds-icon`;
|
|
24
|
+
this.buttonTag = literal `sds-button`;
|
|
25
|
+
this._remove = () => {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('sds-remove', {
|
|
27
|
+
bubbles: true,
|
|
28
|
+
composed: true,
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
this._renderIcon = (iconName, size, cls) => {
|
|
32
|
+
return staticHtml `<${this.iconTag} ${cls ? `class=${cls}` : ''} name="${iconName}" size=${size}></${this.iconTag}>`;
|
|
33
|
+
};
|
|
34
|
+
this._renderRemoveButton = (ariaLabel) => {
|
|
35
|
+
return staticHtml `<${this.buttonTag}
|
|
36
|
+
class="sds-alert__remove-btn"
|
|
37
|
+
variant="tertiary"
|
|
38
|
+
size="sm"
|
|
39
|
+
?icon=${true}
|
|
40
|
+
aria-label=${ariaLabel}
|
|
41
|
+
@click=${this._remove}
|
|
42
|
+
>
|
|
43
|
+
${this._renderIcon('close-material-outlined', 'sm')}
|
|
44
|
+
</${this.buttonTag}>`;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const iconSize = this.variant === 'primary' ? 'md' : this.size ?? 'md';
|
|
49
|
+
const iconName = alertIcons[this.palette] ?? alertIcons['info'];
|
|
50
|
+
return html `<div class="sds-alert">
|
|
51
|
+
<div class="sds-alert__type">${this._renderIcon(iconName, iconSize, 'sds-alert__icon')}</div>
|
|
52
|
+
<div class="sds-alert__content">
|
|
53
|
+
<slot name="title"></slot>
|
|
54
|
+
<slot name="message"></slot>
|
|
55
|
+
</div>
|
|
56
|
+
${this.removableLabel && this.variant === 'primary' ? html `<div class="sds-alert__actions">${this._renderRemoveButton(this.removableLabel)}</div>` : nothing}
|
|
57
|
+
</div>`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
SDSAlertComponent.styles = [styles];
|
|
61
|
+
__decorate([
|
|
62
|
+
property({ type: String, reflect: true })
|
|
63
|
+
], SDSAlertComponent.prototype, "variant", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
property({ type: String, reflect: true })
|
|
66
|
+
], SDSAlertComponent.prototype, "size", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: String, attribute: 'removable-label', reflect: true })
|
|
69
|
+
], SDSAlertComponent.prototype, "removableLabel", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
property({ type: String, attribute: 'data-palette', reflect: true })
|
|
72
|
+
], SDSAlertComponent.prototype, "palette", void 0);
|
|
73
|
+
//# sourceMappingURL=sds-alert.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-alert.component.js","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,MAAM,UAAU,GAAiC;IAChD,IAAI,EAAE,oCAAoC;IAC1C,OAAO,EAAE,8BAA8B;IACvC,SAAS,EAAE,yBAAyB;IACpC,MAAM,EAAE,2BAA2B;CACnC,CAAC;AAQF,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAAjD;;QAG4C,YAAO,GAAa,SAAS,CAAC;QAC9B,SAAI,GAAc,IAAI,CAAC;QAEI,Y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K,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA,mCAAmC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;SACtJ,CAAC;IACT,CAAC;;AAhDe,wBAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAES;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAA+B;AAC9B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAwB;AACO;IAAxE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDAAyB;AAC3B;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAgC","sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { html as staticHtml, literal } from 'lit/static-html.js';\nimport { styles } from './sds-alert.styles';\nimport { SDS_VARIANTS, SDS_SIZES } from '../types';\n\ntype ColorPalette = 'info' | 'success' | 'attention' | 'danger';\ntype Variants = Extract<SDS_VARIANTS, 'primary' | 'secondary'>;\ntype AlertSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\n\nconst alertIcons: Record<ColorPalette, string> = {\n\tinfo: 'InformationSquareFill-aksel-filled',\n\tsuccess: 'check_circle-material-filled',\n\tattention: 'warning-material-filled',\n\tdanger: 'dangerous-material-filled',\n};\n\nexport interface SDSAlertProps {\n\tvariant?: Variants;\n\tsize?: AlertSize;\n\t'removable-label'?: string;\n}\n\nexport class SDSAlertComponent extends LitElement {\n\tstatic override styles = [styles];\n\n\t@property({ type: String, reflect: true }) variant: Variants = 'primary';\n\t@property({ type: String, reflect: true }) size: AlertSize = 'md';\n\t@property({ type: String, attribute: 'removable-label', reflect: true }) removableLabel?: string;\n\t@property({ type: String, attribute: 'data-palette', reflect: true }) palette: ColorPalette = 'info';\n\n\tprotected iconTag = literal`sds-icon`;\n\tprotected buttonTag = literal`sds-button`;\n\n\tprivate readonly _remove = () => {\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent('sds-remove', {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t})\n\t\t);\n\t};\n\n\tprivate readonly _renderIcon = (iconName: string, size: string, cls?: string) => {\n\t\treturn staticHtml`<${this.iconTag} ${cls ? `class=${cls}` : ''} name=\"${iconName}\" size=${size}></${this.iconTag}>`;\n\t};\n\n\tprivate readonly _renderRemoveButton = (ariaLabel: string) => {\n\t\treturn staticHtml`<${this.buttonTag}\n\t\tclass=\"sds-alert__remove-btn\"\n\t\tvariant=\"tertiary\"\n\t\tsize=\"sm\"\n\t\t?icon=${true}\n\t\taria-label=${ariaLabel}\n\t\t@click=${this._remove}\n\t\t>\n\t\t${this._renderIcon('close-material-outlined', 'sm')}\n\t\t</${this.buttonTag}>`;\n\t};\n\n\toverride render() {\n\t\tconst iconSize = this.variant === 'primary' ? 'md' : this.size ?? 'md';\n\t\tconst iconName = alertIcons[this.palette] ?? alertIcons['info'];\n\n\t\treturn html`<div class=\"sds-alert\">\n\t\t\t<div class=\"sds-alert__type\">${this._renderIcon(iconName, iconSize, 'sds-alert__icon')}</div>\n\t\t\t<div class=\"sds-alert__content\">\n\t\t\t\t<slot name=\"title\"></slot>\n\t\t\t\t<slot name=\"message\"></slot>\n\t\t\t</div>\n\t\t\t${this.removableLabel && this.variant === 'primary' ? html`<div class=\"sds-alert__actions\">${this._renderRemoveButton(this.removableLabel)}</div>` : nothing}\n\t\t</div>`;\n\t}\n}\n"]}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SheriffEvent } from '../types';
|
|
2
|
+
import { SDSAlertComponent } from './sds-alert.component';
|
|
3
3
|
import '../sds-icon/sds-icon';
|
|
4
4
|
import '../sds-button/sds-button';
|
|
5
|
-
|
|
6
|
-
type Variants = Extract<SDS_VARIANTS, 'primary' | 'secondary'>;
|
|
7
|
-
type AlertSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
8
|
-
export interface SDSAlertProps {
|
|
9
|
-
variant?: Variants;
|
|
10
|
-
size?: AlertSize;
|
|
11
|
-
'removable-label'?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class SDSAlert extends LitElement {
|
|
14
|
-
static styles: import("lit").CSSResult[];
|
|
15
|
-
variant: Variants;
|
|
16
|
-
size: AlertSize;
|
|
17
|
-
removableLabel?: string;
|
|
18
|
-
palette: ColorPalette;
|
|
19
|
-
private readonly _remove;
|
|
20
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
5
|
+
export declare class SDSAlert extends SDSAlertComponent {
|
|
21
6
|
}
|
|
22
7
|
declare global {
|
|
23
8
|
interface HTMLElementTagNameMap {
|
|
@@ -27,5 +12,4 @@ declare global {
|
|
|
27
12
|
'sds-remove': SheriffEvent;
|
|
28
13
|
}
|
|
29
14
|
}
|
|
30
|
-
export {};
|
|
31
15
|
//# sourceMappingURL=sds-alert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-alert.d.ts","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sds-alert.d.ts","sourceRoot":"","sources":["../../src/sds-alert/sds-alert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAElC,qBACa,QAAS,SAAQ,iBAAiB;CAAG;AAElD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,QAAQ,CAAC;KACtB;IACD,UAAU,2BAA2B;QACpC,YAAY,EAAE,YAAY,CAAC;KAC3B;CACD"}
|
|
@@ -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,yBA+KlB,CAAC"}
|
|
@@ -96,8 +96,9 @@ 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
|
+
--_sds-alert-border-width: var(--sds-alert-border-width, 0);
|
|
99
100
|
|
|
100
|
-
--_sds-alert-padding: var(--sds-alert-padding,
|
|
101
|
+
--_sds-alert-padding: var(--sds-alert-padding, 0);
|
|
101
102
|
--_sds-alert-column-gap: var(--sds-alert-column-gap, var(--sds-spacing-3xs));
|
|
102
103
|
--_sds-alert-content-gap: var(--sds-alert-content-gap, var(--sds-spacing-4xs));
|
|
103
104
|
|
|
@@ -114,7 +115,7 @@ export const styles = css `
|
|
|
114
115
|
width: 16px;
|
|
115
116
|
height: 16px;
|
|
116
117
|
background-color: var(--_sds-alert-icon-color-background);
|
|
117
|
-
z-index:
|
|
118
|
+
z-index: -1;
|
|
118
119
|
clip-path: circle(50%);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
@@ -123,8 +124,8 @@ export const styles = css `
|
|
|
123
124
|
--sds-icon-color: var(--sds-alert-icon-color, var(--sds-color-action-default));
|
|
124
125
|
|
|
125
126
|
&::after {
|
|
126
|
-
top:
|
|
127
|
-
left:
|
|
127
|
+
top: 5px;
|
|
128
|
+
left: 3px;
|
|
128
129
|
width: 20px;
|
|
129
130
|
height: 16px;
|
|
130
131
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+KxB,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\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: 8px;\n\t\t\tleft: 9px;\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\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: 5px;\n\t\t\tleft: 3px;\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,44 @@
|
|
|
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
|
+
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>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# 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,GAAG,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AACxF,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,qBAAa,kBAAmB,SAAQ,UAAU;IACjD,OAAgB,MAAM,4BAAY;IAElC,MAAM,CAAC,cAAc,UAAQ;IAC7B,SAAgB,SAAS,EAAE,gBAAgB,CAAC;IAEA,QAAQ,EAAE,OAAO,CAAS;IAC1B,IAAI,EAAE,OAAO,CAAS;IACtB,OAAO,EAAE,OAAO,CAAS;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAQ;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,UAAU,CAAY;IAC5B,KAAK,EAAE,MAAM,CAAM;IACnB,OAAO,EAAE,aAAa,CAAa;;IAQrE,OAAO,CAAC,OAAO,EAAE,cAAc;IAOxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAuD3B;IAEO,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAIb,MAAM;CA+Bf"}
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
75
|
+
}
|
|
76
|
+
updated(changed) {
|
|
77
|
+
// Cast critical variant to danger palette to prevent breaking changes
|
|
78
|
+
if (changed.has('variant') && this.variant === 'critical') {
|
|
79
|
+
this.setAttribute('data-palette', 'danger');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
focus() {
|
|
83
|
+
if (!this.disabled)
|
|
84
|
+
this.shadowRoot?.querySelector('button')?.focus();
|
|
85
|
+
}
|
|
86
|
+
blur() {
|
|
87
|
+
if (!this.disabled)
|
|
88
|
+
this.shadowRoot?.querySelector('button')?.blur();
|
|
89
|
+
}
|
|
90
|
+
click() {
|
|
91
|
+
if (!this.disabled)
|
|
92
|
+
this.shadowRoot?.querySelector('button')?.click();
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
const buttonClasses = {
|
|
96
|
+
'sds-button': true,
|
|
97
|
+
'sds-button--as-link': !!this.href,
|
|
98
|
+
};
|
|
99
|
+
if (this.href) {
|
|
100
|
+
return html ` <a id="link" class="${classMap(buttonClasses)}" href="${this.href}" target="${ifDefined(this.target)}">
|
|
101
|
+
<slot name="before"></slot>
|
|
102
|
+
<slot></slot>
|
|
103
|
+
<slot name="after"></slot>
|
|
104
|
+
</a>`;
|
|
105
|
+
}
|
|
106
|
+
return html `
|
|
107
|
+
<button
|
|
108
|
+
id="control"
|
|
109
|
+
form="${ifDefined(this.form)}"
|
|
110
|
+
class="${classMap(buttonClasses)}"
|
|
111
|
+
type="${this.type}"
|
|
112
|
+
name="${ifDefined(this.name)}"
|
|
113
|
+
value="${ifDefined(this.value)}"
|
|
114
|
+
?disabled="${this.disabled}"
|
|
115
|
+
@click="${this._handleClick}"
|
|
116
|
+
>
|
|
117
|
+
${this.loading ? html `<sds-loader slot="before" ?contrast="${this.variant !== 'primary'}"></sds-loader>` : nothing} ${this.loading ? nothing : html `<slot name="before"></slot>`}
|
|
118
|
+
<slot></slot>
|
|
119
|
+
${this.loading ? nothing : html `<slot name="after"></slot>`}
|
|
120
|
+
</button>
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
SDSButtonComponent.styles = [styles];
|
|
125
|
+
SDSButtonComponent.formAssociated = true;
|
|
126
|
+
__decorate([
|
|
127
|
+
property({ type: Boolean, reflect: true })
|
|
128
|
+
], SDSButtonComponent.prototype, "disabled", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
property({ type: Boolean, reflect: true })
|
|
131
|
+
], SDSButtonComponent.prototype, "icon", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
property({ type: Boolean, reflect: true })
|
|
134
|
+
], SDSButtonComponent.prototype, "loading", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: String, reflect: true })
|
|
137
|
+
], SDSButtonComponent.prototype, "form", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
property({ type: String, reflect: true })
|
|
140
|
+
], SDSButtonComponent.prototype, "href", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ type: String, reflect: true })
|
|
143
|
+
], SDSButtonComponent.prototype, "name", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property({ type: String, reflect: true })
|
|
146
|
+
], SDSButtonComponent.prototype, "size", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ type: String, reflect: true })
|
|
149
|
+
], SDSButtonComponent.prototype, "target", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: String, reflect: true })
|
|
152
|
+
], SDSButtonComponent.prototype, "type", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: String, reflect: true })
|
|
155
|
+
], SDSButtonComponent.prototype, "value", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: String, reflect: true })
|
|
158
|
+
], SDSButtonComponent.prototype, "variant", void 0);
|
|
159
|
+
//# 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,MAAM,qBAAqB,CAAC;AAqB7C,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAkBjD;QACC,KAAK,EAAE,CAAC;QAbmC,aAAQ,GAAY,KAAK,CAAC;QAC1B,SAAI,GAAY,KAAK,CAAC;QACtB,YAAO,GAAY,KAAK,CAAC;QAI1B,SAAI,GAAe,IAAI,CAAC;QAExB,SAAI,GAAe,QAAQ,CAAC;QAC5B,UAAK,GAAW,EAAE,CAAC;QACnB,YAAO,GAAkB,SAAS,CAAC;QAe7D,iBAAY,GAAG,CAAC,KAAiB,EAAE,EAAE;YACrD,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,wBAAwB,EAAE,CAAC;YAEjC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACpB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;oBACnB,KAAK,QAAQ,CAAC,CAAC,CAAC;wBACf,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE;4BAC7C,OAAO,EAAE,IAAI;4BACb,QAAQ,EAAE,IAAI;4BACd,UAAU,EAAE,IAAI;yBAChB,CAAC,CAAC;wBACH,MAAM,YAAY,GAAG,IAAI,C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EAAE,IAAI,EAAE,CAAC;gDAAe;AACd;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAyB;AACxB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAsB;AACrB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAA6B;AAC5B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAoB;AACnB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,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\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\tthis.attachShadow({ mode: 'open', delegatesFocus: true });\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"]}
|