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

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.
Files changed (105) hide show
  1. package/dist/components/accordion/accordion.component.d.ts +9 -5
  2. package/dist/components/accordion/accordion.component.js +22 -19
  3. package/dist/components/accordion/accordion.d.ts +1 -1
  4. package/dist/components/accordion/accordion.styles.js +3 -3
  5. package/dist/components/alert/alert.component.d.ts +7 -5
  6. package/dist/components/alert/alert.component.js +61 -0
  7. package/dist/components/alert/alert.js +6 -0
  8. package/dist/components/alert/alert.styles.js +63 -0
  9. package/dist/components/button/button.component.js +1 -1
  10. package/dist/components/button/button.styles.js +1 -1
  11. package/dist/components/card/card.component.d.ts +3 -3
  12. package/dist/components/card/card.component.js +16 -19
  13. package/dist/components/card/card.styles.js +11 -3
  14. package/dist/components/checkbox/checkbox.component.d.ts +9 -6
  15. package/dist/components/checkbox/checkbox.component.js +8 -8
  16. package/dist/components/checkbox/checkbox.styles.js +1 -1
  17. package/dist/components/checkbox/checkbox.test.d.ts +1 -0
  18. package/dist/components/collapse/collapse.component.d.ts +9 -6
  19. package/dist/components/collapse/collapse.component.js +39 -36
  20. package/dist/components/collapse/collapse.styles.js +3 -3
  21. package/dist/components/collapse/collapse.test.d.ts +1 -0
  22. package/dist/components/divider/divider.component.d.ts +13 -10
  23. package/dist/components/divider/divider.component.js +34 -29
  24. package/dist/components/divider/divider.styles.js +1 -5
  25. package/dist/components/heading/heading.component.d.ts +12 -2
  26. package/dist/components/heading/heading.component.js +34 -0
  27. package/dist/components/heading/heading.js +6 -0
  28. package/dist/components/heading/heading.styles.js +62 -0
  29. package/dist/components/icon/icon.component.d.ts +14 -8
  30. package/dist/components/icon/icon.component.js +6 -6
  31. package/dist/components/icon/icon.styles.js +1 -1
  32. package/dist/components/input/input.component.d.ts +34 -29
  33. package/dist/components/input/input.component.js +36 -36
  34. package/dist/components/link/link.component.d.ts +15 -12
  35. package/dist/components/link/link.component.js +7 -7
  36. package/dist/components/link/link.styles.js +1 -1
  37. package/dist/components/loader/loader.component.d.ts +7 -7
  38. package/dist/components/loader/loader.component.js +35 -61
  39. package/dist/components/loader/loader.styles.js +42 -10
  40. package/dist/components/logo/logo.component.d.ts +5 -3
  41. package/dist/components/logo/logo.component.js +8 -8
  42. package/dist/components/logo/logo.styles.js +2 -2
  43. package/dist/components/radio/radio.component.d.ts +15 -13
  44. package/dist/components/radio/radio.component.js +3 -3
  45. package/dist/components/radio/radio.styles.js +3 -3
  46. package/dist/components/select/select.component.d.ts +137 -0
  47. package/dist/components/select/select.component.js +311 -0
  48. package/dist/components/select/select.controllers.d.ts +59 -0
  49. package/dist/components/select/select.controllers.js +169 -0
  50. package/dist/components/select/select.d.ts +8 -0
  51. package/dist/components/select/select.js +6 -0
  52. package/dist/components/select/select.styles.d.ts +1 -0
  53. package/dist/components/select/select.styles.js +116 -0
  54. package/dist/components/select-option/select-option.component.d.ts +77 -0
  55. package/dist/components/select-option/select-option.component.js +117 -0
  56. package/dist/components/select-option/select-option.controllers.d.ts +9 -0
  57. package/dist/components/select-option/select-option.d.ts +8 -0
  58. package/dist/components/select-option/select-option.js +6 -0
  59. package/dist/components/select-option/select-option.styles.d.ts +1 -0
  60. package/dist/components/select-option/select-option.styles.js +53 -0
  61. package/dist/components/select-option-group/select-option-group.component.d.ts +16 -0
  62. package/dist/components/select-option-group/select-option-group.component.js +31 -0
  63. package/dist/components/select-option-group/select-option-group.d.ts +8 -0
  64. package/dist/components/select-option-group/select-option-group.js +6 -0
  65. package/dist/components/select-option-group/select-option-group.style.d.ts +1 -0
  66. package/dist/components/select-option-group/select-option-group.style.js +18 -0
  67. package/dist/components/switch/switch.component.d.ts +2 -3
  68. package/dist/components/switch/switch.component.js +106 -0
  69. package/dist/components/switch/switch.js +6 -0
  70. package/dist/components/switch/switch.styles.js +80 -0
  71. package/dist/components/switch/switch.test.d.ts +1 -0
  72. package/dist/components/tag/tag.component.d.ts +25 -4
  73. package/dist/components/tag/tag.component.js +66 -29
  74. package/dist/components/tag/tag.styles.js +6 -5
  75. package/dist/components/textarea/textarea.component.d.ts +26 -23
  76. package/dist/components/textarea/textarea.component.js +15 -12
  77. package/dist/custom-elements.json +960 -305
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.js +48 -30
  80. package/dist/internal/components/formBase.d.ts +18 -1
  81. package/dist/internal/components/formBase.js +25 -13
  82. package/dist/internal/components/skf-element.d.ts +4 -4
  83. package/dist/internal/components/skf-element.js +15 -19
  84. package/dist/internal/helpers/array.d.ts +4 -0
  85. package/dist/internal/helpers/findMatchingTags.d.ts +2 -0
  86. package/dist/internal/helpers/findMatchingTags.js +12 -0
  87. package/dist/internal/helpers/hintSeverity.d.ts +2 -0
  88. package/dist/internal/helpers/hintSeverity.js +6 -0
  89. package/dist/internal/helpers/raiseError.d.ts +28 -0
  90. package/dist/internal/helpers/raiseError.js +29 -0
  91. package/dist/internal/storybook/shadowRootTraverser.d.ts +16 -6
  92. package/dist/react/index.d.ts +3 -0
  93. package/dist/react/index.js +3 -0
  94. package/dist/react/skf-select/index.d.ts +21 -0
  95. package/dist/react/skf-select/index.js +21 -0
  96. package/dist/react/skf-select-option/index.d.ts +9 -0
  97. package/dist/react/skf-select-option/index.js +17 -0
  98. package/dist/react/skf-select-option-group/index.d.ts +3 -0
  99. package/dist/react/skf-select-option-group/index.js +13 -0
  100. package/dist/styles/form-field.styles.js +7 -7
  101. package/dist/types/jsx/custom-element-jsx.d.ts +290 -140
  102. package/dist/types/vue/index.d.ts +223 -90
  103. package/dist/vscode.html-custom-data.json +294 -97
  104. package/dist/web-types.json +614 -242
  105. package/package.json +34 -30
