@politiet/sheriff-web-components 1.1.0 → 1.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.
@@ -2,6 +2,7 @@ import { LitElement } from 'lit';
2
2
  type ButtonType = 'button' | 'submit' | 'reset';
3
3
  type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'critical';
4
4
  type ButtonSize = 'large' | 'medium' | 'small';
5
+ type TargetTypes = '_self' | '_blank' | '_parent' | '_top';
5
6
  export interface SDSButtonProps {
6
7
  type?: ButtonType;
7
8
  variant?: ButtonVariant;
@@ -10,6 +11,8 @@ export interface SDSButtonProps {
10
11
  name?: string;
11
12
  value?: string;
12
13
  form?: string;
14
+ href?: string;
15
+ target?: TargetTypes;
13
16
  onClick?: (event: CustomEvent) => void;
14
17
  onSubmit?: (event: CustomEvent) => void;
15
18
  onReset?: (event: CustomEvent) => void;
@@ -25,6 +28,8 @@ export declare class SDSButton extends LitElement {
25
28
  name?: string;
26
29
  value: string;
27
30
  form?: string;
31
+ href?: string;
32
+ target?: TargetTypes;
28
33
  constructor();
29
34
  private readonly _handleClick;
30
35
  focus(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"sds-button.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAOvC,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAChD,KAAK,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AACvE,KAAK,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC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,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD"}
@@ -92,7 +92,20 @@ let SDSButton = class SDSButton extends LitElement {
92
92
  'sds-button--critical': this.variant === 'critical',
93
93
  'sds-button--medium': this.size === 'medium',
94
94
  'sds-button--small': this.size === 'small',
95
+ 'sds-button--as-link': !!this.href,
95
96
  };
97
+ if (this.href) {
98
+ return html ` <a
99
+ id="link"
100
+ class="${classMap(buttonClasses)}"
101
+ href="${this.href}"
102
+ target="${ifDefined(this.target)}"
103
+ >
104
+ <slot name="before"></slot>
105
+ <slot></slot>
106
+ <slot name="after"></slot>
107
+ </a>`;
108
+ }
96
109
  return html `
97
110
  <button
98
111
  id="control"
@@ -134,6 +147,12 @@ __decorate([
134
147
  __decorate([
135
148
  property({ type: String, reflect: true })
136
149
  ], SDSButton.prototype, "form", void 0);
150
+ __decorate([
151
+ property({ type: String, reflect: true })
152
+ ], SDSButton.prototype, "href", void 0);
153
+ __decorate([
154
+ property({ type: String, reflect: true })
155
+ ], SDSButton.prototype, "target", void 0);
137
156
  SDSButton = __decorate([
138
157
  guardedCustomElement('sds-button')
139
158
  ], SDSButton);
@@ -1 +1 @@
1
- {"version":3,"file":"sds-button.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAoBtC,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IAoBxC;QACC,KAAK,EAAE,CAAC;QAdT,SAAI,GAAe,QAA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;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAoB;AACnB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AAlB7C,SAAS;IADrB,oBAAoB,CAAC,YAAY,CAAC;GACtB,SAAS,CA0HrB","sourcesContent":["import { LitElement, html } 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 { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { styles } from './sds-button.styles';\n\ntype ButtonType = 'button' | 'submit' | 'reset';\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'critical';\ntype ButtonSize = 'large' | 'medium' | 'small';\n\nexport interface SDSButtonProps {\n\ttype?: ButtonType;\n\tvariant?: ButtonVariant;\n\tsize?: ButtonSize;\n\tdisabled?: boolean;\n\tname?: string;\n\tvalue?: string;\n\tform?: string;\n\tonClick?: (event: CustomEvent) => void;\n\tonSubmit?: (event: CustomEvent) => void;\n\tonReset?: (event: CustomEvent) => void;\n}\n\n@guardedCustomElement('sds-button')\nexport class SDSButton extends LitElement {\n\tstatic override styles = [styles];\n\n\tstatic formAssociated = true;\n\tpublic readonly internals: ElementInternals;\n\n\t@property({ type: String, reflect: true })\n\ttype: ButtonType = 'button';\n\n\t@property({ type: String, reflect: true })\n\tvariant: ButtonVariant = 'primary';\n\n\t@property({ type: String, reflect: true })\n\tsize: ButtonSize = 'large';\n\n\t@property({ type: Boolean, reflect: true }) disabled: boolean = false;\n\t@property({ type: String, reflect: true }) name?: string;\n\t@property({ type: String, reflect: true }) value: string = '';\n\t@property({ type: String, reflect: true }) form?: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t\tthis.attachShadow({ mode: 'open', delegatesFocus: true });\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--secondary': this.variant === 'secondary',\n\t\t\t'sds-button--tertiary': this.variant === 'tertiary',\n\t\t\t'sds-button--critical': this.variant === 'critical',\n\t\t\t'sds-button--medium': this.size === 'medium',\n\t\t\t'sds-button--small': this.size === 'small',\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<slot name=\"before\"></slot>\n\t\t\t\t<slot></slot>\n\t\t\t\t<slot name=\"after\"></slot>\n\t\t\t</button>\n\t\t`;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-button': SDSButton;\n\t}\n}\n"]}
1
+ {"version":3,"file":"sds-button.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,M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AX,CAAY;AAE3B,wBAAc,GAAG,IAAI,AAAP,CAAQ;AAI7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCACd;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACP;AAGnC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCACf;AAEiB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAA2B;AAC3B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AACd;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAoB;AACnB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AACd;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AACd;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAsB;AApBpD,SAAS;IADrB,oBAAoB,CAAC,YAAY,CAAC;GACtB,SAAS,CA0IrB","sourcesContent":["import { LitElement, html } 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 { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { styles } from './sds-button.styles';\n\ntype ButtonType = 'button' | 'submit' | 'reset';\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'critical';\ntype ButtonSize = 'large' | 'medium' | 'small';\ntype TargetTypes = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface SDSButtonProps {\n\ttype?: ButtonType;\n\tvariant?: ButtonVariant;\n\tsize?: ButtonSize;\n\tdisabled?: boolean;\n\tname?: string;\n\tvalue?: string;\n\tform?: string;\n\thref?: string;\n\ttarget?: TargetTypes;\n\tonClick?: (event: CustomEvent) => void;\n\tonSubmit?: (event: CustomEvent) => void;\n\tonReset?: (event: CustomEvent) => void;\n}\n\n@guardedCustomElement('sds-button')\nexport class SDSButton extends LitElement {\n\tstatic override styles = [styles];\n\n\tstatic formAssociated = true;\n\tpublic readonly internals: ElementInternals;\n\n\t@property({ type: String, reflect: true })\n\ttype: ButtonType = 'button';\n\n\t@property({ type: String, reflect: true })\n\tvariant: ButtonVariant = 'primary';\n\n\t@property({ type: String, reflect: true })\n\tsize: ButtonSize = 'large';\n\n\t@property({ type: Boolean, reflect: true }) disabled: boolean = false;\n\t@property({ type: String, reflect: true }) name?: string;\n\t@property({ type: String, reflect: true }) value: string = '';\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 }) target?: TargetTypes;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t\tthis.attachShadow({ mode: 'open', delegatesFocus: true });\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--secondary': this.variant === 'secondary',\n\t\t\t'sds-button--tertiary': this.variant === 'tertiary',\n\t\t\t'sds-button--critical': this.variant === 'critical',\n\t\t\t'sds-button--medium': this.size === 'medium',\n\t\t\t'sds-button--small': this.size === 'small',\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\n\t\t\t\tid=\"link\"\n\t\t\t\tclass=\"${classMap(buttonClasses)}\"\n\t\t\t\thref=\"${this.href}\"\n\t\t\t\ttarget=\"${ifDefined(this.target)}\"\n\t\t\t>\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<slot name=\"before\"></slot>\n\t\t\t\t<slot></slot>\n\t\t\t\t<slot name=\"after\"></slot>\n\t\t\t</button>\n\t\t`;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-button': SDSButton;\n\t}\n}\n"]}
@@ -17,6 +17,11 @@ const primaryButtonIds = [
17
17
  'button-primary-medium-icon-only',
18
18
  'button-primary-small-icon-only',
19
19
  'button-primary-disabled-icon-only',
20
+ 'button-as-link-primary-large',
21
+ 'button-as-link-primary-medium',
22
+ 'button-as-link-primary-small',
23
+ 'button-as-link-icon-before',
24
+ 'button-as-link-icon-after',
20
25
  ];
21
26
  const secondaryButtonIds = [
22
27
  // Secondary
@@ -36,6 +41,9 @@ const secondaryButtonIds = [
36
41
  'button-secondary-medium-icon-only',
37
42
  'button-secondary-small-icon-only',
38
43
  'button-secondary-disabled-icon-only',
44
+ 'button-as-link-secondary-large',
45
+ 'button-as-link-secondary-medium',
46
+ 'button-as-link-secondary-small',
39
47
  ];
40
48
  const tertiaryButtonIds = [
41
49
  // Tertiary
@@ -55,6 +63,9 @@ const tertiaryButtonIds = [
55
63
  'button-tertiary-medium-icon-only',
56
64
  'button-tertiary-small-icon-only',
57
65
  'button-tertiary-disabled-icon-only',
66
+ 'button-as-link-tertiary-large',
67
+ 'button-as-link-tertiary-medium',
68
+ 'button-as-link-tertiary-small',
58
69
  ];
59
70
  const criticalButtonIds = [
60
71
  // Critical
@@ -74,6 +85,9 @@ const criticalButtonIds = [
74
85
  'button-critical-medium-icon-only',
75
86
  'button-critical-small-icon-only',
76
87
  'button-critical-disabled-icon-only',
88
+ 'button-as-link-critical-large',
89
+ 'button-as-link-critical-medium',
90
+ 'button-as-link-critical-small',
77
91
  ];
78
92
  test.describe('button-component', () => {
79
93
  test.beforeEach(async ({ page }) => {
@@ -127,5 +141,27 @@ test.describe('button-component', () => {
127
141
  const value = await page.locator('#first-name').getAttribute('value');
128
142
  expect(value).toBeNull();
129
143
  });
144
+ test('button-as-link', async ({ page }) => {
145
+ const buttonAsLink = page.locator('#button-as-link-target-blank');
146
+ await expect(buttonAsLink).toHaveAttribute('href', 'https://www.politiet.no');
147
+ const shadowButtonAsLinkHref = await buttonAsLink.evaluate((el) => {
148
+ const shadowRoot = el.shadowRoot;
149
+ if (shadowRoot) {
150
+ const anchorElement = shadowRoot.querySelector('a');
151
+ return anchorElement?.getAttribute('href');
152
+ }
153
+ return null;
154
+ });
155
+ await expect(shadowButtonAsLinkHref).toBe('https://www.politiet.no');
156
+ const shadowButtonAsLinkTarget = await buttonAsLink.evaluate((el) => {
157
+ const shadowRoot = el.shadowRoot;
158
+ if (shadowRoot) {
159
+ const anchorElement = shadowRoot.querySelector('a');
160
+ return anchorElement?.getAttribute('target');
161
+ }
162
+ return null;
163
+ });
164
+ await expect(shadowButtonAsLinkTarget).toBe('_blank');
165
+ });
130
166
  });
131
167
  //# sourceMappingURL=sds-button.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sds-button.spec.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,gBAAgB,GAAG;IACxB,UAAU;IACV,sBAAsB;IACtB,uBAAuB;IACvB,sBAAsB;IACtB,yBAAyB;IACzB,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;IACrC,iCAAiC;IACjC,kCAAkC;IAClC,iCAAiC;IACjC,oCAAoC;IACpC,gCAAgC;IAChC,iCAAiC;IACjC,gCAAgC;IAChC,mCAAmC;CACnC,CAAC;AACF,MAAM,kBAAkB,GAAG;IAC1B,YAAY;IACZ,wBAAwB;IACxB,yBAAyB;IACzB,wBAAwB;IACxB,2BAA2B;IAC3B,oCAAoC;IACpC,qCAAqC;IACrC,oCAAoC;IACpC,uCAAuC;IACvC,mCAAmC;IACnC,oCAAoC;IACpC,mCAAmC;IACnC,sCAAsC;IACtC,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;CACrC,CAAC;AACF,MAAM,iBAAiB,GAAG;IACzB,WAAW;IACX,uBAAuB;IACvB,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,mCAAmC;IACnC,oCAAoC;IACpC,mCAAmC;IACnC,sCAAsC;IACtC,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;IACrC,iCAAiC;IACjC,kCAAkC;IAClC,iCAAiC;IACjC,oCAAoC;CACpC,CAAC;AACF,MAAM,iBAAiB,GAAG;IACzB,WAAW;IACX,uBAAuB;IACvB,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,mCAAmC;IACnC,oCAAoC;IACpC,mCAAmC;IACnC,sCAAsC;IAC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U,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACrC,CAAC;QACF,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACrC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from '@playwright/test';\n\nconst primaryButtonIds = [\n\t// Primary\n\t'button-primary-large',\n\t'button-primary-medium',\n\t'button-primary-small',\n\t'button-primary-disabled',\n\t'button-primary-large-icon-before',\n\t'button-primary-medium-icon-before',\n\t'button-primary-small-icon-before',\n\t'button-primary-disabled-icon-before',\n\t'button-primary-large-icon-after',\n\t'button-primary-medium-icon-after',\n\t'button-primary-small-icon-after',\n\t'button-primary-disabled-icon-after',\n\t'button-primary-large-icon-only',\n\t'button-primary-medium-icon-only',\n\t'button-primary-small-icon-only',\n\t'button-primary-disabled-icon-only',\n];\nconst secondaryButtonIds = [\n\t// Secondary\n\t'button-secondary-large',\n\t'button-secondary-medium',\n\t'button-secondary-small',\n\t'button-secondary-disabled',\n\t'button-secondary-large-icon-before',\n\t'button-secondary-medium-icon-before',\n\t'button-secondary-small-icon-before',\n\t'button-secondary-disabled-icon-before',\n\t'button-secondary-large-icon-after',\n\t'button-secondary-medium-icon-after',\n\t'button-secondary-small-icon-after',\n\t'button-secondary-disabled-icon-after',\n\t'button-secondary-large-icon-only',\n\t'button-secondary-medium-icon-only',\n\t'button-secondary-small-icon-only',\n\t'button-secondary-disabled-icon-only',\n];\nconst tertiaryButtonIds = [\n\t// Tertiary\n\t'button-tertiary-large',\n\t'button-tertiary-medium',\n\t'button-tertiary-small',\n\t'button-tertiary-disabled',\n\t'button-tertiary-large-icon-before',\n\t'button-tertiary-medium-icon-before',\n\t'button-tertiary-small-icon-before',\n\t'button-tertiary-disabled-icon-before',\n\t'button-tertiary-large-icon-after',\n\t'button-tertiary-medium-icon-after',\n\t'button-tertiary-small-icon-after',\n\t'button-tertiary-disabled-icon-after',\n\t'button-tertiary-large-icon-only',\n\t'button-tertiary-medium-icon-only',\n\t'button-tertiary-small-icon-only',\n\t'button-tertiary-disabled-icon-only',\n];\nconst criticalButtonIds = [\n\t// Critical\n\t'button-critical-large',\n\t'button-critical-medium',\n\t'button-critical-small',\n\t'button-critical-disabled',\n\t'button-critical-large-icon-before',\n\t'button-critical-medium-icon-before',\n\t'button-critical-small-icon-before',\n\t'button-critical-disabled-icon-before',\n\t'button-critical-large-icon-after',\n\t'button-critical-medium-icon-after',\n\t'button-critical-small-icon-after',\n\t'button-critical-disabled-icon-after',\n\t'button-critical-large-icon-only',\n\t'button-critical-medium-icon-only',\n\t'button-critical-small-icon-only',\n\t'button-critical-disabled-icon-only',\n];\n\ntest.describe('button-component', () => {\n\ttest.beforeEach(async ({ page }) => {\n\t\tawait page.goto('iframe.html?viewMode=docs&id=test-button--docs');\n\t});\n\n\ttest('visibility', async ({ page }) => {\n\t\tconst buttonIds = [...primaryButtonIds, ...secondaryButtonIds, ...tertiaryButtonIds, ...criticalButtonIds];\n\n\t\tfor (const id of buttonIds) {\n\t\t\tawait expect(page.locator(`#${id}`)).toBeVisible();\n\t\t}\n\t});\n\n\ttest('design-implementation', async ({ page }) => {\n\t\tconst buttonIds = [...primaryButtonIds, ...secondaryButtonIds, ...tertiaryButtonIds, ...criticalButtonIds];\n\t\tawait page.reload();\n\n\t\tfor (const id of buttonIds) {\n\t\t\t// Default state\n\t\t\tawait expect(page.locator(`#${id}`)).toHaveScreenshot(`${id}.png`);\n\t\t\t// Hover state\n\t\t\tpage.locator(`#${id}`).hover();\n\t\t\tawait expect(page.locator(`#${id}`)).toHaveScreenshot(`${id}-hover.png`);\n\t\t\t// Focus state\n\t\t\tawait page.evaluate((id) => {\n\t\t\t\tconst element = document.getElementById(id);\n\t\t\t\tif (element) {\n\t\t\t\t\tconst parentDiv = document.createElement('div');\n\t\t\t\t\tparentDiv.style.padding = '10px';\n\t\t\t\t\tparentDiv.style.backgroundColor = 'white';\n\t\t\t\t\telement.parentNode?.insertBefore(parentDiv, element);\n\t\t\t\t\tparentDiv.appendChild(element);\n\t\t\t\t}\n\t\t\t}, id);\n\t\t\tpage.locator(`#${id}`).focus();\n\t\t\tconst parentDiv = await page.locator(`#${id}`).locator('xpath=..');\n\t\t\tawait expect(parentDiv).toHaveScreenshot(`${id}-focus.png`);\n\t\t}\n\t});\n\n\ttest('form-submission', async ({ page }) => {\n\t\tlet requestUrl: URL | undefined;\n\t\tpage.on('request', (request) => {\n\t\t\tif (request.url().includes('iframe.html?first-name=John')) {\n\t\t\t\trequestUrl = new URL(request.url());\n\t\t\t}\n\t\t});\n\n\t\tawait page.locator('#first-name').pressSequentially('John');\n\t\tawait page.locator('#submit-button').click();\n\t\tawait expect(requestUrl?.searchParams.get('first-name')).toBe('John');\n\t});\n\n\ttest('form-reset', async ({ page }) => {\n\t\tawait page.locator('#first-name').pressSequentially('John');\n\t\tawait page.locator('#reset-button').click();\n\t\tconst value = await page.locator('#first-name').getAttribute('value');\n\t\texpect(value).toBeNull();\n\t});\n});\n"]}
1
+ {"version":3,"file":"sds-button.spec.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,gBAAgB,GAAG;IACxB,UAAU;IACV,sBAAsB;IACtB,uBAAuB;IACvB,sBAAsB;IACtB,yBAAyB;IACzB,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;IACrC,iCAAiC;IACjC,kCAAkC;IAClC,iCAAiC;IACjC,oCAAoC;IACpC,gCAAgC;IAChC,iCAAiC;IACjC,gCAAgC;IAChC,mCAAmC;IACnC,8BAA8B;IAC9B,+BAA+B;IAC/B,8BAA8B;IAC9B,4BAA4B;IAC5B,2BAA2B;CAC3B,CAAC;AACF,MAAM,kBAAkB,GAAG;IAC1B,YAAY;IACZ,wBAAwB;IACxB,yBAAyB;IACzB,wBAAwB;IACxB,2BAA2B;IAC3B,oCAAoC;IACpC,qCAAqC;IACrC,oCAAoC;IACpC,uCAAuC;IACvC,mCAAmC;IACnC,oCAAoC;IACpC,mCAAmC;IACnC,sCAAsC;IACtC,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;IACrC,gCAAgC;IAChC,iCAAiC;IACjC,gCAAgC;CAChC,CAAC;AACF,MAAM,iBAAiB,GAAG;IACzB,WAAW;IACX,uBAAuB;IACvB,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,mCAAmC;IACnC,oCAAoC;IACpC,mCAAmC;IACnC,sCAAsC;IACtC,kCAAkC;IAClC,mCAAmC;IACnC,kCAAkC;IAClC,qCAAqC;IACrC,iCAAiC;IACjC,kCAAkC;IAClC,iCAAiC;IACjC,oCAAoC;IACpC,+BAA+B;IAC/B,gCAAgC;IAChC,+BAA+B;CAC/B,CAAC;AACF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AAC,CAAC;QAE9E,MAAM,sBAAsB,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE;YACjE,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;YACjC,IAAI,UAAU,EAAE,CAAC;gBAChB,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;gBACpD,OAAO,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAErE,MAAM,wBAAwB,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE;YACnE,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;YACjC,IAAI,UAAU,EAAE,CAAC;gBAChB,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;gBACpD,OAAO,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC9C,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from '@playwright/test';\n\nconst primaryButtonIds = [\n\t// Primary\n\t'button-primary-large',\n\t'button-primary-medium',\n\t'button-primary-small',\n\t'button-primary-disabled',\n\t'button-primary-large-icon-before',\n\t'button-primary-medium-icon-before',\n\t'button-primary-small-icon-before',\n\t'button-primary-disabled-icon-before',\n\t'button-primary-large-icon-after',\n\t'button-primary-medium-icon-after',\n\t'button-primary-small-icon-after',\n\t'button-primary-disabled-icon-after',\n\t'button-primary-large-icon-only',\n\t'button-primary-medium-icon-only',\n\t'button-primary-small-icon-only',\n\t'button-primary-disabled-icon-only',\n\t'button-as-link-primary-large',\n\t'button-as-link-primary-medium',\n\t'button-as-link-primary-small',\n\t'button-as-link-icon-before',\n\t'button-as-link-icon-after',\n];\nconst secondaryButtonIds = [\n\t// Secondary\n\t'button-secondary-large',\n\t'button-secondary-medium',\n\t'button-secondary-small',\n\t'button-secondary-disabled',\n\t'button-secondary-large-icon-before',\n\t'button-secondary-medium-icon-before',\n\t'button-secondary-small-icon-before',\n\t'button-secondary-disabled-icon-before',\n\t'button-secondary-large-icon-after',\n\t'button-secondary-medium-icon-after',\n\t'button-secondary-small-icon-after',\n\t'button-secondary-disabled-icon-after',\n\t'button-secondary-large-icon-only',\n\t'button-secondary-medium-icon-only',\n\t'button-secondary-small-icon-only',\n\t'button-secondary-disabled-icon-only',\n\t'button-as-link-secondary-large',\n\t'button-as-link-secondary-medium',\n\t'button-as-link-secondary-small',\n];\nconst tertiaryButtonIds = [\n\t// Tertiary\n\t'button-tertiary-large',\n\t'button-tertiary-medium',\n\t'button-tertiary-small',\n\t'button-tertiary-disabled',\n\t'button-tertiary-large-icon-before',\n\t'button-tertiary-medium-icon-before',\n\t'button-tertiary-small-icon-before',\n\t'button-tertiary-disabled-icon-before',\n\t'button-tertiary-large-icon-after',\n\t'button-tertiary-medium-icon-after',\n\t'button-tertiary-small-icon-after',\n\t'button-tertiary-disabled-icon-after',\n\t'button-tertiary-large-icon-only',\n\t'button-tertiary-medium-icon-only',\n\t'button-tertiary-small-icon-only',\n\t'button-tertiary-disabled-icon-only',\n\t'button-as-link-tertiary-large',\n\t'button-as-link-tertiary-medium',\n\t'button-as-link-tertiary-small',\n];\nconst criticalButtonIds = [\n\t// Critical\n\t'button-critical-large',\n\t'button-critical-medium',\n\t'button-critical-small',\n\t'button-critical-disabled',\n\t'button-critical-large-icon-before',\n\t'button-critical-medium-icon-before',\n\t'button-critical-small-icon-before',\n\t'button-critical-disabled-icon-before',\n\t'button-critical-large-icon-after',\n\t'button-critical-medium-icon-after',\n\t'button-critical-small-icon-after',\n\t'button-critical-disabled-icon-after',\n\t'button-critical-large-icon-only',\n\t'button-critical-medium-icon-only',\n\t'button-critical-small-icon-only',\n\t'button-critical-disabled-icon-only',\n\t'button-as-link-critical-large',\n\t'button-as-link-critical-medium',\n\t'button-as-link-critical-small',\n];\n\ntest.describe('button-component', () => {\n\ttest.beforeEach(async ({ page }) => {\n\t\tawait page.goto('iframe.html?viewMode=docs&id=test-button--docs');\n\t});\n\n\ttest('visibility', async ({ page }) => {\n\t\tconst buttonIds = [...primaryButtonIds, ...secondaryButtonIds, ...tertiaryButtonIds, ...criticalButtonIds];\n\n\t\tfor (const id of buttonIds) {\n\t\t\tawait expect(page.locator(`#${id}`)).toBeVisible();\n\t\t}\n\t});\n\n\ttest('design-implementation', async ({ page }) => {\n\t\tconst buttonIds = [...primaryButtonIds, ...secondaryButtonIds, ...tertiaryButtonIds, ...criticalButtonIds];\n\t\tawait page.reload();\n\n\t\tfor (const id of buttonIds) {\n\t\t\t// Default state\n\t\t\tawait expect(page.locator(`#${id}`)).toHaveScreenshot(`${id}.png`);\n\t\t\t// Hover state\n\t\t\tpage.locator(`#${id}`).hover();\n\t\t\tawait expect(page.locator(`#${id}`)).toHaveScreenshot(`${id}-hover.png`);\n\t\t\t// Focus state\n\t\t\tawait page.evaluate((id) => {\n\t\t\t\tconst element = document.getElementById(id);\n\t\t\t\tif (element) {\n\t\t\t\t\tconst parentDiv = document.createElement('div');\n\t\t\t\t\tparentDiv.style.padding = '10px';\n\t\t\t\t\tparentDiv.style.backgroundColor = 'white';\n\t\t\t\t\telement.parentNode?.insertBefore(parentDiv, element);\n\t\t\t\t\tparentDiv.appendChild(element);\n\t\t\t\t}\n\t\t\t}, id);\n\t\t\tpage.locator(`#${id}`).focus();\n\t\t\tconst parentDiv = await page.locator(`#${id}`).locator('xpath=..');\n\t\t\tawait expect(parentDiv).toHaveScreenshot(`${id}-focus.png`);\n\t\t}\n\t});\n\n\ttest('form-submission', async ({ page }) => {\n\t\tlet requestUrl: URL | undefined;\n\t\tpage.on('request', (request) => {\n\t\t\tif (request.url().includes('iframe.html?first-name=John')) {\n\t\t\t\trequestUrl = new URL(request.url());\n\t\t\t}\n\t\t});\n\n\t\tawait page.locator('#first-name').pressSequentially('John');\n\t\tawait page.locator('#submit-button').click();\n\t\tawait expect(requestUrl?.searchParams.get('first-name')).toBe('John');\n\t});\n\n\ttest('form-reset', async ({ page }) => {\n\t\tawait page.locator('#first-name').pressSequentially('John');\n\t\tawait page.locator('#reset-button').click();\n\t\tconst value = await page.locator('#first-name').getAttribute('value');\n\t\texpect(value).toBeNull();\n\t});\n\n\ttest('button-as-link', async ({ page }) => {\n\t\tconst buttonAsLink = page.locator('#button-as-link-target-blank');\n\t\tawait expect(buttonAsLink).toHaveAttribute('href', 'https://www.politiet.no');\n\n\t\tconst shadowButtonAsLinkHref = await buttonAsLink.evaluate((el) => {\n\t\t\tconst shadowRoot = el.shadowRoot;\n\t\t\tif (shadowRoot) {\n\t\t\t\tconst anchorElement = shadowRoot.querySelector('a');\n\t\t\t\treturn anchorElement?.getAttribute('href');\n\t\t\t}\n\t\t\treturn null;\n\t\t});\n\n\t\tawait expect(shadowButtonAsLinkHref).toBe('https://www.politiet.no');\n\n\t\tconst shadowButtonAsLinkTarget = await buttonAsLink.evaluate((el) => {\n\t\t\tconst shadowRoot = el.shadowRoot;\n\t\t\tif (shadowRoot) {\n\t\t\t\tconst anchorElement = shadowRoot.querySelector('a');\n\t\t\t\treturn anchorElement?.getAttribute('target');\n\t\t\t}\n\t\t\treturn null;\n\t\t});\n\n\t\tawait expect(shadowButtonAsLinkTarget).toBe('_blank');\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sds-button.styles.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAkJlB,CAAC"}
1
+ {"version":3,"file":"sds-button.styles.d.ts","sourceRoot":"","sources":["../../src/sds-button/sds-button.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAsJlB,CAAC"}
@@ -31,6 +31,12 @@ export const styles = css `
31
31
  border: 2px solid var(--sds-color-semantic-surface-action-hover);
32
32
  }
33
33
 
34
+ &:focus {
35
+ background-color: var(--sds-color-semantic-surface-action-default);
36
+ outline: 2px solid var(--sds-color-semantic-surface-action-default);
37
+ outline-offset: 1px;
38
+ }
39
+
34
40
  &:active {
35
41
  background-color: var(--sds-color-semantic-surface-action-active);
36
42
  border: 2px solid var(--sds-color-semantic-surface-action-active);
@@ -45,13 +51,6 @@ export const styles = css `
45
51
  }
46
52
  }
47
53
 
48
- .sds-button:focus,
49
- :host(:focus) .give-focus {
50
- background-color: var(--sds-color-semantic-surface-action-default);
51
- outline: 2px solid var(--sds-color-semantic-surface-action-default);
52
- outline-offset: 1px;
53
- }
54
-
55
54
  .sds-button--secondary {
56
55
  background-color: var(--sds-color-semantic-surface-action-inverted);
57
56
  border: 2px solid var(--sds-color-semantic-border-action);
@@ -145,5 +144,10 @@ export const styles = css `
145
144
  font-size: 0.875rem;
146
145
  padding: 0 var(--sds-spacing-3);
147
146
  }
147
+
148
+ .sds-button--as-link {
149
+ inline-size: auto;
150
+ text-decoration: none;
151
+ }
148
152
  `;
149
153
  //# sourceMappingURL=sds-button.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sds-button.styles.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkJxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n\t:host {\n\t\t--_color-semantic-surface-critical-hover: #b32a23;\n\t\tdisplay: inline-block;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.sds-button {\n\t\talign-items: center;\n\t\tdisplay: inline-flex;\n\t\tgap: var(--sds-spacing-3, 8px);\n\t\tjustify-content: center;\n\t\tpadding: var(--sds-spacing-3) var(--sds-spacing-4);\n\t\tinline-size: 100%;\n\n\t\tbackground-color: var(--sds-color-semantic-surface-action-default);\n\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\tborder-radius: var(--sds-radius-4);\n\t\tcursor: pointer;\n\n\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\tfont-family: var(--sds-typography-font-family);\n\t\tfont-size: 1rem;\n\t\tfont-weight: 500;\n\t\tline-height: 1.5;\n\t\ttext-align: center;\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-hover);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-hover);\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\toutline: 0;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-disabled);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-disabled);\n\t\t\tcolor: var(--sds-color-semantic-text-subtle);\n\t\t\tcursor: not-allowed;\n\t\t}\n\t}\n\n\t.sds-button:focus,\n\t:host(:focus) .give-focus {\n\t\tbackground-color: var(--sds-color-semantic-surface-action-default);\n\t\toutline: 2px solid var(--sds-color-semantic-surface-action-default);\n\t\toutline-offset: 1px;\n\t}\n\n\t.sds-button--secondary {\n\t\tbackground-color: var(--sds-color-semantic-surface-action-inverted);\n\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\tcolor: var(--sds-color-semantic-text-default);\n\n\t\t&:focus {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-inverted);\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-subtle);\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\t\toutline: 0;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-disabled);\n\t\t\tbackground: var(--sds-color-semantic-surface-action-inverted);\n\t\t\tcolor: var(--sds-color-semantic-text-disabled);\n\t\t}\n\t}\n\n\t.sds-button--tertiary {\n\t\tbackground-color: transparent;\n\t\tborder: 2px solid transparent;\n\t\tcolor: var(--sds-color-semantic-text-action-default);\n\n\t\t&:focus {\n\t\t\tbackground-color: transparent;\n\t\t\tborder: 2px solid transparent;\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-subtle);\n\t\t\tborder: 2px solid transparent;\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\t\toutline: 0;\n\t\t\tposition: relative;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tborder: 2px solid transparent;\n\t\t\tbackground: transparent;\n\t\t\tcolor: var(--sds-color-semantic-text-disabled);\n\t\t}\n\t}\n\n\t.sds-button--critical {\n\t\tbackground-color: var(--sds-color-semantic-surface-critical-xtreme);\n\t\tborder: 2px solid var(--sds-color-semantic-border-critical);\n\t\tcolor: var(--sds-color-semantic-text-on-critical);\n\n\t\t&:focus {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-critical-xtreme);\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-critical);\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--_color-semantic-surface-critical-hover);\n\t\t\tborder: 2px solid var(--_color-semantic-surface-critical-hover);\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t}\n\n\t\t&:disabled {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-disabled);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-disabled);\n\t\t\tcolor: var(--sds-color-semantic-text-subtle);\n\t\t}\n\t}\n\n\t.sds-button--medium {\n\t\tpadding: var(--sds-spacing-1) var(--sds-spacing-3);\n\t}\n\n\t.sds-button--small {\n\t\tfont-size: 0.875rem;\n\t\tpadding: 0 var(--sds-spacing-3);\n\t}\n`;\n"]}
1
+ {"version":3,"file":"sds-button.styles.js","sourceRoot":"","sources":["../../src/sds-button/sds-button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsJxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n\t:host {\n\t\t--_color-semantic-surface-critical-hover: #b32a23;\n\t\tdisplay: inline-block;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.sds-button {\n\t\talign-items: center;\n\t\tdisplay: inline-flex;\n\t\tgap: var(--sds-spacing-3, 8px);\n\t\tjustify-content: center;\n\t\tpadding: var(--sds-spacing-3) var(--sds-spacing-4);\n\t\tinline-size: 100%;\n\n\t\tbackground-color: var(--sds-color-semantic-surface-action-default);\n\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\tborder-radius: var(--sds-radius-4);\n\t\tcursor: pointer;\n\n\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\tfont-family: var(--sds-typography-font-family);\n\t\tfont-size: 1rem;\n\t\tfont-weight: 500;\n\t\tline-height: 1.5;\n\t\ttext-align: center;\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-hover);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-hover);\n\t\t}\n\n\t\t&:focus {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-default);\n\t\t\toutline: 2px solid var(--sds-color-semantic-surface-action-default);\n\t\t\toutline-offset: 1px;\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\toutline: 0;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-disabled);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-disabled);\n\t\t\tcolor: var(--sds-color-semantic-text-subtle);\n\t\t\tcursor: not-allowed;\n\t\t}\n\t}\n\n\t.sds-button--secondary {\n\t\tbackground-color: var(--sds-color-semantic-surface-action-inverted);\n\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\tcolor: var(--sds-color-semantic-text-default);\n\n\t\t&:focus {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-inverted);\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-action);\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-subtle);\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\t\toutline: 0;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-disabled);\n\t\t\tbackground: var(--sds-color-semantic-surface-action-inverted);\n\t\t\tcolor: var(--sds-color-semantic-text-disabled);\n\t\t}\n\t}\n\n\t.sds-button--tertiary {\n\t\tbackground-color: transparent;\n\t\tborder: 2px solid transparent;\n\t\tcolor: var(--sds-color-semantic-text-action-default);\n\n\t\t&:focus {\n\t\t\tbackground-color: transparent;\n\t\t\tborder: 2px solid transparent;\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-subtle);\n\t\t\tborder: 2px solid transparent;\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t\tcolor: var(--sds-color-semantic-text-on-action);\n\t\t\toutline: 0;\n\t\t\tposition: relative;\n\t\t}\n\n\t\t&:disabled {\n\t\t\tborder: 2px solid transparent;\n\t\t\tbackground: transparent;\n\t\t\tcolor: var(--sds-color-semantic-text-disabled);\n\t\t}\n\t}\n\n\t.sds-button--critical {\n\t\tbackground-color: var(--sds-color-semantic-surface-critical-xtreme);\n\t\tborder: 2px solid var(--sds-color-semantic-border-critical);\n\t\tcolor: var(--sds-color-semantic-text-on-critical);\n\n\t\t&:focus {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-critical-xtreme);\n\t\t\tborder: 2px solid var(--sds-color-semantic-border-critical);\n\t\t}\n\n\t\t&:hover {\n\t\t\tbackground-color: var(--_color-semantic-surface-critical-hover);\n\t\t\tborder: 2px solid var(--_color-semantic-surface-critical-hover);\n\t\t}\n\n\t\t&:active {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-action-active);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-action-active);\n\t\t}\n\n\t\t&:disabled {\n\t\t\tbackground-color: var(--sds-color-semantic-surface-disabled);\n\t\t\tborder: 2px solid var(--sds-color-semantic-surface-disabled);\n\t\t\tcolor: var(--sds-color-semantic-text-subtle);\n\t\t}\n\t}\n\n\t.sds-button--medium {\n\t\tpadding: var(--sds-spacing-1) var(--sds-spacing-3);\n\t}\n\n\t.sds-button--small {\n\t\tfont-size: 0.875rem;\n\t\tpadding: 0 var(--sds-spacing-3);\n\t}\n\n\t.sds-button--as-link {\n\t\tinline-size: auto;\n\t\ttext-decoration: none;\n\t}\n`;\n"]}
@@ -679,6 +679,12 @@ const styles$h = i$4`
679
679
  border: 2px solid var(--sds-color-semantic-surface-action-hover);
680
680
  }
681
681
 
682
+ &:focus {
683
+ background-color: var(--sds-color-semantic-surface-action-default);
684
+ outline: 2px solid var(--sds-color-semantic-surface-action-default);
685
+ outline-offset: 1px;
686
+ }
687
+
682
688
  &:active {
683
689
  background-color: var(--sds-color-semantic-surface-action-active);
684
690
  border: 2px solid var(--sds-color-semantic-surface-action-active);
@@ -693,13 +699,6 @@ const styles$h = i$4`
693
699
  }
694
700
  }
695
701
 
696
- .sds-button:focus,
697
- :host(:focus) .give-focus {
698
- background-color: var(--sds-color-semantic-surface-action-default);
699
- outline: 2px solid var(--sds-color-semantic-surface-action-default);
700
- outline-offset: 1px;
701
- }
702
-
703
702
  .sds-button--secondary {
704
703
  background-color: var(--sds-color-semantic-surface-action-inverted);
705
704
  border: 2px solid var(--sds-color-semantic-border-action);
@@ -793,6 +792,11 @@ const styles$h = i$4`
793
792
  font-size: 0.875rem;
794
793
  padding: 0 var(--sds-spacing-3);
795
794
  }
795
+
796
+ .sds-button--as-link {
797
+ inline-size: auto;
798
+ text-decoration: none;
799
+ }
796
800
  `;
797
801
  var __defProp$h = Object.defineProperty;
798
802
  var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
@@ -882,8 +886,21 @@ let SDSButton = class extends i$1 {
882
886
  "sds-button--tertiary": this.variant === "tertiary",
883
887
  "sds-button--critical": this.variant === "critical",
884
888
  "sds-button--medium": this.size === "medium",
885
- "sds-button--small": this.size === "small"
889
+ "sds-button--small": this.size === "small",
890
+ "sds-button--as-link": !!this.href
886
891
  };
892
+ if (this.href) {
893
+ return x` <a
894
+ id="link"
895
+ class="${e$1(buttonClasses)}"
896
+ href="${this.href}"
897
+ target="${o$1(this.target)}"
898
+ >
899
+ <slot name="before"></slot>
900
+ <slot></slot>
901
+ <slot name="after"></slot>
902
+ </a>`;
903
+ }
887
904
  return x`
888
905
  <button
889
906
  id="control"
@@ -925,6 +942,12 @@ __decorateClass$h([
925
942
  __decorateClass$h([
926
943
  n2({ type: String, reflect: true })
927
944
  ], SDSButton.prototype, "form", 2);
945
+ __decorateClass$h([
946
+ n2({ type: String, reflect: true })
947
+ ], SDSButton.prototype, "href", 2);
948
+ __decorateClass$h([
949
+ n2({ type: String, reflect: true })
950
+ ], SDSButton.prototype, "target", 2);
928
951
  SDSButton = __decorateClass$h([
929
952
  guardedCustomElement("sds-button")
930
953
  ], SDSButton);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@politiet/sheriff-web-components",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Sheriff Design System Web Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",