@skf-design-system/ui-components 1.0.1-beta.1 → 1.0.2-beta.0

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 (186) hide show
  1. package/README.md +1 -18
  2. package/dist/components/accordion/accordion.component.d.ts +4 -4
  3. package/dist/components/accordion/accordion.component.js +8 -8
  4. package/dist/components/alert/alert.component.d.ts +8 -9
  5. package/dist/components/alert/alert.component.js +7 -7
  6. package/dist/components/breadcrumb/breadcrumb.component.d.ts +1 -1
  7. package/dist/components/card/card.component.js +18 -30
  8. package/dist/components/card/card.styles.js +25 -28
  9. package/dist/components/checkbox/checkbox.component.d.ts +8 -8
  10. package/dist/components/checkbox/checkbox.component.js +3 -3
  11. package/dist/components/collapse/collapse.component.js +1 -1
  12. package/dist/components/date-picker/datepicker.calendar.component.d.ts +5 -0
  13. package/dist/components/date-picker/datepicker.calendar.component.js +128 -95
  14. package/dist/components/date-picker/datepicker.calendar.styles.js +35 -25
  15. package/dist/components/date-picker/datepicker.component.d.ts +5 -0
  16. package/dist/components/date-picker/datepicker.component.js +117 -97
  17. package/dist/components/date-picker/datepicker.helpers.d.ts +3 -2
  18. package/dist/components/date-picker/datepicker.helpers.js +46 -39
  19. package/dist/components/date-picker/datepicker.styles.js +14 -26
  20. package/dist/components/date-picker-input/datepicker-input.component.d.ts +13 -5
  21. package/dist/components/date-picker-input/datepicker-input.component.js +263 -219
  22. package/dist/components/date-picker-input/datepicker-input.helpers.d.ts +36 -2
  23. package/dist/components/date-picker-input/datepicker-input.helpers.js +25 -23
  24. package/dist/components/date-picker-input/datepicker-input.styles.js +6 -10
  25. package/dist/components/dialog/dialog.component.d.ts +18 -28
  26. package/dist/components/dialog/dialog.component.js +89 -79
  27. package/dist/components/divider/divider.component.d.ts +4 -8
  28. package/dist/components/divider/divider.component.js +24 -46
  29. package/dist/components/divider/divider.styles.js +34 -30
  30. package/dist/components/drawer/drawer.component.d.ts +57 -0
  31. package/dist/components/drawer/drawer.component.js +124 -0
  32. package/dist/components/drawer/drawer.d.ts +8 -0
  33. package/dist/components/drawer/drawer.js +6 -0
  34. package/dist/components/drawer/drawer.styles.d.ts +1 -0
  35. package/dist/components/drawer/drawer.styles.js +71 -0
  36. package/dist/components/header/header.component.d.ts +45 -0
  37. package/dist/components/header/header.component.js +110 -0
  38. package/dist/components/header/header.d.ts +8 -0
  39. package/dist/components/header/header.js +6 -0
  40. package/dist/components/header/header.styles.d.ts +1 -0
  41. package/dist/components/header/header.styles.js +68 -0
  42. package/dist/components/heading/heading.component.d.ts +6 -12
  43. package/dist/components/heading/heading.component.js +11 -11
  44. package/dist/components/heading/heading.styles.d.ts +1 -2
  45. package/dist/components/heading/heading.styles.js +1 -1
  46. package/dist/components/icon/icon.component.d.ts +1 -1
  47. package/dist/components/input/input.component.d.ts +2 -2
  48. package/dist/components/input/input.component.js +3 -3
  49. package/dist/components/input/input.controllers.d.ts +20 -6
  50. package/dist/components/input/input.controllers.js +14 -10
  51. package/dist/components/link/link.component.js +1 -0
  52. package/dist/components/link/link.styles.js +24 -20
  53. package/dist/components/menu/menu.component.d.ts +4 -5
  54. package/dist/components/menu/menu.component.js +1 -1
  55. package/dist/components/nav/nav.component.d.ts +17 -0
  56. package/dist/components/nav/nav.component.js +34 -0
  57. package/dist/components/nav/nav.d.ts +8 -0
  58. package/dist/components/nav/nav.js +6 -0
  59. package/dist/components/nav/nav.styles.d.ts +1 -0
  60. package/dist/components/nav/nav.styles.js +17 -0
  61. package/dist/components/nav-item/nav-item.component.d.ts +20 -0
  62. package/dist/components/nav-item/nav-item.component.js +38 -0
  63. package/dist/components/nav-item/nav-item.d.ts +8 -0
  64. package/dist/components/nav-item/nav-item.js +6 -0
  65. package/dist/components/nav-item/nav-item.styles.d.ts +1 -0
  66. package/dist/components/nav-item/nav-item.styles.js +39 -0
  67. package/dist/components/popover/popover.component.d.ts +5 -6
  68. package/dist/components/popover/popover.component.js +19 -19
  69. package/dist/components/radio/radio.component.d.ts +10 -6
  70. package/dist/components/radio/radio.component.js +10 -10
  71. package/dist/components/radio/radio.styles.d.ts +1 -2
  72. package/dist/components/radio/radio.styles.js +1 -1
  73. package/dist/components/segmented-button/segmented-button.component.d.ts +32 -0
  74. package/dist/components/segmented-button/segmented-button.d.ts +8 -0
  75. package/dist/components/segmented-button/segmented-button.styles.d.ts +1 -0
  76. package/dist/components/segmented-button-item/segmented-button-item.component.d.ts +36 -0
  77. package/dist/components/segmented-button-item/segmented-button-item.d.ts +8 -0
  78. package/dist/components/segmented-button-item/segmented-button-item.styles.d.ts +1 -0
  79. package/dist/components/select/select.component.js +2 -2
  80. package/dist/components/select/select.controllers.d.ts +20 -9
  81. package/dist/components/select/select.controllers.js +27 -22
  82. package/dist/components/select-option/select-option.controllers.d.ts +11 -5
  83. package/dist/components/stepper/stepper.component.d.ts +2 -1
  84. package/dist/components/stepper-item/stepper-item.component.js +2 -2
  85. package/dist/components/switch/switch.component.d.ts +7 -6
  86. package/dist/components/switch/switch.component.js +7 -7
  87. package/dist/components/tag/tag.component.d.ts +4 -2
  88. package/dist/components/tag/tag.component.js +6 -6
  89. package/dist/components/textarea/textarea.component.js +7 -7
  90. package/dist/components/toast/toast.component.d.ts +1 -1
  91. package/dist/components/tooltip/tooltip.component.d.ts +5 -6
  92. package/dist/components/tooltip/tooltip.component.js +11 -11
  93. package/dist/custom-elements.json +2477 -1745
  94. package/dist/index.d.ts +4 -0
  95. package/dist/index.js +82 -70
  96. package/dist/internal/base-classes/popover/popover.base.d.ts +17 -7
  97. package/dist/internal/base-classes/popover/popover.base.js +119 -75
  98. package/dist/internal/base-classes/popover/popover.styles.js +14 -1
  99. package/dist/internal/controllers/elementOverflowController.d.ts +13 -0
  100. package/dist/internal/controllers/popover.controller.d.ts +12 -7
  101. package/dist/internal/controllers/popover.controller.js +9 -14
  102. package/dist/internal/helpers/utilityTypes.d.ts +1 -1
  103. package/dist/internal/helpers/uuid.d.ts +15 -0
  104. package/dist/internal/helpers/uuid.js +14 -0
  105. package/dist/internal/storybook/styles.d.ts +1 -0
  106. package/dist/styles/form-field.styles.js +11 -6
  107. package/dist/styles/global.css +1 -1
  108. package/dist/types/jsx/custom-element-jsx.d.ts +642 -1261
  109. package/dist/types/vue/index.d.ts +422 -267
  110. package/dist/vscode.html-custom-data.json +805 -525
  111. package/dist/web-types.json +928 -653
  112. package/package.json +41 -51
  113. package/dist/react/index.d.ts +0 -36
  114. package/dist/react/index.js +0 -36
  115. package/dist/react/skf-accordion/index.d.ts +0 -3
  116. package/dist/react/skf-accordion/index.js +0 -13
  117. package/dist/react/skf-alert/index.d.ts +0 -9
  118. package/dist/react/skf-alert/index.js +0 -17
  119. package/dist/react/skf-breadcrumb/index.d.ts +0 -9
  120. package/dist/react/skf-breadcrumb/index.js +0 -17
  121. package/dist/react/skf-breadcrumb-item/index.d.ts +0 -3
  122. package/dist/react/skf-breadcrumb-item/index.js +0 -13
  123. package/dist/react/skf-button/index.d.ts +0 -9
  124. package/dist/react/skf-button/index.js +0 -17
  125. package/dist/react/skf-card/index.d.ts +0 -3
  126. package/dist/react/skf-card/index.js +0 -13
  127. package/dist/react/skf-checkbox/index.d.ts +0 -9
  128. package/dist/react/skf-checkbox/index.js +0 -17
  129. package/dist/react/skf-collapse/index.d.ts +0 -9
  130. package/dist/react/skf-collapse/index.js +0 -17
  131. package/dist/react/skf-datepicker/index.d.ts +0 -12
  132. package/dist/react/skf-datepicker/index.js +0 -18
  133. package/dist/react/skf-dialog/index.d.ts +0 -15
  134. package/dist/react/skf-dialog/index.js +0 -19
  135. package/dist/react/skf-divider/index.d.ts +0 -3
  136. package/dist/react/skf-divider/index.js +0 -13
  137. package/dist/react/skf-heading/index.d.ts +0 -3
  138. package/dist/react/skf-heading/index.js +0 -13
  139. package/dist/react/skf-icon/index.d.ts +0 -3
  140. package/dist/react/skf-icon/index.js +0 -13
  141. package/dist/react/skf-input/index.d.ts +0 -12
  142. package/dist/react/skf-input/index.js +0 -18
  143. package/dist/react/skf-link/index.d.ts +0 -3
  144. package/dist/react/skf-link/index.js +0 -13
  145. package/dist/react/skf-loader/index.d.ts +0 -3
  146. package/dist/react/skf-loader/index.js +0 -13
  147. package/dist/react/skf-logo/index.d.ts +0 -3
  148. package/dist/react/skf-logo/index.js +0 -13
  149. package/dist/react/skf-menu/index.d.ts +0 -12
  150. package/dist/react/skf-menu/index.js +0 -18
  151. package/dist/react/skf-menu-item/index.d.ts +0 -27
  152. package/dist/react/skf-menu-item/index.js +0 -23
  153. package/dist/react/skf-popover/index.d.ts +0 -12
  154. package/dist/react/skf-popover/index.js +0 -18
  155. package/dist/react/skf-progress/index.d.ts +0 -3
  156. package/dist/react/skf-progress/index.js +0 -13
  157. package/dist/react/skf-radio/index.d.ts +0 -9
  158. package/dist/react/skf-radio/index.js +0 -17
  159. package/dist/react/skf-select/index.d.ts +0 -21
  160. package/dist/react/skf-select/index.js +0 -21
  161. package/dist/react/skf-select-option/index.d.ts +0 -9
  162. package/dist/react/skf-select-option/index.js +0 -17
  163. package/dist/react/skf-select-option-group/index.d.ts +0 -3
  164. package/dist/react/skf-select-option-group/index.js +0 -13
  165. package/dist/react/skf-stepper/index.d.ts +0 -9
  166. package/dist/react/skf-stepper/index.js +0 -17
  167. package/dist/react/skf-stepper-item/index.d.ts +0 -9
  168. package/dist/react/skf-stepper-item/index.js +0 -17
  169. package/dist/react/skf-switch/index.d.ts +0 -3
  170. package/dist/react/skf-switch/index.js +0 -13
  171. package/dist/react/skf-tab/index.d.ts +0 -12
  172. package/dist/react/skf-tab/index.js +0 -18
  173. package/dist/react/skf-tab-group/index.d.ts +0 -3
  174. package/dist/react/skf-tab-group/index.js +0 -13
  175. package/dist/react/skf-tab-panel/index.d.ts +0 -3
  176. package/dist/react/skf-tab-panel/index.js +0 -13
  177. package/dist/react/skf-tag/index.d.ts +0 -3
  178. package/dist/react/skf-tag/index.js +0 -13
  179. package/dist/react/skf-textarea/index.d.ts +0 -12
  180. package/dist/react/skf-textarea/index.js +0 -18
  181. package/dist/react/skf-toast/index.d.ts +0 -3
  182. package/dist/react/skf-toast/index.js +0 -13
  183. package/dist/react/skf-toast-wrapper/index.d.ts +0 -3
  184. package/dist/react/skf-toast-wrapper/index.js +0 -13
  185. package/dist/react/skf-tooltip/index.d.ts +0 -12
  186. package/dist/react/skf-tooltip/index.js +0 -18
