@skf-design-system/ui-components 0.0.1-beta.4 → 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 (102) 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 -4
  6. package/dist/components/alert/alert.component.js +1 -1
  7. package/dist/components/alert/alert.styles.js +1 -1
  8. package/dist/components/button/button.component.js +1 -1
  9. package/dist/components/button/button.styles.js +1 -1
  10. package/dist/components/card/card.component.d.ts +3 -3
  11. package/dist/components/card/card.component.js +16 -19
  12. package/dist/components/card/card.styles.js +11 -3
  13. package/dist/components/checkbox/checkbox.component.d.ts +9 -6
  14. package/dist/components/checkbox/checkbox.component.js +8 -8
  15. package/dist/components/checkbox/checkbox.styles.js +1 -1
  16. package/dist/components/checkbox/checkbox.test.d.ts +1 -0
  17. package/dist/components/collapse/collapse.component.d.ts +9 -6
  18. package/dist/components/collapse/collapse.component.js +39 -36
  19. package/dist/components/collapse/collapse.styles.js +3 -3
  20. package/dist/components/collapse/collapse.test.d.ts +1 -0
  21. package/dist/components/divider/divider.component.d.ts +13 -10
  22. package/dist/components/divider/divider.component.js +34 -29
  23. package/dist/components/divider/divider.styles.js +1 -5
  24. package/dist/components/heading/heading.component.d.ts +12 -2
  25. package/dist/components/heading/heading.component.js +14 -14
  26. package/dist/components/heading/heading.styles.js +1 -1
  27. package/dist/components/icon/icon.component.d.ts +14 -8
  28. package/dist/components/icon/icon.component.js +6 -6
  29. package/dist/components/icon/icon.styles.js +1 -1
  30. package/dist/components/input/input.component.d.ts +34 -29
  31. package/dist/components/input/input.component.js +36 -36
  32. package/dist/components/link/link.component.d.ts +15 -12
  33. package/dist/components/link/link.component.js +7 -7
  34. package/dist/components/link/link.styles.js +1 -1
  35. package/dist/components/loader/loader.component.d.ts +7 -7
  36. package/dist/components/loader/loader.component.js +35 -61
  37. package/dist/components/loader/loader.styles.js +42 -10
  38. package/dist/components/logo/logo.component.d.ts +5 -3
  39. package/dist/components/logo/logo.component.js +8 -8
  40. package/dist/components/logo/logo.styles.js +2 -2
  41. package/dist/components/radio/radio.component.d.ts +15 -13
  42. package/dist/components/radio/radio.component.js +3 -3
  43. package/dist/components/radio/radio.styles.js +3 -3
  44. package/dist/components/select/select.component.d.ts +137 -0
  45. package/dist/components/select/select.component.js +311 -0
  46. package/dist/components/select/select.controllers.d.ts +59 -0
  47. package/dist/components/select/select.controllers.js +169 -0
  48. package/dist/components/select/select.d.ts +8 -0
  49. package/dist/components/select/select.js +6 -0
  50. package/dist/components/select/select.styles.d.ts +1 -0
  51. package/dist/components/select/select.styles.js +116 -0
  52. package/dist/components/select-option/select-option.component.d.ts +77 -0
  53. package/dist/components/select-option/select-option.component.js +117 -0
  54. package/dist/components/select-option/select-option.controllers.d.ts +9 -0
  55. package/dist/components/select-option/select-option.d.ts +8 -0
  56. package/dist/components/select-option/select-option.js +6 -0
  57. package/dist/components/select-option/select-option.styles.d.ts +1 -0
  58. package/dist/components/select-option/select-option.styles.js +53 -0
  59. package/dist/components/select-option-group/select-option-group.component.d.ts +16 -0
  60. package/dist/components/select-option-group/select-option-group.component.js +31 -0
  61. package/dist/components/select-option-group/select-option-group.d.ts +8 -0
  62. package/dist/components/select-option-group/select-option-group.js +6 -0
  63. package/dist/components/select-option-group/select-option-group.style.d.ts +1 -0
  64. package/dist/components/select-option-group/select-option-group.style.js +18 -0
  65. package/dist/components/switch/switch.component.d.ts +2 -3
  66. package/dist/components/switch/switch.component.js +1 -1
  67. package/dist/components/switch/switch.styles.js +1 -1
  68. package/dist/components/switch/switch.test.d.ts +1 -0
  69. package/dist/components/tag/tag.component.d.ts +25 -4
  70. package/dist/components/tag/tag.component.js +66 -29
  71. package/dist/components/tag/tag.styles.js +6 -5
  72. package/dist/components/textarea/textarea.component.d.ts +26 -23
  73. package/dist/components/textarea/textarea.component.js +15 -12
  74. package/dist/custom-elements.json +960 -305
  75. package/dist/index.d.ts +3 -0
  76. package/dist/index.js +39 -30
  77. package/dist/internal/components/formBase.d.ts +18 -1
  78. package/dist/internal/components/formBase.js +25 -13
  79. package/dist/internal/components/skf-element.d.ts +4 -4
  80. package/dist/internal/components/skf-element.js +15 -19
  81. package/dist/internal/helpers/array.d.ts +4 -0
  82. package/dist/internal/helpers/findMatchingTags.d.ts +2 -0
  83. package/dist/internal/helpers/findMatchingTags.js +12 -0
  84. package/dist/internal/helpers/hintSeverity.d.ts +2 -0
  85. package/dist/internal/helpers/hintSeverity.js +6 -0
  86. package/dist/internal/helpers/raiseError.d.ts +28 -0
  87. package/dist/internal/helpers/raiseError.js +29 -0
  88. package/dist/internal/storybook/shadowRootTraverser.d.ts +16 -6
  89. package/dist/react/index.d.ts +3 -0
  90. package/dist/react/index.js +3 -0
  91. package/dist/react/skf-select/index.d.ts +21 -0
  92. package/dist/react/skf-select/index.js +21 -0
  93. package/dist/react/skf-select-option/index.d.ts +9 -0
  94. package/dist/react/skf-select-option/index.js +17 -0
  95. package/dist/react/skf-select-option-group/index.d.ts +3 -0
  96. package/dist/react/skf-select-option-group/index.js +13 -0
  97. package/dist/styles/form-field.styles.js +7 -7
  98. package/dist/types/jsx/custom-element-jsx.d.ts +290 -140
  99. package/dist/types/vue/index.d.ts +223 -90
  100. package/dist/vscode.html-custom-data.json +294 -97
  101. package/dist/web-types.json +614 -242
  102. package/package.json +34 -30
