@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
@@ -0,0 +1,192 @@
1
+ import { css as e } from "lit";
2
+ const r = e`
3
+ @layer components {
4
+ :host {
5
+ box-sizing: inherit;
6
+ contain: layout;
7
+ display: block;
8
+ width: 100%;
9
+ }
10
+
11
+ :host([hidden]) {
12
+ display: none !important;
13
+ }
14
+
15
+ .grid {
16
+ display: grid;
17
+ grid-template-columns: repeat(7, 1fr);
18
+ list-style: none;
19
+ margin: 0;
20
+ padding: 0;
21
+ }
22
+
23
+ h4 {
24
+ color: var(--title-fg);
25
+ font-size: 1.2em;
26
+ margin: 0;
27
+ padding: 0;
28
+ white-space: nowrap;
29
+ }
30
+
31
+ .weekdays > li {
32
+ color: var(--weekday-fg);
33
+ display: grid;
34
+ font-size: 1.2em;
35
+ margin-block: 1em 0.5em;
36
+ place-items: center;
37
+ user-select: none;
38
+ }
39
+
40
+ .calendar > li {
41
+ background-color: transparent;
42
+ border-radius: 0.2em;
43
+ display: grid;
44
+ min-width: 2.5em;
45
+ outline: 1px solid var(--day-outline);
46
+ place-items: center;
47
+
48
+ & button {
49
+ aspect-ratio: 1.2 / 1;
50
+ background-color: transparent;
51
+ border: 0;
52
+ border-radius: 0;
53
+ cursor: pointer;
54
+ display: grid;
55
+ font-size: 1.2em;
56
+ margin-block: 0.4em;
57
+ place-items: center;
58
+ transition: background-color 0.3s;
59
+ width: 100%;
60
+
61
+ &:focus-visible {
62
+ border-radius: 0.2em;
63
+ outline: 2px solid #469;
64
+ outline-offset: 2px;
65
+ }
66
+
67
+ &.today {
68
+ background-color: var(--today);
69
+ color: var(--today-fg);
70
+ }
71
+
72
+ &.in-range {
73
+ background-color: var(--in-range-bg);
74
+ }
75
+
76
+ &.selected {
77
+ background-color: var(--selected-bg);
78
+ color: var(--selected-fg);
79
+ }
80
+
81
+ &.selected-start {
82
+ border-radius: 5px 0 0 5px;
83
+ }
84
+
85
+ &.selected-end {
86
+ border-radius: 0 5px 5px 0;
87
+ }
88
+
89
+ &.selected-start.selected-end {
90
+ border-radius: 5px;
91
+ }
92
+
93
+ &.prevmonth,
94
+ &.nextmonth {
95
+ color: var(--other-month-fg);
96
+ }
97
+
98
+ &:not(.selected):hover {
99
+ background-color: var(--hover-bg);
100
+ transition-duration: 0s;
101
+ }
102
+
103
+ &[disabled] {
104
+ cursor: not-allowed;
105
+ opacity: 0.5;
106
+ position: relative;
107
+
108
+ &::after {
109
+ background: linear-gradient(-45deg, transparent 45%, black 50%, transparent 50%);
110
+ content: '';
111
+ inset: 0;
112
+ position: absolute;
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ .calendar-head {
119
+ align-items: baseline;
120
+ display: flex;
121
+ font-size: 1.2em;
122
+ gap: 0;
123
+ grid-template-columns: min-content auto min-content;
124
+ justify-content: space-between;
125
+ margin: 0 0 1em;
126
+ padding: 0;
127
+ position: relative;
128
+
129
+ &::after {
130
+ background-color: var(--border-color);
131
+ bottom: -0.8em;
132
+ content: '';
133
+ display: block;
134
+ grid-column: 1 / -1;
135
+ height: 1px;
136
+ left: 0;
137
+ margin-inline: calc(var(--calendar-padding) * -1);
138
+ position: absolute;
139
+ right: 0;
140
+ }
141
+
142
+ & .calendar-head__controls {
143
+ display: contents;
144
+
145
+ &.hide {
146
+ display: none;
147
+ }
148
+ }
149
+
150
+ & h4 {
151
+ color: var(--title-fg);
152
+ font-size: 1.2em;
153
+ margin: 0;
154
+ padding: 0;
155
+ text-align: center;
156
+ white-space: nowrap;
157
+ }
158
+
159
+ & button {
160
+ background-color: transparent;
161
+ border: none;
162
+ color: var(--button-control-fg);
163
+ cursor: pointer;
164
+ min-width: 1.5em;
165
+ padding: 0.2em;
166
+ text-align: center;
167
+
168
+ &:focus-visible {
169
+ border-radius: 0.2em;
170
+ outline: 2px solid #469;
171
+ outline-offset: 2px;
172
+ }
173
+
174
+ & > div {
175
+ width: 1em;
176
+ }
177
+
178
+ &:hover {
179
+ color: var(--button-control-fg-hover);
180
+ }
181
+ }
182
+ }
183
+
184
+ .hide {
185
+ pointer-events: none;
186
+ visibility: hidden;
187
+ }
188
+ }
189
+ `;
190
+ export {
191
+ r as styles
192
+ };
@@ -0,0 +1,74 @@
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
+ render(): import("lit").TemplateResult<1>;
68
+ /** @internal */
69
+ private _renderTodayBtn;
70
+ /** @internal */
71
+ private _handleChangeCalendarView;
72
+ /** @internal */
73
+ private _animateView;
74
+ }
@@ -0,0 +1,241 @@
1
+ import "../button/button.js";
2
+ import { dateFormatter as c } from "../date-picker-input/datepicker-input.helpers.js";
3
+ import { SkfElement as $ } from "../../internal/components/skf-element.js";
4
+ import { watch as g } from "../../internal/helpers/watch.js";
5
+ import C from "../../styles/component.styles.js";
6
+ import { html as y } from "lit";
7
+ import { property as l, state as p } from "lit/decorators.js";
8
+ import "./datepicker.js";
9
+ import { getDateParts as h, earliestDate as S, latestDate as k, compareDates as M, doAnimate as f } from "./datepicker.helpers.js";
10
+ import { styles as T } from "./datepicker.styles.js";
11
+ var V = Object.defineProperty, F = Object.getOwnPropertyDescriptor, i = (u, e, s, t) => {
12
+ for (var a = t > 1 ? void 0 : t ? F(e, s) : e, d = u.length - 1, r; d >= 0; d--)
13
+ (r = u[d]) && (a = (t ? r(e, s, a) : r(a)) || a);
14
+ return t && a && V(e, s, a), a;
15
+ };
16
+ const m = class m extends $ {
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 s;
29
+ if (this.selectedDate = e.detail.date, console.log("selectedDate", this.selectedDate), this.range) {
30
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelectorAll("datepicker-calendar"), a = this.selectedDateRange, d = a.start && this.selectedDate < a.start;
31
+ if ((a.start && a.end) ?? d)
32
+ this.selectedDateRange = {
33
+ start: this.selectedDate,
34
+ end: null
35
+ };
36
+ else {
37
+ const D = !!a.start ? { end: e.detail.date } : { start: e.detail.date };
38
+ this.selectedDateRange = {
39
+ ...a,
40
+ ...D
41
+ };
42
+ }
43
+ this._onRangeCompleteEmitEvent(), t != null && t.length && [...t].forEach((o) => {
44
+ o.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: s } = h(), { month: t, year: a } = h(this.date);
52
+ if (t === e && a === s && (this.selectedDateRange.start || this.selectedDate)) {
53
+ this.date = c(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: c(/* @__PURE__ */ new Date())
61
+ });
62
+ return;
63
+ }
64
+ this.date = c(/* @__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
+ }
73
+ clearSelection() {
74
+ this.selectedDateRange = {
75
+ start: null,
76
+ end: null
77
+ }, this.selectedDate = void 0;
78
+ }
79
+ /** @internal */
80
+ _onRangeCompleteEmitEvent() {
81
+ if (!this.selectedDateRange.start || !this.selectedDateRange.end) return;
82
+ const e = Math.abs(
83
+ this.selectedDateRange.end.getTime() - this.selectedDateRange.start.getTime()
84
+ ), s = Math.ceil(e / (1e3 * 60 * 60 * 24)) + 1;
85
+ this.emit("selected-date-range-changed", {
86
+ detail: {
87
+ ...this.selectedDateRange,
88
+ days: s,
89
+ id: this.id
90
+ }
91
+ });
92
+ }
93
+ _handleRangeChange() {
94
+ this.style.setProperty("--max-width", this.range ? "43em" : "21em");
95
+ }
96
+ _handleDateChange() {
97
+ console.log("%cdate changed", "color:red", this.date), this.date = this.date ? this.date : c(/* @__PURE__ */ new Date()), this.date = S(
98
+ k(this.date, this.selectableFrom ?? this.date),
99
+ this.selectableTo ?? this.date
100
+ ), this._date = new Date(this.date), this._datePlusOneMonth = new Date(this._date.getFullYear(), this._date.getMonth() + 1, 1);
101
+ }
102
+ _handleSelectedDateRangeChange() {
103
+ }
104
+ _handleSelectedDateChange() {
105
+ console.log("selected date changed", this.selectedDate);
106
+ }
107
+ render() {
108
+ return y`
109
+ <div class="calendar-container">
110
+ <skf-datepicker-calendar
111
+ .date=${this._date ?? /* @__PURE__ */ new Date()}
112
+ .eventid="${this.id}"
113
+ .range=${this.range}
114
+ .selectedDate=${this.selectedDate}
115
+ .selectedDateRange=${this.selectedDateRange}
116
+ .selectableFrom=${this.selectableFrom}
117
+ .selectableTo=${this.selectableTo}
118
+ .invalidDates=${this.invalidDates}
119
+ class="start"
120
+ id=${this.id}
121
+ locale="${this.locale}"
122
+ ></skf-datepicker-calendar>
123
+ <skf-datepicker-calendar
124
+ ?hidden=${!this.range}
125
+ .date=${this._datePlusOneMonth}
126
+ .eventid="${this.id}"
127
+ .range=${!0}
128
+ .selectedDate="${this.selectedDate}"
129
+ .selectedDateRange=${this.selectedDateRange}
130
+ .selectableFrom=${this.selectableFrom}
131
+ .selectableTo=${this.selectableTo}
132
+ .invalidDates=${this.invalidDates}
133
+ class="end"
134
+ id=${`${this.id}-range-end`}
135
+ locale="${this.locale}"
136
+ ></skf-datepicker-calendar>
137
+ </div>
138
+ ${this._renderTodayBtn()}
139
+ <slot></slot>
140
+ <div class="triangle"></div>
141
+ `;
142
+ }
143
+ /** @internal */
144
+ _renderTodayBtn() {
145
+ const { month: e, year: s } = h(), { month: t, year: a } = h(this.date), d = this.selectedDate ?? this.selectedDateRange.start, r = e === t && s === a;
146
+ let o = !1;
147
+ return (r && !d || d && e === d.getMonth() && s === d.getFullYear()) && (o = !0), y`
148
+ <div class="today">
149
+ <skf-button
150
+ @click=${this._handleTodayClick}
151
+ ?disabled=${o}
152
+ variant="tertiary"
153
+ size="sm"
154
+ >
155
+ ${D(this.date) && (this.selectedDate || this.selectedDateRange.start) && !o ? "Selected date" : "Today"}
156
+ </skf-button>
157
+ </div>
158
+ `;
159
+ function D(_) {
160
+ const { month: w, year: R } = h(), { month: v, year: b } = h(_);
161
+ return w === v && R === b;
162
+ }
163
+ }
164
+ /** @internal */
165
+ _handleChangeCalendarView(e) {
166
+ const s = M(this.date, e);
167
+ this._animateView(s, () => {
168
+ this.date = e;
169
+ }).then(() => {
170
+ }).catch((t) => {
171
+ console.error(t);
172
+ });
173
+ }
174
+ /** @internal */
175
+ async _animateView(e, s) {
176
+ if (!this.shadowRoot) return;
177
+ const t = [...this.shadowRoot.querySelectorAll("skf-datepicker-calendar")];
178
+ return t.length ? (await f(
179
+ t,
180
+ [{ opacity: 0, transform: `translateX(calc(16px * ${e.toString()}))` }],
181
+ { duration: 100, easing: "ease-in", fill: "backwards" }
182
+ ), s(), await f(
183
+ t,
184
+ [
185
+ { opacity: 0, transform: `translateX(${(-16 * e).toString()}px)` },
186
+ { opacity: 1, transform: "translateX(0)" }
187
+ ],
188
+ { duration: 100, easing: "ease-out", fill: "backwards" }
189
+ )) : Promise.resolve();
190
+ }
191
+ };
192
+ m.styles = [C, T];
193
+ let n = m;
194
+ i([
195
+ l({ reflect: !0 })
196
+ ], n.prototype, "locale", 2);
197
+ i([
198
+ l({ type: String, reflect: !0 })
199
+ ], n.prototype, "date", 2);
200
+ i([
201
+ l({ type: String })
202
+ ], n.prototype, "id", 2);
203
+ i([
204
+ l({ attribute: "invalid-dates" })
205
+ ], n.prototype, "invalidDates", 2);
206
+ i([
207
+ l({ type: Boolean })
208
+ ], n.prototype, "range", 2);
209
+ i([
210
+ p()
211
+ ], n.prototype, "selectedDate", 2);
212
+ i([
213
+ l({ attribute: "selectable-from" })
214
+ ], n.prototype, "selectableFrom", 2);
215
+ i([
216
+ l({ attribute: "selectable-to" })
217
+ ], n.prototype, "selectableTo", 2);
218
+ i([
219
+ p()
220
+ ], n.prototype, "selectedDateRange", 2);
221
+ i([
222
+ p()
223
+ ], n.prototype, "_date", 2);
224
+ i([
225
+ p()
226
+ ], n.prototype, "_datePlusOneMonth", 2);
227
+ i([
228
+ g("range")
229
+ ], n.prototype, "_handleRangeChange", 1);
230
+ i([
231
+ g("date")
232
+ ], n.prototype, "_handleDateChange", 1);
233
+ i([
234
+ g("selectedDateRange")
235
+ ], n.prototype, "_handleSelectedDateRangeChange", 1);
236
+ i([
237
+ g("selectedDate")
238
+ ], n.prototype, "_handleSelectedDateChange", 1);
239
+ export {
240
+ n as SkfDatePicker
241
+ };
@@ -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,40 @@
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
+ * @returns - 0 if the dates are the same, 1 if dateOne is after dateTwo, -1 if dateOne is before dateTwo
21
+ */
22
+ export declare function compareDates(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string): 0 | 1 | -1;
23
+ /**
24
+ * @param dateOne - first date to compare as string
25
+ * @param dateTwo - second date to compare as string
26
+ * @param unit - the unit to compare the dates by [days, months, years]
27
+ * @returns the difference between the two dates in the specified unit
28
+ */
29
+ export declare function timeBetween(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string, unit?: 'days' | 'months' | 'years'): number;
30
+ /**
31
+ * @param dates - a list of dates to compare
32
+ * @returns - the earliest date of the list
33
+ */
34
+ export declare function earliestDate(...dates: (string | Date)[]): string;
35
+ /**
36
+ * @param dates - a list of dates to compare
37
+ * @returns the latest date of the list
38
+ */
39
+ export declare function latestDate(...dates: (string | Date)[]): string;
40
+ export declare function assertISODate(date: string | Temporal.PlainDate | Date): string;
@@ -0,0 +1,69 @@
1
+ import { Temporal as s } from "@js-temporal/polyfill";
2
+ function h(t, n, e) {
3
+ const o = (r) => Array.isArray(r) ? r : [r], a = o(t);
4
+ n = o(n);
5
+ const f = [];
6
+ for (const r of a) {
7
+ const { promise: i, resolve: c, reject: D } = Promise.withResolvers(), l = r.animate(n, {
8
+ fill: "forwards",
9
+ duration: 300,
10
+ iterations: 1,
11
+ ...e
12
+ });
13
+ l.onfinish = () => c("finished"), l.oncancel = () => D("canceled"), f.push(i);
14
+ }
15
+ return Promise.allSettled(f);
16
+ }
17
+ function w(t = s.Now.plainDateISO()) {
18
+ return t ?? (t = s.Now.plainDateISO()), t instanceof Date && (t = s.PlainDate.from(t.toISOString())), typeof t == "string" && (t = s.PlainDate.from(u(t))), {
19
+ year: t.year,
20
+ month: t.month - 1,
21
+ // new Date is 0 based
22
+ day: t.day
23
+ };
24
+ }
25
+ function y(t, n) {
26
+ const e = m(t, n);
27
+ return o(e);
28
+ function o(a) {
29
+ return Math.max(-1, Math.min(a, 1));
30
+ }
31
+ }
32
+ function m(t, n, e = "days") {
33
+ return typeof t == "string" && (t = s.PlainDate.from(t)), typeof n == "string" && (n = s.PlainDate.from(n)), console.assert(
34
+ t instanceof s.PlainDate && n instanceof s.PlainDate,
35
+ `Invalid date was sent to helper function timeBetween(). Got ${JSON.stringify(t)} and ${JSON.stringify(n)} passed in`
36
+ ), t.since(n).total({ unit: e });
37
+ }
38
+ function p(...t) {
39
+ if (t.length === 0)
40
+ throw new Error("At least one date must be provided");
41
+ const n = (i) => i instanceof Date, e = t.map((i) => n(i) ? i : new Date(i));
42
+ if (e.length === 1)
43
+ return e[0].toISOString().split("T")[0];
44
+ const [o, ...a] = e, f = p(...a), r = new Date(f);
45
+ return o < r ? o.toISOString().split("T")[0] : r.toISOString().split("T")[0];
46
+ }
47
+ function S(...t) {
48
+ if (t.length === 0)
49
+ throw new Error("At least one date must be provided");
50
+ const n = (i) => i instanceof Date, e = t.map((i) => n(i) ? i : new Date(i));
51
+ if (e.length === 1)
52
+ return e[0].toISOString().split("T")[0];
53
+ const [o, ...a] = e, f = S(...a), r = new Date(f);
54
+ return o > r ? o.toISOString().split("T")[0] : r.toISOString().split("T")[0];
55
+ }
56
+ function u(t) {
57
+ if (t instanceof Date && (t = s.PlainDate.from(t.toISOString())), typeof t != "string" && (t = t.toString()), !/^\d{4}-\d{2}-\d{2}$/.test(t))
58
+ throw new Error(`Invalid date format. Got ${t} passed in.`);
59
+ return t;
60
+ }
61
+ export {
62
+ u as assertISODate,
63
+ y as compareDates,
64
+ h as doAnimate,
65
+ p as earliestDate,
66
+ w as getDateParts,
67
+ S as latestDate,
68
+ m as timeBetween
69
+ };
@@ -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;