@@ -1,227 +1,262 @@
1
- import { dateFormatter as v, isPopoverOpen as S, debounce as E, isDate as $ } from "./datepicker-input.helpers.js";
2
- import { computePosition as C, flip as I, offset as M } from "@floating-ui/dom";
3
- import { FormBase as O } from "../../internal/components/formBase.js";
4
- import { PopoverController as T } from "../../internal/controllers/popover.controller.js";
5
- import { hintSeverity as B } from "../../internal/helpers/hintSeverity.js";
6
- import { watch as P } from "../../internal/helpers/watch.js";
1
+ import { dateFormatter as v, is as f, isPopoverOpen as S, debounce as E } from "./datepicker-input.helpers.js";
2
+ import "../icon/icon.js";
3
+ import { computePosition as C, flip as I, offset as O } from "@floating-ui/dom";
4
+ import { FormBase as M } from "../../internal/components/formBase.js";
5
+ import { PopoverController as P } from "../../internal/controllers/popover.controller.js";
6
+ import { hintSeverity as T } from "../../internal/helpers/hintSeverity.js";
7
+ import { watch as B } from "../../internal/helpers/watch.js";
7
8
  import { Asterisk as x } from "../../internal/templates/asterisk.js";
8
- import { Temporal as F } from "@js-temporal/polyfill";
9
- import q from "../../styles/component.styles.js";
10
- import { html as m, nothing as g } from "lit";
11
- import { property as d, state as b, query as y, queryAssignedNodes as R } from "lit/decorators.js";
12
- import { ifDefined as u } from "lit/directives/if-defined.js";
13
- import { live as k } from "lit/directives/live.js";
9
+ import { Temporal as w } from "@js-temporal/polyfill";
10
+ import L from "../../styles/component.styles.js";
11
+ import { nothing as g, html as y } from "lit";
12
+ import { property as h, state as $, query as b, queryAssignedNodes as R } from "lit/decorators.js";
13
+ import { ifDefined as p } from "lit/directives/if-defined.js";
14
+ import { live as F } from "lit/directives/live.js";
14
15
  import "../date-picker/datepicker.js";
