scb-wc-test 0.1.76 → 0.1.78

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.
@@ -1,97 +1,161 @@
1
- import { css as m, LitElement as d, html as i } from "lit";
2
- import { property as o, customElement as h } from "lit/decorators.js";
1
+ import { css as m, LitElement as p, html as r } from "lit";
2
+ import { property as i, customElement as b } from "lit/decorators.js";
3
3
  import "@material/web/icon/icon.js";
4
- var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, e = (p, s, n, l) => {
5
- for (var r = l > 1 ? void 0 : l ? b(s, n) : s, a = p.length - 1, c; a >= 0; a--)
6
- (c = p[a]) && (r = (l ? c(s, n, r) : c(r)) || r);
7
- return l && r && v(s, n, r), r;
4
+ import "@material/web/ripple/ripple.js";
5
+ import "@material/web/focus/md-focus-ring.js";
6
+ var h = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (e, a, n, o) => {
7
+ for (var l = o > 1 ? void 0 : o ? v(a, n) : a, c = e.length - 1, d; c >= 0; c--)
8
+ (d = e[c]) && (l = (o ? d(a, n, l) : d(l)) || l);
9
+ return o && l && h(a, n, l), l;
8
10
  };
9
- let t = class extends d {
11
+ let t = class extends p {
10
12
  constructor() {
11
- super(...arguments), this.label = "", this.symbolVariant = "number", this.number = 0, this.active = !1, this.completed = !1, this.changeOnCompleted = !1, this.islast = !1, this.variant = "horizontal", this.icon = "";
13
+ super(...arguments), this.label = "", this.subLabel = "", this.symbolVariant = "number", this.number = 0, this.active = !1, this.completed = !1, this.changeOnCompleted = !1, this.islast = !1, this.variant = "horizontal", this.icon = "";
14
+ }
15
+ updated() {
16
+ !this.subLabel || this.subLabel.trim() === "" ? this.setAttribute("no-content", "") : this.removeAttribute("no-content");
17
+ }
18
+ handleKeyDown(e) {
19
+ e.key === "Enter" || e.key === " " ? (e.preventDefault(), this.dispatchEvent(new MouseEvent("click", { bubbles: !0, composed: !0 }))) : (e.key === "ArrowRight" || e.key === "ArrowLeft") && (this.dispatchEvent(new CustomEvent("scb-stepper-keynav", {
20
+ detail: { key: e.key },
21
+ bubbles: !0,
22
+ composed: !0
23
+ })), e.preventDefault());
12
24
  }
13
25
  render() {
26
+ const e = this.active ? "step" : void 0, a = this.label ? `${this.label}${this.subLabel ? ": " + this.subLabel : ""}` : void 0;
14
27
  switch (this.symbolVariant) {
15
28
  case "icon":
16
- return i`
17
- <div class="symbol">
18
- ${this.completed && this.changeOnCompleted ? i`<md-icon>check</md-icon>` : i`<md-icon>${this.icon}</md-icon>`}
19
- </div>
20
-
21
- <div class="content">
22
- <div class="label">${this.label}</div>
23
- <slot></slot>
24
- </div>
25
- `;
29
+ return r`
30
+ <div
31
+ class="scb-step-content"
32
+ tabindex="0"
33
+ role="listitem"
34
+ aria-current=${e}
35
+ aria-label=${a}
36
+ @keydown=${this.handleKeyDown}
37
+ >
38
+ <md-ripple></md-ripple>
39
+ <div class="symbol">
40
+ ${this.completed && this.changeOnCompleted ? r`<md-icon>check</md-icon>` : r`<md-icon>${this.icon}</md-icon>`}
41
+ </div>
42
+ <div class="content">
43
+ <div class="label">${this.label}</div>
44
+ <div class="sub-label">${this.subLabel}</div>
45
+ </div>
46
+ <md-focus-ring></md-focus-ring>
47
+ </div>
48
+ `;
26
49
  case "marker":
27
- return i`
28
- <div class="symbol">
29
- </div>
30
- <div class="content">
31
- <div class="label">${this.label}</div>
32
- <slot></slot>
33
- </div>
34
- `;
50
+ return r`
51
+ <div
52
+ class="scb-step-content"
53
+ tabindex="0"
54
+ role="listitem"
55
+ aria-current=${e}
56
+ aria-label=${a}
57
+ @keydown=${this.handleKeyDown}
58
+ >
59
+ <md-ripple></md-ripple>
60
+ <div class="symbol">
61
+ ${this.completed && this.changeOnCompleted ? r`<md-icon>check</md-icon>` : r``}
62
+ </div>
63
+ <div class="content">
64
+ <div class="label">${this.label}</div>
65
+ <div class="sub-label">${this.subLabel}</div>
66
+ </div>
67
+ <md-focus-ring></md-focus-ring>
68
+ </div>
69
+ `;
35
70
  default:
36
- return i`
37
- <div class="symbol">
38
- ${this.completed && this.changeOnCompleted ? i`<md-icon>check</md-icon>` : i`<span>${this.number}</span>`}
39
- </div>
40
- <div class="content">
41
- <div class="label">${this.label}</div>
42
- <slot></slot>
43
- </div>
44
- `;
71
+ return r`
72
+ <div
73
+ class="scb-step-content"
74
+ tabindex="0"
75
+ role="listitem"
76
+ aria-current=${e}
77
+ aria-label=${a}
78
+ @keydown=${this.handleKeyDown}
79
+ >
80
+ <md-ripple></md-ripple>
81
+ <div class="symbol">
82
+ ${this.completed && this.changeOnCompleted ? r`<md-icon>check</md-icon>` : r`<span>${this.number}</span>`}
83
+ </div>
84
+ <div class="content">
85
+ <div class="label">${this.label}</div>
86
+ <div class="sub-label">${this.subLabel}</div>
87
+ </div>
88
+ <md-focus-ring></md-focus-ring>
89
+ </div>
90
+ `;
45
91
  }
46
92
  }
47
93
  };
48
94
  t.styles = m`
49
95
  :host {
50
- display: flex;
51
- flex-direction: column;
52
- align-items: center;
53
- min-width: 80px;
54
- flex: 1 1 0;
55
- cursor: pointer;
56
- background: none;
57
- box-sizing: border-box;
58
- user-select: none;
59
-
60
- }
61
-
96
+ font-family: var(--brand-font);
97
+ }
98
+ .scb-step-content {
99
+ width: 100%;
100
+ height: 100%;
101
+ display: flex;
102
+ flex-direction: column;
103
+ align-items: center;
104
+ position: relative;
105
+ flex: 1 1 0;
106
+ cursor: pointer;
107
+ background: none;
108
+ box-sizing: border-box;
109
+ user-select: none;
110
+ padding: var(--spacing-4);
111
+ }
112
+ .scb-step-content:focus,
113
+ .scb-step-content:focus-visible {
114
+ outline: none ;
115
+ box-shadow: none ;
116
+ }
62
117
  .symbol {
63
- background-color: var(--n-70);
64
- color: var(--md-sys-color-on-primary);
65
- border-radius: 50%;
66
- min-width: 32px;
67
- height: 32px;
68
- display: flex;
69
- align-items: center;
70
- justify-content: center;
71
- font-weight: 600;
72
- font-size: 14px;
73
- position: relative;
74
- z-index: 1;
118
+ background-color: var(--md-sys-color-outline-variant);
119
+ color: var(--md-sys-color-on-primary);
120
+ border-radius: var(--md-sys-shape-corner-full);
121
+ min-width: var(--icon-size-medium);
122
+ height: var(--icon-size-medium);
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ font-weight: var(--md-sys-typescale-label-small-weight);
127
+ font-size: var(--md-sys-typescale-label-small-size);
128
+ line-height: var(--md-sys-typescale-label-small-line-height);
129
+ letter-spacing: var(--md-sys-typescale-label-small-tracking);
130
+ position: relative;
131
+ z-index: 1;
132
+ }
133
+ md-focus-ring {
134
+ border-radius: var(--md-sys-shape-corner-small);
75
135
  }
76
136
  md-icon {
77
137
  font-size: 20px;
78
138
  }
79
139
  :host([active]) .symbol {
80
140
  background-color: var(--md-sys-color-primary);
141
+ color: var(--md-sys-color-on-primary);
81
142
  }
82
143
  :host([completed]) .symbol {
83
144
  background-color: var(--md-sys-color-primary);
145
+ color: var(--md-sys-color-on-primary);
84
146
  }
85
147
  .label {
86
- margin-top: 8px;
148
+ margin-top: var(--spacing-3);
87
149
  text-align: center;
88
- font-size: 16px;
89
- color: var(--md-sys-color-on-surface, #222);
150
+ font-size: var(--md-sys-typescale-label-medium-size);
151
+ line-height: var(--md-sys-typescale-label-medium-line-height);
152
+ letter-spacing: var(--md-sys-typescale-label-medium-tracking);
153
+ color: var(--md-sys-color-on-surface);
90
154
  max-width: 90px;
91
155
  word-break: break-word;
92
- margin-bottom: 8px;
156
+ margin-bottom: var(--spacing-3);
93
157
  }
94
- :host([active]) .label, :host([active]) slot {
158
+ :host([active]) .label, :host([active]) .sub-label {
95
159
  font-weight: 600;
96
160
  }
97
161
  .content{
@@ -100,51 +164,73 @@ t.styles = m`
100
164
  align-items: center;
101
165
  }
102
166
  :host([variant="vertical"]) {
103
- flex-direction: row;
104
- align-items: flex-start;
105
- gap: 16px;
106
-
167
+ .scb-step-content {
168
+ flex-direction: row;
169
+ align-items: flex-start;
170
+ gap: var(--spacing-5);
171
+ padding: var(--spacing-4);
172
+ }
173
+ }
174
+ :host([no-content]) {
175
+ .scb-step-content {
176
+ align-items: center;
177
+ .label {
178
+ margin-bottom: 0px;
179
+ }
180
+ }
107
181
  }
108
182
  :host([variant="vertical"]) .label{
109
183
  margin-top: 0;
110
184
  }
111
185
  :host([variant="vertical"]) .content{
112
186
  align-items: flex-start;
187
+
113
188
  }
114
189
  :host([symbol-variant="marker"]) .symbol {
115
190
  min-width: 16px;
116
191
  height: 16px;
117
192
  }
193
+ :host([symbol-variant="marker"][completed][change-on-completed]) .symbol {
194
+ background-color: transparent;
195
+ color: var(--md-sys-color-primary);
196
+ md-icon{
197
+ font-size: var(--icon-size-small);
198
+ }
199
+ }
200
+
118
201
  `;
119
- e([
120
- o({ type: String, reflect: !0 })
202
+ s([
203
+ i({ type: String, reflect: !0 })
121
204
  ], t.prototype, "label", 2);
122
- e([
123
- o({ type: String, reflect: !0, attribute: "symbol-variant" })
205
+ s([
206
+ i({ type: String, reflect: !0, attribute: "sub-label" })
207
+ ], t.prototype, "subLabel", 2);
208
+ s([
209
+ i({ type: String, reflect: !0, attribute: "symbol-variant" })
124
210
  ], t.prototype, "symbolVariant", 2);
125
- e([
126
- o({ type: Number, reflect: !0 })
211
+ s([
212
+ i({ type: Number, reflect: !0 })
127
213
  ], t.prototype, "number", 2);
128
- e([
129
- o({ type: Boolean, reflect: !0 })
214
+ s([
215
+ i({ type: Boolean, reflect: !0 })
130
216
  ], t.prototype, "active", 2);
131
- e([
132
- o({ type: Boolean, reflect: !0 })
217
+ s([
218
+ i({ type: Boolean, reflect: !0 })
133
219
  ], t.prototype, "completed", 2);
134
- e([
135
- o({ type: Boolean, reflect: !0 })
220
+ s([
221
+ i({ type: Boolean, reflect: !0, attribute: "change-on-completed" })
136
222
  ], t.prototype, "changeOnCompleted", 2);
137
- e([
138
- o({ type: Boolean, reflect: !0 })
223
+ s([
224
+ i({ type: Boolean, reflect: !0 })
139
225
  ], t.prototype, "islast", 2);
140
- e([
141
- o({ type: String, reflect: !0 })
226
+ s([
227
+ i({ type: String, reflect: !0 })
142
228
  ], t.prototype, "variant", 2);
143
- e([
144
- o({ type: String })
229
+ s([
230
+ i({ type: String })
145
231
  ], t.prototype, "icon", 2);
146
- t = e([
147
- h("scb-step")
232
+ t = s([
233
+ b("scb-step")
148
234
  ], t);
149
235
  export {
150
236
  t as ScbStep
@@ -4,6 +4,7 @@ import { LitElement } from 'lit';
4
4
  * @slot - Innehåll för stegen
5
5
  */
6
6
  export declare class ScbStepper extends LitElement {
7
+ type: string;
7
8
  label: string;
8
9
  changeOnCompleted: boolean;
9
10
  variant: 'horizontal' | 'vertical';
@@ -11,10 +12,23 @@ export declare class ScbStepper extends LitElement {
11
12
  private activeIndex;
12
13
  static styles: import('lit').CSSResult;
13
14
  private _onStepClick;
15
+ /**
16
+ * Gå till nästa steg programatiskt
17
+ */
18
+ nextStep(): void;
19
+ /**
20
+ * Gå till föregående steg programatiskt
21
+ */
22
+ prevStep(): void;
23
+ /**
24
+ * Hämta nuvarande aktiva steg-index
25
+ */
26
+ getActiveIndex(): number;
14
27
  private _updateSteps;
15
28
  private _getSteps;
16
29
  firstUpdated(): void;
17
30
  updated(): void;
18
31
  render(): import('lit-html').TemplateResult<1>;
32
+ private _onKeyNav;
19
33
  private _onStepContainerClick;
20
34
  }
@@ -1,25 +1,76 @@
1
- import { css as c, LitElement as d, html as h } from "lit";
2
- import { property as n, state as f, customElement as v } from "lit/decorators.js";
1
+ import { css as l, LitElement as h, html as d } from "lit";
2
+ import { property as p, state as v, customElement as f } from "lit/decorators.js";
3
3
  import "./scb-step.js";
4
- var b = Object.defineProperty, x = Object.getOwnPropertyDescriptor, o = (e, t, i, a) => {
5
- for (var r = a > 1 ? void 0 : a ? x(t, i) : t, l = e.length - 1, p; l >= 0; l--)
6
- (p = e[l]) && (r = (a ? p(t, i, r) : p(r)) || r);
7
- return a && r && b(t, i, r), r;
4
+ var b = Object.defineProperty, u = Object.getOwnPropertyDescriptor, r = (e, t, s, i) => {
5
+ for (var n = i > 1 ? void 0 : i ? u(t, s) : t, a = e.length - 1, c; a >= 0; a--)
6
+ (c = e[a]) && (n = (i ? c(t, s, n) : c(n)) || n);
7
+ return i && n && b(t, s, n), n;
8
8
  };
9
- let s = class extends d {
9
+ let o = class extends h {
10
10
  constructor() {
11
- super(...arguments), this.label = "", this.changeOnCompleted = !1, this.variant = "horizontal", this.symbolVariant = "number", this.activeIndex = 0, this._onStepContainerClick = (e) => {
12
- const t = this._getSteps(), i = e.composedPath(), a = t.findIndex((r) => i.includes(r));
13
- a !== -1 && this._onStepClick(a);
11
+ super(...arguments), this.type = "", this.label = "", this.changeOnCompleted = !1, this.variant = "horizontal", this.symbolVariant = "number", this.activeIndex = 0, this._onKeyNav = (e) => {
12
+ const t = this._getSteps(), s = this.activeIndex;
13
+ let i = s;
14
+ e.detail.key === "ArrowRight" ? s < t.length - 1 ? i = s + 1 : i = 0 : e.detail.key === "ArrowLeft" && (s > 0 ? i = s - 1 : i = t.length - 1), i !== s && (this._onStepClick(i), setTimeout(() => {
15
+ var a;
16
+ const n = (a = t[i].shadowRoot) == null ? void 0 : a.querySelector(".scb-step-content");
17
+ n && "focus" in n && typeof n.focus == "function" && n.focus();
18
+ }, 0));
19
+ }, this._onStepContainerClick = (e) => {
20
+ const t = this._getSteps(), s = e.composedPath(), i = t.findIndex((n) => s.includes(n));
21
+ i !== -1 && this._onStepClick(i);
14
22
  };
15
23
  }
16
24
  _onStepClick(e) {
17
- this.activeIndex = e, this._updateSteps();
25
+ const t = this.activeIndex;
26
+ this.activeIndex = e, this._updateSteps(), this.dispatchEvent(new CustomEvent("scb-step-change", {
27
+ detail: {
28
+ index: this.activeIndex,
29
+ step: this._getSteps()[this.activeIndex]
30
+ },
31
+ bubbles: !0,
32
+ composed: !0
33
+ })), e > t ? this.dispatchEvent(new CustomEvent("scb-step-next", {
34
+ detail: {
35
+ from: t,
36
+ to: e,
37
+ step: this._getSteps()[e]
38
+ },
39
+ bubbles: !0,
40
+ composed: !0
41
+ })) : e < t && this.dispatchEvent(new CustomEvent("scb-step-prev", {
42
+ detail: {
43
+ from: t,
44
+ to: e,
45
+ step: this._getSteps()[e]
46
+ },
47
+ bubbles: !0,
48
+ composed: !0
49
+ }));
50
+ }
51
+ /**
52
+ * Gå till nästa steg programatiskt
53
+ */
54
+ nextStep() {
55
+ const e = this._getSteps();
56
+ this.activeIndex < e.length - 1 && this._onStepClick(this.activeIndex + 1);
57
+ }
58
+ /**
59
+ * Gå till föregående steg programatiskt
60
+ */
61
+ prevStep() {
62
+ this.activeIndex > 0 && this._onStepClick(this.activeIndex - 1);
63
+ }
64
+ /**
65
+ * Hämta nuvarande aktiva steg-index
66
+ */
67
+ getActiveIndex() {
68
+ return this.activeIndex;
18
69
  }
19
70
  _updateSteps() {
20
71
  const e = this._getSteps();
21
- e.forEach((t, i) => {
22
- t.active = i === this.activeIndex, t.completed = i < this.activeIndex, t.islast = !1, t.changeOnCompleted = this.changeOnCompleted, t.number = i + 1, t.variant = this.variant, t.symbolVariant = this.symbolVariant;
72
+ e.forEach((t, s) => {
73
+ t.active = s === this.activeIndex, t.completed = s < this.activeIndex, t.islast = !1, t.changeOnCompleted = this.changeOnCompleted, t.number = s + 1, t.variant = this.variant, t.symbolVariant = this.symbolVariant;
23
74
  }), e.length > 0 && (e[e.length - 1].islast = !0);
24
75
  }
25
76
  _getSteps() {
@@ -32,19 +83,25 @@ let s = class extends d {
32
83
  this._updateSteps();
33
84
  }
34
85
  render() {
35
- return h`
36
- <div class="steps" style="flex-direction: ${this.variant === "vertical" ? "column" : "row"}; align-items: ${this.variant === "vertical", "flex-start"};" @click=${this._onStepContainerClick}>
86
+ return d`
87
+ <div
88
+ class="steps"
89
+ role="list"
90
+ aria-label="Steg i processen"
91
+ @click=${this._onStepContainerClick}
92
+ @scb-stepper-keynav=${this._onKeyNav}
93
+ >
37
94
  <slot></slot>
38
- </div>
95
+ </div>
39
96
  `;
40
97
  }
