@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,261 @@
1
+ import "../button/button.js";
2
+ import { dateFormatter as l, is as v } from "../date-picker-input/datepicker-input.helpers.js";
3
+ import { SkfElement as R } from "../../internal/components/skf-element.js";
4
+ import { watch as p } from "../../internal/helpers/watch.js";
5
+ import S from "../../styles/component.styles.js";
6
+ import { html as D } from "lit";
7
+ import { property as o, state as m } from "lit/decorators.js";
8
+ import "./datepicker.js";
9
+ import { getDateParts as g, assertISODate as $, earliestDate as T, latestDate as C, compareDates as c, doAnimate as b } from "./datepicker.helpers.js";
10
+ import { styles as k } from "./datepicker.styles.js";
11
+ var F = Object.defineProperty, E = Object.getOwnPropertyDescriptor, n = (w, e, t, a) => {
12
+ for (var s = a > 1 ? void 0 : a ? E(e, t) : e, r = w.length - 1, d; r >= 0; r--)
13
+ (d = w[r]) && (s = (a ? d(e, t, s) : d(s)) || s);
14
+ return a && s && F(e, t, s), s;
15
+ };
16
+ const y = class y extends R {
17
+ constructor() {
18
+ super(...arguments), this.locale = "en-CA", this.date = (/* @__PURE__ */ new Date()).toLocaleDateString(this.locale), this.id = "", this.range = !1, this.selectedDate = void 0, this.selectedDateRange = {
19
+ start: null,
20
+ end: null
21
+ }, this._datePlusOneMonth = new Date(
22
+ new Date(this.date).getFullYear(),
23
+ new Date(this.date).getMonth() + 1,
24
+ 1
25
+ ), this._handleCalendarView = (e) => {
26
+ this._handleChangeCalendarView(e.detail);
27
+ }, this._handleSelectedDate = (e) => {
28
+ var t;
29
+ if (this.selectedDate = e.detail.date, console.log("selectedDate", this.selectedDate), this.range) {
30
+ const a = (t = this.shadowRoot) == null ? void 0 : t.querySelectorAll("skf-datepicker-calendar"), s = this.selectedDateRange, r = s.start && this.selectedDate < s.start;
31
+ if (!!(s.start && s.end) || r)
32
+ this.selectedDateRange = {
33
+ start: this.selectedDate,
34
+ end: null
35
+ };
36
+ else {
37
+ const f = !!s.start ? { end: e.detail.date } : { start: e.detail.date };
38
+ this.selectedDateRange = {
39
+ ...s,
40
+ ...f
41
+ };
42
+ }
43
+ this._onRangeCompleteEmitEvent(), a != null && a.length && [...a].forEach((h) => {
44
+ h.selectedDateRange = this.selectedDateRange;
45
+ });
46
+ }
47
+ this.emit("skf-datepicker-selected", {
48
+ detail: { date: this.range ? this.selectedDateRange : this.selectedDate }
49
+ }), this.requestUpdate();
50
+ }, this._handleTodayClick = () => {
51
+ const { month: e, year: t } = g(), { month: a, year: s } = g(this.date);
52
+ if (a === e && s === t && (this.selectedDateRange.start || this.selectedDate)) {
53
+ this.date = l(this.selectedDateRange.start ?? this.selectedDate), this.emit("update-calendar-view", {
54
+ detail: this.date
55
+ });
56
+ return;
57
+ }
58
+ if (this.range) {
59
+ this.emit("update-calendar-view", {
60
+ detail: l(/* @__PURE__ */ new Date())
61
+ });
62
+ return;
63
+ }
64
+ this.date = l(/* @__PURE__ */ new Date());
65
+ };
66
+ }
67
+ connectedCallback() {
68
+ super.connectedCallback(), this.addEventListener("update-calendar-view", this._handleCalendarView), this.addEventListener("selected-date-changed", this._handleSelectedDate);
69
+ }
70
+ firstUpdated() {
71
+ (this.selectedDateRange.start ?? this.selectedDate) && this._onRangeCompleteEmitEvent();
72
+ const t = this.selectedDate ?? this.selectedDateRange.start;
73
+ t instanceof Date && this.gotoDate(t);
74
+ }
75
+ clearSelection() {
76
+ this.selectedDateRange = {
77
+ start: null,
78
+ end: null
79
+ }, this.selectedDate = void 0;
80
+ }
81
+ /** @internal */
82
+ _onRangeCompleteEmitEvent() {
83
+ if (!this.selectedDateRange.start || !this.selectedDateRange.end) return;
84
+ const e = Math.abs(
85
+ this.selectedDateRange.end.getTime() - this.selectedDateRange.start.getTime()
86
+ ), t = Math.ceil(e / (1e3 * 60 * 60 * 24)) + 1;
87
+ this.emit("selected-date-range-changed", {
88
+ detail: {
89
+ ...this.selectedDateRange,
90
+ days: t,
91
+ id: this.id
92
+ }
93
+ });
94
+ }
95
+ _handleRangeChange() {
96
+ this.style.setProperty("--max-width", this.range ? "43em" : "21em");
97
+ }
98
+ _handleDateChange() {
99
+ console.log("%cdate changed", "color:red", this.date), this.date = this.date && $(this.date) ? this.date : l(/* @__PURE__ */ new Date()), this.date = T(
100
+ C(this.date, this.selectableFrom ?? this.date),
101
+ this.selectableTo ?? this.date
102
+ ), this._date = new Date(this.date), this._datePlusOneMonth = new Date(this._date.getFullYear(), this._date.getMonth() + 1, 1);
103
+ }
104
+ _handleSelectedDateRangeChange() {
105
+ }
106
+ _handleSelectedDateChange() {
107
+ console.log("selected date changed", this.selectedDate);
108
+ }
109
+ /**
110
+ * Navigates to the given date.
111
+ * @param date - The date to navigate to, either a Date object or a string in the format 'yyyy-mm-dd'
112
+ */
113
+ gotoDate(e) {
114
+ if (e instanceof Date)
115
+ this.date = l(e);
116
+ else if (v(e).dateISO())
117
+ this.date = e;
118
+ else
119
+ throw new Error("Invalid date format");
120
+ this.emit("update-calendar-view", {
121
+ detail: e
122
+ });
123
+ }
124
+ render() {
125
+ return D`
126
+ <div class="calendar-container">
127
+ <skf-datepicker-calendar
128
+ .date=${this._date ?? /* @__PURE__ */ new Date()}
129
+ .eventid="${this.id}"
130
+ .range=${this.range}
131
+ .selectedDate=${this.selectedDate}
132
+ .selectedDateRange=${this.selectedDateRange}
133
+ .selectableFrom=${this.selectableFrom}
134
+ .selectableTo=${this.selectableTo}
135
+ .invalidDates=${this.invalidDates}
136
+ class="start"
137
+ id=${this.id}
138
+ locale="${this.locale}"
139
+ ></skf-datepicker-calendar>
140
+ <skf-datepicker-calendar
141
+ ?hidden=${!this.range}
142
+ .date=${this._datePlusOneMonth}
143
+ .eventid="${this.id}"
144
+ .range=${!0}
145
+ .selectedDate="${this.selectedDate}"
146
+ .selectedDateRange=${this.selectedDateRange}
147
+ .selectableFrom=${this.selectableFrom}
148
+ .selectableTo=${this.selectableTo}
149
+ .invalidDates=${this.invalidDates}
150
+ class="end"
151
+ id=${`${this.id}-range-end`}
152
+ locale="${this.locale}"
153
+ ></skf-datepicker-calendar>
154
+ </div>
155
+ ${this._renderTodayBtn()}
156
+ <slot></slot>
157
+ <div class="triangle"></div>
158
+ `;
159
+ }
160
+ /** @internal */
161
+ _renderTodayBtn() {
162
+ let e = !1;
163
+ if (this.selectableTo && c(this.selectableTo, l(/* @__PURE__ */ new Date())) === -1)
164
+ return D``;
165
+ if (this.selectableFrom && c(this.selectableFrom, l(/* @__PURE__ */ new Date())) === 1)
166
+ return D``;
167
+ const { month: t, year: a } = g(), { month: s, year: r } = g(this.date), d = this.selectedDate ?? this.selectedDateRange.start, h = t === s && a === r, f = d && c(l(/* @__PURE__ */ new Date()), l(d), "months") === 0;
168
+ return (h && !d || f && h) && (e = !0), D`
169
+ <div class="today">
170
+ <skf-button
171
+ @click=${this._handleTodayClick}
172
+ ?disabled=${e}
173
+ variant="tertiary"
174
+ size="sm"
175
+ >
176
+ ${_(this.date) && (this.selectedDate || this.selectedDateRange.start) && !e ? "Selected date" : "Today"}
177
+ </skf-button>
178
+ </div>
179
+ `;
180
+ function _(u) {
181
+ return c(u, l(/* @__PURE__ */ new Date()), "months") === 0;
182
+ }
183
+ }
184
+ /** @internal */
185
+ _handleChangeCalendarView(e) {
186
+ const t = c(this.date, e);
187
+ this._animateView(t, () => {
188
+ this.date = e;
189
+ }).then(() => {
190
+ }).catch((a) => {
191
+ console.error(a);
192
+ });
193
+ }
194
+ /** @internal */
195
+ async _animateView(e, t) {
196
+ if (!this.shadowRoot) return;
197
+ const a = [...this.shadowRoot.querySelectorAll("skf-datepicker-calendar")];
198
+ return a.length ? (await b(
199
+ a,
200
+ [{ opacity: 0, transform: `translateX(calc(16px * ${e.toString()}))` }],
201
+ { duration: 100, easing: "ease-in", fill: "backwards" }
202
+ ), t(), await b(
203
+ a,
204
+ [
205
+ { opacity: 0, transform: `translateX(${(-16 * e).toString()}px)` },
206
+ { opacity: 1, transform: "translateX(0)" }
207
+ ],
208
+ { duration: 100, easing: "ease-out", fill: "backwards" }
209
+ )) : Promise.resolve();
210
+ }
211
+ };
212
+ y.styles = [S, k];
213
+ let i = y;
214
+ n([
215
+ o({ reflect: !0 })
216
+ ], i.prototype, "locale", 2);
217
+ n([
218
+ o({ type: String, reflect: !0 })
219
+ ], i.prototype, "date", 2);
220
+ n([
221
+ o({ type: String })
222
+ ], i.prototype, "id", 2);
223
+ n([
224
+ o({ attribute: "invalid-dates" })
225
+ ], i.prototype, "invalidDates", 2);
226
+ n([
227
+ o({ type: Boolean })
228
+ ], i.prototype, "range", 2);
229
+ n([
230
+ m()
231
+ ], i.prototype, "selectedDate", 2);
232
+ n([
233
+ o({ attribute: "selectable-from" })
234
+ ], i.prototype, "selectableFrom", 2);
235
+ n([
236
+ o({ attribute: "selectable-to" })
237
+ ], i.prototype, "selectableTo", 2);
238
+ n([
239
+ m()
240
+ ], i.prototype, "selectedDateRange", 2);
241
+ n([
242
+ m()
243
+ ], i.prototype, "_date", 2);
244
+ n([
245
+ m()
246
+ ], i.prototype, "_datePlusOneMonth", 2);
247
+ n([
248
+ p("range")
249
+ ], i.prototype, "_handleRangeChange", 1);
250
+ n([
251
+ p("date")
252
+ ], i.prototype, "_handleDateChange", 1);
253
+ n([
254
+ p("selectedDateRange")
255
+ ], i.prototype, "_handleSelectedDateRangeChange", 1);
256
+ n([
257
+ p("selectedDate")
258
+ ], i.prototype, "_handleSelectedDateChange", 1);
259
+ export {
260
+ i as SkfDatePicker
261
+ };
@@ -0,0 +1,10 @@
1
+ import { SkfDatePickerCalendar } from './datepicker.calendar.component.js';
2
+ import { SkfDatePicker } from './datepicker.component.js';
3
+ export * from './datepicker.component.js';
4
+ export default SkfDatePicker;
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ 'skf-datepicker': SkfDatePicker;
8
+ 'skf-datepicker-calendar': SkfDatePickerCalendar;
9
+ }
10
+ }
@@ -0,0 +1,41 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ /**
3
+ * A nifty little waapi wrapper helper that
4
+ * mainly turns the onfinished callback to a promise.
5
+ * But also allows animations on multiple targets.
6
+ */
7
+ export declare function doAnimate(target: Element | Element[] | HTMLElement | HTMLElement[], keyframes: Keyframe | Keyframe[], options: KeyframeAnimationOptions): Promise<PromiseSettledResult<any>[]>;
8
+ /**
9
+ * @param date - optional date to get parts from, uses todays date if not provided
10
+ * @returns destructable object with year, month and day. NB: month is 0 based.
11
+ */
12
+ export declare function getDateParts(date?: undefined | string | Date | Temporal.PlainDate): {
13
+ year: number;
14
+ month: number;
15
+ day: number;
16
+ };
17
+ /**
18
+ * @param dateOne - first date to compare as string
19
+ * @param dateTwo - second date to compare as string
20
+ * @param granularity - the unit to compare the dates by [days, months, years], defaults to days
21
+ * @returns - 0 if the dates are the same, 1 if dateOne is after dateTwo, -1 if dateOne is before dateTwo
22
+ */
23
+ export declare function compareDates(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string, granularity?: 'days' | 'months' | 'years'): 0 | 1 | -1;
24
+ /**
25
+ * @param dateOne - first date to compare as string
26
+ * @param dateTwo - second date to compare as string
27
+ * @param unit - the unit to compare the dates by [days, months, years]
28
+ * @returns the difference between the two dates in the specified unit
29
+ */
30
+ export declare function timeBetween(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string, unit?: 'days' | 'months' | 'years'): number;
31
+ /**
32
+ * @param dates - a list of dates to compare
33
+ * @returns - the earliest date of the list
34
+ */
35
+ export declare function earliestDate(...dates: (string | Date)[]): string;
36
+ /**
37
+ * @param dates - a list of dates to compare
38
+ * @returns the latest date of the list
39
+ */
40
+ export declare function latestDate(...dates: (string | Date)[]): string;
41
+ export declare function assertISODate(date: string | Temporal.PlainDate | Date, throwErr?: boolean): string;
@@ -0,0 +1,76 @@
1
+ import { is as c } from "../date-picker-input/datepicker-input.helpers.js";
2
+ import { Temporal as e } from "@js-temporal/polyfill";
3
+ function I(t, n, s) {
4
+ const o = (r) => Array.isArray(r) ? r : [r], f = o(t);
5
+ n = o(n);
6
+ const a = [];
7
+ for (const r of f) {
8
+ const { promise: i, resolve: m, reject: p } = Promise.withResolvers(), l = r.animate(n, {
9
+ fill: "forwards",
10
+ duration: 300,
11
+ iterations: 1,
12
+ ...s
13
+ });
14
+ l.onfinish = () => m("finished"), l.oncancel = () => p("canceled"), a.push(i);
15
+ }
16
+ return Promise.allSettled(a);
17
+ }
18
+ function P(t = e.Now.plainDateISO()) {
19
+ return t ?? (t = e.Now.plainDateISO()), t instanceof Date && (t = e.PlainDate.from(t.toISOString())), typeof t == "string" && (t = e.PlainDate.from(S(t, !0))), {
20
+ year: t.year,
21
+ month: t.month - 1,
22
+ // new Date is 0 based
23
+ day: t.day
24
+ };
25
+ }
26
+ function v(t, n, s = "days") {
27
+ console.assert(c(t, n).plainISO(), "Invalid dates passed to compareDates()"), typeof t == "string" && (t = e.PlainDate.from(t)), typeof n == "string" && (n = e.PlainDate.from(n)), console.assert(
28
+ c(t, n).plain(),
29
+ `Invalid date was sent to helper function compareDates(). Got ${JSON.stringify(t)} and ${JSON.stringify(n)} passed in`
30
+ );
31
+ const o = D(t, n, s);
32
+ return f(o);
33
+ function f(a) {
34
+ return Math.max(-1, Math.min(a, 1));
35
+ }
36
+ }
37
+ function D(t, n, s = "days") {
38
+ return typeof t == "string" && (t = e.PlainDate.from(t)), typeof n == "string" && (n = e.PlainDate.from(n)), console.assert(
39
+ t instanceof e.PlainDate && n instanceof e.PlainDate,
40
+ `Invalid date was sent to helper function timeBetween(). Got ${JSON.stringify(t)} and ${JSON.stringify(n)} passed in`
41
+ ), s === "months" ? n.until(t, { largestUnit: "months" }).months : s === "years" ? n.until(t, { largestUnit: "years" }).years : n.until(t, { largestUnit: "days" }).days;
42
+ }
43
+ function u(...t) {
44
+ if (t.length === 0)
45
+ throw new Error("At least one date must be provided");
46
+ const n = (i) => i instanceof Date, s = t.map((i) => n(i) ? i : new Date(i));
47
+ if (s.length === 1)
48
+ return s[0].toISOString().split("T")[0];
49
+ const [o, ...f] = s, a = u(...f), r = new Date(a);
50
+ return o < r ? o.toISOString().split("T")[0] : r.toISOString().split("T")[0];
51
+ }
52
+ function g(...t) {
53
+ if (t.length === 0)
54
+ throw new Error("At least one date must be provided");
55
+ const n = (i) => i instanceof Date, s = t.map((i) => n(i) ? i : new Date(i));
56
+ if (s.length === 1)
57
+ return s[0].toISOString().split("T")[0];
58
+ const [o, ...f] = s, a = g(...f), r = new Date(a);
59
+ return o > r ? o.toISOString().split("T")[0] : r.toISOString().split("T")[0];
60
+ }
61
+ function S(t, n = !1) {
62
+ t instanceof Date && (t = e.PlainDate.from(t.toISOString())), typeof t != "string" && (t = t.toString());
63
+ const s = /^\d{4}-\d{2}-\d{2}$/;
64
+ if (!s.test(t) && n)
65
+ throw new Error(`Invalid date format. Got ${t} passed in.`);
66
+ return s.test(t) ? t : "";
67
+ }
68
+ export {
69
+ S as assertISODate,
70
+ v as compareDates,
71
+ I as doAnimate,
72
+ u as earliestDate,
73
+ P as getDateParts,
74
+ g as latestDate,
75
+ D as timeBetween
76
+ };
@@ -0,0 +1,8 @@
1
+ import { SkfDatePickerCalendar as e } from "./datepicker.calendar.component.js";
2
+ import { SkfDatePicker as r } from "./datepicker.component.js";
3
+ r.define("skf-datepicker");
4
+ e.define("skf-datepicker-calendar");
5
+ export {
6
+ r as SkfDatePicker,
7
+ r as default
8
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,87 @@
1
+ import { css as r } from "lit";
2
+ const a = r`
3
+ @layer components {
4
+ :host {
5
+ --max-width: 21em;
6
+ --day-outline: transparent;
7
+
8
+ background-color: var(--skf-bg-color-neutral-1);
9
+ border: solid 1px var(--skf-border-color-primary);
10
+ border-radius: 3px;
11
+ box-shadow: 0 0 10px rgba(0 0 0 / 30%);
12
+ box-sizing: border-box;
13
+ display: block;
14
+ font-family: Helvetica, sans-serif;
15
+ font-size: 0.7rem;
16
+ max-width: var(--max-width);
17
+ position: relative;
18
+ }
19
+
20
+ .triangle {
21
+ border: 10px solid transparent;
22
+ border-bottom-color: #fff;
23
+ border-top: 0;
24
+ display: block;
25
+ height: 0;
26
+ left: 50%;
27
+ margin-left: -10px;
28
+ position: absolute;
29
+ top: -10px;
30
+ width: 0;
31
+ }
32
+
33
+ :host([hidden]) {
34
+ display: none !important;
35
+ }
36
+
37
+ .calendar-container {
38
+ display: flex;
39
+ flex-direction: row;
40
+ gap: var(--skf-text-color-primary);
41
+ justify-content: space-between;
42
+ overflow: hidden;
43
+ padding: var(--skf-spacing-50);
44
+ }
45
+
46
+ skf-datepicker-calendar {
47
+ margin: var(--skf-spacing-50) var(--skf-spacing-50) 0 var(--skf-spacing-50);
48
+ }
49
+
50
+ .today {
51
+ border-top: 1px solid var(--skf-border-color-primary);
52
+ margin-bottom: 0.5rem;
53
+ padding-top: 0.5rem;
54
+ text-align: center;
55
+
56
+ button {
57
+ background-color: #333;
58
+ border-radius: 4px;
59
+ color: white;
60
+ padding-inline: 0.7em;
61
+ transition: background-color 0.2s;
62
+
63
+ &[disabled] {
64
+ opacity: 0.5;
65
+ pointer-events: none;
66
+ }
67
+
68
+ &:hover {
69
+ background-color: var(--skf-interactive-bg-color-primary);
70
+ }
71
+
72
+ &:active {
73
+ background-color: lch(from var(--skf-interactive-bg-color-primary) calc(l - 5) c h);
74
+ }
75
+
76
+ &:focus-visible {
77
+ border-radius: 0.2em;
78
+ outline: 2px solid #469;
79
+ outline-offset: 2px;
80
+ }
81
+ }
82
+ }
83
+ }
84
+ `;
85
+ export {
86
+ a as styles
87
+ };
@@ -0,0 +1,115 @@
1
+ import '../icon/icon.js';
2
+ import { FormBase } from '../../internal/components/formBase.js';
3
+ import { PopoverController } from '../../internal/controllers/popover.controller.js';
4
+ import type { FormFieldBaseProps } from '../../internal/types/formField.js';
5
+ import { type CSSResultGroup } from 'lit';
6
+ import '../date-picker/datepicker.js';
7
+ import type { SkfDatePicker, SkfDatePickerDateRange } from '../date-picker/datepicker.js';
8
+ export declare class SkfDatePickerInput extends FormBase {
9
+ /** @internal */
10
+ static styles: CSSResultGroup;
11
+ /** @inernal */
12
+ focusTimeoutId: ReturnType<typeof setTimeout> | undefined;
13
+ /** @internal */
14
+ private customError;
15
+ /** @internal */
16
+ popoverController: PopoverController;
17
+ /** If defined, forces component to invalid state until removed. Its value is used as hint text. */
18
+ set customInvalid(value: string | undefined);
19
+ get customInvalid(): string | undefined;
20
+ id: string;
21
+ /** If defined, sets the input's label. Alternatively, you can use the `label` attribute. */
22
+ label?: string;
23
+ /** If true, hides the label visually */
24
+ hideLabel?: boolean;
25
+ /** If defined, displays informational text below the field */
26
+ hint?: string;
27
+ /**
28
+ * A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
29
+ */
30
+ invalidDates?: string;
31
+ /** If defined, adds name to the input-element */
32
+ name?: string;
33
+ placeholder: string;
34
+ range: boolean;
35
+ /** If true, makes the element not mutable, meaning the user can not edit the control */
36
+ readonly?: boolean;
37
+ /** If defined, renders an alternative A11y text for the asterisk */
38
+ requiredLabel?: string;
39
+ /**
40
+ * Earliest selectable date. (yyyy-mm-dd format)
41
+ */
42
+ selectableFrom?: string;
43
+ /**
44
+ * Latest selectable date. (yyyy-mm-dd format)
45
+ */
46
+ selectableTo?: string;
47
+ /**
48
+ * If defined, displays provided severity state
49
+ * @type { "alert" | "success" | "info" | "warning" }
50
+ */
51
+ severity?: FormFieldBaseProps['severity'];
52
+ /** Size of the input */
53
+ size: 'sm' | 'md';
54
+ /** Sets validation start */
55
+ validateOn: 'input' | 'change' | 'submit';
56
+ /** The current value of the input field */
57
+ value?: string;
58
+ private _init_date?;
59
+ /** @internal */
60
+ /** true if the internal state is invalid */
61
+ invalid: boolean;
62
+ /** @internal */
63
+ selectedRangeDates: SkfDatePickerDateRange;
64
+ /** @internal */
65
+ private showClearbutton;
66
+ /** @internal */
67
+ $popover: HTMLElement;
68
+ /** @internal */
69
+ $anchor: HTMLDivElement;
70
+ /** @internal */
71
+ $input: HTMLInputElement;
72
+ /** @internal */
73
+ $input_range_end: HTMLInputElement;
74
+ /** @internal */
75
+ $datepicker: SkfDatePicker;
76
+ /** @internal */
77
+ _defaultSlot: Node[];
78
+ abortController: AbortController;
79
+ abortSignal: AbortSignal;
80
+ constructor();
81
+ connectedCallback(): void;
82
+ disconnectedCallback(): void;
83
+ _handleSelectedDate: () => void;
84
+ protected firstUpdated(): void;
85
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
86
+ private _handleDateSelected;
87
+ /** @internal */
88
+ _handleKeyboardEvents: (e: KeyboardEvent) => void;
89
+ /** @internal */
90
+ private _handleFocus;
91
+ showPopover: () => void;
92
+ hidePopover: () => void;
93
+ /** @internal */
94
+ _handleBlur: (event: FocusEvent) => void;
95
+ /** @internal */
96
+ private _handleClose;
97
+ /** @internal */
98
+ private clearInput;
99
+ _handleValueChange(): void;
100
+ /**
101
+ * Clears the input field
102
+ */
103
+ clear: () => void;
104
+ /** @internal although called on input its only triggered once value is valid date */
105
+ _handleInput: (event: Event) => void;
106
+ /** @internal */
107
+ _toggleClearButton: (show?: boolean) => void;
108
+ /** @internal */
109
+ private _animatePopover;
110
+ /** @internal consider sharing this functionality with input */
111
+ validateInput(): void;
112
+ /** @internal */
113
+ reposition: () => Promise<void>;
114
+ render(): import("lit").TemplateResult<1>;
115
+ }