@skf-design-system/ui-components 1.0.0-beta.7 → 1.0.1-beta.1

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 (127) hide show
  1. package/dist/components/alert/alert.component.d.ts +2 -2
  2. package/dist/components/alert/alert.component.js +34 -34
  3. package/dist/components/breadcrumb/breadcrumb.component.d.ts +29 -0
  4. package/dist/components/breadcrumb/breadcrumb.d.ts +8 -0
  5. package/dist/components/breadcrumb/breadcrumb.styles.d.ts +1 -0
  6. package/dist/components/breadcrumb-item/breadcrumb-item.component.d.ts +25 -0
  7. package/dist/components/breadcrumb-item/breadcrumb-item.d.ts +8 -0
  8. package/dist/components/breadcrumb-item/breadcrumb-item.styles.d.ts +1 -0
  9. package/dist/components/button/button.component.d.ts +6 -4
  10. package/dist/components/button/button.component.js +87 -70
  11. package/dist/components/button/button.styles.js +64 -45
  12. package/dist/components/checkbox/checkbox.component.d.ts +3 -1
  13. package/dist/components/checkbox/checkbox.component.js +71 -58
  14. package/dist/components/date-picker/datepicker.calendar.component.d.ts +72 -0
  15. package/dist/components/date-picker/datepicker.calendar.component.js +382 -0
  16. package/dist/components/date-picker/datepicker.calendar.styles.d.ts +1 -0
  17. package/dist/components/date-picker/datepicker.calendar.styles.js +192 -0
  18. package/dist/components/date-picker/datepicker.component.d.ts +74 -0
  19. package/dist/components/date-picker/datepicker.component.js +241 -0
  20. package/dist/components/date-picker/datepicker.d.ts +10 -0
  21. package/dist/components/date-picker/datepicker.helpers.d.ts +40 -0
  22. package/dist/components/date-picker/datepicker.helpers.js +69 -0
  23. package/dist/components/date-picker/datepicker.js +8 -0
  24. package/dist/components/date-picker/datepicker.styles.d.ts +1 -0
  25. package/dist/components/date-picker/datepicker.styles.js +99 -0
  26. package/dist/components/date-picker-input/datepicker-input.component.d.ts +107 -0
  27. package/dist/components/date-picker-input/datepicker-input.component.js +397 -0
  28. package/dist/components/date-picker-input/datepicker-input.d.ts +8 -0
  29. package/dist/components/date-picker-input/datepicker-input.helpers.d.ts +4 -0
  30. package/dist/components/date-picker-input/datepicker-input.helpers.js +29 -0
  31. package/dist/components/date-picker-input/datepicker-input.js +6 -0
  32. package/dist/components/date-picker-input/datepicker-input.styles.d.ts +1 -0
  33. package/dist/components/date-picker-input/datepicker-input.styles.js +22 -0
  34. package/dist/components/dialog/dialog.component.d.ts +0 -1
  35. package/dist/components/dialog/dialog.component.js +2 -4
  36. package/dist/components/icon/icon.component.d.ts +1 -4
  37. package/dist/components/icon/icon.component.js +28 -19
  38. package/dist/components/icon/icon.styles.js +53 -47
  39. package/dist/components/input/input.component.d.ts +1 -0
  40. package/dist/components/input/input.component.js +87 -80
  41. package/dist/components/link/link.component.d.ts +1 -0
  42. package/dist/components/link/link.component.js +21 -21
  43. package/dist/components/menu/menu.component.d.ts +24 -0
  44. package/dist/components/menu/menu.component.js +18 -0
  45. package/dist/components/menu/menu.d.ts +8 -0
  46. package/dist/components/menu/menu.js +6 -0
  47. package/dist/components/menu/menu.styles.d.ts +1 -0
  48. package/dist/components/menu/menu.styles.js +11 -0
  49. package/dist/components/menu-item/menu-item.component.d.ts +25 -0
  50. package/dist/components/menu-item/menu-item.component.js +13 -0
  51. package/dist/components/menu-item/menu-item.d.ts +8 -0
  52. package/dist/components/menu-item/menu-item.js +6 -0
  53. package/dist/components/menu-item/menu-item.styles.d.ts +1 -0
  54. package/dist/components/menu-item/menu-item.styles.js +19 -0
  55. package/dist/components/popover/popover.component.d.ts +29 -0
  56. package/dist/components/popover/popover.component.js +37 -0
  57. package/dist/components/popover/popover.d.ts +8 -0
  58. package/dist/components/popover/popover.js +6 -0
  59. package/dist/components/popover/popover.styles.d.ts +1 -0
  60. package/dist/components/popover/popover.styles.js +12 -0
  61. package/dist/components/select/select.component.d.ts +8 -10
  62. package/dist/components/select/select.component.js +115 -118
  63. package/dist/components/select/select.controllers.d.ts +0 -25
  64. package/dist/components/select/select.controllers.js +35 -95
  65. package/dist/components/stepper/stepper.component.d.ts +38 -0
  66. package/dist/components/stepper/stepper.component.js +91 -0
  67. package/dist/components/stepper/stepper.d.ts +8 -0
  68. package/dist/components/stepper/stepper.helpers.d.ts +16 -0
  69. package/dist/components/stepper/stepper.helpers.js +18 -0
  70. package/dist/components/stepper/stepper.js +6 -0
  71. package/dist/components/stepper/stepper.styles.d.ts +1 -0
  72. package/dist/components/stepper/stepper.styles.js +15 -0
  73. package/dist/components/stepper-item/stepper-item.component.d.ts +47 -0
  74. package/dist/components/stepper-item/stepper-item.component.js +113 -0
  75. package/dist/components/stepper-item/stepper-item.d.ts +8 -0
  76. package/dist/components/stepper-item/stepper-item.js +6 -0
  77. package/dist/components/stepper-item/stepper-item.styles.d.ts +1 -0
  78. package/dist/components/stepper-item/stepper-item.styles.js +98 -0
  79. package/dist/components/toast/toast.component.d.ts +7 -4
  80. package/dist/components/toast/toast.component.js +24 -20
  81. package/dist/components/toast/toast.singleton.d.ts +2 -7
  82. package/dist/components/toast/toast.singleton.js +25 -25
  83. package/dist/components/toast-item/toast-item.component.js +15 -15
  84. package/dist/components/toast-item/toast-item.styles.js +13 -11
  85. package/dist/components/tooltip/tooltip.component.d.ts +24 -0
  86. package/dist/components/tooltip/tooltip.component.js +18 -0
  87. package/dist/components/tooltip/tooltip.d.ts +8 -0
  88. package/dist/components/tooltip/tooltip.js +6 -0
  89. package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
  90. package/dist/components/tooltip/tooltip.styles.js +12 -0
  91. package/dist/custom-elements.json +3278 -1321
  92. package/dist/index.d.ts +8 -0
  93. package/dist/index.js +78 -54
  94. package/dist/internal/base-classes/popover/popover.base.d.ts +29 -0
  95. package/dist/internal/base-classes/popover/popover.base.js +116 -0
  96. package/dist/internal/base-classes/popover/popover.styles.d.ts +1 -0
  97. package/dist/internal/base-classes/popover/popover.styles.js +29 -0
  98. package/dist/internal/controllers/popover.controller.d.ts +17 -0
  99. package/dist/internal/controllers/popover.controller.js +44 -0
  100. package/dist/internal/helpers/dateFormatter.d.ts +2 -0
  101. package/dist/internal/helpers/hintSeverity.d.ts +1 -1
  102. package/dist/internal/helpers/utilityTypes.d.ts +22 -0
  103. package/dist/react/index.d.ts +11 -2
  104. package/dist/react/index.js +11 -2
  105. package/dist/react/skf-breadcrumb/index.d.ts +9 -0
  106. package/dist/react/skf-breadcrumb/index.js +17 -0
  107. package/dist/react/skf-breadcrumb-item/index.d.ts +3 -0
  108. package/dist/react/skf-breadcrumb-item/index.js +13 -0
  109. package/dist/react/skf-datepicker/index.d.ts +12 -0
  110. package/dist/react/skf-datepicker/index.js +18 -0
  111. package/dist/react/skf-menu/index.d.ts +12 -0
  112. package/dist/react/skf-menu/index.js +18 -0
  113. package/dist/react/skf-menu-item/index.d.ts +27 -0
  114. package/dist/react/skf-menu-item/index.js +23 -0
  115. package/dist/react/skf-popover/index.d.ts +12 -0
  116. package/dist/react/skf-popover/index.js +18 -0
  117. package/dist/react/skf-stepper/index.d.ts +9 -0
  118. package/dist/react/skf-stepper/index.js +17 -0
  119. package/dist/react/skf-stepper-item/index.d.ts +9 -0
  120. package/dist/react/skf-stepper-item/index.js +17 -0
  121. package/dist/react/skf-tooltip/index.d.ts +12 -0
  122. package/dist/react/skf-tooltip/index.js +18 -0
  123. package/dist/types/jsx/custom-element-jsx.d.ts +628 -155
  124. package/dist/types/vue/index.d.ts +369 -74
  125. package/dist/vscode.html-custom-data.json +761 -391
  126. package/dist/web-types.json +936 -293
  127. package/package.json +34 -33