41
98
  };
42
- s.styles = c`
99
+ o.styles = l`
43
100
  :host {
44
101
  --scb-stepper-width: 100%;
45
102
  --scb-stepper-height: 100%;
46
103
  display: block;
47
- padding: 16px;
104
+ padding: var(--spacing-5) 0;
48
105
  width: 100%;
49
106
  color: var(--md-sys-color-on-surface);
50
107
  font-family: var(--brand-font);
@@ -54,34 +111,32 @@ s.styles = c`
54
111
  .steps {
55
112
  display: flex;
56
113
  flex-direction: row;
57
- align-items: flex-start;
114
+ align-items: stretch;
58
115
  justify-content: center;
59
116
  position: relative;
60
117
  width: 100%;
61
- gap: 24px;
62
- height: 100%;
118
+ gap: var(--spacing-7);
119
+ height: 100%;
63
120
  }
64
121
  :host([variant='vertical']) .steps {
65
122
  flex-direction: column;
66
- align-items: flex-start;
67
- gap: 32px;
123
+ gap: var(--spacing-8);
68
124
  }
69
125
  ::slotted(scb-step) {
70
126
  position: relative;
71
127
  flex: 1 1 0;
72
- min-width: 80px;
73
128
  z-index: 1;
129
+ width: 100%;
74
130
  }
75
131
  /* Horisontell connector */
76
132
  ::slotted(scb-step:not(:first-child))::before {
77
133
  content: '';
78
134
  position: absolute;
79
135
  left: -50%;
80
- top: 16px;
136
+ top: 28px;
81
137
  width: calc(100% - 24px);
82
138
  height: 1px;
83
139
  background: var(--n-70);
84
- border-radius: 1px;
85
140
  z-index: 0;
86
141
  }
87
142
  /* Vertikal connector */
@@ -91,46 +146,50 @@ s.styles = c`
91
146
  ::slotted(scb-step[variant="vertical"]:not(:last-child))::after {
92
147
  content: '';
93
148
  position: absolute;
94
- left: 16px;
95
- top: 40px;
149
+ left: 28px;
150
+ top: 52px;
96
151
  width: 1px;
97
152
  height: calc(100% - 16px);
98
153
  background: var(--n-70);
99
- border-radius: 1px;
100
154
  z-index: 0;
101
155
  transform: translateX(-50%);
102
156
  }
103
157
  ::slotted(scb-step[variant="vertical"][symbol-variant="marker"]:not(:last-child))::after {
104
158
  content: "";
105
159
  position: absolute;
106
- left: 8px;
107
- top: 25px;
160
+ left: 20px;
161
+ top: 38px;
108
162
  width: 1px;
109
163
  height: calc(100% - 2px);
110
164
  background: var(--n-70);
111
- border-radius: 1px;
112
165
  z-index: 0;
113
166
  transform: translateX(-50%);
114
167
  }
168
+ ::slotted(scb-step[symbol-variant="marker"]:not(:first-child))::before {
169
+ top: 20px;
170
+ }
115
171
  `;
116
- o([
117
- n({ type: String, reflect: !0 })
118
- ], s.prototype, "label", 2);
119
- o([
120
- n({ type: Boolean, reflect: !0, attribute: "change-on-completed" })
121
- ], s.prototype, "changeOnCompleted", 2);
122
- o([
123
- n({ type: String })
124
- ], s.prototype, "variant", 2);
125
- o([
126
- n({ type: String, reflect: !0, attribute: "symbol-variant" })
127
- ], s.prototype, "symbolVariant", 2);
128
- o([
129
- f()
130
- ], s.prototype, "activeIndex", 2);
131
- s = o([
132
- v("scb-stepper")
133
- ], s);
172
+ r([
173
+ p({ type: String, reflect: !0 })
174
+ ], o.prototype, "type", 2);
175
+ r([
176
+ p({ type: String, reflect: !0 })
177
+ ], o.prototype, "label", 2);
178
+ r([
179
+ p({ type: Boolean, reflect: !0, attribute: "change-on-completed" })
180
+ ], o.prototype, "changeOnCompleted", 2);
181
+ r([
182
+ p({ type: String })
183
+ ], o.prototype, "variant", 2);
184
+ r([
185
+ p({ type: String, reflect: !0, attribute: "symbol-variant" })
186
+ ], o.prototype, "symbolVariant", 2);
187
+ r([
188
+ v()
189
+ ], o.prototype, "activeIndex", 2);
190
+ o = r([
191
+ f("scb-stepper")
192
+ ], o);
134
193
  export {
135
- s as ScbStepper
194
+ o as ScbStepper
136
195
  };