@skf-design-system/ui-components 0.0.1-beta.3 → 0.0.1-beta.4

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.
@@ -3,7 +3,6 @@ import '@components/icon/icon.js';
3
3
  import { SkfElement } from '@internal/components/skf-element.js';
4
4
  import type { SeverityFgColor } from '@skf-design-system/ui-assets';
5
5
  import { type CSSResultGroup } from 'lit';
6
- import '../link/link';
7
6
  /**
8
7
  * The `<skf-alert>` is a type of notification that appears in-line
9
8
  *
@@ -0,0 +1,61 @@
1
+ import "../icon/icon.js";
2
+ import { SkfElement as c } from "../../internal/components/skf-element.js";
3
+ import b from "../../styles/component.styles.js";
4
+ import { html as d, nothing as f } from "lit";
5
+ import { property as o } from "lit/decorators.js";
6
+ import { ifDefined as r } from "lit/directives/if-defined.js";
7
+ import h from "./alert.styles.js";
8
+ var u = Object.defineProperty, i = (n, a, m, y) => {
9
+ for (var t = void 0, s = n.length - 1, p; s >= 0; s--)
10
+ (p = n[s]) && (t = p(a, m, t) || t);
11
+ return t && u(a, m, t), t;
12
+ };
13
+ const l = class l extends c {
14
+ constructor() {
15
+ super(...arguments), this.buttonLabel = "Close", this._handleClose = () => this.emit("skf-alert-close");
16
+ }
17
+ render() {
18
+ return d`
19
+ <div
20
+ id="alert"
21
+ aria-describedby="main"
22
+ aria-modal=${r(this.closeable && "true")}
23
+ role=${this.closeable ? "alertdialog" : "alert"}
24
+ >
25
+ <skf-icon
26
+ color=${r(this.severity ?? "secondary")}
27
+ name=${r(this.icon)}
28
+ size="sm"
29
+ ></skf-icon>
30
+ <div id="body">
31
+ <div id="main">
32
+ <slot></slot>
33
+ </div>
34
+ <slot name="link"></slot>
35
+ </div>
36
+ ${this.closeable ? d`
37
+ <button @click="${this._handleClose}" aria-label=${this.buttonLabel} type="button">
38
+ <skf-icon name="close" size="sm"></skf-icon>
39
+ </button>
40
+ ` : f}
41
+ </div>
42
+ `;
43
+ }
44
+ };
45
+ l.styles = [b, h];
46
+ let e = l;
47
+ i([
48
+ o({ type: Boolean })
49
+ ], e.prototype, "closeable");
50
+ i([
51
+ o({ attribute: "button-label" })
52
+ ], e.prototype, "buttonLabel");
53
+ i([
54
+ o()
55
+ ], e.prototype, "icon");
56
+ i([
57
+ o()
58
+ ], e.prototype, "severity");
59
+ export {
60
+ e as SkfAlert
61
+ };
@@ -0,0 +1,6 @@
1
+ import { SkfAlert as e } from "./alert.component.js";
2
+ e.define("skf-alert");
3
+ export {
4
+ e as SkfAlert,
5
+ e as default
6
+ };
@@ -0,0 +1,63 @@
1
+ import { css as r } from "lit";
2
+ const s = r`
3
+ :host {
4
+ contain: layout;
5
+ }
6
+
7
+ #alert {
8
+ background-color: var(--_skf-alert-bg-color, var(--skf-bg-color-neutral-2));
9
+ border: var(--skf-border-width-sm) solid
10
+ var(--_skf-alert-border-color, var(--skf-border-color-primary));
11
+ border-radius: var(--skf-border-radius-sm);
12
+ box-shadow: var(--skf-shadow-md);
13
+ display: flex;
14
+ font-size: var(--skf-font-size-75);
15
+ gap: var(--skf-spacing-50);
16
+ padding-block: var(--skf-spacing-75);
17
+ padding-inline: var(--skf-spacing-50);
18
+
19
+ :host([severity='alert']) & {
20
+ --_skf-alert-bg-color: var(--skf-severity-bg-color-alert);
21
+ --_skf-alert-border-color: var(--skf-severity-fg-color-alert);
22
+ }
23
+
24
+ :host([severity='error']) & {
25
+ --_skf-alert-bg-color: var(--skf-severity-bg-color-error);
26
+ --_skf-alert-border-color: var(--skf-severity-fg-color-error);
27
+ }
28
+
29
+ :host([severity='info']) & {
30
+ --_skf-alert-bg-color: var(--skf-severity-bg-color-info);
31
+ --_skf-alert-border-color: var(--skf-severity-fg-color-info);
32
+ }
33
+
34
+ :host([severity='success']) & {
35
+ --_skf-alert-bg-color: var(--skf-severity-bg-color-success);
36
+ --_skf-alert-border-color: var(--skf-severity-fg-color-success);
37
+ }
38
+
39
+ :host([severity='warning']) & {
40
+ --_skf-alert-bg-color: var(--skf-severity-bg-color-warning);
41
+ --_skf-alert-border-color: var(--skf-severity-fg-color-warning);
42
+ }
43
+ }
44
+
45
+ #body {
46
+ display: flex;
47
+ flex: auto;
48
+ flex-wrap: wrap;
49
+ gap: var(--skf-spacing-25) var(--skf-spacing-100);
50
+ justify-content: space-between;
51
+ }
52
+
53
+ ::slotted(skf-link) {
54
+ text-transform: uppercase;
55
+ }
56
+
57
+ button {
58
+ display: inline-flex;
59
+ }
60
+ `;
61
+ export {
62
+ s as default
63
+ };
@@ -0,0 +1,34 @@
1
+ import { SkfElement as f } from "../../internal/components/skf-element.js";
2
+ import u from "../../styles/component.styles.js";
3
+ import "lit";
4
+ import { property as a } from "lit/decorators.js";
5
+ import { html as h, unsafeStatic as l } from "lit/static-html.js";
6
+ import y from "./heading.styles.js";
7
+ var c = Object.defineProperty, n = (o, p, i, d) => {
8
+ for (var t = void 0, e = o.length - 1, m; e >= 0; e--)
9
+ (m = o[e]) && (t = m(p, i, t) || t);
10
+ return t && c(p, i, t), t;
11
+ };
12
+ const s = class s extends f {
13
+ constructor() {
14
+ super(...arguments), this.as = "h1";
15
+ }
16
+ render() {
17
+ return h`
18
+ <${l(this.as)} id="heading">
19
+ <slot></slot>
20
+ </${l(this.as)}>
21
+ `;
22
+ }
23
+ };
24
+ s.styles = [u, y];
25
+ let r = s;
26
+ n([
27
+ a({ reflect: !0 })
28
+ ], r.prototype, "as");
29
+ n([
30
+ a({ attribute: "styled-as" })
31
+ ], r.prototype, "styledAs");
32
+ export {
33
+ r as SkfHeading
34
+ };
@@ -0,0 +1,6 @@
1
+ import { SkfHeading as e } from "./heading.component.js";
2
+ e.define("skf-heading");
3
+ export {
4
+ e as SkfHeading,
5
+ e as default
6
+ };
@@ -0,0 +1,62 @@
1
+ import { css as s } from "lit";
2
+ const t = s`
3
+ @layer components {
4
+ :host {
5
+ display: contents;
6
+ }
7
+
8
+ #heading {
9
+ color: var(--skf-text-color-primary);
10
+ font-size: var(--_skf-heading-size);
11
+ font-weight: var(--_skf-heading-weight);
12
+ line-height: 1.2;
13
+
14
+ /* Defaults */
15
+ :host([as='h1']) & {
16
+ --_skf-heading-size: var(--skf-font-size-700);
17
+ --_skf-heading-weight: var(--skf-font-weight-regular);
18
+ }
19
+
20
+ :host(:is([as='h2'], [as='h3'], [as='h4'])) & {
21
+ --_skf-heading-weight: var(--skf-font-weight-bold);
22
+ }
23
+
24
+ :host([as='h2']) & {
25
+ --_skf-heading-size: var(--skf-font-size-300);
26
+ }
27
+
28
+ :host([as='h3']) & {
29
+ --_skf-heading-size: var(--skf-font-size-200);
30
+ }
31
+
32
+ :host([as='h4']) & {
33
+ --_skf-heading-size: var(--skf-font-size-200);
34
+ }
35
+
36
+ /** Styled As */
37
+ :host([styled-as='h1']) & {
38
+ --_skf-heading-size: var(--skf-font-size-700);
39
+ --_skf-heading-weight: var(--skf-font-weight-regular);
40
+ }
41
+
42
+ :host(:is([styled-as='h2'], [styled-as='h3'], [styled-as='h4'])) & {
43
+ --_skf-heading-weight: var(--skf-font-weight-bold);
44
+ }
45
+
46
+ :host([styled-as='h2']) & {
47
+ --_skf-heading-size: var(--skf-font-size-300);
48
+ }
49
+
50
+ :host([styled-as='h3']) & {
51
+ --_skf-heading-size: var(--skf-font-size-200);
52
+ }
53
+
54
+ :host([styled-as='h4']) & {
55
+ --_skf-heading-size: var(--skf-font-size-200);
56
+ }
57
+ }
58
+ }
59
+ `;
60
+ export {
61
+ t as default
62
+ };
@@ -0,0 +1,106 @@
1
+ import { FormBase as o } from "../../internal/components/formBase.js";
2
+ import { Asterisk as u } from "../../internal/templates/asterisk.js";
3
+ import p from "../../styles/component.styles.js";
4
+ import { html as c } from "lit";
5
+ import { property as s, state as v, query as f } from "lit/decorators.js";
6
+ import { ifDefined as m } from "lit/directives/if-defined.js";
7
+ import { styles as b } from "./switch.styles.js";
8
+ var y = Object.defineProperty, i = (d, e, a, _) => {
9
+ for (var l = void 0, r = d.length - 1, n; r >= 0; r--)
10
+ (n = d[r]) && (l = n(e, a, l) || l);
11
+ return l && y(e, a, l), l;
12
+ };
13
+ const h = class h extends o {
14
+ constructor() {
15
+ super(...arguments), this._initialChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._handleChange = (e) => {
16
+ var a;
17
+ e.stopPropagation(), this.pristine = !1, this.checked = (a = this.$input) == null ? void 0 : a.checked, this._validateInput(), this.checked ? this.setFormValue(this.value) : this.setFormValue(null), this.emitEvent("change");
18
+ }, this._handleInvalid = (e) => {
19
+ this.pristine = !1, this._invalid = !0, this.customErrorDisplay && e.preventDefault();
20
+ }, this._resetValue = (e) => {
21
+ e.stopPropagation(), this.checked = this._initialChecked, this.$input && (this.$input.checked = !!this._initialChecked), this.setFormValue(this.checked ? this.value : null);
22
+ };
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), this._validateInput();
26
+ }
27
+ willUpdate(e) {
28
+ e.has("_invalid") && (this._invalid ? (this.setAttribute("invalid", ""), this.checkValidity()) : this.removeAttribute("invalid"));
29
+ }
30
+ firstUpdated() {
31
+ this._initialChecked = this.checked;
32
+ }
33
+ updated(e) {
34
+ super.updated(e), e.has("_invalid") && this._invalid && this.debug && this.debugOutput();
35
+ }
36
+ debugOutput() {
37
+ this.debug && !this.validity.valid && console.log(`Switch invalidity reason: ${this.validationMessage}`);
38
+ }
39
+ /** @internal */
40
+ _validateInput() {
41
+ var e;
42
+ if (this._invalid = !1, this.required && !this.checked) {
43
+ this.pristine || (this._invalid = !0);
44
+ const a = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : ((e = this.$input) == null ? void 0 : e.validationMessage) ?? "Please check this box if you want to proceed";
45
+ this.setValidity({ valueMissing: !0 }, String(a));
46
+ } else
47
+ this.setValidity({});
48
+ }
49
+ render() {
50
+ return c`
51
+ <label id="switch">
52
+ <input
53
+ ?checked=${this.checked}
54
+ ?disabled=${this.disabled}
55
+ ?required=${this.required}
56
+ @change=${this._handleChange}
57
+ @invalid=${this._handleInvalid}
58
+ @reset=${this._resetValue}
59
+ aria-invalid=${!!this._invalid}
60
+ name=${m(this.name)}
61
+ type="checkbox"
62
+ value=${this.value}
63
+ />
64
+ <div id="label">
65
+ <slot>${this.label}</slot>
66
+ ${this.required ? u(this.requiredLabel) : null}
67
+ </div>
68
+ </label>
69
+ `;
70
+ }
71
+ };
72
+ h.styles = [p, b];
73
+ let t = h;
74
+ i([
75
+ s({ type: Boolean })
76
+ ], t.prototype, "debug");
77
+ i([
78
+ s({ type: Boolean, reflect: !0 })
79
+ ], t.prototype, "checked");
80
+ i([
81
+ s({ type: Boolean, attribute: "hide-label", reflect: !0 })
82
+ ], t.prototype, "hideLabel");
83
+ i([
84
+ s()
85
+ ], t.prototype, "label");
86
+ i([
87
+ s()
88
+ ], t.prototype, "name");
89
+ i([
90
+ s({ attribute: "required-label" })
91
+ ], t.prototype, "requiredLabel");
92
+ i([
93
+ s({ reflect: !0 })
94
+ ], t.prototype, "size");
95
+ i([
96
+ s()
97
+ ], t.prototype, "value");
98
+ i([
99
+ v()
100
+ ], t.prototype, "_invalid");
101
+ i([
102
+ f("input")
103
+ ], t.prototype, "$input");
104
+ export {
105
+ t as SkfSwitch
106
+ };
@@ -0,0 +1,6 @@
1
+ import { SkfSwitch as f } from "./switch.component.js";
2
+ f.define("skf-switch");
3
+ export {
4
+ f as SkfSwitch,
5
+ f as default
6
+ };
@@ -0,0 +1,80 @@
1
+ import { visuallyHidden as s } from "../../styles/util.styles.js";
2
+ import { css as r } from "lit";
3
+ const t = [
4
+ s,
5
+ r`
6
+ @layer components {
7
+ :host {
8
+ contain: layout;
9
+ }
10
+
11
+ label {
12
+ align-items: center;
13
+ display: flex;
14
+ grid-gap: var(--skf-spacing-50);
15
+
16
+ :host([size='sm']) & {
17
+ --_skf-switch-height: var(--skf-size-20);
18
+ --_skf-switch-width: var(--skf-size-32);
19
+
20
+ font-size: var(--skf-font-size-75);
21
+ font-weight: var(--skf-font-weight-medium);
22
+ }
23
+ }
24
+
25
+ input {
26
+ --_skf-switch-width: var(--skf-size-44);
27
+ --_skf-switch-height: var(--skf-size-24);
28
+
29
+ background-color: var(--_skf-switch-bg-color, var(--skf-bg-color-neutral-4));
30
+ block-size: var(--_skf-switch-height);
31
+ border: var(--skf-border-width-sm) solid
32
+ var(--_skf-switch-border-color, var(--skf-border-color-primary));
33
+ border-radius: calc(var(--_skf-switch-height) / 2);
34
+ display: flex;
35
+ inline-size: var(--_skf-switch-width);
36
+ transition: background-color calc(var(--skf-motion-duration-fast) * 1ms)
37
+ var(--skf-motion-easing-ease-out);
38
+
39
+ &::after {
40
+ aspect-ratio: 1;
41
+ background: var(--skf-bg-color-neutral-1);
42
+ block-size: calc(100% - 2px);
43
+ border-radius: 50%;
44
+ content: '';
45
+ margin: 1px;
46
+ transition: transform calc(var(--skf-motion-duration-fast) * 1ms)
47
+ var(--skf-motion-easing-ease-out);
48
+ }
49
+
50
+ &:focus-visible {
51
+ outline: var(--skf-border-width-md) solid var(--skf-interactive-border-color-focus);
52
+ outline-offset: var(--skf-size-2);
53
+ }
54
+
55
+ &:is(:checked, :disabled) {
56
+ --_skf-switch-border-color: transparent;
57
+ }
58
+
59
+ &:checked {
60
+ --_skf-switch-bg-color: var(--skf-bg-color-emphasised);
61
+
62
+ &::after {
63
+ transform: translateX(calc(var(--_skf-switch-width) - var(--_skf-switch-height)));
64
+ }
65
+ }
66
+
67
+ &:disabled {
68
+ --_skf-switch-bg-color: var(--skf-interactive-bg-color-disabled);
69
+ }
70
+ }
71
+
72
+ #asterisk {
73
+ color: var(--skf-severity-fg-color-error);
74
+ }
75
+ }
76
+ `
77
+ ];
78
+ export {
79
+ t as styles
80
+ };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  export { default as SkfAccordion, SkfAccordionItem } from './components/accordion/accordion.js';
2
+ export { default as SkfAlert } from './components/alert/alert.js';
2
3
  export { default as SkfButton } from './components/button/button.js';
3
4
  export { default as SkfCard } from './components/card/card.js';
4
5
  export { default as SkfCheckbox } from './components/checkbox/checkbox.js';
5
6
  export { default as SkfCollapse } from './components/collapse/collapse.js';
6
7
  export { default as SkfDivider } from './components/divider/divider.js';
8
+ export { default as SkfHeading } from './components/heading/heading.js';
7
9
  export { default as SkfIcon } from './components/icon/icon.js';
8
10
  export { default as SkfInput } from './components/input/input.js';
9
11
  export { default as SkfLink } from './components/link/link.js';
10
12
  export { default as SkfLoader } from './components/loader/loader.js';
11
13
  export { default as SkfLogo } from './components/logo/logo.js';
12
14
  export { default as SkfRadio } from './components/radio/radio.js';
15
+ export { default as SkfSwitch } from './components/switch/switch.js';
13
16
  export { default as SkfTag } from './components/tag/tag.js';
14
17
  export { default as SkfTextArea } from './components/textarea/textarea.js';
package/dist/index.js CHANGED
@@ -1,46 +1,55 @@
1
1
  import "./components/accordion/accordion.js";
2
+ import "./components/alert/alert.js";
2
3
  import "./components/button/button.js";
3
4
  import "./components/card/card.js";
4
5
  import "./components/checkbox/checkbox.js";
5
6
  import "./components/collapse/collapse.js";
6
7
  import "./components/divider/divider.js";
8
+ import "./components/heading/heading.js";
7
9
  import "./components/icon/icon.js";
8
10
  import "./components/input/input.js";
9
11
  import "./components/link/link.js";
10
12
  import "./components/loader/loader.js";
11
13
  import "./components/logo/logo.js";
12
14
  import "./components/radio/radio.js";
15
+ import "./components/switch/switch.js";
13
16
  import "./components/tag/tag.js";
14
17
  import "./components/textarea/textarea.js";
15
- import { SkfAccordion as C } from "./components/accordion/accordion.component.js";
16
- import { SkfButton as L } from "./components/button/button.component.js";
17
- import { SkfCard as l } from "./components/card/card.component.js";
18
- import { SkfCheckbox as T } from "./components/checkbox/checkbox.component.js";
19
- import { SkfCollapse as h } from "./components/collapse/collapse.component.js";
20
- import { SkfDivider as v } from "./components/divider/divider.component.js";
21
- import { SkfIcon as D } from "./components/icon/icon.component.js";
22
- import { SkfInput as j } from "./components/input/input.component.js";
23
- import { SkfLink as w } from "./components/link/link.component.js";
24
- import { SkfLoader as z } from "./components/loader/loader.component.js";
25
- import { SkfLogo as F } from "./components/logo/logo.component.js";
26
- import { SkfRadio as H } from "./components/radio/radio.component.js";
27
- import { SkfTag as K } from "./components/tag/tag.component.js";
28
- import { SkfTextArea as N } from "./components/textarea/textarea.component.js";
29
- import { SkfAccordionItem as P } from "./components/accordion/accordion-item.js";
18
+ import { SkfAccordion as I } from "./components/accordion/accordion.component.js";
19
+ import { SkfAlert as h } from "./components/alert/alert.component.js";
20
+ import { SkfButton as T } from "./components/button/button.component.js";
21
+ import { SkfCard as s } from "./components/card/card.component.js";
22
+ import { SkfCheckbox as w } from "./components/checkbox/checkbox.component.js";
23
+ import { SkfCollapse as D } from "./components/collapse/collapse.component.js";
24
+ import { SkfDivider as R } from "./components/divider/divider.component.js";
25
+ import { SkfHeading as q } from "./components/heading/heading.component.js";
26
+ import { SkfIcon as z } from "./components/icon/icon.component.js";
27
+ import { SkfInput as F } from "./components/input/input.component.js";
28
+ import { SkfLink as J } from "./components/link/link.component.js";
29
+ import { SkfLoader as M } from "./components/loader/loader.component.js";
30
+ import { SkfLogo as O } from "./components/logo/logo.component.js";
31
+ import { SkfRadio as Q } from "./components/radio/radio.component.js";
32
+ import { SkfSwitch as V } from "./components/switch/switch.component.js";
33
+ import { SkfTag as X } from "./components/tag/tag.component.js";
34
+ import { SkfTextArea as Z } from "./components/textarea/textarea.component.js";
35
+ import { SkfAccordionItem as $ } from "./components/accordion/accordion-item.js";
30
36
  export {
31
- C as SkfAccordion,
32
- P as SkfAccordionItem,
33
- L as SkfButton,
34
- l as SkfCard,
35
- T as SkfCheckbox,
36
- h as SkfCollapse,
37
- v as SkfDivider,
38
- D as SkfIcon,
39
- j as SkfInput,
40
- w as SkfLink,
41
- z as SkfLoader,
42
- F as SkfLogo,
43
- H as SkfRadio,
44
- K as SkfTag,
45
- N as SkfTextArea
37
+ I as SkfAccordion,
38
+ $ as SkfAccordionItem,
39
+ h as SkfAlert,
40
+ T as SkfButton,
41
+ s as SkfCard,
42
+ w as SkfCheckbox,
43
+ D as SkfCollapse,
44
+ R as SkfDivider,
45
+ q as SkfHeading,
46
+ z as SkfIcon,
47
+ F as SkfInput,
48
+ J as SkfLink,
49
+ M as SkfLoader,
50
+ O as SkfLogo,
51
+ Q as SkfRadio,
52
+ V as SkfSwitch,
53
+ X as SkfTag,
54
+ Z as SkfTextArea
46
55
  };
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "sideEffects": true,
35
35
  "type": "module",
36
36
  "types": "./dist/index.d.ts",
37
- "version": "0.0.1-beta.3",
37
+ "version": "0.0.1-beta.4",
38
38
  "devDependencies": {
39
39
  "@chromatic-com/storybook": "^2.0.2",
40
40
  "@commitlint/cli": "^19.5.0",