@skf-design-system/ui-components 1.0.0-alpha.40 → 1.0.0-alpha.42

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.
@@ -8,20 +8,23 @@ import { nothing as P, html as m } from "lit";
8
8
  import { property as u, state as c, query as S } from "lit/decorators.js";
9
9
  import { classMap as A } from "lit/directives/class-map.js";
10
10
  import { styles as L } from "./popover.styles.js";
11
- var x = Object.defineProperty, F = Object.getOwnPropertyDescriptor, r = (g, t, s, o) => {
12
- for (var e = o > 1 ? void 0 : o ? F(t, s) : t, n = g.length - 1, a; n >= 0; n--)
13
- (a = g[n]) && (e = (o ? a(t, s, e) : a(e)) || e);
14
- return o && e && x(t, s, e), e;
15
- }, h;
16
- const i = (h = class extends C {
11
+ var x = Object.defineProperty, F = Object.getOwnPropertyDescriptor, i = (g, t, r, o) => {
12
+ for (var e = o > 1 ? void 0 : o ? F(t, r) : t, n = g.length - 1, a; n >= 0; n--)
13
+ (a = g[n]) && (e = (o ? a(t, r, e) : a(e)) || e);
14
+ return o && e && x(t, r, e), e;
15
+ }, l;
16
+ const s = (l = class extends C {
17
17
  constructor() {
18
18
  super(...arguments), this._skipClosingThisTick = !1, this._abortCtrl = new AbortController(), this._signal = this._abortCtrl.signal, this.$popover = this, this.placement = "top", this.variant = "popup", this.isOpen = !1, this.offset = 0, this.arrow = !1, this.triggerEvent = "mouseenter", this.popoverController = new E(this), this._toggleOpen = (t) => {
19
19
  this.isOpen = t ?? !this.isOpen;
20
20
  }, this._handleToggle = (t) => {
21
- const s = t.newState === "open";
22
- this.isOpen = s, this.emit(s ? "skf-opened" : "skf-closed");
21
+ const r = t.newState === "open";
22
+ this.isOpen = r, this.emit(r ? "skf-opened" : "skf-closed");
23
23
  }, this.handleToggleOpen = async () => {
24
- this.$anchor && (this.isOpen ? (this.$popover.togglePopover(!0), this.$popover.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250, fill: "forwards" })) : (await this.$popover.animate([{ opacity: 0 }], { duration: 150, fill: "forwards" }).finished, this.$popover && this.$popover.togglePopover(this.isOpen)));
24
+ this.$anchor && this.$popover.isConnected && (this.isOpen ? (this.$popover.togglePopover(!0), this.$popover.animate([{ opacity: 0 }, { opacity: 1 }], {
25
+ duration: 250,
26
+ fill: "forwards"
27
+ })) : (await this.$popover.animate([{ opacity: 0 }], { duration: 150, fill: "forwards" }).finished, this.$popover && this.$popover.togglePopover(this.isOpen)));
25
28
  }, this.handleAnchorChange = async () => {
26
29
  if (!this.anchor) return;
27
30
  await this.popoverController.stop(), this.$anchor && this.removeEventListeners();
@@ -31,16 +34,16 @@ const i = (h = class extends C {
31
34
  if (!this.$anchor) return;
32
35
  const t = [y(), $(this.offset)];
33
36
  this.arrow && t.push(O({ element: this.$arrow }));
34
- const { x: s, y: o, middlewareData: e } = await _(this.$anchor, this.$popover, {
37
+ const { x: r, y: o, middlewareData: e } = await _(this.$anchor, this.$popover, {
35
38
  placement: this.placement,
36
39
  middleware: t,
37
40
  strategy: "fixed"
38
41
  });
39
42
  if (Object.assign(this.$popover.style, {
40
- left: `${String(s)}px`,
43
+ left: `${String(r)}px`,
41
44
  top: `${String(o)}px`
42
45
  }), this.arrow) {
43
- const n = this.placement.split("-")[0], a = { top: "bottom", right: "left", bottom: "top", left: "right" }[n] ?? "", p = e.flip?.index, d = e.arrow?.x, l = e.arrow?.y, v = typeof d == "number" ? `${String(d)}px` : "", b = typeof l == "number" ? `${String(l)}px` : "", w = {
46
+ const n = this.placement.split("-")[0], a = { top: "bottom", right: "left", bottom: "top", left: "right" }[n] ?? "", p = e.flip?.index, d = e.arrow?.x, h = e.arrow?.y, v = typeof d == "number" ? `${String(d)}px` : "", b = typeof h == "number" ? `${String(h)}px` : "", w = {
44
47
  bottom: 45,
45
48
  right: 135,
46
49
  top: 225,
@@ -59,8 +62,8 @@ const i = (h = class extends C {
59
62
  t.stopPropagation(), this.tagName === "SKF-TOOLTIP" && this.isOpen && this.close();
60
63
  const o = this.tagName === "SKF-MENU" ? void 0 : !0;
61
64
  this._toggleOpen(o), this._abortCtrl = new AbortController(), this._signal = this._abortCtrl.signal, document.addEventListener("keydown", this.handleEscapeKey, { signal: this._signal }), this.tagName === "SKF-TOOLTIP" && this.$anchor?.setAttribute("aria-describedby", this.id);
62
- }, this.close = (t = "") => {
63
- console.log("Popover closing", t), this._toggleOpen(!1), this._abortCtrl.abort(), this.tagName === "SKF-TOOLTIP" && this.$anchor?.removeAttribute("aria-describedby");
65
+ }, this.close = () => {
66
+ this._toggleOpen(!1), this._abortCtrl.abort(), this.tagName === "SKF-TOOLTIP" && this.$anchor?.removeAttribute("aria-describedby");
64
67
  };
65
68
  }
66
69
  connectedCallback() {
@@ -78,25 +81,23 @@ const i = (h = class extends C {
78
81
  "focusout",
79
82
  (o) => {
80
83
  const e = this.contains(o.relatedTarget);
81
- t && e || this._skipClosingThisTick || this.close("anchor focus out");
84
+ t && e || this._skipClosingThisTick || this.close();
82
85
  },
83
86
  { signal: this._signal }
84
87
  ), this.addEventListener(
85
88
  "focusout",
86
89
  (o) => {
87
90
  const e = this.contains(o.relatedTarget);
88
- t && e || this.close("popover focusout");
91
+ t && e || this.contains(o.target) || this.close();
89
92
  },
90
93
  { signal: this._signal }
91
94
  ), this._skfPopoverOutsideClickListener ??= (o) => {
92
- this.isOpen && this.$anchor && !this.contains(o.target) && !this.$anchor.contains(o.target) ? this.close("outside click") : (this._skipClosingThisTick = !0, setTimeout(() => {
95
+ this.isOpen && this.$anchor && !this.contains(o.target) && !this.$anchor.contains(o.target) ? this.close() : (this._skipClosingThisTick = !0, setTimeout(() => {
93
96
  this._skipClosingThisTick = !1;
94
97
  }, 0));
95
98
  }, document.addEventListener("mousedown", this._skfPopoverOutsideClickListener, {
96
99
  signal: this._signal
97
- });
98
- const s = window.top && window.self !== window.top;
99
- console.log("contains frames", s), s && window.top && !this._skipClosingThisTick && window.top.addEventListener("mousedown", this._skfPopoverOutsideClickListener, {
100
+ }), window.top && window.self !== window.top && window.top && !this._skipClosingThisTick && window.top.addEventListener("mousedown", this._skfPopoverOutsideClickListener, {
100
101
  signal: this._signal
101
102
  }), this.$popover.id = await T(this.$anchor.id), ["popup", "menu"].includes(this.variant) && (this.$anchor.setAttribute("aria-haspopup", "true"), this.setAttribute("aria-labelledby", this.$anchor.id)), ["menu"].includes(this.variant) && this.$anchor.setAttribute("aria-controls", this.$popover.id), ["popup"].includes(this.variant) && t && (this.role = "dialog"), ["tooltip"].includes(this.variant) && this.$anchor.addEventListener("focusin", this.open, { signal: this._signal });
102
103
  }
@@ -110,7 +111,7 @@ const i = (h = class extends C {
110
111
  }
111
112
  render() {
112
113
  return ["popup", "menu"].includes(this.variant) && this.$anchor?.setAttribute("aria-expanded", this.isOpen ? "true" : "false"), m`
113
- <div class=${A({ popover: !0, ...h.classMap })} id="root">
114
+ <div class=${A({ popover: !0, ...l.classMap })} id="root">
114
115
  <slot></slot>
115
116
  ${this.arrow ? m`<div id="arrow"></div>` : P}
116
117
  </div>
@@ -129,52 +130,52 @@ const i = (h = class extends C {
129
130
  function e(n, a) {
130
131
  const p = Array.from(
131
132
  n.querySelectorAll(a.join(", "))
132
- ), d = Array.from(n.querySelectorAll("*")).map((l) => l.shadowRoot).filter((l) => l !== null);
133
- for (const l of d)
133
+ ), d = Array.from(n.querySelectorAll("*")).map((h) => h.shadowRoot).filter((h) => h !== null);
134
+ for (const h of d)
134
135
  p.push(
135
- ...e(l, a)
136
+ ...e(h, a)
136
137
  );
137
138
  return p;
138
139
  }
139
140
  }
140
- }, h.styles = [k, L], h.classMap = {}, h);
141
- r([
141
+ }, l.styles = [k, L], l.classMap = {}, l);
142
+ i([
142
143
  u()
143
- ], i.prototype, "placement", 2);
144
- r([
144
+ ], s.prototype, "placement", 2);
145
+ i([
145
146
  u()
146
- ], i.prototype, "variant", 2);
147
- r([
147
+ ], s.prototype, "variant", 2);
148
+ i([
148
149
  u()
149
- ], i.prototype, "anchor", 2);
150
- r([
150
+ ], s.prototype, "anchor", 2);
151
+ i([
151
152
  c()
152
- ], i.prototype, "isOpen", 2);
153
- r([
153
+ ], s.prototype, "isOpen", 2);
154
+ i([
154
155
  c()
155
- ], i.prototype, "offset", 2);
156
- r([
156
+ ], s.prototype, "offset", 2);
157
+ i([
157
158
  c()
158
- ], i.prototype, "$anchor", 2);
159
- r([
159
+ ], s.prototype, "$anchor", 2);
160
+ i([
160
161
  c()
161
- ], i.prototype, "arrow", 2);
162
- r([
162
+ ], s.prototype, "arrow", 2);
163
+ i([
163
164
  c()
164
- ], i.prototype, "triggerEvent", 2);
165
- r([
165
+ ], s.prototype, "triggerEvent", 2);
166
+ i([
166
167
  S("#arrow")
167
- ], i.prototype, "$arrow", 2);
168
- r([
168
+ ], s.prototype, "$arrow", 2);
169
+ i([
169
170
  f("isOpen", { afterUpdate: !0 })
170
- ], i.prototype, "handleToggleOpen", 2);
171
- r([
171
+ ], s.prototype, "handleToggleOpen", 2);
172
+ i([
172
173
  f("$anchor")
173
- ], i.prototype, "handleAnchorEl", 1);
174
- r([
174
+ ], s.prototype, "handleAnchorEl", 1);
175
+ i([
175
176
  f("anchor")
176
- ], i.prototype, "handleAnchorChange", 2);
177
- let z = i;
177
+ ], s.prototype, "handleAnchorChange", 2);
178
+ let W = s;
178
179
  export {
179
- z as SkfPopoverBase
180
+ W as SkfPopoverBase
180
181
  };
@@ -481,6 +481,10 @@ export type SkfDatepickerProps = {
481
481
  "name"?: SkfDatepicker['name'];
482
482
  /** */
483
483
  "placeholder"?: SkfDatepicker['placeholder'];
484
+ /** Placeholder for the end date input in range mode */
485
+ "placeholder-end"?: SkfDatepicker['placeholderEnd'];
486
+ /** Placeholder for the end date input in range mode */
487
+ "placeholderEnd"?: SkfDatepicker['placeholderEnd'];
484
488
  /** */
485
489
  "range"?: SkfDatepicker['range'];
486
490
  /** If true, makes the element not mutable, meaning the user can not edit the control */
@@ -1590,6 +1594,7 @@ export type SkfTooltipProps = {
1590
1594
  * - `invalid-dates`/`invalidDates`: A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
1591
1595
  * - `name`: If defined, adds name to the input-element
1592
1596
  * - `placeholder`: undefined
1597
+ * - `placeholder-end`/`placeholderEnd`: Placeholder for the end date input in range mode
1593
1598
  * - `range`: undefined
1594
1599
  * - `readonly`: If true, makes the element not mutable, meaning the user can not edit the control
1595
1600
  * - `selectable-from`/`selectableFrom`: Earliest selectable date. (yyyy-mm-dd format)
@@ -243,6 +243,8 @@ type SkfDatepickerProps = {
243
243
  name?: SkfDatepicker["name"];
244
244
  /** */
245
245
  placeholder?: SkfDatepicker["placeholder"];
246
+ /** Placeholder for the end date input in range mode */
247
+ "placeholder-end"?: SkfDatepicker["placeholderEnd"];
246
248
  /** */
247
249
  range?: SkfDatepicker["range"];
248
250
  /** If true, makes the element not mutable, meaning the user can not edit the control */
@@ -403,6 +403,11 @@
403
403
  "values": []
404
404
  },
405
405
  { "name": "placeholder", "values": [] },
406
+ {
407
+ "name": "placeholder-end",
408
+ "description": "Placeholder for the end date input in range mode",
409
+ "values": []
410
+ },
406
411
  { "name": "range", "values": [] },
407
412
  {
408
413
  "name": "readonly",
@@ -863,6 +863,11 @@
863
863
  "name": "placeholder",
864
864
  "value": { "type": "string", "default": "'YYYY-MM-DD'" }
865
865
  },
866
+ {
867
+ "name": "placeholder-end",
868
+ "description": "Placeholder for the end date input in range mode",
869
+ "value": { "type": "string", "default": "''" }
870
+ },
866
871
  {
867
872
  "name": "range",
868
873
  "value": { "type": "boolean", "default": "false" }
@@ -972,6 +977,11 @@
972
977
  "type": "string | undefined"
973
978
  },
974
979
  { "name": "placeholder", "type": "string" },
980
+ {
981
+ "name": "placeholderEnd",
982
+ "description": "Placeholder for the end date input in range mode",
983
+ "type": "string"
984
+ },
975
985
  { "name": "range", "type": "boolean" },
976
986
  {
977
987
  "name": "readonly",
package/package.json CHANGED
@@ -35,7 +35,7 @@
35
35
  "sideEffects": true,
36
36
  "type": "module",
37
37
  "types": "./dist/index.d.ts",
38
- "version": "1.0.0-alpha.40",
38
+ "version": "1.0.0-alpha.42",
39
39
  "dependencies": {
40
40
  "@floating-ui/dom": "^1.7.4",
41
41
  "@js-temporal/polyfill": "^0.5.1",