scb-wc-test 0.1.106 → 0.1.108

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,16 +1,16 @@
1
- import { css as p, LitElement as f, html as v } from "lit";
2
- import { property as o, customElement as b } from "lit/decorators.js";
1
+ import { css as p, LitElement as f, html as b } from "lit";
2
+ import { property as l, customElement as v } from "lit/decorators.js";
3
3
  import "./scb-segmented-item.js";
4
- var g = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, m = (t) => {
4
+ var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, m = (t) => {
5
5
  throw TypeError(t);
6
- }, l = (t, e, s, i) => {
7
- for (var r = i > 1 ? void 0 : i ? _(e, s) : e, a = t.length - 1, d; a >= 0; a--)
8
- (d = t[a]) && (r = (i ? d(e, s, r) : d(r)) || r);
6
+ }, o = (t, e, s, i) => {
7
+ for (var r = i > 1 ? void 0 : i ? y(e, s) : e, n = t.length - 1, d; n >= 0; n--)
8
+ (d = t[n]) && (r = (i ? d(e, s, r) : d(r)) || r);
9
9
  return i && r && g(e, s, r), r;
10
- }, y = (t, e, s) => e.has(t) || m("Cannot " + s), S = (t, e, s) => e.has(t) ? m("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), c = (t, e, s) => (y(t, e, "access private method"), s), u, h;
11
- let n = class extends f {
10
+ }, _ = (t, e, s) => e.has(t) || m("Cannot " + s), S = (t, e, s) => e.has(t) ? m("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), h = (t, e, s) => (_(t, e, "access private method"), s), u, c;
11
+ let a = class extends f {
12
12
  constructor() {
13
- super(), S(this, u), this._internals = null, this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1, this.name = "", this.spacing = "", this._form = null, this._formResetHandler = null, this._initialValue = "", this._initialValues = [], "attachInternals" in this && (this._internals = this.attachInternals());
13
+ super(), S(this, u), this._internals = null, this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1, this.name = "", this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this._form = null, this._formResetHandler = null, this._initialValue = "", this._initialValues = [], "attachInternals" in this && (this._internals = this.attachInternals());
14
14
  }
15
15
  connectedCallback() {
16
16
  super.connectedCallback(), this._form = this.closest("form"), this._form && (this._formResetHandler = () => {
@@ -48,10 +48,10 @@ let n = class extends f {
48
48
  r && !r.hasAttribute("disabled") && !this.disabled && (this.onSlotClick(s), s.preventDefault());
49
49
  }
50
50
  }
51
- })), this._syncFormValue(), c(this, u, h).call(this);
51
+ })), this._syncFormValue(), h(this, u, c).call(this);
52
52
  }
