@skf-design-system/ui-components 1.0.1-beta.0 → 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 (206) 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 +14 -14
  6. package/dist/components/breadcrumb/breadcrumb.component.d.ts +1 -1
  7. package/dist/components/button/button.component.d.ts +3 -3
  8. package/dist/components/button/button.component.js +59 -55
  9. package/dist/components/card/card.component.js +18 -30
  10. package/dist/components/card/card.styles.js +25 -28
  11. package/dist/components/checkbox/checkbox.component.d.ts +9 -7
  12. package/dist/components/checkbox/checkbox.component.js +71 -58
  13. package/dist/components/collapse/collapse.component.js +1 -1
  14. package/dist/components/date-picker/datepicker.calendar.component.d.ts +77 -0
  15. package/dist/components/date-picker/datepicker.calendar.component.js +415 -0
  16. package/dist/components/date-picker/datepicker.calendar.styles.d.ts +1 -0
  17. package/dist/components/date-picker/datepicker.calendar.styles.js +202 -0
  18. package/dist/components/date-picker/datepicker.component.d.ts +79 -0
  19. package/dist/components/date-picker/datepicker.component.js +261 -0
  20. package/dist/components/date-picker/datepicker.d.ts +10 -0
  21. package/dist/components/date-picker/datepicker.helpers.d.ts +41 -0
  22. package/dist/components/date-picker/datepicker.helpers.js +76 -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 +87 -0
  26. package/dist/components/date-picker-input/datepicker-input.component.d.ts +115 -0
  27. package/dist/components/date-picker-input/datepicker-input.component.js +441 -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 +38 -0
  30. package/dist/components/date-picker-input/datepicker-input.helpers.js +31 -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 +18 -0
  34. package/dist/components/dialog/dialog.component.d.ts +18 -28
  35. package/dist/components/dialog/dialog.component.js +94 -84
  36. package/dist/components/divider/divider.component.d.ts +4 -8
  37. package/dist/components/divider/divider.component.js +24 -46
  38. package/dist/components/divider/divider.styles.js +34 -30
  39. package/dist/components/drawer/drawer.component.d.ts +57 -0
  40. package/dist/components/drawer/drawer.component.js +124 -0
  41. package/dist/components/drawer/drawer.d.ts +8 -0
  42. package/dist/components/drawer/drawer.js +6 -0
  43. package/dist/components/drawer/drawer.styles.d.ts +1 -0
  44. package/dist/components/drawer/drawer.styles.js +71 -0
  45. package/dist/components/header/header.component.d.ts +45 -0
  46. package/dist/components/header/header.component.js +110 -0
  47. package/dist/components/header/header.d.ts +8 -0
  48. package/dist/components/header/header.js +6 -0
  49. package/dist/components/header/header.styles.d.ts +1 -0
  50. package/dist/components/header/header.styles.js +68 -0
  51. package/dist/components/heading/heading.component.d.ts +6 -12
  52. package/dist/components/heading/heading.component.js +17 -17
  53. package/dist/components/heading/heading.styles.d.ts +1 -2
  54. package/dist/components/heading/heading.styles.js +1 -1
  55. package/dist/components/icon/icon.component.d.ts +1 -1
  56. package/dist/components/icon/icon.component.js +19 -19
  57. package/dist/components/input/input.component.d.ts +3 -2
  58. package/dist/components/input/input.component.js +89 -82
  59. package/dist/components/input/input.controllers.d.ts +20 -6
  60. package/dist/components/input/input.controllers.js +14 -10
  61. package/dist/components/link/link.component.js +29 -28
  62. package/dist/components/link/link.styles.js +24 -20
  63. package/dist/components/loader/loader.component.js +19 -19
  64. package/dist/components/logo/logo.component.js +6 -6
  65. package/dist/components/menu/menu.component.d.ts +4 -5
  66. package/dist/components/menu/menu.component.js +1 -1
  67. package/dist/components/nav/nav.component.d.ts +17 -0
  68. package/dist/components/nav/nav.component.js +34 -0
  69. package/dist/components/nav/nav.d.ts +8 -0
  70. package/dist/components/nav/nav.js +6 -0
  71. package/dist/components/nav/nav.styles.d.ts +1 -0
  72. package/dist/components/nav/nav.styles.js +17 -0
  73. package/dist/components/nav-item/nav-item.component.d.ts +20 -0
  74. package/dist/components/nav-item/nav-item.component.js +38 -0
  75. package/dist/components/nav-item/nav-item.d.ts +8 -0
  76. package/dist/components/nav-item/nav-item.js +6 -0
  77. package/dist/components/nav-item/nav-item.styles.d.ts +1 -0
  78. package/dist/components/nav-item/nav-item.styles.js +39 -0
  79. package/dist/components/popover/popover.component.d.ts +5 -6
  80. package/dist/components/popover/popover.component.js +24 -24
  81. package/dist/components/progress/progress.component.js +7 -7
  82. package/dist/components/radio/radio.component.d.ts +10 -6
  83. package/dist/components/radio/radio.component.js +14 -14
  84. package/dist/components/radio/radio.styles.d.ts +1 -2
  85. package/dist/components/radio/radio.styles.js +1 -1
  86. package/dist/components/segmented-button/segmented-button.component.d.ts +32 -0
  87. package/dist/components/segmented-button/segmented-button.d.ts +8 -0
  88. package/dist/components/segmented-button/segmented-button.styles.d.ts +1 -0
  89. package/dist/components/segmented-button-item/segmented-button-item.component.d.ts +36 -0
  90. package/dist/components/segmented-button-item/segmented-button-item.d.ts +8 -0
  91. package/dist/components/segmented-button-item/segmented-button-item.styles.d.ts +1 -0
  92. package/dist/components/select/select.component.js +2 -2
  93. package/dist/components/select/select.controllers.d.ts +20 -9
  94. package/dist/components/select/select.controllers.js +27 -22
  95. package/dist/components/select-option/select-option.controllers.d.ts +11 -5
  96. package/dist/components/select-option-group/select-option-group.component.js +9 -9
  97. package/dist/components/stepper/stepper.component.d.ts +2 -1
  98. package/dist/components/stepper/stepper.component.js +9 -9
  99. package/dist/components/stepper/stepper.helpers.js +5 -5
  100. package/dist/components/stepper-item/stepper-item.component.js +25 -25
  101. package/dist/components/switch/switch.component.d.ts +7 -6
  102. package/dist/components/switch/switch.component.js +7 -7
  103. package/dist/components/tab/tab.component.js +4 -4
  104. package/dist/components/tab-panel/tab-panel.component.js +12 -12
  105. package/dist/components/tag/tag.component.d.ts +4 -2
  106. package/dist/components/tag/tag.component.js +14 -14
  107. package/dist/components/textarea/textarea.component.js +10 -10
  108. package/dist/components/toast/toast.component.d.ts +1 -1
  109. package/dist/components/toast/toast.component.js +13 -13
  110. package/dist/components/toast-wrapper/toast-wrapper.component.js +10 -10
  111. package/dist/components/tooltip/tooltip.component.d.ts +5 -6
  112. package/dist/components/tooltip/tooltip.component.js +11 -11
  113. package/dist/custom-elements.json +3702 -2190
  114. package/dist/index.d.ts +6 -0
  115. package/dist/index.js +84 -66
  116. package/dist/internal/base-classes/popover/popover.base.d.ts +17 -7
  117. package/dist/internal/base-classes/popover/popover.base.js +119 -75
  118. package/dist/internal/base-classes/popover/popover.styles.js +14 -1
  119. package/dist/internal/components/hint/hint.component.js +13 -13
  120. package/dist/internal/controllers/elementOverflowController.d.ts +13 -0
  121. package/dist/internal/controllers/popover.controller.d.ts +12 -6
  122. package/dist/internal/controllers/popover.controller.js +9 -14
  123. package/dist/internal/helpers/dateFormatter.d.ts +2 -0
  124. package/dist/internal/helpers/utilityTypes.d.ts +22 -0
  125. package/dist/internal/helpers/uuid.d.ts +15 -0
  126. package/dist/internal/helpers/uuid.js +14 -0
  127. package/dist/internal/storybook/styles.d.ts +1 -0
  128. package/dist/styles/form-field.styles.js +11 -6
  129. package/dist/styles/global.css +1 -1
  130. package/dist/types/jsx/custom-element-jsx.d.ts +663 -1240
  131. package/dist/types/vue/index.d.ts +453 -255
  132. package/dist/vscode.html-custom-data.json +821 -503
  133. package/dist/web-types.json +1005 -633
  134. package/package.json +43 -52
  135. package/dist/react/index.d.ts +0 -35
  136. package/dist/react/index.js +0 -35
  137. package/dist/react/skf-accordion/index.d.ts +0 -3
  138. package/dist/react/skf-accordion/index.js +0 -13
  139. package/dist/react/skf-alert/index.d.ts +0 -9
  140. package/dist/react/skf-alert/index.js +0 -17
  141. package/dist/react/skf-breadcrumb/index.d.ts +0 -9
  142. package/dist/react/skf-breadcrumb/index.js +0 -17
  143. package/dist/react/skf-breadcrumb-item/index.d.ts +0 -3
  144. package/dist/react/skf-breadcrumb-item/index.js +0 -13
  145. package/dist/react/skf-button/index.d.ts +0 -9
  146. package/dist/react/skf-button/index.js +0 -17
  147. package/dist/react/skf-card/index.d.ts +0 -3
  148. package/dist/react/skf-card/index.js +0 -13
  149. package/dist/react/skf-checkbox/index.d.ts +0 -9
  150. package/dist/react/skf-checkbox/index.js +0 -17
  151. package/dist/react/skf-collapse/index.d.ts +0 -9
  152. package/dist/react/skf-collapse/index.js +0 -17
  153. package/dist/react/skf-dialog/index.d.ts +0 -15
  154. package/dist/react/skf-dialog/index.js +0 -19
  155. package/dist/react/skf-divider/index.d.ts +0 -3
  156. package/dist/react/skf-divider/index.js +0 -13
  157. package/dist/react/skf-heading/index.d.ts +0 -3
  158. package/dist/react/skf-heading/index.js +0 -13
  159. package/dist/react/skf-icon/index.d.ts +0 -3
  160. package/dist/react/skf-icon/index.js +0 -13
  161. package/dist/react/skf-input/index.d.ts +0 -12
  162. package/dist/react/skf-input/index.js +0 -18
  163. package/dist/react/skf-link/index.d.ts +0 -3
  164. package/dist/react/skf-link/index.js +0 -13
  165. package/dist/react/skf-loader/index.d.ts +0 -3
  166. package/dist/react/skf-loader/index.js +0 -13
  167. package/dist/react/skf-logo/index.d.ts +0 -3
  168. package/dist/react/skf-logo/index.js +0 -13
  169. package/dist/react/skf-menu/index.d.ts +0 -12
  170. package/dist/react/skf-menu/index.js +0 -18
  171. package/dist/react/skf-menu-item/index.d.ts +0 -27
  172. package/dist/react/skf-menu-item/index.js +0 -23
  173. package/dist/react/skf-popover/index.d.ts +0 -12
  174. package/dist/react/skf-popover/index.js +0 -18
  175. package/dist/react/skf-progress/index.d.ts +0 -3
  176. package/dist/react/skf-progress/index.js +0 -13
  177. package/dist/react/skf-radio/index.d.ts +0 -9
  178. package/dist/react/skf-radio/index.js +0 -17
  179. package/dist/react/skf-select/index.d.ts +0 -21
  180. package/dist/react/skf-select/index.js +0 -21
  181. package/dist/react/skf-select-option/index.d.ts +0 -9
  182. package/dist/react/skf-select-option/index.js +0 -17
  183. package/dist/react/skf-select-option-group/index.d.ts +0 -3
  184. package/dist/react/skf-select-option-group/index.js +0 -13
  185. package/dist/react/skf-stepper/index.d.ts +0 -9
  186. package/dist/react/skf-stepper/index.js +0 -17
  187. package/dist/react/skf-stepper-item/index.d.ts +0 -9
  188. package/dist/react/skf-stepper-item/index.js +0 -17
  189. package/dist/react/skf-switch/index.d.ts +0 -3
  190. package/dist/react/skf-switch/index.js +0 -13
  191. package/dist/react/skf-tab/index.d.ts +0 -12
  192. package/dist/react/skf-tab/index.js +0 -18
  193. package/dist/react/skf-tab-group/index.d.ts +0 -3
  194. package/dist/react/skf-tab-group/index.js +0 -13
  195. package/dist/react/skf-tab-panel/index.d.ts +0 -3
  196. package/dist/react/skf-tab-panel/index.js +0 -13
  197. package/dist/react/skf-tag/index.d.ts +0 -3
  198. package/dist/react/skf-tag/index.js +0 -13
  199. package/dist/react/skf-textarea/index.d.ts +0 -12
  200. package/dist/react/skf-textarea/index.js +0 -18
  201. package/dist/react/skf-toast/index.d.ts +0 -3
  202. package/dist/react/skf-toast/index.js +0 -13
  203. package/dist/react/skf-toast-wrapper/index.d.ts +0 -3
  204. package/dist/react/skf-toast-wrapper/index.js +0 -13
  205. package/dist/react/skf-tooltip/index.d.ts +0 -12
  206. package/dist/react/skf-tooltip/index.js +0 -18