@@ -9,13 +9,12 @@ import { type CSSResultGroup } from 'lit';
9
9
  * @attribute {boolean} disabled - If true, sets disabled state
10
10
  * @attribute {boolean} required - If true, value is required or must be checked for the form to be submittable
11
11
  *
12
- * @slot - The component's placeholder content
12
+ * @slot - The Switchs label. Alternatively, you can use the `label` attribute.
13
13
  *
14
14
  * @tagname skf-switch
15
15
  */
16
16
  export declare class SkfSwitch extends FormBase implements FormFieldBaseProps {
17
17
  static styles: CSSResultGroup;
18
- /** @internal */
19
18
  private _initialChecked;
20
19
  /** If true, outputs helping hints in console */
21
20
  debug?: boolean;
@@ -23,7 +22,7 @@ export declare class SkfSwitch extends FormBase implements FormFieldBaseProps {
23
22
  checked?: boolean;
24
23
  /** If true, hides the label visually */
25
24
  hideLabel?: boolean;
26
- /** If defined, sets the input's label. Alternatively, you can use the `label` attribute. */
25
+ /** If defined, sets the input's label unless the default slot is used. Alternatively, you can use the `label` attribute. */
27
26
  label?: string;
28
27
  /** If defined, adds name to the input-element */
29
28
  name?: string;
@@ -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="root">
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
+ #root {
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -13,15 +13,36 @@ import { type CSSResultGroup } from 'lit';
13
13
  */
14
14
  export declare class SkfTag extends SkfElement {
15
15
  static styles: CSSResultGroup;
16
- /** Specifies Tag size - @default "md" */
16
+ private _onClick?;
17
+ protected _onRemove?: (event: Event) => void;
18
+ /** Specifies Tag size */
17
19
  size: 'sm' | 'md' | 'lg';
18
- /** If defined, displays leading/provided icon - @type { "arrowDown" | "arrowDownUp" | "arrowLeft" | "arrowRight" | "arrowUp" | "article" | "artificialIntelligence" | "asset" | "attachment" | "bandCursor" | "bands" | "batteryEmpty" | "batteryFull" | "batteryLow" | "bearingFault" | "book" | "bulb" | "burger" | "cPM" | "calendar" | "calendarBooked" | "calendarEmpty" | "calendarNotBooked" | "calendarRecurring" | "caretDown" | "caretUp" | "caretUpDown" | "chat" | "check" | "checkCircle" | "checkSmall" | "chevronDown" | "chevronLeft" | "chevronRight" | "chevronUp" | "chevronUpDown" | "close" | "closeAllFaults" | "closeFault" | "closeSmall" | "columnGraph" | "comment" | "connection1" | "connection2" | "connection3" | "connection4" | "danger" | "defectFrequencies" | "defectFrequenciesAlternative" | "doubleChevronLeft" | "doubleChevronRight" | "download" | "draft" | "draftFilled" | "draftOutlined" | "dragNDrop" | "drop" | "duplicate" | "edit" | "emailFilled" | "emailOutlined" | "exclamation" | "eye" | "eyeHidden" | "eyeVisible" | "filter" | "forbidden" | "fullScreen" | "fullScreenExit" | "functionalLocation" | "harmonicCursor" | "heatmap" | "hierarchy" | "history" | "historyAlt" | "hourglassFramedFilled" | "hourglassFramedOutlined" | "hourglassOutlined" | "hz" | "iMX" | "image" | "infoCircleFilled" | "infoCircleOutlined" | "integration" | "kebab" | "link" | "listGroup" | "listItem" | "locationPin" | "lock" | "logOut" | "meatballs" | "microphone" | "minus" | "minusSmall" | "noData" | "o" | "openInNew" | "overlayBaseline" | "pDF" | "paper" | "pause" | "pieChart" | "pin" | "play" | "plus" | "powerOff" | "printer" | "proCollect" | "recAction" | "received" | "refresh" | "reorder" | "replace" | "reply" | "rewalkableRoute" | "routes" | "search" | "send" | "sensorA" | "sensorB" | "settings" | "sidebandCursor" | "singleCursor" | "spectrum" | "starFilled" | "starOutlined" | "statusCircle" | "stop" | "structuralVibration" | "sync" | "timewave" | "trash" | "trend" | "trendingUp" | "undo" | "unknownCircle" | "unknownDiamond" | "unlink" | "unlock" | "unscheduledAction" | "upload" | "user" | "viewFull" | "viewHorizontal" | "viewVertical" | "warning" | "warningCircle" | "warningDiamond" | "zoomIn" | "zoomOut" } */
20
+ /**
21
+ * If defined, displays leading/provided icon
22
+ * @type { "arrowDown" | "arrowDownUp" | "arrowLeft" | "arrowRight" | "arrowUp" | "article" | "artificialIntelligence" | "asset" | "attachment" | "bandCursor" | "bands" | "batteryEmpty" | "batteryFull" | "batteryLow" | "bearingFault" | "book" | "bulb" | "burger" | "cPM" | "calendar" | "calendarBooked" | "calendarEmpty" | "calendarNotBooked" | "calendarRecurring" | "caretDown" | "caretUp" | "caretUpDown" | "chat" | "check" | "checkCircle" | "checkSmall" | "chevronDown" | "chevronLeft" | "chevronRight" | "chevronUp" | "chevronUpDown" | "close" | "closeAllFaults" | "closeFault" | "closeSmall" | "columnGraph" | "comment" | "connection1" | "connection2" | "connection3" | "connection4" | "danger" | "defectFrequencies" | "defectFrequenciesAlternative" | "doubleChevronLeft" | "doubleChevronRight" | "download" | "draft" | "draftFilled" | "draftOutlined" | "dragNDrop" | "drop" | "duplicate" | "edit" | "emailFilled" | "emailOutlined" | "exclamation" | "eye" | "eyeHidden" | "eyeVisible" | "filter" | "forbidden" | "fullScreen" | "fullScreenExit" | "functionalLocation" | "harmonicCursor" | "heatmap" | "hierarchy" | "history" | "historyAlt" | "hourglassFramedFilled" | "hourglassFramedOutlined" | "hourglassOutlined" | "hz" | "iMX" | "image" | "infoCircleFilled" | "infoCircleOutlined" | "integration" | "kebab" | "link" | "listGroup" | "listItem" | "locationPin" | "lock" | "logOut" | "meatballs" | "microphone" | "minus" | "minusSmall" | "noData" | "o" | "openInNew" | "overlayBaseline" | "pDF" | "paper" | "pause" | "pieChart" | "pin" | "play" | "plus" | "powerOff" | "printer" | "proCollect" | "recAction" | "received" | "refresh" | "reorder" | "replace" | "reply" | "rewalkableRoute" | "routes" | "search" | "send" | "sensorA" | "sensorB" | "settings" | "sidebandCursor" | "singleCursor" | "spectrum" | "starFilled" | "starOutlined" | "statusCircle" | "stop" | "structuralVibration" | "sync" | "timewave" | "trash" | "trend" | "trendingUp" | "undo" | "unknownCircle" | "unknownDiamond" | "unlink" | "unlock" | "unscheduledAction" | "upload" | "user" | "viewFull" | "viewHorizontal" | "viewVertical" | "warning" | "warningCircle" | "warningDiamond" | "zoomIn" | "zoomOut" }
23
+ */
19
24
  icon?: Icon;
20
- /** If defined, gives the supplied appearance - @type { "warning" | "success" | "info" | "error" | "alert" } */
25
+ /**
26
+ * If defined, gives the supplied appearance
27
+ * @type { "warning" | "success" | "info" | "error" | "alert" }
28
+ */
21
29
  color?: SeverityBgColor;
30
+ /** If defined, accepts a function that runs on click */
31
+ set onClick(onClickFn: ((event: Event) => void) | undefined);
32
+ get onClick(): ((event: Event) => void) | undefined;
33
+ /** If defined, accepts a function that runs on click. Self removal can be overridden by using `event.stopPropagation()`. */
34
+ set onRemove(onRemoveFn: ((event: Event) => void) | undefined);
35
+ get onRemove(): ((event: Event) => void) | undefined;
22
36
  /** If true, adds trailing button to remove tag */
23
37
  removable?: boolean;
24
38
  /** @internal */
25
- private _remove;
39
+ $removeButton: HTMLButtonElement;
40
+ connectedCallback(): void;
41
+ disconnectedCallback(): void;
42
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
43
+ protected _handleKeyDown: (e: KeyboardEvent) => void;
44
+ /** run externally provided callback (if any) first. Let click propagate to handleClick. */
45
+ protected _handleRemove: (e: Event) => void;
46
+ protected _handleClick: (e: Event) => void;
26
47
  render(): import("lit").TemplateResult<1>;
27
48
  }
@@ -1,51 +1,88 @@
1
1
  import "../icon/icon.js";
2
- import { SkfElement as a } from "../../internal/components/skf-element.js";
3
- import h from "../../styles/component.styles.js";
4
- import { html as s, nothing as f } from "lit";
5
- import { property as e } from "lit/decorators.js";
2
+ import { SkfElement as u } from "../../internal/components/skf-element.js";
3
+ import d from "../../styles/component.styles.js";
4
+ import { html as a, nothing as m } from "lit";
5
+ import { property as s, query as f } from "lit/decorators.js";
6
6
  import { ifDefined as v } from "lit/directives/if-defined.js";
7
- import { styles as u } from "./tag.styles.js";
8
- var d = Object.defineProperty, r = (m, p, l, y) => {
9
- for (var t = void 0, i = m.length - 1, c; i >= 0; i--)
10
- (c = m[i]) && (t = c(p, l, t) || t);
11
- return t && d(p, l, t), t;
7
+ import { styles as k } from "./tag.styles.js";
8
+ var y = Object.defineProperty, C = Object.getOwnPropertyDescriptor, r = (p, e, i, n) => {
9
+ for (var t = n > 1 ? void 0 : n ? C(e, i) : e, l = p.length - 1, c; l >= 0; l--)
10
+ (c = p[l]) && (t = (n ? c(e, i, t) : c(t)) || t);
11
+ return n && t && y(e, i, t), t;
12
12
  };
13
- const n = class n extends a {
13
+ const h = class h extends u {
14
14
  constructor() {
15
- super(...arguments), this.size = "md", this._remove = () => {
16
- this.remove();
15
+ super(...arguments), this.size = "md", this._handleKeyDown = (e) => {
16
+ (e.key === "Enter" || e.key === " ") && this.$removeButton.click();
17
+ }, this._handleRemove = (e) => {
18
+ this._onRemove && this._onRemove(e);
19
+ }, this._handleClick = (e) => {
20
+ var t;
21
+ e.stopPropagation();
22
+ const i = e.composedPath()[0];
23
+ console.log("$clickTarget", i), i.localName === "button" ? this.remove() : (t = this.onClick) == null || t.call(this, e);
17
24
  };
18
25
  }
26
+ set onClick(e) {
27
+ e && (this._onClick = e);
28
+ }
29
+ get onClick() {
30
+ return this._onClick;
31
+ }
32
+ set onRemove(e) {
33
+ e && (this._onRemove = e);
34
+ }
35
+ get onRemove() {
36
+ return this._onRemove;
37
+ }
38
+ connectedCallback() {
39
+ super.connectedCallback(), this.addEventListener("click", this._handleClick);
40
+ }
41
+ disconnectedCallback() {
42
+ super.disconnectedCallback(), this.removeEventListener("click", this._handleClick);
43
+ }
44
+ attributeChangedCallback(e, i, n) {
45
+ super.attributeChangedCallback(e, i, n), e === "removable" && n !== null ? this.addEventListener("keydown", this._handleKeyDown) : this.removeEventListener("keydown", this._handleKeyDown);
46
+ }
19
47
  render() {
20
- return s`
21
- <div id="tag">
22
- ${this.icon ? s`<skf-icon color=${v(this.color)} name=${this.icon} size="sm"></skf-icon>` : f}
48
+ return a`
49
+ <div id="root">
50
+ ${this.icon ? a`<skf-icon color=${v(this.color)} name=${this.icon} size="sm"></skf-icon>` : m}
23
51
  <span>
24
52
  <slot></slot>
25
53
  </span>
26
- ${this.removable ? s`
27
- <button @click=${this._remove} type="button">
28
- <skf-icon name="close" size="sm"></skf-icon>
54
+ ${this.removable ? a`
55
+ <button @click=${this._handleRemove} type="button">
56
+ <skf-icon name="close" size="xs"></skf-icon>
29
57
  </button>
30
- ` : f}
58
+ ` : m}
31
59
  </div>
32
60
  `;
33
61
  }
34
62
  };
35
- n.styles = [h, u];
36
- let o = n;
63
+ h.styles = [d, k];
64
+ let o = h;
65
+ r([
66
+ s({ reflect: !0 })
67
+ ], o.prototype, "size", 2);
68
+ r([
69
+ s()
70
+ ], o.prototype, "icon", 2);
71
+ r([
72
+ s({ reflect: !0 })
73
+ ], o.prototype, "color", 2);
37
74
  r([
38
- e({ reflect: !0 })
39
- ], o.prototype, "size");
75
+ s({ attribute: !1 })
76
+ ], o.prototype, "onClick", 1);
40
77
  r([
41
- e()
42
- ], o.prototype, "icon");
78
+ s({ attribute: !1 })
79
+ ], o.prototype, "onRemove", 1);
43
80
  r([
44
- e({ reflect: !0 })
45
- ], o.prototype, "color");
81
+ s({ type: Boolean, reflect: !0 })
82
+ ], o.prototype, "removable", 2);
46
83
  r([
47
- e({ type: Boolean })
48
- ], o.prototype, "removable");
84
+ f("button")
85
+ ], o.prototype, "$removeButton", 2);
49
86
  export {
50
87
  o as SkfTag
51
88
  };
@@ -1,11 +1,7 @@
1
1
  import { css as r } from "lit";
2
2
  const s = r`
3
3
  @layer components {
4
- :host {
5
- display: contents;
6
- }
7
-
8
- #tag {
4
+ #root {
9
5
  align-items: center;
10
6
  background-color: var(--_skf-tag-bg-color, var(--skf-bg-color-neutral-1));
11
7
  block-size: var(--_skf-tag-height, var(--skf-size-32));
@@ -59,6 +55,11 @@ const s = r`
59
55
 
60
56
  button {
61
57
  display: flex;
58
+
59
+ &:focus-visible {
60
+ border-radius: var(--skf-border-radius-sm);
61
+ outline: var(--skf-border-width-md) solid var(--skf-interactive-border-color-focus);
62
+ }
62
63
  }
63
64
  }
64
65
  `;
@@ -12,7 +12,7 @@ interface SkfTextAreaProps extends Omit<FormFieldBaseProps, 'type'> {
12
12
  /**
13
13
  * The skf-textarea is used to create a textarea. Use it inside a form element or wherever you like.
14
14
  *
15
- * @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/619e4125b3d2147c0c584b11) for design principles.
15
+ * @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/143f9d-text-area) for design principles.
16
16
  *
17
17
  * @attribute {boolean} disabled - If true, sets disabled state
18
18
  * @attribute {boolean} required - If true, value is required or must be checked for the form to be submittable
@@ -20,48 +20,51 @@ interface SkfTextAreaProps extends Omit<FormFieldBaseProps, 'type'> {
20
20
  * @event change - Fires when the value of the input changes
21
21
  * @event invalid - Fires when the input is invalid
22
22
  *
23
- * @slot The textareas label. Alternatively, you can use the `label` attribute.
23
+ * @slot - The textareas label. Alternatively, you can use the `label` attribute.
24
24
  *
25
25
  * @tagname skf-textarea
26
26
  */
27
27
  export declare class SkfTextArea extends FormBase implements SkfTextAreaProps {
28
28
  static styles: CSSResultGroup;
29
29
  private customError;
30
- /** If provided, sets the cols of the textarea */
31
- cols?: number | undefined;
32
- /** If provided, forces component to invalid state until removed. Its value is used as hint text. */
30
+ /** If defined, sets the cols of the textarea */
31
+ cols?: number;
32
+ /** If defined, forces component to invalid state until removed. Its value is used as hint text. */
33
33
  set customInvalid(value: string | undefined);
34
34
  get customInvalid(): string | undefined;
35
- /** If provided, outputs helping hints in console */
36
- debug: boolean;
37
- /** hide-label - If true, hides the label visually */
38
- hideLabel: boolean;
39
- /** If provided, displays informational text below the field */
35
+ /** If true, outputs helping hints in console */
36
+ debug?: boolean;
37
+ /** If true, hides the label visually */
38
+ hideLabel?: boolean;
39
+ /** If defined, displays informational text below the field */
40
40
  hint?: string;
41
- /** The input's label. Alternatively, you can use the component slot. */
42
- label: string;
43
- /** If provided, adds name to the input-element */
41
+ /** If defined, sets the input's label unless the default slot is used. Alternatively, you can use the `label` attribute. */
42
+ label?: string;
43
+ /** If defined, adds name to the input-element */
44
44
  name?: string;
45
- /** If provided, sets the maximum character length to accept for this input */
45
+ /** If defined, sets the maximum character length to accept for this input */
46
46
  maxLength?: number;
47
- /** If provided, sets the minimum character length to accept for this input */
47
+ /** If defined, sets the minimum character length to accept for this input */
48
48
  minLength?: number;
49
- /** If provided, displays placeholder text */
49
+ /** If defined, displays placeholder text */
50
50
  placeholder?: string;
51
51
  /** If true, makes the element not mutable, meaning the user can not edit the control */
52
52
  readonly?: boolean;
53
- /** If provided, renders an alternative A11y text for the asterisk */
53
+ /** If defined, renders an alternative A11y text for the asterisk */
54
54
  requiredLabel?: string;
55
- /** If provided, sets the rows of the textarea */
56
- rows?: number | undefined;
57
- /** @type { "success" | "error" } - If provided, displays provided severity state */
55
+ /** If defined, sets the rows of the textarea */
56
+ rows?: number;
57
+ /**
58
+ * If defined, displays provided severity state
59
+ * @type {"success" | "info" | "warning" | "alert"}
60
+ */
58
61
  severity?: SkfTextAreaProps['severity'];
59
62
  /** If true, displays valid state after interaction */
60
63
  showValid?: boolean;
61
- /** If provided, displays an alternative size */
64
+ /** Size of the Textarea */
62
65
  size?: 'sm' | 'md';
63
- /** If provided, sets validation start, "input", "change" or "submit" */
64
- validateOn?: 'input' | 'change' | 'submit';
66
+ /** Sets validation start */
67
+ validateOn: 'input' | 'change' | 'submit';
65
68
  /** The current value of the text area */
66
69
  value: string;
67
70
  /** @internal */
@@ -14,7 +14,7 @@ var $ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, e = (h, t, s
14
14
  };
15
15
  const u = class u extends m {
16
16
  constructor() {
17
- super(...arguments), this.cols = 20, this.debug = !1, this.hideLabel = !1, this.label = "Default label", this.rows = 2, this.size = "md", this.validateOn = "change", this.value = "", this.invalid = !1, this._resetValue = (t) => {
17
+ super(...arguments), this.size = "md", this.validateOn = "change", this.value = "", this.invalid = !1, this._resetValue = (t) => {
18
18
  var s;
19
19
  t.stopPropagation(), this.value = ((s = this.getAttribute("value")) == null ? void 0 : s.trim()) ?? "", this._internals.setFormValue(this.value), this.$input.focus();
20
20
  }, this._handleInput = () => {
@@ -22,7 +22,7 @@ const u = class u extends m {
22
22
  };
23
23
  }
24
24
  set customInvalid(t) {
25
- this.customError = String(t);
25
+ this.customError = t || "";
26
26
  }
27
27
  get customInvalid() {
28
28
  return this.customError;
@@ -78,14 +78,15 @@ const u = class u extends m {
78
78
  render() {
79
79
  var t, s;
80
80
  return p`
81
- <div id="field">
81
+ <div id="root">
82
82
  <label>
83
83
  <div class=${this.hideLabel ? "visually-hidden" : ""} id="label">
84
- ${this.label} ${this.required ? c(this.requiredLabel) : null}
84
+ <slot>${this.label}</slot> ${this.required ? c(this.requiredLabel) : null}
85
85
  </div>
86
86
  <div id="input">
87
87
  <textarea
88
88
  ?disabled=${this.disabled}
89
+ ?readonly=${this.readonly}
89
90
  ?required=${this.required}
90
91
  .value=${this.value}
91
92
  @input=${this._handleInput}
@@ -93,22 +94,24 @@ const u = class u extends m {
93
94
  aria-errormessage=${n((s = this.hint) != null && s.trim() ? "hint" : v)}
94
95
  aria-invalid=${!!this.invalid}
95
96
  cols=${n(this.cols)}
96
- name=${n(this.name)}
97
97
  maxlength=${n(this.maxLength)}
98
98
  minlength=${n(this.minLength)}
99
+ name=${n(this.name)}
99
100
  placeholder=${n(this.placeholder)}
100
- ?readonly=${this.readonly}
101
101
  rows=${n(this.rows)}
102
102
  >
103
103
  </textarea>
104
104
  </div>
105
105
  </label>
106
- ${this.hint && p`<skf-hint
107
- aria-live=${this.invalid ? "assertive" : "polite"}
108
- id="hint"
109
- severity=${n(_(this.severity, this.invalid))}
110
- >${this.hint}</skf-hint
111
- >`}
106
+ ${this.hint && p`
107
+ <skf-hint
108
+ aria-live=${this.invalid ? "assertive" : "polite"}
109
+ id="hint"
110
+ severity=${n(_(this.severity, this.invalid))}
111
+ >
112
+ ${this.customInvalid ? this.customInvalid : this.hint}
113
+ </skf-hint>
114
+ `}
112
115
  </div>
113
116
  `;
114
117
  }