53
53
  updated(t) {
54
- super.updated(t), this.updateSegments(), (t.has("value") || t.has("values") || t.has("disabled") || t.has("variant") || t.has("name")) && this._syncFormValue(), t.has("spacing") && c(this, u, h).call(this);
54
+ super.updated(t), this.updateSegments(), (t.has("value") || t.has("values") || t.has("disabled") || t.has("variant") || t.has("name")) && this._syncFormValue(), (t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && h(this, u, c).call(this);
55
55
  }
56
56
  onSlotClick(t) {
57
57
  let e = t.target;
@@ -59,7 +59,7 @@ let n = class extends f {
59
59
  const s = e.closest("scb-segmented-item");
60
60
  if (!s || this.disabled || s.hasAttribute("disabled")) return;
61
61
  const i = s.getAttribute("value") || "";
62
- i && (this.variant === "multi-select" ? (this.values.indexOf(i) === -1 ? this.values = [...this.values, i] : this.values = this.values.filter((a) => a !== i), this.dispatchEvent(
62
+ i && (this.variant === "multi-select" ? (this.values.indexOf(i) === -1 ? this.values = [...this.values, i] : this.values = this.values.filter((n) => n !== i), this.dispatchEvent(
63
63
  new CustomEvent("change", {
64
64
  detail: { values: this.values },
65
65
  bubbles: !0,
@@ -77,8 +77,8 @@ let n = class extends f {
77
77
  if (i.tagName === "SCB-SEGMENTED-ITEM") {
78
78
  const r = i.getAttribute("value") || "";
79
79
  if (r) {
80
- let a = !1;
81
- this.variant === "multi-select" ? a = !!this.values && this.values.includes(r) : a = r === this.value, i.setAttribute("aria-pressed", a ? "true" : "false"), a ? i.setAttribute("selected", "true") : i.removeAttribute("selected");
80
+ let n = !1;
81
+ this.variant === "multi-select" ? n = !!this.values && this.values.includes(r) : n = r === this.value, i.setAttribute("aria-pressed", n ? "true" : "false"), n ? i.setAttribute("selected", "true") : i.removeAttribute("selected");
82
82
  }
83
83
  this.disabled && i.setAttribute("disabled", "true");
84
84
  }
@@ -126,65 +126,72 @@ let n = class extends f {
126
126
  return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
127
127
  }
128
128
  render() {
129
- return v`<slot></slot>`;
129
+ return b`<slot></slot>`;
130
130
  }
131
131
  };
132
132
  u = /* @__PURE__ */ new WeakSet();
133
- h = function() {
134
- const t = this.mapSpacingToken(this.spacing);
135
- t ? this.style.setProperty("--scb-segmented-button-spacing-block", t) : this.style.removeProperty("--scb-segmented-button-spacing-block");
133
+ c = function() {
134
+ const t = this.mapSpacingToken(this.spacing), e = this.mapSpacingToken(this.spacingTop) ?? t, s = this.mapSpacingToken(this.spacingBottom) ?? t;
135
+ e ? this.style.setProperty("--scb-segmented-button-spacing-block-start", e) : this.style.removeProperty("--scb-segmented-button-spacing-block-start"), s ? this.style.setProperty("--scb-segmented-button-spacing-block-end", s) : this.style.removeProperty("--scb-segmented-button-spacing-block-end");
136
136
  };
137
- n.formAssociated = !0;
138
- n.styles = p`
137
+ a.formAssociated = !0;
138
+ a.styles = p`
139
139
  :host {
140
- --scb-segmented-button-width: 100%;
141
- --scb-segmented-button-height: 48px;
142
- max-width: var(--scb-segmented-button-width);
143
- height: var(--scb-segmented-button-height);
144
- display: grid;
145
- grid-auto-flow: column;
146
- grid-auto-columns: 1fr;
147
- font-family: var(--brand, Inter);
148
- margin-block: var(--scb-segmented-button-spacing-block, 0);
140
+ --scb-segmented-button-width: 100%;
141
+ --scb-segmented-button-height: 48px;
142
+ max-width: var(--scb-segmented-button-width);
143
+ height: var(--scb-segmented-button-height);
144
+ display: grid;
145
+ grid-auto-flow: column;
146
+ grid-auto-columns: 1fr;
147
+ font-family: var(--brand, Inter);
148
+ margin-block-start: var(--scb-segmented-button-spacing-block-start, 0);
149
+ margin-block-end: var(--scb-segmented-button-spacing-block-end, 0);
149
150
  }
150
151
  /* Border radius only on first and last button */
151
152
  ::slotted(scb-segmented-item:first-child .segmented-item),
152
- ::slotted([role="button"]:first-child .segmented-item) {
153
+ ::slotted([role='button']:first-child .segmented-item) {
153
154
  border-top-left-radius: var(--md-sys-shape-corner-full);
154
155
  border-bottom-left-radius: var(--md-sys-shape-corner-full);
155
156
  }
156
157
  ::slotted(scb-segmented-item:last-child .segmented-item),
157
- ::slotted([role="button"]:last-child .segmented-item) {
158
+ ::slotted([role='button']:last-child .segmented-item) {
158
159
  border-top-right-radius: var(--md-sys-shape-corner-full);
159
160
  border-bottom-right-radius: var(--md-sys-shape-corner-full);
160
161
  }
161
162
  /* First button gets left border */
162
163
  ::slotted(scb-segmented-item:first-child .segmented-item),
163
- ::slotted([role="button"]:first-child .segmented-item) {
164
+ ::slotted([role='button']:first-child .segmented-item) {
164
165
  border-left: 1px solid var(--md-sys-color-outline);
165
166
  }
166
167
  `;
167
- l([
168
- o({ type: String, reflect: !0 })
169
- ], n.prototype, "variant", 2);
170
- l([
171
- o({ type: String, reflect: !0 })
172
- ], n.prototype, "value", 2);
173
- l([
174
- o({ type: Array })
175
- ], n.prototype, "values", 2);
176
- l([
177
- o({ type: Boolean, reflect: !0 })
178
- ], n.prototype, "disabled", 2);
179
- l([
180
- o({ type: String, reflect: !0 })
181
- ], n.prototype, "name", 2);
182
- l([
183
- o({ type: String, reflect: !0 })
184
- ], n.prototype, "spacing", 2);
185
- n = l([
186
- b("scb-segmented-button")
187
- ], n);
168
+ o([
169
+ l({ type: String, reflect: !0 })
170
+ ], a.prototype, "variant", 2);
171
+ o([
172
+ l({ type: String, reflect: !0 })
173
+ ], a.prototype, "value", 2);
174
+ o([
175
+ l({ type: Array })
176
+ ], a.prototype, "values", 2);
177
+ o([
178
+ l({ type: Boolean, reflect: !0 })
179
+ ], a.prototype, "disabled", 2);
180
+ o([
181
+ l({ type: String, reflect: !0 })
182
+ ], a.prototype, "name", 2);
183
+ o([
184
+ l({ type: String, reflect: !0 })
185
+ ], a.prototype, "spacing", 2);
186
+ o([
187
+ l({ type: String, attribute: "spacing-top", reflect: !0 })
188
+ ], a.prototype, "spacingTop", 2);
189
+ o([
190
+ l({ type: String, attribute: "spacing-bottom", reflect: !0 })
191
+ ], a.prototype, "spacingBottom", 2);
192
+ a = o([
193
+ v("scb-segmented-button")
194
+ ], a);
188
195
  export {
189
- n as ScbSegmentedButton
196
+ a as ScbSegmentedButton
190
197
  };
@@ -27,8 +27,11 @@ export declare class ScbTextField extends LitElement {
27
27
  private _formResetHandler;
28
28
  private _initialValue;
29
29
  private _inputId;
30
+ private _showDatepicker;
30
31
  static styles: import('lit').CSSResult[];
31
32
  render(): TemplateResult;
33
+ private _toggleDatepicker;
34
+ private _onDateSelected;
32
35
  /**
33
36
  * Vi re-dispatchar inbyggda "input", "change" och "select"-events med { bubbles: true, composed: true }.
34
37
  * Vi kör också ett customevent onValueChanged.
@@ -1,16 +1,27 @@
1
1
  import { css as m, LitElement as x, html as d } from "lit";
2
2
  import { property as a, customElement as v } from "lit/decorators.js";
3
3
  import "@material/web/icon/icon.js";
4
+ import "../scb-datepicker/scb-datepicker.js";
4
5
  var y = Object.defineProperty, g = Object.getOwnPropertyDescriptor, f = (t) => {
5
6
  throw TypeError(t);
6
7
  }, r = (t, e, i, l) => {
7
- for (var o = l > 1 ? void 0 : l ? g(e, i) : e, p = t.length - 1, u; p >= 0; p--)
8
- (u = t[p]) && (o = (l ? u(e, i, o) : u(o)) || o);
8
+ for (var o = l > 1 ? void 0 : l ? g(e, i) : e, h = t.length - 1, u; h >= 0; h--)
9
+ (u = t[h]) && (o = (l ? u(e, i, o) : u(o)) || o);
9
10
  return l && o && y(e, i, o), o;
10
- }, _ = (t, e, i) => e.has(t) || f("Cannot " + i), w = (t, e, i) => e.has(t) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), c = (t, e, i) => (_(t, e, "access private method"), i), n, b, h;
11
+ }, _ = (t, e, i) => e.has(t) || f("Cannot " + i), w = (t, e, i) => e.has(t) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), c = (t, e, i) => (_(t, e, "access private method"), i), n, b, p;
11
12
  let s = class extends x {
12
13
  constructor() {
13
- super(), w(this, n), this._internals = null, this.type = "text", this.label = "", this.supportingText = "", this.errorText = "", this.leadingIcon = "", this.name = "", this.pattern = "", this.value = "", this.underLabel = "", this.error = !1, this.disabled = !1, this.required = !1, this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this._form = null, this._formSubmitHandler = null, this._formResetHandler = null, this._initialValue = "", this._inputId = "", "attachInternals" in this && (this._internals = this.attachInternals());
14
+ super(), w(this, n), this._internals = null, this.type = "text", this.label = "", this.supportingText = "", this.errorText = "", this.leadingIcon = "", this.name = "", this.pattern = "", this.value = "", this.underLabel = "", this.error = !1, this.disabled = !1, this.required = !1, this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this._form = null, this._formSubmitHandler = null, this._formResetHandler = null, this._initialValue = "", this._inputId = "", this._showDatepicker = !1, this._toggleDatepicker = () => {
15
+ this._showDatepicker = !this._showDatepicker;
16
+ }, this._onDateSelected = (t) => {
17
+ this.value = t.detail.value, this._showDatepicker = !1, this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
18
+ new CustomEvent("onValueChanged", {
19
+ detail: { value: this.value },
20
+ bubbles: !0,
21
+ composed: !0
22
+ })
23
+ );
24
+ }, "attachInternals" in this && (this._internals = this.attachInternals());
14
25
  }
15
26
  render() {
16
27
  const t = this.leadingIcon ? d`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>` : null, e = this.error ? d`<md-icon class="scb-textfield-error-icon" aria-hidden="true">error</md-icon>` : null;
@@ -70,6 +81,36 @@ let s = class extends x {
70
81
  ${this.value}</textarea
71
82
  >
72
83
  </div>
84
+ ` : this.type === "date" ? d`
85
+ <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
86
+ <span
87
+ class="scb-textfield-supporting-text"
88
+ id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
89
+ >${this.underLabel}</span
90
+ >
91
+ <div class="scb-textfield-wrapper" style="position:relative;">
92
+ ${t}
93
+ <input
94
+ class="scb-textfield${this.error ? " has-error-icon" : ""}"
95
+ .value=${this.value}
96
+ type="text"
97
+ name="${this.name}"
98
+ id="${this._inputId}"
99
+ ?disabled=${this.disabled}
100
+ ?required=${this.required}
101
+ aria-invalid=${this.error ? "true" : "false"}
102
+ aria-describedby=${i}
103
+ readonly
104
+ />
105
+ <scb-icon-button icon="calendar_today" @click=${this._toggleDatepicker} aria-label="Välj datum" style="position:absolute;right:8px;top:50%;transform:translateY(-50%);"></scb-icon-button>
106
+ <scb-datepicker
107
+ variant="popup"
108
+ .selectedValue=${this.value}
109
+ .open=${this._showDatepicker}
110
+ @date-selected=${this._onDateSelected}
111
+ ></scb-datepicker>
112
+ ${e}
113
+ </div>
73
114
  ` : d`
74
115
  <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
75
116
  <span
@@ -190,10 +231,10 @@ ${this.value}</textarea
190
231
  };
191
232
  n = /* @__PURE__ */ new WeakSet();
192
233
  b = function() {
193
- const t = c(this, n, h).call(this, this.spacing), e = c(this, n, h).call(this, this.spacingTop) ?? t, i = c(this, n, h).call(this, this.spacingBottom) ?? t;
234
+ const t = c(this, n, p).call(this, this.spacing), e = c(this, n, p).call(this, this.spacingTop) ?? t, i = c(this, n, p).call(this, this.spacingBottom) ?? t;
194
235
  e ? this.style.setProperty("--scb-textfield-spacing-block-start", e) : this.style.removeProperty("--scb-textfield-spacing-block-start"), i ? this.style.setProperty("--scb-textfield-spacing-block-end", i) : this.style.removeProperty("--scb-textfield-spacing-block-end");
195
236
  };
196
- h = function(t) {
237
+ p = function(t) {
197
238
  if (!t) return;
198
239
  const e = String(t).trim();
199
240
  if (e)
@@ -225,6 +266,9 @@ s.styles = [
225
266
  :host([type='text']) {
226
267
  --scb-textfield-max-width: var(--scb-textfield-text-max-width);
227
268
  }
269
+ :host([type='date']) {
270
+ --scb-textfield-max-width: var(--scb-textfield-text-max-width);
271
+ }
228
272
  :host([type='search']) {
229
273
  --scb-textfield-max-width: var(--scb-textfield-search-max-width);
230
274
  }
@@ -425,6 +469,9 @@ r([
425
469
  r([
426
470
  a({ type: String, attribute: "spacing-bottom", reflect: !0 })
427
471
  ], s.prototype, "spacingBottom", 2);
472
+ r([
473
+ a({ type: Boolean })
474
+ ], s.prototype, "_showDatepicker", 2);
428
475
  s = r([
429
476
  v("scb-textfield")
430
477
  ], s);