@@ -0,0 +1,415 @@
1
+ import { dateFormatter as y } from "../date-picker-input/datepicker-input.helpers.js";
2
+ import { compareDates as $ } from "./datepicker.helpers.js";
3
+ import { SkfElement as O } from "../../internal/components/skf-element.js";
4
+ import { watch as R } from "../../internal/helpers/watch.js";
5
+ import { Temporal as m } from "@js-temporal/polyfill";
6
+ import C from "../../styles/component.styles.js";
7
+ import { html as p } from "lit";
8
+ import { property as g, state as M } from "lit/decorators.js";
9
+ import { repeat as w } from "lit/directives/repeat.js";
10
+ import { styles as F } from "./datepicker.calendar.styles.js";
11
+ var A = Object.defineProperty, P = Object.getOwnPropertyDescriptor, d = (D, t, e, a) => {
12
+ for (var s = a > 1 ? void 0 : a ? P(t, e) : t, i = D.length - 1, h; i >= 0; i--)
13
+ (h = D[i]) && (s = (a ? h(t, e, s) : h(s)) || s);
14
+ return a && s && A(t, e, s), s;
15
+ };
16
+ const E = class E extends O {
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._listenToKeyboard = () => ({
22
+ start: () => {
23
+ this.addEventListener("keydown", this._handleKeyDown);
24
+ },
25
+ stop: () => {
26
+ this.removeEventListener("keydown", this._handleKeyDown);
27
+ }
28
+ }), this._handleKeyDown = (t) => {
29
+ var s, i, h, v, _, S, b;
30
+ const { key: e } = t;
31
+ if ((e === "ArrowRight" || e === "ArrowLeft" || e === "ArrowDown" || e === "ArrowUp") && t.preventDefault(), e === "ArrowRight") {
32
+ const n = (s = this.shadowRoot) == null ? void 0 : s.activeElement, r = n == null ? void 0 : n.parentElement, c = r == null ? void 0 : r.nextElementSibling, l = c == null ? void 0 : c.firstElementChild;
33
+ l == null || l.focus();
34
+ }
35
+ if (e === "ArrowLeft") {
36
+ const n = (i = this.shadowRoot) == null ? void 0 : i.activeElement, r = n == null ? void 0 : n.parentElement, c = r == null ? void 0 : r.previousElementSibling, l = c == null ? void 0 : c.firstElementChild;
37
+ l == null || l.focus();
38
+ }
39
+ if (e === "ArrowDown") {
40
+ const n = (h = this.shadowRoot) == null ? void 0 : h.activeElement, r = n == null ? void 0 : n.parentElement, c = a(r), l = (v = r == null ? void 0 : r.parentElement) == null ? void 0 : v.children[c + 7], f = l == null ? void 0 : l.firstElementChild;
41
+ f == null || f.focus();
42
+ }
43
+ if (e === "ArrowUp") {
44
+ const n = (_ = this.shadowRoot) == null ? void 0 : _.activeElement, r = n == null ? void 0 : n.parentElement;
45
+ if (!r) return;
46
+ const c = Array.from(((S = r.parentElement) == null ? void 0 : S.children) ?? []).indexOf(r), l = (b = r.parentElement) == null ? void 0 : b.children[c - 7], f = l == null ? void 0 : l.firstElementChild;
47
+ f == null || f.focus();
48
+ }
49
+ function a(u) {
50
+ var n;
51
+ return u ? Array.from(((n = u.parentElement) == null ? void 0 : n.children) ?? []).indexOf(u) : 0;
52
+ }
53
+ }, this.dateSelectable = (t) => {
54
+ var h;
55
+ const e = (h = this.invalidDates) == null ? void 0 : h.split(",").includes(t), a = !this.selectableTo || $(t, this.selectableTo) < 0, s = !this.selectableFrom || $(t, this.selectableFrom) > 0;
56
+ return { matchesInvalidDates: e, dateWithinRange: !(a && s) };
57
+ };
58
+ }
59
+ firstUpdated() {
60
+ this._secondCalendarOffset = this.id.endsWith("-range-end") ? -1 : 0, this.addEventListener("focusin", this._listenToKeyboard().start), this.addEventListener("focusout", this._listenToKeyboard().stop);
61
+ }
62
+ /** For single select, the selected date */
63
+ attributeChangedCallback(t, e, a) {
64
+ t === "selected-date" && e !== a && (this.selectedDate = new Date(a));
65
+ }
66
+ handleDateChange() {
67
+ var t, e;
68
+ 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({
69
+ months: 1
70
+ }).daysInMonth) ?? 0;
71
+ }
72
+ _createDate({ year: t, month: e, day: a = 1 }, s) {
73
+ switch (e ?? (e = this.date.getMonth()), t ?? (t = this.date.getFullYear()), !0) {
74
+ case e < 0:
75
+ e = 11, t--;
76
+ break;
77
+ case e > 11:
78
+ e = 0, t++;
79
+ break;
80
+ }
81
+ if (s)
82
+ try {
83
+ return m.PlainDate.from({
84
+ year: t,
85
+ month: e + 1,
86
+ day: a
87
+ });
88
+ } catch (i) {
89
+ console.error("error", i);
90
+ }
91
+ return new Date(t, e, a);
92
+ }
93
+ /** @internal Converts a new Date object to PlainDate type. If no argument sent, uses 'this.date' */
94
+ _plainDate(t) {
95
+ if (!t) return null;
96
+ const e = {
97
+ year: t.getFullYear(),
98
+ month: t.getMonth() + 1,
99
+ // Months are 0-based in Date, but 1-based in Temporal
100
+ day: t.getDate()
101
+ };
102
+ try {
103
+ return m.PlainDate.from(e);
104
+ } catch (a) {
105
+ return console.log(e), console.error("error", a), null;
106
+ }
107
+ }
108
+ /** @internal Check if a day is between two dates */
109
+ _isDateBetween(t, e, a) {
110
+ if (!e || !a) return !1;
111
+ const s = m.PlainDate.compare(t, e) > 0, i = m.PlainDate.compare(t, a) < 0;
112
+ return s && i;
113
+ }
114
+ render() {
115
+ return p`
116
+ ${this.getCalendarHead()}
117
+
118
+ <!-- weekdays -->
119
+ <ul class="weekdays grid">
120
+ ${w(
121
+ Array.from({ length: 7 }, (t, e) => e),
122
+ (t) => t,
123
+ (t) => p`<li>
124
+ ${new Intl.DateTimeFormat(this.locale, {
125
+ weekday: "short"
126
+ }).format(new Date(2018, 0, t)).slice(0, 2)}
127
+ </li>`
128
+ )}
129
+ </ul>
130
+
131
+ <!-- start of calendar -->
132
+ <ol class="calendar grid">
133
+ <!-- previous month -->
134
+ ${this.getCalendarPreMonthDays()}
135
+ <!-- current days -->
136
+ ${w(
137
+ Array.from({ length: this._numberOfDays }, (t, e) => e + 1),
138
+ (t) => t,
139
+ (t) => {
140
+ const e = this._createDate({ day: t }, !0).toString(), a = this.returnDayClasses(t);
141
+ return p`<li>
142
+ <button
143
+ class="day ${a}"
144
+ data-date=${e}
145
+ aria-label="Choose ${this._createDate({
146
+ day: t
147
+ }).toLocaleDateString(this.locale, {
148
+ weekday: "long",
149
+ year: "numeric",
150
+ month: "short",
151
+ day: "numeric"
152
+ })}"
153
+ @click="${() => {
154
+ this.handleSelectDay({ day: t });
155
+ }}"
156
+ ?disabled="${a.includes("invalid")}"
157
+ >
158
+ ${t}
159
+ </button>
160
+ </li>`;
161
+ }
162
+ )}
163
+ <!-- next month -->
164
+ ${this.getCalendarRemaningDays()}
165
+ </ol>
166
+ <slot></slot>
167
+ <div class="triangle"></div>
168
+ `;
169
+ }
170
+ /** @internal */
171
+ returnDayClasses(t) {
172
+ var b, u, n, r;
173
+ const e = [], a = this._createDate({ day: t }).getDate(), s = ((b = this.selectedDate) == null ? void 0 : b.getMonth()) === this.date.getMonth(), i = ((u = this.selectedDate) == null ? void 0 : u.getFullYear()) === this.date.getFullYear();
174
+ this.range && this._isDateBetween(
175
+ this._createDate({ day: t }, !0),
176
+ this._plainDate(this.selectedDateRange.start) ?? void 0,
177
+ this._plainDate(this.selectedDateRange.end) ?? void 0
178
+ ) && e.push("in-range"), this.range && this.selectedDateRange.start && (this.selectedDateRange.start.getFullYear() === this.date.getFullYear() && this.selectedDateRange.start.getMonth() === this.date.getMonth() && this.selectedDateRange.start.getDate() === a && e.push("selected selected-start"), ((n = this.selectedDateRange.end) == null ? void 0 : n.getFullYear()) === this.date.getFullYear() && this.selectedDateRange.end.getMonth() === this.date.getMonth() && this.selectedDateRange.end.getDate() === a && e.push("selected selected-end"));
179
+ const { matchesInvalidDates: h, dateWithinRange: v } = this.dateSelectable(
180
+ this._createDate({ day: t }, !0).toString()
181
+ );
182
+ (h || v) && e.push("invalid");
183
+ const _ = ((r = this.selectedDate) == null ? void 0 : r.getDate()) === a;
184
+ return !this.range && _ && s && i && (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(" ");
185
+ }
186
+ /** @internal */
187
+ handleSelectDay({
188
+ year: t = this.date.getFullYear(),
189
+ month: e = this.date.getMonth(),
190
+ day: a
191
+ }) {
192
+ this.emit("selected-date-changed", {
193
+ detail: {
194
+ date: new Date(t, e, a),
195
+ id: this.eventid
196
+ }
197
+ });
198
+ }
199
+ /** @internal */
200
+ getCalendarPreMonthDays() {
201
+ return w(
202
+ Array.from(
203
+ {
204
+ length: this.getCalendarStartDay().getDay()
205
+ },
206
+ (t, e) => this._numberOfDaysLastMonth - this.getCalendarStartDay().getDay() + 1 + e
207
+ ),
208
+ (t) => t,
209
+ (t) => {
210
+ const e = ["prevmonth"], a = this._createDate(
211
+ {
212
+ year: this.date.getFullYear(),
213
+ month: this.date.getMonth() - 1,
214
+ day: t + 1
215
+ },
216
+ !0
217
+ ).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
218
+ return (s || i) && e.push("invalid"), p`<li class="day ">
219
+ <button
220
+ class=${e.join(" ")}
221
+ data-date=${a}
222
+ @click="${() => {
223
+ this.handleSelectDay({
224
+ month: this.date.getMonth() - 1,
225
+ day: t
226
+ }), this.emit("update-calendar-view", {
227
+ detail: m.PlainDate.from(y(this.date)).subtract({ months: 1 }).toString()
228
+ });
229
+ }}"
230
+ ?disabled=${e.includes("invalid")}
231
+ >
232
+ ${t}
233
+ </button>
234
+ </li>`;
235
+ }
236
+ );
237
+ }
238
+ /** @internal */
239
+ getCalendarRemaningDays() {
240
+ return (this._numberOfDays + this.calendarMonthStartsOn()) % 7 === 0 ? "" : w(
241
+ Array.from(
242
+ {
243
+ length: 7 - this._createDate({
244
+ year: this.date.getFullYear(),
245
+ month: this.date.getMonth(),
246
+ day: this._numberOfDays + 1
247
+ }).getDay()
248
+ },
249
+ (t, e) => e
250
+ ),
251
+ (t) => t,
252
+ (t) => {
253
+ const e = ["nextmonth"], a = this._createDate(
254
+ {
255
+ year: this.date.getFullYear(),
256
+ month: this.date.getMonth() + 1,
257
+ day: t + 1
258
+ },
259
+ !0
260
+ ).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
261
+ return (s || i) && e.push("invalid"), p`<li class="day">
262
+ <button
263
+ data-date=${a}
264
+ class=${e.join(" ")}
265
+ @click="${() => {
266
+ this.handleSelectDay({
267
+ month: this.date.getMonth() + 1,
268
+ day: t + 1
269
+ }), this.emit("update-calendar-view", {
270
+ detail: m.PlainDate.from(y(this.date)).add({ months: 1 }).toString()
271
+ });
272
+ }}"
273
+ ?disabled=${e.includes("invalid")}
274
+ >
275
+ ${t + 1}
276
+ </button>
277
+ </li>`;
278
+ }
279
+ );
280
+ }
281
+ /** @internal */
282
+ calendarMonthStartsOn({
283
+ year: t = this.date.getFullYear(),
284
+ month: e = this.date.getMonth()
285
+ } = {}) {
286
+ return this._createDate({ year: t, month: e, day: 1 }).getDay();
287
+ }
288
+ /** @internal */
289
+ getCalendarStartDay(t) {
290
+ const e = t ?? this.date;
291
+ return this._createDate({
292
+ year: e.getFullYear(),
293
+ month: e.getMonth(),
294
+ day: 1
295
+ });
296
+ }
297
+ /** @internal */
298
+ getCalendarHead() {
299
+ return p` <div class="calendar-head">
300
+ <div
301
+ class="calendar-head-controls${this.range && this.classList.contains("end") ? " hide" : ""}"
302
+ >
303
+ <button
304
+ aria-label="Previous year"
305
+ title="Previous year"
306
+ @click="${() => {
307
+ this.emit("update-calendar-view", {
308
+ detail: m.PlainDate.from(y(this.date)).subtract({ years: 1 }).toString()
309
+ });
310
+ }}"
311
+ >
312
+ <div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❮❮</div>
313
+ </button>
314
+ <button
315
+ aria-label="Previous month"
316
+ title="Previous month"
317
+ @click="${() => {
318
+ this.emit("update-calendar-view", {
319
+ detail: m.PlainDate.from(y(this.date)).subtract({ months: 1 }).toString()
320
+ });
321
+ }}"
322
+ >
323
+
324
+ </button>
325
+ </div>
326
+ <h4>
327
+ ${this.date.toLocaleString(this.locale, { month: "short" })}
328
+ ${this.range && this.classList.contains("start") ? p` -&nbsp;` : this.date.getFullYear()}
329
+ </h4>
330
+ <div
331
+ class="calendar-head-controls${this.range && this.classList.contains("start") ? " hide" : ""}"
332
+ >
333
+ <button
334
+ aria-label="Next month"
335
+ title="Next month"
336
+ @click="${() => {
337
+ this.emit("update-calendar-view", {
338
+ detail: m.PlainDate.from(y(this.date)).add({ months: 1 + this._secondCalendarOffset }).toString()
339
+ });
340
+ }}"
341
+ >
342
+
343
+ </button>
344
+ <button
345
+ aria-label="Next year"
346
+ title="Next year"
347
+ @click="${() => {
348
+ this.emit("update-calendar-view", {
349
+ detail: m.PlainDate.from(y(this.date)).add({ months: 12 + this._secondCalendarOffset }).toString()
350
+ });
351
+ }}"
352
+ >
353
+ <div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❯❯</div>
354
+ </button>
355
+ </div>
356
+ </div>`;
357
+ }
358
+ };
359
+ E.styles = [C, F];
360
+ let o = E;
361
+ d([
362
+ g({
363
+ converter: {
364
+ fromAttribute(D) {
365
+ return console.log("value", typeof D), new Date(D);
366
+ },
367
+ toAttribute(D) {
368
+ return D.toISOString();
369
+ }
370
+ }
371
+ })
372
+ ], o.prototype, "date", 2);
373
+ d([
374
+ g()
375
+ ], o.prototype, "eventid", 2);
376
+ d([
377
+ g({ type: Number })
378
+ ], o.prototype, "firstDayOfWeek", 2);
379
+ d([
380
+ g({ reflect: !0, attribute: "invalid-dates" })
381
+ ], o.prototype, "invalidDates", 2);
382
+ d([
383
+ g({ reflect: !0 })
384
+ ], o.prototype, "locale", 2);
385
+ d([
386
+ g({ type: Boolean })
387
+ ], o.prototype, "range", 2);
388
+ d([
389
+ g({ attribute: "selectable-from" })
390
+ ], o.prototype, "selectableFrom", 2);
391
+ d([
392
+ g({ attribute: "selectable-to" })
393
+ ], o.prototype, "selectableTo", 2);
394
+ d([
395
+ g({
396
+ attribute: "selected-date",
397
+ converter: { fromAttribute: (D) => new Date(D) },
398
+ reflect: !0
399
+ })
400
+ ], o.prototype, "selectedDate", 2);
401
+ d([
402
+ g({ type: Object })
403
+ ], o.prototype, "selectedDateRange", 2);
404
+ d([
405
+ M()
406
+ ], o.prototype, "_numberOfDays", 2);
407
+ d([
408
+ M()
409
+ ], o.prototype, "_numberOfDaysLastMonth", 2);
410
+ d([
411
+ R("date")
412
+ ], o.prototype, "handleDateChange", 1);
413
+ export {
414
+ o as SkfDatePickerCalendar
415
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,202 @@
1
+ import { css as e } from "lit";
2
+ const o = e`
3
+ @layer components {
4
+ :host {
5
+ box-sizing: inherit;
6
+ contain: layout;
7
+ display: block;
8
+ position: relative;
9
+ width: 100%;
10
+ }
11
+
12
+ :host([hidden]) {
13
+ display: none !important;
14
+ }
15
+
16
+ .grid {
17
+ display: grid;
18
+ grid-template-columns: repeat(7, 1fr);
19
+ list-style: none;
20
+ margin: 0;
21
+ padding: 0;
22
+ }
23
+
24
+ h4 {
25
+ color: var(--skf-bg-color-neutral-7);
26
+ font-size: 1.2em;
27
+ margin: 0;
28
+ padding: 0;
29
+ white-space: nowrap;
30
+ }
31
+
32
+ .weekdays > li {
33
+ color: var(--skf-text-color-primary);
34
+ display: grid;
35
+ font-size: 1.2em;
36
+ margin-block: 1em 0.5em;
37
+ place-items: center;
38
+ user-select: none;
39
+ }
40
+
41
+ .calendar > li {
42
+ background-color: transparent;
43
+ border-radius: 0.2em;
44
+ display: grid;
45
+ min-width: 2.5em;
46
+ outline: 1px solid transparent;
47
+ place-items: center;
48
+
49
+ & button {
50
+ aspect-ratio: 1.2 / 1;
51
+ background-color: transparent;
52
+ border: 0;
53
+ border-radius: 0;
54
+ cursor: pointer;
55
+ display: grid;
56
+ font-size: 1.2em;
57
+ margin-block: 0.4em;
58
+ place-items: center;
59
+ transition: background-color 0.3s;
60
+ width: 100%;
61
+
62
+ &:focus-visible {
63
+ border-radius: 0.2em;
64
+ outline: 2px solid #469; /* TODO: token? */
65
+ outline-offset: 2px;
66
+ }
67
+
68
+ &.today {
69
+ background-color: var(--skf-bg-color-neutral-3);
70
+ color: var(--skf-bg-color-neutral-7);
71
+ }
72
+
73
+ &.in-range {
74
+ background-color: var(--skf-interactive-bg-color-secondary-hover);
75
+ }
76
+
77
+ &.selected {
78
+ background-color: var(--skf-interactive-bg-color-primary);
79
+ color: var(--skf-bg-color-neutral-1);
80
+ }
81
+
82
+ &.selected-start {
83
+ border-radius: 5px 0 0 5px;
84
+ }
85
+
86
+ &.selected-end {
87
+ border-radius: 0 5px 5px 0;
88
+ }
89
+
90
+ &.selected-start.selected-end {
91
+ border-radius: 5px;
92
+ }
93
+
94
+ &.prevmonth,
95
+ &.nextmonth {
96
+ color: var(--skf-text-color-tertiary);
97
+ }
98
+
99
+ &:not(.selected):hover {
100
+ background-color: var(--skf-interactive-bg-color-secondary-hover);
101
+ transition-duration: 0s;
102
+ }
103
+
104
+ &[disabled] {
105
+ cursor: not-allowed;
106
+ opacity: 0.5;
107
+ position: relative;
108
+
109
+ &::after {
110
+ background: linear-gradient(-45deg, transparent 45%, black 50%, transparent 50%);
111
+ content: '';
112
+ inset: 0;
113
+ position: absolute;
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ .calendar-head {
120
+ align-items: center;
121
+ display: flex;
122
+ font-size: 1.2em;
123
+ gap: 0;
124
+ justify-content: space-between;
125
+ margin: 0;
126
+ padding: 0;
127
+
128
+ :host([class='end']) & {
129
+ transform: translateX(calc(var(--skf-spacing-50) * -1));
130
+ }
131
+
132
+ :host([class='start']) & {
133
+ transform: translateX(var(--skf-spacing-50));
134
+ }
135
+
136
+ &::after {
137
+ background-color: var(--skf-border-color-primary);
138
+ bottom: -0.8em;
139
+ content: '';
140
+ display: block;
141
+ grid-column: 1 / -1;
142
+ height: 1px;
143
+ left: calc(var(--skf-spacing-50) * -1);
144
+ margin-inline: calc(var(--skf-spacing-50) * -2);
145
+ position: absolute;
146
+ right: calc(var(--skf-spacing-50) * -1);
147
+ }
148
+
149
+ & .calendar-head-controls {
150
+ display: contents;
151
+
152
+ &.hide {
153
+ display: none;
154
+ }
155
+ }
156
+
157
+ & h4 {
158
+ color: var(--skf-bg-color-neutral-7);
159
+ font-size: 1.2em;
160
+ margin: 0;
161
+ padding: 0;
162
+ text-align: center;
163
+ white-space: nowrap;
164
+ }
165
+
166
+ /* stylelint-disable-next-line no-descending-specificity */
167
+ & button {
168
+ background-color: transparent;
169
+ border: none;
170
+ color: var(--skf-text-color-primary);
171
+ cursor: pointer;
172
+ min-width: 1.5em;
173
+ padding: 0.2em;
174
+ text-align: center;
175
+
176
+ /* stylelint-disable-next-line no-descending-specificity */
177
+ &:focus-visible {
178
+ border-radius: 0.2em;
179
+ outline: 2px solid #469;
180
+ outline-offset: 2px;
181
+ }
182
+
183
+ & > div {
184
+ width: 1em;
185
+ }
186
+
187
+ /* stylelint-disable-next-line no-descending-specificity */
188
+ &:hover {
189
+ color: var(--skf-interactive-bg-color-primary);
190
+ }
191
+ }
192
+ }
193
+
194
+ .hide {
195
+ pointer-events: none;
196
+ visibility: hidden;
197
+ }
198
+ }
199
+ `;
200
+ export {
201
+ o as styles
202
+ };
@@ -0,0 +1,79 @@
1
+ import '../button/button';
2
+ import { SkfElement } from '../../internal/components/skf-element.js';
3
+ import { type CSSResultGroup } from 'lit';
4
+ import './datepicker';
5
+ export interface SkfDatePickerDateRange {
6
+ start: Date | null;
7
+ end: Date | null;
8
+ }
9
+ /**
10
+ * A date picker component that allows users to select a date or a range of dates.
11
+ *
12
+ * @element skf-datepicker
13
+ * @fires selected-date-changed - When a date is selected
14
+ * @fires selected-date-range-changed - When a range of dates is selected
15
+ *
16
+ * @prop {string} date - The date to display in the date picker
17
+ * @prop {boolean} range - If true, the date picker will allow the selection of a range of dates
18
+ * @prop {string} locale - The locale to use for formatting the date
19
+ *
20
+ * @slot - Default hint content placed inside the date picker
21
+ *
22
+ * @cssprop --max-width - The maximum width of the date picker
23
+ */
24
+ export declare class SkfDatePicker extends SkfElement {
25
+ static styles: CSSResultGroup;
26
+ locale: string;
27
+ date: string;
28
+ id: string;
29
+ /**
30
+ * A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
31
+ */
32
+ invalidDates?: string;
33
+ range: boolean;
34
+ selectedDate: Date | undefined;
35
+ /**
36
+ * Earliest selectable date. (yyyy-mm-dd format)
37
+ */
38
+ selectableFrom?: string;
39
+ /**
40
+ * Latest selectable date. (yyyy-mm-dd format)
41
+ */
42
+ selectableTo?: string;
43
+ selectedDateRange: SkfDatePickerDateRange;
44
+ /** @internal */
45
+ private _date?;
46
+ /** @internal */
47
+ _datePlusOneMonth: Date;
48
+ connectedCallback(): void;
49
+ protected firstUpdated(): void;
50
+ clearSelection(): void;
51
+ /** @internal */
52
+ private _handleCalendarView;
53
+ /** @internal */
54
+ private _handleSelectedDate;
55
+ /** @internal */
56
+ _onRangeCompleteEmitEvent(): void;
57
+ /** @internal */
58
+ _handleRangeChange(): void;
59
+ /** @internal */
60
+ _handleDateChange(): void;
61
+ /** @internal */
62
+ _handleSelectedDateRangeChange(): void;
63
+ /** @internal */
64
+ _handleSelectedDateChange(): void;
65
+ /** @internal */
66
+ _handleTodayClick: () => void;
67
+ /**
68
+ * Navigates to the given date.
69
+ * @param date - The date to navigate to, either a Date object or a string in the format 'yyyy-mm-dd'
70
+ */
71
+ gotoDate(date: Date | string): void;
72
+ render(): import("lit").TemplateResult<1>;
73
+ /** @internal */
74
+ private _renderTodayBtn;
75
+ /** @internal */
76
+ private _handleChangeCalendarView;
77
+ /** @internal */
78
+ private _animateView;
79
+ }