@@ -0,0 +1,77 @@
1
+ import { SkfElement } from '@internal/components/skf-element.js';
2
+ import type { IconColor } from '@skf-design-system/ui-assets';
3
+ import { type CSSResultGroup } from 'lit';
4
+ import '../icon/icon';
5
+ import { SkfIcon } from '../icon/icon';
6
+ import type { SkfSelect } from '../select/select.component.js';
7
+ export interface SelectOptionEvent {
8
+ value: string | null;
9
+ option: SkfSelectOption;
10
+ }
11
+ /**
12
+ * The `<skf-select-option>` is a component is used nested in a skf-select or skf-select-option-group.
13
+ *
14
+ * @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
15
+ *
16
+ * @slot - The option's text content
17
+ * @slot icon - The option's slot for icon or custom meta information (svg).
18
+ *
19
+ * @event skf-select-option:select - {detail: { value: string | null, option: SkfSelectOption }} Fires when the option is selected/deselected.
20
+ *
21
+ * @tagname skf-select-option
22
+ */
23
+ export declare class SkfSelectOption extends SkfElement {
24
+ static styles: CSSResultGroup;
25
+ static shadowRootOptions: {
26
+ delegatesFocus: boolean;
27
+ mode: ShadowRootMode;
28
+ serializable?: boolean;
29
+ slotAssignment?: SlotAssignmentMode;
30
+ };
31
+ /** @internal */
32
+ _parent: SkfSelect | null;
33
+ /** @internal */
34
+ protected _value?: string;
35
+ /**
36
+ * @internal
37
+ * Do not use directly, instead use `setSelectedDiscrete`.
38
+ * If true, instantly sets/unsets the selected property, without engaging ui feedback. Primarily for unselecting previous option in single select.
39
+ */
40
+ _shortcutUpdate?: boolean;
41
+ /** If true, prevents interaction with the option */
42
+ disabled?: boolean;
43
+ /** If defined, set an icon */
44
+ icon?: SkfIcon['name'];
45
+ /** If defined, sets provided color on the icon */
46
+ iconColor?: IconColor;
47
+ /** If true, sets the option as selected */
48
+ selected?: boolean;
49
+ /** If defined, sets a short label */
50
+ shortLabel?: string;
51
+ /** The option's label text (equivalent to the tags textContent) */
52
+ set text(slottedTextContent: string);
53
+ get text(): string;
54
+ /** Returns or sets the tags value. If value is omitted, defaults to the tags text. */
55
+ set value(optionValue: string);
56
+ get value(): string;
57
+ /** @internal */
58
+ private _assignedNodes?;
59
+ constructor();
60
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
61
+ /**
62
+ * @internal
63
+ * This internal setter is to change selected state without emitting events triggering other side effects,
64
+ * e.g deselecting previous selected in a single select. Is used by skf-select in single select mode.
65
+ */
66
+ set setSelectedDiscrete(value: boolean);
67
+ /**
68
+ * @internal
69
+ * Returns the slotted content as a string. If no slotted content, returns an empty string.
70
+ */
71
+ private _getSlottedContent;
72
+ /** @internal */
73
+ private get _slotContainsOnlyText();
74
+ /** @internal */
75
+ _handleClick: (e: Event) => void;
76
+ render(): import("lit").TemplateResult<1>;
77
+ }
@@ -0,0 +1,117 @@
1
+ import { SkfElement as p } from "../../internal/components/skf-element.js";
2
+ import u from "../../styles/component.styles.js";
3
+ import { LitElement as f, html as h } from "lit";
4
+ import { property as n, queryAssignedNodes as m } from "lit/decorators.js";
5
+ import { ifDefined as _ } from "lit/directives/if-defined.js";
6
+ import "../icon/icon.js";
7
+ import { styles as y } from "./select-option.styles.js";
8
+ var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (d, t, s, i) => {
9
+ for (var r = i > 1 ? void 0 : i ? b(t, s) : t, a = d.length - 1, c; a >= 0; a--)
10
+ (c = d[a]) && (r = (i ? c(t, s, r) : c(r)) || r);
11
+ return i && r && v(t, s, r), r;
12
+ };
13
+ const l = class l extends p {
14
+ constructor() {
15
+ super(), this._handleClick = (s) => {
16
+ s.stopPropagation(), this.selected = !this.selected;
17
+ };
18
+ const t = this.attachInternals();
19
+ t.role = "option", this._parent = this.closest("skf-select"), this._shortcutUpdate = !1;
20
+ }
21
+ set text(t) {
22
+ this.textContent = t.trim();
23
+ }
24
+ get text() {
25
+ var t;
26
+ return ((t = this.textContent) == null ? void 0 : t.trim()) ?? "";
27
+ }
28
+ set value(t) {
29
+ this._value = t.trim();
30
+ }
31
+ get value() {
32
+ var t;
33
+ return !this._value && this._slotContainsOnlyText ? this._getSlottedContent().trim() : ((t = this._value) == null ? void 0 : t.trim()) ?? this.text;
34
+ }
35
+ updated(t) {
36
+ super.updated(t), t.has("selected") && !this._shortcutUpdate && this.emit("skf-select-option:select", {
37
+ detail: {
38
+ value: this.selected ? this.value : null,
39
+ option: this
40
+ }
41
+ });
42
+ }
43
+ /**
44
+ * @internal
45
+ * This internal setter is to change selected state without emitting events triggering other side effects,
46
+ * e.g deselecting previous selected in a single select. Is used by skf-select in single select mode.
47
+ */
48
+ set setSelectedDiscrete(t) {
49
+ (async () => {
50
+ this._shortcutUpdate = !0, this.selected = t, await this.updateComplete, this._shortcutUpdate = !1;
51
+ })();
52
+ }
53
+ /**
54
+ * @internal
55
+ * Returns the slotted content as a string. If no slotted content, returns an empty string.
56
+ */
57
+ _getSlottedContent() {
58
+ return this._assignedNodes ? [...this._assignedNodes].map((t) => t.nodeType === Node.ELEMENT_NODE ? t.outerHTML : t.textContent).join() : "";
59
+ }
60
+ /** @internal */
61
+ get _slotContainsOnlyText() {
62
+ return this._assignedNodes ? [...this._assignedNodes].every(
63
+ (s) => {
64
+ var i;
65
+ return s.nodeType === Node.TEXT_NODE && ((i = s.textContent) == null ? void 0 : i.trim()) !== "";
66
+ }
67
+ ) : "";
68
+ }
69
+ render() {
70
+ return h`
71
+ <button
72
+ @click=${this._handleClick}
73
+ aria-selected=${this.selected ? "true" : "false"}
74
+ ?disabled=${this.disabled}
75
+ role="option"
76
+ >
77
+ <skf-icon id="icon-check" name="check" size="sm"></skf-icon>
78
+ <slot>${this.text}</slot>
79
+ <div id="adornments">
80
+ <slot name="icon">
81
+ ${this.icon && h`<skf-icon name=${this.icon} color=${_(this.iconColor)}></skf-icon>`}
82
+ </slot>
83
+ ${this.shortLabel && h`<div id="short-label">${this.shortLabel}</div>`}
84
+ </div>
85
+ </button>
86
+ `;
87
+ }
88
+ };
89
+ l.styles = [u, y], l.shadowRootOptions = { ...f.shadowRootOptions, delegatesFocus: !0 };
90
+ let e = l;
91
+ o([
92
+ n({ type: Boolean, reflect: !0 })
93
+ ], e.prototype, "disabled", 2);
94
+ o([
95
+ n({ reflect: !0 })
96
+ ], e.prototype, "icon", 2);
97
+ o([
98
+ n({ reflect: !0, attribute: "icon-color" })
99
+ ], e.prototype, "iconColor", 2);
100
+ o([
101
+ n({ type: Boolean, reflect: !0 })
102
+ ], e.prototype, "selected", 2);
103
+ o([
104
+ n({ reflect: !0, attribute: "short-label" })
105
+ ], e.prototype, "shortLabel", 2);
106
+ o([
107
+ n({ attribute: !1 })
108
+ ], e.prototype, "text", 1);
109
+ o([
110
+ n({ reflect: !0 })
111
+ ], e.prototype, "value", 1);
112
+ o([
113
+ m({ flatten: !0 })
114
+ ], e.prototype, "_assignedNodes", 2);
115
+ export {
116
+ e as SkfSelectOption
117
+ };
@@ -0,0 +1,9 @@
1
+ import type { SkfSelectOption } from '@components/select-option/select-option.component.js';
2
+ import type { ReactiveController } from 'lit';
3
+ type ControllerHost = SkfSelectOption;
4
+ export declare class DeveloperFeedbackController implements ReactiveController {
5
+ host: ControllerHost;
6
+ constructor(host: ControllerHost);
7
+ hostUpdated(): void;
8
+ }
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SkfSelectOption } from './select-option.component.js';
2
+ export * from './select-option.component.js';
3
+ export default SkfSelectOption;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'skf-select-option': SkfSelectOption;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { SkfSelectOption as e } from "./select-option.component.js";
2
+ e.define("skf-select-option");
3
+ export {
4
+ e as SkfSelectOption,
5
+ e as default
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,53 @@
1
+ import { css as e } from "lit";
2
+ const o = e`
3
+ @layer components {
4
+ button {
5
+ align-items: center;
6
+ background-color: var(--_skf-select-option-bg, var(--skf-interactive-bg-color-secondary));
7
+ block-size: var(--_skf-select-option-height, var(--skf-size-44));
8
+ color: var(--_skf-select-option-color, inherit);
9
+ display: flex;
10
+ gap: var(--skf-spacing-50);
11
+ padding-inline: var(--skf-spacing-50);
12
+ width: 100%;
13
+
14
+ &:disabled {
15
+ --_skf-select-option-color: var(--skf-interactive-text-color-disabled);
16
+ }
17
+
18
+ &:is(:hover, :focus):not(:disabled) {
19
+ --_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-hover);
20
+ }
21
+
22
+ &:active:not(:disabled) {
23
+ --_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-active);
24
+ }
25
+
26
+ :host-context(skf-select[size='sm']) & {
27
+ --_skf-select-option-height: var(--skf-size-32);
28
+ }
29
+ }
30
+
31
+ #icon-check {
32
+ opacity: 0;
33
+
34
+ :host([selected]) & {
35
+ opacity: 1;
36
+ }
37
+ }
38
+
39
+ #adornments {
40
+ align-items: inherit;
41
+ display: inherit;
42
+ gap: inherit;
43
+ margin-inline-start: auto;
44
+ }
45
+
46
+ #short-label {
47
+ color: var(--skf-text-color-tertiary);
48
+ }
49
+ }
50
+ `;
51
+ export {
52
+ o as styles
53
+ };
@@ -0,0 +1,16 @@
1
+ import { SkfElement } from '@internal/components/skf-element';
2
+ import { type CSSResultGroup } from 'lit';
3
+ /**
4
+ * The `<skf-select-option-group>` is a component that groups select-options
5
+ *
6
+ * @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
7
+ *
8
+ * @slot - The component's placeholder content
9
+ *
10
+ * @tagname skf-select-option-group
11
+ */
12
+ export declare class SkfSelectOptionGroup extends SkfElement {
13
+ static styles: CSSResultGroup;
14
+ label: string;
15
+ render(): import("lit").TemplateResult<1>;
16
+ }
@@ -0,0 +1,31 @@
1
+ import { SkfElement as a } from "../../internal/components/skf-element.js";
2
+ import f from "../../styles/component.styles.js";
3
+ import { html as p } from "lit";
4
+ import { property as d } from "lit/decorators.js";
5
+ import { styles as n } from "./select-option-group.style.js";
6
+ var v = Object.defineProperty, u = (o, s, i, b) => {
7
+ for (var r = void 0, e = o.length - 1, m; e >= 0; e--)
8
+ (m = o[e]) && (r = m(s, i, r) || r);
9
+ return r && v(s, i, r), r;
10
+ };
11
+ const l = class l extends a {
12
+ constructor() {
13
+ super(...arguments), this.label = "Default label";
14
+ }
15
+ render() {
16
+ return p`
17
+ <div role="group">
18
+ <div id="label">${this.label}</div>
19
+ <slot></slot>
20
+ </div>
21
+ `;
22
+ }
23
+ };
24
+ l.styles = [f, n];
25
+ let t = l;
26
+ u([
27
+ d({ reflect: !0 })
28
+ ], t.prototype, "label");
29
+ export {
30
+ t as SkfSelectOptionGroup
31
+ };
@@ -0,0 +1,8 @@
1
+ import { SkfSelectOptionGroup } from './select-option-group.component';
2
+ export * from './select-option-group.component';
3
+ export default SkfSelectOptionGroup;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'skf-select-option-group': SkfSelectOptionGroup;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { SkfSelectOptionGroup as e } from "./select-option-group.component.js";
2
+ e.define("skf-select-option-group");
3
+ export {
4
+ e as SkfSelectOptionGroup,
5
+ e as default
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,18 @@
1
+ import { css as e } from "lit";
2
+ const t = e`
3
+ @layer components {
4
+ #label {
5
+ align-items: center;
6
+ block-size: var(--_skf-select-option-group-height, var(--skf-size-44));
7
+ display: flex;
8
+ font-weight: var(--skf-font-weight-bold);
9
+
10
+ :host-context(skf-select[size='sm']) & {
11
+ --_skf-select-option-group-height: var(--skf-size-32);
12
+ }
13
+ }
14
+ }
15
+ `;
16
+ export {
17
+ t as styles
18
+ };
@@ -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;
@@ -48,7 +48,7 @@ const h = class h extends o {
48
48
  }
49
49
  render() {
50
50
  return c`
51
- <label id="switch">
51
+ <label id="root">
52
52
  <input
53
53
  ?checked=${this.checked}
54
54
  ?disabled=${this.disabled}
@@ -8,7 +8,7 @@ const t = [
8
8
  contain: layout;
9
9
  }
10
10
 
11
- label {
11
+ #root {
12
12
  align-items: center;
13
13
  display: flex;
14
14
  grid-gap: var(--skf-spacing-50);
@@ -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
  `;