@@ -1,25 +1,35 @@
1
1
  import "../icon/icon.js";
2
- import { FormBase as c } from "../../internal/components/formBase.js";
2
+ import { FormBase as p } from "../../internal/components/formBase.js";
3
3
  import { watch as h } from "../../internal/helpers/watch.js";
4
4
  import { Asterisk as v } from "../../internal/templates/asterisk.js";
5
5
  import m from "../../styles/component.styles.js";
6
- import { html as p, nothing as y } from "lit";
7
- import { property as r, state as f, query as _ } from "lit/decorators.js";
8
- import { ifDefined as b } from "lit/directives/if-defined.js";
9
- import g from "./checkbox.styles.js";
10
- var $ = Object.defineProperty, I = Object.getOwnPropertyDescriptor, e = (u, i, s, a) => {
11
- for (var l = a > 1 ? void 0 : a ? I(i, s) : i, o = u.length - 1, n; o >= 0; o--)
12
- (n = u[o]) && (l = (a ? n(i, s, l) : n(l)) || l);
13
- return a && l && $(i, s, l), l;
6
+ import { html as c, nothing as f } from "lit";
7
+ import { property as r, state as y, query as g } from "lit/decorators.js";
8
+ import { ifDefined as _ } from "lit/directives/if-defined.js";
9
+ import b from "./checkbox.styles.js";
10
+ var k = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, i = (u, t, s, a) => {
11
+ for (var l = a > 1 ? void 0 : a ? $(t, s) : t, n = u.length - 1, o; n >= 0; n--)
12
+ (o = u[n]) && (l = (a ? o(t, s, l) : o(l)) || l);
13
+ return a && l && k(t, s, l), l;
14
14
  };
15
- const d = class d extends c {
15
+ const d = class d extends p {
16
16
  constructor() {
17
- super(...arguments), this._initiallyChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._resetValue = (i) => {
18
- i.stopPropagation(), this.checked = this._initiallyChecked, this.$input && (this.$input.checked = !!this._initiallyChecked), this.setFormValue(this.checked ? this.value : null);
19
- }, this._renderIcon = (i) => p`
20
- <skf-icon color="inverse" name=${i} size=${this.size === "sm" ? "sm" : "md"}></skf-icon>
17
+ super(...arguments), this._initiallyChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._resetValue = (t) => {
18
+ t.stopPropagation(), this.checked = this._initiallyChecked, this.$input && (this.$input.checked = !!this._initiallyChecked), this.setFormValue(this.checked ? this.value : null);
19
+ }, this._renderIcon = (t) => c`
20
+ <skf-icon color="inverse" name=${t} size=${this.size === "sm" ? "sm" : "md"}></skf-icon>
21
21
  `;
22
22
  }
23
+ get checked() {
24
+ var t;
25
+ return ((t = this.$input) == null ? void 0 : t.checked) ?? !1;
26
+ }
27
+ set checked(t) {
28
+ this.setAttribute("checked", String(!!t)), this.$input && (this.$input.checked = !!t);
29
+ }
30
+ handleCheckedChange() {
31
+ this.setFormValue(this.checked ? this.value : null), this._validateInput();
32
+ }
23
33
  handleInvalidChange() {
24
34
  this._invalid ? (this.setAttribute("invalid", ""), this.showValid && this.removeAttribute("valid"), this.checkValidity()) : (this.removeAttribute("invalid"), !this.pristine && this.showValid && this.setAttribute("valid", "true"));
25
35
  }
@@ -37,8 +47,8 @@ const d = class d extends c {
37
47
  this.setValidity({}), this._validateInput();
38
48
  }
39
49
  firstUpdated() {
40
- var i;
41
- (i = this.$input) == null || i.addEventListener("change", (s) => {
50
+ var t;
51
+ (t = this.$input) == null || t.addEventListener("change", (s) => {
42
52
  var a;
43
53
  s.stopPropagation(), this.pristine = !1, this.checked = (a = this.$input) == null ? void 0 : a.checked, this._validateInput(), this.checked ? (this.indeterminate = !1, this.setFormValue(this.value)) : this.setFormValue(null), this.emitEvent("change");
44
54
  }), this.addEventListener("invalid", (s) => {
@@ -47,21 +57,21 @@ const d = class d extends c {
47
57
  }
48
58
  /** @internal */
49
59
  _validateInput() {
50
- var i;
60
+ var t;
51
61
  if (this._invalid = !1, this.customInvalid)
52
62
  this.setValidity({ customError: !0 }, "Custom error"), this._invalid = !0;
53
63
  else if (this.required && !this.checked) {
54
64
  this.pristine || (this._invalid = !0);
55
65
  const s = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : (
56
66
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
57
- ((i = this.$input) == null ? void 0 : i.validationMessage) || "Please check this box if you want to proceed"
67
+ ((t = this.$input) == null ? void 0 : t.validationMessage) || "Please check this box if you want to proceed"
58
68
  );
59
69
  this.setValidity({ valueMissing: !0 }, String(s));
60
70
  } else
61
71
  this.setValidity({});
62
72
  }
63
73
  render() {
64
- return p`
74
+ return c`
65
75
  <label id="root">
66
76
  <input
67
77
  ?checked=${this.checked}
@@ -69,69 +79,72 @@ const d = class d extends c {
69
79
  ?required=${this.required}
70
80
  .indeterminate=${this.indeterminate ?? !1}
71
81
  aria-invalid=${!!this._invalid}
72
- name=${b(this.name)}
82
+ name=${_(this.name)}
73
83
  type="checkbox"
74
84
  value=${this.value}
75
85
  />
76
86
  ${this._renderIcon("check")} ${this._renderIcon("removeMinus")}
77
87
  <div id="label">
78
88
  <slot>${this.label}</slot>
79
- ${this.required ? v(this.requiredLabel) : y}
89
+ ${this.required ? v(this.requiredLabel) : f}
80
90
  </div>
81
91
  </label>
82
92
  `;
83
93
  }
84
94
  };
85
- d.styles = [m, g];
86
- let t = d;
87
- e([
95
+ d.styles = [m, b];
96
+ let e = d;
97
+ i([
88
98
  r({ type: Boolean })
89
- ], t.prototype, "debug", 2);
90
- e([
99
+ ], e.prototype, "debug", 2);
100
+ i([
91
101
  r({ type: Boolean, reflect: !0 })
92
- ], t.prototype, "checked", 2);
93
- e([
102
+ ], e.prototype, "checked", 1);
103
+ i([
94
104
  r({ type: Boolean, attribute: "custom-invalid", reflect: !0 })
95
- ], t.prototype, "customInvalid", 2);
96
- e([
105
+ ], e.prototype, "customInvalid", 2);
106
+ i([
97
107
  r({ type: Boolean, reflect: !0 })
98
- ], t.prototype, "indeterminate", 2);
99
- e([
108
+ ], e.prototype, "indeterminate", 2);
109
+ i([
100
110
  r()
101
- ], t.prototype, "label", 2);
102
- e([
111
+ ], e.prototype, "label", 2);
112
+ i([
103
113
  r()
104
- ], t.prototype, "name", 2);
105
- e([
114
+ ], e.prototype, "name", 2);
115
+ i([
106
116
  r({ attribute: "required-label" })
107
- ], t.prototype, "requiredLabel", 2);
108
- e([
117
+ ], e.prototype, "requiredLabel", 2);
118
+ i([
109
119
  r({ reflect: !0 })
110
- ], t.prototype, "severity", 2);
111
- e([
120
+ ], e.prototype, "severity", 2);
121
+ i([
112
122
  r({ type: Boolean, attribute: "show-valid" })
113
- ], t.prototype, "showValid", 2);
114
- e([
123
+ ], e.prototype, "showValid", 2);
124
+ i([
115
125
  r({ reflect: !0 })
116
- ], t.prototype, "size", 2);
117
- e([
126
+ ], e.prototype, "size", 2);
127
+ i([
118
128
  r()
119
- ], t.prototype, "value", 2);
120
- e([
121
- f()
122
- ], t.prototype, "_invalid", 2);
123
- e([
124
- _("input")
125
- ], t.prototype, "$input", 2);
126
- e([
129
+ ], e.prototype, "value", 2);
130
+ i([
131
+ y()
132
+ ], e.prototype, "_invalid", 2);
133
+ i([
134
+ g("input")
135
+ ], e.prototype, "$input", 2);
136
+ i([
137
+ h("checked", { afterUpdate: !0 })
138
+ ], e.prototype, "handleCheckedChange", 1);
139
+ i([
127
140
  h("_invalid")
128
- ], t.prototype, "handleInvalidChange", 1);
129
- e([
141
+ ], e.prototype, "handleInvalidChange", 1);
142
+ i([
130
143
  h("_invalid", { afterUpdate: !0 })
131
- ], t.prototype, "handleDebugInvalid", 1);
132
- e([
144
+ ], e.prototype, "handleDebugInvalid", 1);
145
+ i([
133
146
  h("customInvalid")
134
- ], t.prototype, "handleCustomInvalidChange", 1);
147
+ ], e.prototype, "handleCustomInvalidChange", 1);
135
148
  export {
136
- t as SkfCheckbox
149
+ e as SkfCheckbox
137
150
  };
@@ -0,0 +1,72 @@
1
+ import { SkfElement } from '../../internal/components/skf-element.js';
2
+ import { Temporal } from '@js-temporal/polyfill';
3
+ import { type CSSResultGroup } from 'lit';
4
+ interface DateParts {
5
+ year?: number;
6
+ month?: number;
7
+ day?: number;
8
+ }
9
+ export declare class SkfDatePickerCalendar extends SkfElement {
10
+ static styles: CSSResultGroup;
11
+ /** @internal */
12
+ _secondCalendarOffset: number;
13
+ /** @internal calendar month to display */
14
+ date: Date;
15
+ eventid: string;
16
+ firstDayOfWeek: number;
17
+ /**
18
+ * A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
19
+ */
20
+ invalidDates?: string;
21
+ locale: string;
22
+ range: boolean;
23
+ /**
24
+ * Earliest selectable date. (yyyy-mm-dd format)
25
+ */
26
+ selectableFrom?: string;
27
+ /**
28
+ * Latest selectable date. (yyyy-mm-dd format)
29
+ */
30
+ selectableTo?: string;
31
+ selectedDate?: Date;
32
+ selectedDateRange: {
33
+ start: Date | null;
34
+ end: Date | null;
35
+ };
36
+ /** @internal */
37
+ _numberOfDays: number;
38
+ /** @internal */
39
+ _numberOfDaysLastMonth: number;
40
+ firstUpdated(): void;
41
+ /** For single select, the selected date */
42
+ attributeChangedCallback(name: string, oldVal: unknown, newVal: unknown): void;
43
+ /** @internal */
44
+ handleDateChange(): void;
45
+ /** @internal */
46
+ _createDate({ year, month, day }: DateParts, useTemporalApi: true): Temporal.PlainDate;
47
+ _createDate({ year, month, day }: DateParts, useTemporalApi?: false): Date;
48
+ /** @internal Converts a new Date object to PlainDate type. If no argument sent, uses 'this.date' */
49
+ _plainDate(date?: Date | null): Temporal.PlainDate | null;
50
+ /** @internal Check if a day is between two dates */
51
+ _isDateBetween(dateToCheck: Temporal.PlainDate, startDate?: Temporal.PlainDate, endDate?: Temporal.PlainDate): boolean;
52
+ render(): import("lit").TemplateResult<1>;
53
+ /** @internal */
54
+ private returnDayClasses;
55
+ /** @internal */
56
+ private handleSelectDay;
57
+ /** @internal */
58
+ private getCalendarPreMonthDays;
59
+ /** @internal */
60
+ private getCalendarRemaningDays;
61
+ /** @internal */
62
+ private calendarMonthStartsOn;
63
+ /** @internal */
64
+ private getCalendarStartDay;
65
+ dateSelectable: (dateString: string) => {
66
+ matchesInvalidDates: boolean | undefined;
67
+ dateWithinRange: boolean;
68
+ };
69
+ /** @internal */
70
+ private getCalendarHead;
71
+ }
72
+ export {};
@@ -0,0 +1,382 @@
1
+ import { dateFormatter as c } from "../date-picker-input/datepicker-input.helpers.js";
2
+ import { compareDates as y } from "./datepicker.helpers.js";
3
+ import { SkfElement as _ } from "../../internal/components/skf-element.js";
4
+ import { watch as S } from "../../internal/helpers/watch.js";
5
+ import { Temporal as l } from "@js-temporal/polyfill";
6
+ import $ from "../../styles/component.styles.js";
7
+ import { html as u } from "lit";
8
+ import { property as o, state as b } from "lit/decorators.js";
9
+ import { repeat as D } from "lit/directives/repeat.js";
10
+ import { styles as M } from "./datepicker.calendar.styles.js";
11
+ var O = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (h, t, e, a) => {
12
+ for (var s = a > 1 ? void 0 : a ? w(t, e) : t, i = h.length - 1, d; i >= 0; i--)
13
+ (d = h[i]) && (s = (a ? d(t, e, s) : d(s)) || s);
14
+ return a && s && O(t, e, s), s;
15
+ };
16
+ const g = class g extends _ {
17
+ constructor() {
18
+ super(...arguments), this._secondCalendarOffset = 0, this.date = /* @__PURE__ */ new Date(), this.firstDayOfWeek = 0, this.locale = "en-CA", this.range = !1, this.selectedDate = void 0, this.selectedDateRange = {
19
+ start: null,
20
+ end: null
21
+ }, this._numberOfDays = 0, this._numberOfDaysLastMonth = 0, this.dateSelectable = (t) => {
22
+ var d;
23
+ const e = (d = this.invalidDates) == null ? void 0 : d.split(",").includes(t), a = !this.selectableTo || y(t, this.selectableTo) < 0, s = !this.selectableFrom || y(t, this.selectableFrom) > 0;
24
+ return { matchesInvalidDates: e, dateWithinRange: !(a && s) };
25
+ };
26
+ }
27
+ firstUpdated() {
28
+ this._secondCalendarOffset = this.id.endsWith("-range-end") ? -1 : 0;
29
+ }
30
+ /** For single select, the selected date */
31
+ attributeChangedCallback(t, e, a) {
32
+ t === "selected-date" && e !== a && (this.selectedDate = new Date(a));
33
+ }
34
+ handleDateChange() {
35
+ var t, e;
36
+ this._numberOfDays = ((t = this._plainDate(this.date)) == null ? void 0 : t.daysInMonth) ?? 0, this._numberOfDaysLastMonth = ((e = this._plainDate(this.date)) == null ? void 0 : e.subtract({
37
+ months: 1
38
+ }).daysInMonth) ?? 0;
39
+ }
40
+ _createDate({ year: t, month: e, day: a = 1 }, s) {
41
+ switch (e ?? (e = this.date.getMonth()), t ?? (t = this.date.getFullYear()), !0) {
42
+ case e < 0:
43
+ e = 11, t--;
44
+ break;
45
+ case e > 11:
46
+ e = 0, t++;
47
+ break;
48
+ }
49
+ if (s)
50
+ try {
51
+ return l.PlainDate.from({
52
+ year: t,
53
+ month: e + 1,
54
+ day: a
55
+ });
56
+ } catch (i) {
57
+ console.error("error", i);
58
+ }
59
+ return new Date(t, e, a);
60
+ }
61
+ /** @internal Converts a new Date object to PlainDate type. If no argument sent, uses 'this.date' */
62
+ _plainDate(t) {
63
+ if (!t) return null;
64
+ const e = {
65
+ year: t.getFullYear(),
66
+ month: t.getMonth() + 1,
67
+ // Months are 0-based in Date, but 1-based in Temporal
68
+ day: t.getDate()
69
+ };
70
+ try {
71
+ return l.PlainDate.from(e);
72
+ } catch (a) {
73
+ return console.log(e), console.error("error", a), null;
74
+ }
75
+ }
76
+ /** @internal Check if a day is between two dates */
77
+ _isDateBetween(t, e, a) {
78
+ if (!e || !a) return !1;
79
+ const s = l.PlainDate.compare(t, e) > 0, i = l.PlainDate.compare(t, a) < 0;
80
+ return s && i;
81
+ }
82
+ render() {
83
+ return u`
84
+ ${this.getCalendarHead()}
85
+
86
+ <!-- weekdays -->
87
+ <ul class="weekdays grid">
88
+ ${D(
89
+ Array.from({ length: 7 }, (t, e) => e),
90
+ (t) => t,
91
+ (t) => u`<li>
92
+ ${new Intl.DateTimeFormat(this.locale, {
93
+ weekday: "short"
94
+ }).format(new Date(2018, 0, t)).slice(0, 2)}
95
+ </li>`
96
+ )}
97
+ </ul>
98
+
99
+ <!-- start of calendar -->
100
+ <ol class="calendar grid">
101
+ <!-- previous month -->
102
+ ${this.getCalendarPreMonthDays()}
103
+ <!-- current days -->
104
+ ${D(
105
+ Array.from({ length: this._numberOfDays }, (t, e) => e + 1),
106
+ (t) => t,
107
+ (t) => {
108
+ const e = this._createDate({ day: t }, !0).toString(), a = this.returnDayClasses(t);
109
+ return u`<li>
110
+ <button
111
+ class="day ${a}"
112
+ data-date=${e}
113
+ aria-label="Choose ${this._createDate({
114
+ day: t
115
+ }).toLocaleDateString(this.locale, {
116
+ weekday: "long",
117
+ year: "numeric",
118
+ month: "short",
119
+ day: "numeric"
120
+ })}"
121
+ @click="${() => {
122
+ this.handleSelectDay({ day: t });
123
+ }}"
124
+ ?disabled="${a.includes("invalid")}"
125
+ >
126
+ ${t}
127
+ </button>
128
+ </li>`;
129
+ }
130
+ )}
131
+ <!-- next month -->
132
+ ${this.getCalendarRemaningDays()}
133
+ </ol>
134
+ <slot></slot>
135
+ <div class="triangle"></div>
136
+ `;
137
+ }
138
+ /** @internal */
139
+ returnDayClasses(t) {
140
+ var m, p, f;
141
+ const e = [], a = this._createDate({ day: t }).getDate(), s = ((m = this.selectedDate) == null ? void 0 : m.getMonth()) === this.date.getMonth();
142
+ this.range && this._isDateBetween(
143
+ this._createDate({ day: t }, !0),
144
+ this._plainDate(this.selectedDateRange.start) ?? void 0,
145
+ this._plainDate(this.selectedDateRange.end) ?? void 0
146
+ ) && e.push("in-range"), this.range && this.selectedDateRange.start && (this.selectedDateRange.start.getMonth() === this.date.getMonth() && this.selectedDateRange.start.getDate() === a && e.push("selected selected-start"), ((p = this.selectedDateRange.end) == null ? void 0 : p.getMonth()) === this.date.getMonth() && this.selectedDateRange.end.getDate() === a && e.push("selected selected-end"));
147
+ const { matchesInvalidDates: i, dateWithinRange: d } = this.dateSelectable(
148
+ this._createDate({ day: t }, !0).toString()
149
+ );
150
+ (i || d) && e.push("invalid");
151
+ const v = ((f = this.selectedDate) == null ? void 0 : f.getDate()) === a;
152
+ return !this.range && v && s && (console.log("is single date selected", this.selectedDate), e.push("selected")), this._createDate({ day: t }, !0).equals(String(this._plainDate(/* @__PURE__ */ new Date()))) && e.push("today"), e.join(" ");
153
+ }
154
+ /** @internal */
155
+ handleSelectDay({
156
+ year: t = this.date.getFullYear(),
157
+ month: e = this.date.getMonth(),
158
+ day: a
159
+ }) {
160
+ this.emit("selected-date-changed", {
161
+ detail: {
162
+ date: new Date(t, e, a),
163
+ id: this.eventid
164
+ }
165
+ });
166
+ }
167
+ /** @internal */
168
+ getCalendarPreMonthDays() {
169
+ return D(
170
+ Array.from(
171
+ {
172
+ length: this.getCalendarStartDay().getDay()
173
+ },
174
+ (t, e) => this._numberOfDaysLastMonth - this.getCalendarStartDay().getDay() + 1 + e
175
+ ),
176
+ (t) => t,
177
+ (t) => {
178
+ const e = ["prevmonth"], a = this._createDate(
179
+ {
180
+ year: this.date.getFullYear(),
181
+ month: this.date.getMonth() - 1,
182
+ day: t + 1
183
+ },
184
+ !0
185
+ ).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
186
+ return (s || i) && e.push("invalid"), u`<li class="day ">
187
+ <button
188
+ class=${e.join(" ")}
189
+ data-date=${a}
190
+ @click="${() => {
191
+ this.handleSelectDay({
192
+ month: this.date.getMonth() - 1,
193
+ day: t
194
+ }), this.emit("update-calendar-view", {
195
+ detail: l.PlainDate.from(c(this.date)).subtract({ months: 1 }).toString()
196
+ });
197
+ }}"
198
+ ?disabled=${e.includes("invalid")}
199
+ >
200
+ ${t}
201
+ </button>
202
+ </li>`;
203
+ }
204
+ );
205
+ }
206
+ /** @internal */
207
+ getCalendarRemaningDays() {
208
+ return (this._numberOfDays + this.calendarMonthStartsOn()) % 7 === 0 ? "" : D(
209
+ Array.from(
210
+ {
211
+ length: 7 - this._createDate({
212
+ year: this.date.getFullYear(),
213
+ month: this.date.getMonth(),
214
+ day: this._numberOfDays + 1
215
+ }).getDay()
216
+ },
217
+ (t, e) => e
218
+ ),
219
+ (t) => t,
220
+ (t) => {
221
+ const e = ["nextmonth"], a = this._createDate(
222
+ {
223
+ year: this.date.getFullYear(),
224
+ month: this.date.getMonth() + 1,
225
+ day: t + 1
226
+ },
227
+ !0
228
+ ).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
229
+ return (s || i) && e.push("invalid"), u`<li class="day">
230
+ <button
231
+ data-date=${a}
232
+ class=${e.join(" ")}
233
+ @click="${() => {
234
+ this.handleSelectDay({
235
+ month: this.date.getMonth() + 1,
236
+ day: t + 1
237
+ }), this.emit("update-calendar-view", {
238
+ detail: l.PlainDate.from(c(this.date)).add({ months: 1 }).toString()
239
+ });
240
+ }}"
241
+ ?disabled=${e.includes("invalid")}
242
+ >
243
+ ${t + 1}
244
+ </button>
245
+ </li>`;
246
+ }
247
+ );
248
+ }
249
+ /** @internal */
250
+ calendarMonthStartsOn({
251
+ year: t = this.date.getFullYear(),
252
+ month: e = this.date.getMonth()
253
+ } = {}) {
254
+ return this._createDate({ year: t, month: e, day: 1 }).getDay();
255
+ }
256
+ /** @internal */
257
+ getCalendarStartDay(t) {
258
+ const e = t ?? this.date;
259
+ return this._createDate({
260
+ year: e.getFullYear(),
261
+ month: e.getMonth(),
262
+ day: 1
263
+ });
264
+ }
265
+ /** @internal */
266
+ getCalendarHead() {
267
+ return u` <div class="calendar-head">
268
+ <div
269
+ class="calendar-head__controls${this.range && this.classList.contains("end") ? " hide" : ""}"
270
+ >
271
+ <button
272
+ aria-label="Previous year"
273
+ title="Previous year"
274
+ @click="${() => {
275
+ this.emit("update-calendar-view", {
276
+ detail: l.PlainDate.from(c(this.date)).subtract({ years: 1 }).toString()
277
+ });
278
+ }}"
279
+ >
280
+ <div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❮❮</div>
281
+ </button>
282
+ <button
283
+ aria-label="Previous month"
284
+ title="Previous month"
285
+ @click="${() => {
286
+ this.emit("update-calendar-view", {
287
+ detail: l.PlainDate.from(c(this.date)).subtract({ months: 1 }).toString()
288
+ });
289
+ }}"
290
+ >
291
+
292
+ </button>
293
+ </div>
294
+ <h4>
295
+ ${this.date.toLocaleString(this.locale, { month: "short" })} ${this.date.getFullYear()}
296
+ </h4>
297
+ <div
298
+ class="calendar-head__controls${this.range && this.classList.contains("start") ? " hide" : ""}"
299
+ >
300
+ <button
301
+ aria-label="Next month"
302
+ title="Next month"
303
+ @click="${() => {
304
+ this.emit("update-calendar-view", {
305
+ detail: l.PlainDate.from(c(this.date)).add({ months: 1 + this._secondCalendarOffset }).toString()
306
+ });
307
+ }}"
308
+ >
309
+
310
+ </button>
311
+ <button
312
+ aria-label="Next year"
313
+ title="Next year"
314
+ @click="${() => {
315
+ this.emit("update-calendar-view", {
316
+ detail: l.PlainDate.from(c(this.date)).add({ months: 12 + this._secondCalendarOffset }).toString()
317
+ });
318
+ }}"
319
+ >
320
+ <div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❯❯</div>
321
+ </button>
322
+ </div>
323
+ </div>`;
324
+ }
325
+ };
326
+ g.styles = [$, M];
327
+ let r = g;
328
+ n([
329
+ o({
330
+ converter: {
331
+ fromAttribute(h) {
332
+ return console.log("value", typeof h), new Date(h);
333
+ },
334
+ toAttribute(h) {
335
+ return h.toISOString();
336
+ }
337
+ }
338
+ })
339
+ ], r.prototype, "date", 2);
340
+ n([
341
+ o()
342
+ ], r.prototype, "eventid", 2);
343
+ n([
344
+ o({ type: Number })
345
+ ], r.prototype, "firstDayOfWeek", 2);
346
+ n([
347
+ o({ reflect: !0, attribute: "invalid-dates" })
348
+ ], r.prototype, "invalidDates", 2);
349
+ n([
350
+ o({ reflect: !0 })
351
+ ], r.prototype, "locale", 2);
352
+ n([
353
+ o({ type: Boolean })
354
+ ], r.prototype, "range", 2);
355
+ n([
356
+ o({ attribute: "selectable-from" })
357
+ ], r.prototype, "selectableFrom", 2);
358
+ n([
359
+ o({ attribute: "selectable-to" })
360
+ ], r.prototype, "selectableTo", 2);
361
+ n([
362
+ o({
363
+ attribute: "selected-date",
364
+ converter: { fromAttribute: (h) => new Date(h) },
365
+ reflect: !0
366
+ })
367
+ ], r.prototype, "selectedDate", 2);
368
+ n([
369
+ o({ type: Object })
370
+ ], r.prototype, "selectedDateRange", 2);
371
+ n([
372
+ b()
373
+ ], r.prototype, "_numberOfDays", 2);
374
+ n([
375
+ b()
376
+ ], r.prototype, "_numberOfDaysLastMonth", 2);
377
+ n([
378
+ S("date")
379
+ ], r.prototype, "handleDateChange", 1);
380
+ export {
381
+ r as SkfDatePickerCalendar
382
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;