15
- import { styles as j } from "./datepicker-input.styles.js";
16
- var L = Object.defineProperty, V = Object.getOwnPropertyDescriptor, n = (D, t, e, a) => {
17
- for (var l = a > 1 ? void 0 : a ? V(t, e) : t, o = D.length - 1, h; o >= 0; o--)
18
- (h = D[o]) && (l = (a ? h(t, e, l) : h(l)) || l);
19
- return a && l && L(t, e, l), l;
16
+ import { styles as A } from "./datepicker-input.styles.js";
17
+ var j = Object.defineProperty, q = Object.getOwnPropertyDescriptor, r = (D, e, t, a) => {
18
+ for (var l = a > 1 ? void 0 : a ? q(e, t) : e, n = D.length - 1, d; n >= 0; n--)
19
+ (d = D[n]) && (l = (a ? d(e, t, l) : d(l)) || l);
20
+ return a && l && j(e, t, l), l;
20
21
  };
21
- const _ = class _ extends O {
22
+ const _ = class _ extends M {
22
23
  constructor() {
23
- super(), this.popoverController = new T(this), this.id = "skf-datepicker-input", this.placeholder = "Select date", this.range = !1, this.validateOn = "change", this.invalid = !1, this.selectedRangeDates = { start: null, end: null }, this.showClearbutton = !1, this._handleSelectedDate = (t) => {
24
- console.log("selected-date-changed event fired", this.value || "no value", t.detail), this.pristine = !1, this._internals.setFormValue(this.value ?? ""), this.validateInput();
25
- }, this._handleDateSelected = (t) => {
26
- if (this.range && "start" in t.detail.date && "end" in t.detail.date) {
27
- const e = t.detail.date.start, a = t.detail.date.end;
28
- this.value = `${v(e)},${v(a)}`, this.selectedRangeDates = { start: e, end: a };
29
- } else !this.range && t.detail.date instanceof Date && (this.value = v(t.detail.date), this._animatePopover({ el: this.$popover, show: !1 }).then(() => {
24
+ super(), this.popoverController = new P(this), this.id = "skf-datepicker-input", this.placeholder = "YYYY-MM-DD", this.range = !1, this.size = "md", this.validateOn = "change", this.invalid = !1, this.selectedRangeDates = { start: null, end: null }, this.showClearbutton = !1, this.abortController = new AbortController(), this.abortSignal = this.abortController.signal, this._handleSelectedDate = () => {
25
+ this.pristine = !1, this._internals.setFormValue(this.value ?? ""), this.validateInput();
26
+ }, this._handleDateSelected = (e) => {
27
+ if (this.range && "start" in e.detail.date && "end" in e.detail.date) {
28
+ const t = e.detail.date.start, a = e.detail.date.end;
29
+ this.value = `${v(t)},${v(a)}`, this.selectedRangeDates = { start: t, end: a };
30
+ } else !this.range && e.detail.date instanceof Date && (this.value = v(e.detail.date), this._animatePopover({ el: this.$popover, show: !1 }).then(() => {
30
31
  this.$popover.hidePopover();
31
32
  }));
33
+ }, this._handleKeyboardEvents = (e) => {
34
+ var a, l;
35
+ const t = e.target.closest("input");
36
+ if (t) {
37
+ if ((t.selectionStart ?? 0) < t.value.length && /[[0-9-]/.test(e.key)) {
38
+ const n = t.selectionStart ?? 0, u = t.value.split("").slice(0, n);
39
+ t.value = u.join("");
40
+ }
41
+ if (t.name.endsWith("-end") && (e.key === "Backspace" && t.value.length === 0 || t.selectionStart === 0 && e.key === "ArrowLeft") && (e.preventDefault(), this.$input.focus()), e.key === "Tab" && !e.shiftKey && t.name.endsWith("-end")) {
42
+ e.preventDefault();
43
+ const d = (a = this.$popover.childNodes[1].shadowRoot) == null ? void 0 : a.querySelector("skf-datepicker-calendar"), u = (l = d == null ? void 0 : d.shadowRoot) == null ? void 0 : l.querySelector("button");
44
+ u == null || u.focus();
45
+ }
46
+ if ((t.value.length === 4 || t.value.length === 7) && /[[0-9]/.test(e.key) && (t.value = `${t.value}-${e.key}`, e.preventDefault()), e.key === "Escape")
47
+ if (t.blur(), this.$popover.hidePopover(), this.range) {
48
+ const n = this.$input.value, d = this.$input_range_end.value;
49
+ if (!f(n, d).date()) return;
50
+ this.$datepicker.selectedDateRange = {
51
+ start: new Date(n),
52
+ end: new Date(d)
53
+ }, this.$datepicker.emit("selected-date-changed", {
54
+ detail: { date: new Date(n) }
55
+ });
56
+ } else {
57
+ if (!t.value || !f(t.value).date()) return;
58
+ this.$datepicker.emit("selected-date-changed", {
59
+ detail: { date: new Date(t.value) }
60
+ });
61
+ }
62
+ e.key === "Enter" && (t.blur(), this.$popover.hidePopover());
63
+ }
32
64
  }, this._handleFocus = () => {
65
+ this.showPopover();
66
+ }, this.showPopover = () => {
33
67
  if (S(this.$popover)) return;
34
68
  E(() => {
35
69
  this.$popover.showPopover(), this._animatePopover({ show: !0 });
36
- }, 200)();
37
- }, this._handleBlur = (t) => {
38
- const e = t.target;
39
- if (!e.name.endsWith("-end") && !this.range) return;
40
- if ($(e.value) && this.$datepicker.emit("selected-date-changed", {
41
- detail: { date: new Date(e.value) }
42
- }), e.name.endsWith("-end") || !this.range) {
43
- const l = t.relatedTarget;
44
- a(this, l);
45
- }
46
- function a(l, o) {
47
- var h, c;
48
- if (o && !l.contains(o)) {
49
- console.log("Tab out detected");
50
- const r = (h = l.$popover.childNodes[1].shadowRoot) == null ? void 0 : h.querySelector("skf-datepicker-calendar"), p = (c = r == null ? void 0 : r.shadowRoot) == null ? void 0 : c.querySelector("button");
51
- p == null || p.focus();
52
- }
53
- }
70
+ }, 200)(), this.addEventListener("focusout", this.hidePopover, { once: !0, signal: this.abortSignal });
71
+ }, this.hidePopover = () => {
72
+ var t;
73
+ this.removeEventListener("focusout", this.hidePopover), ((t = document.activeElement) == null ? void 0 : t.closest("skf-datepicker-input")) !== this && this.$popover.hidePopover();
74
+ }, this._handleBlur = (e) => {
75
+ !e.target.name.endsWith("-end") && this.range;
54
76
  }, this._handleClose = () => {
55
77
  this.$anchor.blur();
56
78
  }, this.clearInput = () => {
57
79
  this.value = "", this.$datepicker.clearSelection();
58
80
  }, this.clear = () => {
59
81
  this.clearInput(), this._toggleClearButton(!1);
60
- }, this._handleInput = (t) => {
61
- const e = t.target;
62
- e.setCustomValidity(this.customError ?? ""), this.focusTomeoutId && clearTimeout(this.focusTomeoutId), this.$datepicker.date = e.value, this.range ? (this.$datepicker.selectedDateRange = {
63
- start: $(this.$input.value) ? new Date(this.$input.value) : null,
64
- end: $(this.$input_range_end.value) ? new Date(this.$input_range_end.value) : null
65
- }, $(this.$input.value) && (this.focusTomeoutId = setTimeout(() => {
66
- this.$input_range_end.focus();
67
- }, 2e3))) : this.$datepicker.selectedDate = new Date(e.value), this.validateOn === "input" && (this._pristine = !1, this.validateInput());
68
- }, this._toggleClearButton = (t = !1) => {
69
- this.showClearbutton = t;
82
+ }, this._handleInput = (e) => {
83
+ const t = e.target, a = String(t.value).replace(/[^0-9-]/g, "");
84
+ if (t.value = a, t.setCustomValidity(this.customError ?? ""), !!f(t.value).ISO()) {
85
+ if (this.focusTimeoutId && clearTimeout(this.focusTimeoutId), this.$datepicker.date = t.value, this.range) {
86
+ this.$datepicker.selectedDateRange = {
87
+ start: f(this.$input.value).ISO() ? new Date(this.$input.value) : null,
88
+ end: f(this.$input_range_end.value).ISO() ? new Date(this.$input_range_end.value) : null
89
+ };
90
+ const l = Object.values(this.$datepicker.selectedDateRange).filter(Boolean).map((n) => new Date(n).toLocaleDateString("en-CA")).join();
91
+ this.value = l, f(this.$input.value).ISO() && (this.focusTimeoutId = setTimeout(() => {
92
+ this.$input_range_end.focus();
93
+ }, 200));
94
+ } else
95
+ this.$datepicker.selectedDate = new Date(t.value), this.$datepicker.emit("selected-date-changed", {
96
+ detail: { date: new Date(t.value) }
97
+ });
98
+ this.validateOn === "input" && (this._pristine = !1, this.validateInput());
99
+ }
100
+ }, this._toggleClearButton = (e = !1) => {
101
+ this.showClearbutton = e;
70
102
  }, this.reposition = async () => {
71
- const { x: t, y: e } = await C(this.$anchor, this.$popover, {
103
+ const { x: e, y: t } = await C(this.$anchor, this.$popover, {
72
104
  placement: "bottom-start",
73
- middleware: [I(), M(0)],
105
+ middleware: [I(), O(0)],
74
106
  strategy: "fixed"
75
107
  });
76
108
  Object.assign(this.$popover.style, {
77
- left: `${String(t)}px`,
78
- top: `${String(e)}px`
109
+ left: `${String(e)}px`,
110
+ top: `${String(t)}px`
79
111
  });
80
112
  }, this.addEventListener("skf-datepicker-selected", this._handleDateSelected), this.addEventListener("reset", () => {
81
113
  this.clearInput(), this.validateInput();
82
114
  });
83
115
  }
84
- set customInvalid(t) {
85
- this.customError = t || "";
116
+ set customInvalid(e) {
117
+ this.customError = e ?? "";
86
118
  }
87
119
  get customInvalid() {
88
120
  return this.customError;
89
121
  }
90
122
  connectedCallback() {
91
- var t;
92
- super.connectedCallback(), this._init_date = (t = this.value) == null ? void 0 : t.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
123
+ var e;
124
+ super.connectedCallback(), this._init_date = (e = this.value) == null ? void 0 : e.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
125
+ }
126
+ disconnectedCallback() {
127
+ super.disconnectedCallback(), this.abortController.abort();
93
128
  }
94
129
  firstUpdated() {
95
- var t;
96
- this.$datepicker.date = this._init_date ? F.PlainDate.from(this._init_date).toString() : F.Now.plainDateISO().toString(), this.range ? this.$datepicker.selectedDateRange = {
130
+ var e;
131
+ this.$datepicker.date = this._init_date ? w.PlainDate.from(this._init_date).toString() : w.Now.plainDateISO().toString(), this.range ? this.$datepicker.selectedDateRange = {
97
132
  start: this._init_date ? new Date(this._init_date) : null,
98
- end: (t = this.value) != null && t.split(",")[1] ? new Date(this.value.split(",")[1]) : null
99
- } : this.$datepicker.selectedDate = this._init_date ? new Date(this._init_date) : void 0, this.validateInput();
133
+ end: (e = this.value) != null && e.split(",")[1] ? new Date(this.value.split(",")[1]) : null
134
+ } : this.$datepicker.selectedDate = this._init_date ? new Date(this._init_date) : void 0, this.hint && !this.hasAttribute("hint") && this.setAttribute("hint", this.hint), this.validateInput();
100
135
  }
101
- attributeChangedCallback(t, e, a) {
102
- if (super.attributeChangedCallback(t, e, a), t === "custom-invalid")
136
+ attributeChangedCallback(e, t, a) {
137
+ if (super.attributeChangedCallback(e, t, a), e === "custom-invalid")
103
138
  if (typeof a == "string") {
104
- const o = this.withFallback(a);
105
- this._pristine = !1, this._internals.setValidity({ customError: !0 }, o), this.invalid = !0, this.hint = o, this.checkValidity();
139
+ const n = this.withFallback(a);
140
+ this._pristine = !1, this._internals.setValidity({ customError: !0 }, n), this.invalid = !0, this.hint = n, this.checkValidity();
106
141
  } else
107
142
  this._internals.setValidity({}), this.validateInput();
108
143
  }
109
144
  _handleValueChange() {
110
- var t, e, a, l, o, h, c, i;
111
- (t = this.value) != null && t.trim() || this.$datepicker.clearSelection(), this._internals.setFormValue(this.value ?? ""), this.validateInput(), this._pristine = !1, this.$input.value = v((e = this.value) == null ? void 0 : e.split(",")[0]), this.range ? (this.$datepicker.selectedDateRange = {
112
- start: (o = this.value) != null && o.split(",")[0] ? new Date(this.value.split(",")[0]) : null,
113
- end: (h = this.value) != null && h.split(",")[1] ? new Date(this.value.split(",")[1]) : null
114
- }, this.$input_range_end.value = v((c = this.value) == null ? void 0 : c.split(",")[1]), this.$datepicker.date = ((i = this.value) == null ? void 0 : i.split(",")[0]) ?? "") : (this.$datepicker.selectedDate = (a = this.value) != null && a.split(",")[0] ? new Date(this.value.split(",")[0]) : void 0, this.$datepicker.date = ((l = this.value) == null ? void 0 : l.split(",")[0]) ?? ""), this.validateInput();
145
+ var e, t, a, l, n, d, u, i;
146
+ (e = this.value) != null && e.trim() || this.$datepicker.clearSelection(), this._internals.setFormValue(this.value ?? ""), this.validateInput(), this._pristine = !1, this.$input.value = v((t = this.value) == null ? void 0 : t.split(",")[0]), this.range ? (this.$datepicker.selectedDateRange = {
147
+ start: (n = this.value) != null && n.split(",")[0] ? new Date(this.value.split(",")[0]) : null,
148
+ end: (d = this.value) != null && d.split(",")[1] ? new Date(this.value.split(",")[1]) : null
149
+ }, this.$input_range_end.value = v((u = this.value) == null ? void 0 : u.split(",")[1]), this.$datepicker.date = ((i = this.value) == null ? void 0 : i.split(",")[0]) ?? "") : (this.$datepicker.selectedDate = (a = this.value) != null && a.split(",")[0] ? new Date(this.value.split(",")[0]) : void 0, this.$datepicker.date = ((l = this.value) == null ? void 0 : l.split(",")[0]) ?? ""), this.validateInput();
115
150
  }
116
151
  /** @internal */
117
- async _animatePopover({ el: t = this.$popover, show: e }) {
118
- return e && (t.style.opacity = "0", t.style.transform = "scaleY(0.5)"), new Promise((a) => {
152
+ async _animatePopover({ el: e = this.$popover, show: t }) {
153
+ return t && (e.style.opacity = "0", e.style.transform = "scaleY(0.5)"), new Promise((a) => {
119
154
  const l = [
120
155
  { opacity: 0, transform: "scaleY(0.5)" },
121
156
  { opacity: 1, transform: "scaleY(1)" }
122
- ], o = e ? l : l.reverse();
157
+ ], n = t ? l : l.reverse();
123
158
  setTimeout(
124
159
  () => {
125
- t.style.transformOrigin = "top";
126
- const h = this.$popover.animate(o, {
160
+ e.style.transformOrigin = "top";
161
+ const d = this.$popover.animate(n, {
127
162
  duration: 100,
128
163
  easing: "linear",
129
164
  fill: "both"
130
165
  });
131
- h.onfinish = () => {
166
+ d.onfinish = () => {
132
167
  a();
133
168
  };
134
169
  },
135
- e ? 0 : 50
170
+ t ? 0 : 50
136
171
  );
137
172
  });
138
173
  }
139
174
  /** @internal consider sharing this functionality with input */
140
175
  validateInput() {
141
176
  if (this._internals.validity.customError) return;
142
- let e = JSON.parse(JSON.stringify(this._internals.validity)), a = {};
177
+ let t = JSON.parse(JSON.stringify(this._internals.validity)), a = {};
143
178
  if (this.selectableFrom) {
144
- const { validityFragment: i, errorMessageFragment: r } = l(this);
145
- e = { ...e, ...i }, a = { ...a, ...r };
179
+ const { validityFragment: i, errorMessageFragment: o } = l(this);
180
+ t = { ...t, ...i }, a = { ...a, ...o };
146
181
  }
147
182
  if (this.selectableTo) {
148
- const { validityFragment: i, errorMessageFragment: r } = o(this);
149
- e = { ...e, ...i }, a = { ...a, ...r };
183
+ const { validityFragment: i, errorMessageFragment: o } = n(this);
184
+ t = { ...t, ...i }, a = { ...a, ...o };
150
185
  }
151
186
  if (this.range) {
152
- const { validityFragment: i, errorMessageFragment: r } = h(this);
153
- e = { ...e, ...i }, a = { ...a, ...r };
187
+ const { validityFragment: i, errorMessageFragment: o } = d(this);
188
+ t = { ...t, ...i }, a = { ...a, ...o };
154
189
  }
155
190
  if (this.required) {
156
- const { validityFragment: i, errorMessageFragment: r } = c(this);
157
- e = { ...e, ...i }, a = { ...a, ...r };
191
+ const { validityFragment: i, errorMessageFragment: o } = u(this);
192
+ t = { ...t, ...i }, a = { ...a, ...o };
158
193
  }
159
- if (e.valid = !Object.values(e).some((i) => i), this.invalid = !1, e.valid)
160
- this._internals.setValidity({ customError: this._internals.validity.customError });
194
+ if (t.valid = !Object.values(t).some((i) => i), this.invalid = !1, t.valid)
195
+ this._internals.setValidity({ customError: this._internals.validity.customError }), this.hint = this.getAttribute("hint") ?? "";
161
196
  else {
162
- this.invalid = !this._pristine && !e.valid;
197
+ this.invalid = !this._pristine && !t.valid;
163
198
  let i;
164
- for (i in e) {
165
- const r = `data-${i.toString()}`;
166
- if (e[i]) {
199
+ for (i in t) {
200
+ const o = `data-${i.toString()}`;
201
+ if (t[i]) {
167
202
  this.validationError = i.toString();
168
- const p = this.hasAttribute(r) ? this.getAttribute(r) : a[i];
203
+ const c = this.hasAttribute(o) ? this.getAttribute(o) : a[i];
169
204
  this._internals.setValidity(
170
205
  { [this.validationError]: !0, customError: this._internals.validity.customError },
171
- this.withFallback(p)
172
- ), this.invalid && this.customErrorDisplay && this.checkValidity();
206
+ this.withFallback(c)
207
+ ), c && !this._pristine && (this.hint = c), this.invalid && this.customErrorDisplay && this.checkValidity();
173
208
  }
174
209
  }
175
210
  }
176
211
  function l(i) {
177
- const r = { validityFragment: {}, errorMessageFragment: {} };
178
- if (!i.selectableFrom) return r;
179
- const p = new Date(i.selectableFrom);
180
- if (new Date(i.$input.value) < p) {
181
- const f = i.getAttribute("data-rangeunderflow") ?? "Date is out of range";
212
+ const o = { validityFragment: {}, errorMessageFragment: {} };
213
+ if (!i.selectableFrom) return o;
214
+ const c = new Date(i.selectableFrom);
215
+ if (new Date(i.$input.value) < c) {
216
+ const m = i.getAttribute("data-rangeunderflow") ?? `Date is out of range. Earliest selectable date is ${i.selectableFrom}.`;
182
217
  return {
183
218
  validityFragment: { rangeUnderflow: !0, valid: !1 },
184
- errorMessageFragment: { rangeUnderflow: f }
219
+ errorMessageFragment: { rangeUnderflow: m }
185
220
  };
186
221
  }
187
- return r;
222
+ return o;
188
223
  }
189
- function o(i) {
190
- const r = { validityFragment: {}, errorMessageFragment: {} };
191
- if (!i.selectableTo) return r;
192
- const p = new Date(i.selectableTo);
193
- if (new Date(i.$input.value) > p) {
194
- const f = i.getAttribute("data-rangeoverflow") ?? "Date is out of range";
224
+ function n(i) {
225
+ const o = { validityFragment: {}, errorMessageFragment: {} };
226
+ if (!i.selectableTo) return o;
227
+ const c = new Date(i.selectableTo);
228
+ if (new Date(i.$input.value) > c) {
229
+ const m = i.getAttribute("data-rangeoverflow") ?? `Date is out of range. Latest selectable date is ${i.selectableTo}.`;
195
230
  return {
196
231
  validityFragment: { rangeOverflow: !0, valid: !1 },
197
- errorMessageFragment: { rangeOverflow: f }
232
+ errorMessageFragment: { rangeOverflow: m }
198
233
  };
199
234
  }
200
- return r;
235
+ return o;
201
236
  }
202
- function h(i) {
203
- const r = { validityFragment: {}, errorMessageFragment: {} }, p = new Date(i.$input.value);
204
- if (new Date(i.$input_range_end.value) < p) {
205
- const f = i.getAttribute("data-rangeunderflow") ?? "Date is out of range";
237
+ function d(i) {
238
+ const o = { validityFragment: {}, errorMessageFragment: {} }, c = new Date(i.$input.value);
239
+ if (new Date(i.$input_range_end.value) < c) {
240
+ const m = i.getAttribute("data-rangeunderflow") ?? "End date cannot be before start date";
206
241
  return {
207
242
  validityFragment: { rangeUnderflow: !0, valid: !1 },
208
- errorMessageFragment: { rangeUnderflow: f }
243
+ errorMessageFragment: { rangeUnderflow: m }
209
244
  };
210
245
  }
211
- return r;
246
+ return o;
212
247
  }
213
- function c(i) {
214
- const r = { validityFragment: {}, errorMessageFragment: {} };
248
+ function u(i) {
249
+ const o = { validityFragment: {}, errorMessageFragment: {} };
215
250
  return !i.$input.value || i.range && !i.$input_range_end.value ? {
216
251
  validityFragment: { valueMissing: !0, valid: !1 },
217
252
  errorMessageFragment: { valueMissing: "This field is required" }
218
- } : r;
253
+ } : o;
219
254
  }
220
255
  }
221
256
  render() {
222
- var e, a, l, o, h, c, i, r;
223
- const t = (this._defaultSlot.length === 0 || !((a = (e = this._defaultSlot[0]) == null ? void 0 : e.textContent) != null && a.trim())) && !this.label;
224
- return m`
257
+ var t, a, l, n, d, u, i, o;
258
+ const e = (this._defaultSlot.length === 0 || !((a = (t = this._defaultSlot[0]) == null ? void 0 : t.textContent) != null && a.trim())) && !this.label;
259
+ return y`
225
260
  <div
226
261
  id="root"
227
262
  @mouseenter=${() => {
@@ -232,67 +267,73 @@ const _ = class _ extends O {
232
267
  }}
233
268
  >
234
269
  <label>
235
- <div class=${this.hideLabel ? "visually-hidden" : ""} ?hidden=${t} id="label">
270
+ <div class=${this.hideLabel ? "visually-hidden" : ""} ?hidden=${e} id="label">
236
271
  <slot>${this.label}</slot>
237
272
  ${this.required ? x(this.requiredLabel) : null}
238
273
  </div>
239
274
  <div id="input">
240
- <div id="affix">
241
- <input
242
- ?disabled=${this.disabled}
243
- ?readonly=${this.readonly}
244
- .value=${k(
275
+ <input
276
+ ?disabled=${this.disabled}
277
+ ?readonly=${this.readonly}
278
+ .value=${F(
245
279
  this.range ? v((l = this.value) == null ? void 0 : l.split(",")[0]) : v(this.value)
246
280
  )}
247
- @blur=${this._handleBlur}
248
- @click=${this._handleFocus}
249
- @focus=${this._handleFocus}
250
- @input=${this._handleInput}
251
- aria-describedby=${u((o = this.hint) != null && o.trim() ? "hint" : g)}
252
- aria-errormessage=${u((h = this.hint) != null && h.trim() ? "hint" : g)}
253
- aria-invalid=${!!this.invalid}
254
- autocomplete="off"
255
- data-testid="field-input"
256
- inputmode=${u(this.inputMode)}
257
- name=${u(this.name)}
258
- placeholder=${u(this.placeholder)}
259
- type="date"
260
- />
261
- </div>
262
- ${this.range ? m`<div style="align-content:center">→</div>
281
+ @blur=${this._handleBlur}
282
+ @click=${this._handleFocus}
283
+ @focus=${this._handleFocus}
284
+ @input=${this._handleInput}
285
+ @keydown=${this._handleKeyboardEvents}
286
+ aria-describedby=${p((n = this.hint) != null && n.trim() ? "hint" : g)}
287
+ aria-errormessage=${p((d = this.hint) != null && d.trim() ? "hint" : g)}
288
+ aria-invalid=${!!this.invalid}
289
+ autocomplete="off"
290
+ data-testid="field-input"
291
+ inputmode=${p(this.inputMode)}
292
+ maxlength="10"
293
+ name=${this.name ?? "calendar"}
294
+ placeholder=${p(this.placeholder)}
295
+ type="text"
296
+ />
297
+ ${this.range ? y`
298
+ <skf-icon name="arrowRight"></skf-icon>
263
299
  <input
264
300
  ?disabled=${this.disabled}
265
301
  ?readonly=${this.readonly}
266
- .value=${k(v((c = this.value) == null ? void 0 : c.split(",")[1]))}
302
+ .value=${F(v((u = this.value) == null ? void 0 : u.split(",")[1]))}
267
303
  @blur=${this._handleBlur}
268
304
  @click=${this._handleFocus}
269
305
  @focus=${this._handleFocus}
270
306
  @input=${this._handleInput}
271
- aria-describedby=${u((i = this.hint) != null && i.trim() ? "hint" : g)}
272
- aria-errormessage=${u((r = this.hint) != null && r.trim() ? "hint" : g)}
307
+ @keydown=${this._handleKeyboardEvents}
308
+ aria-describedby=${p((i = this.hint) != null && i.trim() ? "hint" : g)}
309
+ aria-errormessage=${p((o = this.hint) != null && o.trim() ? "hint" : g)}
273
310
  aria-invalid=${!!this.invalid}
274
311
  autocomplete="off"
275
312
  data-testid="field-input-range-end"
276
- inputmode=${u(this.inputMode)}
277
- name=${u(String(this.name) + "-end")}
278
- placeholder=${u(this.placeholder)}
279
- type="date"
280
- />` : g}
281
- ${this.showClearbutton ? m`<button class="password skf-icon-host" type="button" @click=${this.clear}>
282
- <skf-icon name="close" size="sm"></skf-icon>
283
- </button>` : m`
313
+ inputmode=${p(this.inputMode)}
314
+ maxlength="10"
315
+ name=${(this.name ?? "calendar") + "-end"}
316
+ placeholder=${p(this.placeholder)}
317
+ type="text"
318
+ />
319
+ ` : g}
320
+ ${this.showClearbutton ? y`
321
+ <button class="password skf-icon-host" type="button" @click=${this.clear}>
322
+ <skf-icon name="close" size="sm"></skf-icon>
323
+ </button>
324
+ ` : y`
284
325
  <button class="password skf-icon-host" type="button">
285
326
  <skf-icon name="calendarMonth" size="sm"></skf-icon>
286
327
  </button>
287
328
  `}
288
329
  </div>
289
330
  </label>
290
- ${this.hint && m`
331
+ ${this.hint && y`
291
332
  <skf-hint
292
333
  aria-live=${this.invalid ? "assertive" : "polite"}
293
334
  id="hint"
294
- severity=${u(B(this.severity, this.invalid))}
295
- >${this.customInvalid ? this.customInvalid : this.hint}
335
+ severity=${p(T(this.severity, this.invalid))}
336
+ >${this.customInvalid ?? this.hint}
296
337
  </skf-hint>
297
338
  `}
298
339
  </div>
@@ -301,96 +342,99 @@ const _ = class _ extends O {
301
342
  <skf-datepicker
302
343
  ?range=${this.range}
303
344
  id=${this.id}
304
- invalid-dates=${u(this.invalidDates)}
305
- selectable-from=${u(this.selectableFrom)}
306
- selectable-to=${u(this.selectableTo)}
345
+ invalid-dates=${p(this.invalidDates)}
346
+ selectable-from=${p(this.selectableFrom)}
347
+ selectable-to=${p(this.selectableTo)}
307
348
  ></skf-datepicker>
308
349
  </div>
309
350
  `;
310
351
  }
311
352
  };
312
- _.styles = [q, j];
353
+ _.styles = [L, A];
313
354
  let s = _;
314
- n([
315
- d({ attribute: "custom-invalid", reflect: !0 })
355
+ r([
356
+ h({ attribute: "custom-invalid", reflect: !0 })
316
357
  ], s.prototype, "customInvalid", 1);
317
- n([
318
- d({ type: String })
358
+ r([
359
+ h({ type: String })
319
360
  ], s.prototype, "id", 2);
320
- n([
321
- d()
361
+ r([
362
+ h()
322
363
  ], s.prototype, "label", 2);
323
- n([
324
- d({ type: Boolean, attribute: "hide-label" })
364
+ r([
365
+ h({ type: Boolean, attribute: "hide-label" })
325
366
  ], s.prototype, "hideLabel", 2);
326
- n([
327
- d()
367
+ r([
368
+ h()
328
369
  ], s.prototype, "hint", 2);
329
- n([
330
- d({ attribute: "invalid-dates" })
370
+ r([
371
+ h({ attribute: "invalid-dates" })
331
372
  ], s.prototype, "invalidDates", 2);
332
- n([
333
- d({ reflect: !0 })
373
+ r([
374
+ h({ reflect: !0 })
334
375
  ], s.prototype, "name", 2);
335
- n([
336
- d()
376
+ r([
377
+ h()
337
378
  ], s.prototype, "placeholder", 2);
338
- n([
339
- d({ type: Boolean })
379
+ r([
380
+ h({ type: Boolean })
340
381
  ], s.prototype, "range", 2);
341
- n([
342
- d({ type: Boolean })
382
+ r([
383
+ h({ type: Boolean })
343
384
  ], s.prototype, "readonly", 2);
344
- n([
345
- d({ attribute: "required-label" })
385
+ r([
386
+ h({ attribute: "required-label" })
346
387
  ], s.prototype, "requiredLabel", 2);
347
- n([
348
- d({ attribute: "selectable-from" })
388
+ r([
389
+ h({ attribute: "selectable-from" })
349
390
  ], s.prototype, "selectableFrom", 2);
350
- n([
351
- d({ attribute: "selectable-to" })
391
+ r([
392
+ h({ attribute: "selectable-to" })
352
393
  ], s.prototype, "selectableTo", 2);
353
- n([
354
- d({ reflect: !0 })
394
+ r([
395
+ h({ reflect: !0 })
355
396
  ], s.prototype, "severity", 2);
356
- n([
357
- d({ type: String, attribute: "validate-on" })
397
+ r([
398
+ h({ reflect: !0 })
399
+ ], s.prototype, "size", 2);
400
+ r([
401
+ h({ type: String, attribute: "validate-on" })
358
402
  ], s.prototype, "validateOn", 2);
359
- n([
360
- d()
403
+ r([
404
+ h()
361
405
  ], s.prototype, "value", 2);
362
- n([
363
- b()
406
+ r([
407
+ $()
364
408
  ], s.prototype, "_init_date", 2);
365
- n([
366
- d({ type: Boolean, reflect: !0 })
409
+ r([
410
+ h({ type: Boolean, reflect: !0 })
367
411
  ], s.prototype, "invalid", 2);
368
- n([
369
- b()
412
+ r([
413
+ $()
370
414
  ], s.prototype, "selectedRangeDates", 2);
371
- n([
372
- b()
415
+ r([
416
+ $()
373
417
  ], s.prototype, "showClearbutton", 2);
374
- n([
375
- y("#popover")
418
+ r([
419
+ b("#popover")
376
420
  ], s.prototype, "$popover", 2);
377
- n([
378
- y("#input")
421
+ r([
422
+ b("#input")
379
423
  ], s.prototype, "$anchor", 2);
380
- n([
381
- y('input[data-testid="field-input"]')
424
+ r([
425
+ b('input[data-testid="field-input"]')
382
426
  ], s.prototype, "$input", 2);
383
- n([
384
- y('input[data-testid="field-input-range-end"]')
427
+ r([
428
+ b('input[data-testid="field-input-range-end"]')
385
429
  ], s.prototype, "$input_range_end", 2);
386
- n([
387
- y("skf-datepicker")
430
+ r([
431
+ b("skf-datepicker")
388
432
  ], s.prototype, "$datepicker", 2);
389
- n([
433
+ r([
390
434
  R({ flatten: !0 })
391
435
  ], s.prototype, "_defaultSlot", 2);
392
- n([
393
- P("value", { waitUntilFirstUpdate: !0, afterUpdate: !0 })
436
+ r([
437
+ B("value", { waitUntilFirstUpdate: !0, afterUpdate: !0 })
394
438
  ], s.prototype, "_handleValueChange", 1);
395
439
  export {
396
440
  s as SkfDatePickerInput