@haiilo/catalyst 10.4.0 → 10.7.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 (156) hide show
  1. package/dist/catalyst/catalyst.css +2 -2
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.esm.js +1 -1
  5. package/dist/catalyst/index.esm.js.map +1 -1
  6. package/dist/catalyst/p-2c8ac8cf.js +2 -0
  7. package/dist/catalyst/p-2c8ac8cf.js.map +1 -0
  8. package/dist/catalyst/p-b2ec6eb3.entry.js +10 -0
  9. package/dist/catalyst/p-b2ec6eb3.entry.js.map +1 -0
  10. package/dist/catalyst/scss/_variables.scss +0 -1
  11. package/dist/catalyst/scss/core/_form.scss +2 -2
  12. package/dist/cjs/{cat-alert_28.cjs.entry.js → cat-alert_29.cjs.entry.js} +387 -218
  13. package/dist/cjs/cat-alert_29.cjs.entry.js.map +1 -0
  14. package/dist/cjs/catalyst.cjs.js +1 -1
  15. package/dist/cjs/index.cjs.js +4 -1
  16. package/dist/cjs/index.cjs.js.map +1 -1
  17. package/dist/cjs/loader.cjs.js +1 -1
  18. package/dist/cjs/{of-45281229.js → of-f2844da8.js} +12 -4
  19. package/dist/cjs/of-f2844da8.js.map +1 -0
  20. package/dist/collection/collection-manifest.json +1 -0
  21. package/dist/collection/components/cat-button/cat-button.css +12 -2
  22. package/dist/collection/components/cat-checkbox/cat-checkbox.css +2 -1
  23. package/dist/collection/components/cat-date/cat-date.css +2 -96
  24. package/dist/collection/components/cat-date/cat-date.js +77 -245
  25. package/dist/collection/components/cat-date/cat-date.js.map +1 -1
  26. package/dist/collection/components/cat-date/cat-date.spec.js +2 -1
  27. package/dist/collection/components/cat-date/cat-date.spec.js.map +1 -1
  28. package/dist/collection/components/cat-date-inline/cat-date-inline.css +166 -0
  29. package/dist/collection/components/cat-date-inline/cat-date-inline.e2e.js +11 -0
  30. package/dist/collection/components/cat-date-inline/cat-date-inline.e2e.js.map +1 -0
  31. package/dist/collection/components/cat-date-inline/cat-date-inline.js +505 -0
  32. package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -0
  33. package/dist/collection/components/cat-date-inline/cat-date-inline.spec.js +16 -0
  34. package/dist/collection/components/cat-date-inline/cat-date-inline.spec.js.map +1 -0
  35. package/dist/collection/components/{cat-date → cat-date-inline}/cat-date-locale.js +22 -1
  36. package/dist/collection/components/cat-date-inline/cat-date-locale.js.map +1 -0
  37. package/dist/collection/components/cat-date-inline/cat-date-math.js.map +1 -0
  38. package/dist/collection/components/cat-datepicker/cat-datepicker.js +2 -2
  39. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
  40. package/dist/collection/components/cat-dropdown/cat-dropdown.js +29 -2
  41. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  42. package/dist/collection/components/cat-form-group/cat-form-group.js +4 -1
  43. package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
  44. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +6 -0
  45. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  46. package/dist/collection/components/cat-icon/cat-icon-registry.js +4 -2
  47. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
  48. package/dist/collection/components/cat-icon/cat-icon.js +1 -1
  49. package/dist/collection/components/cat-input/cat-input.js +4 -4
  50. package/dist/collection/components/cat-notification/cat-notification.js +3 -0
  51. package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
  52. package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
  53. package/dist/collection/components/cat-radio/cat-radio.css +1 -1
  54. package/dist/collection/components/cat-radio/cat-radio.js +1 -1
  55. package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
  56. package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
  57. package/dist/collection/components/cat-select/cat-select.js +5 -5
  58. package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
  59. package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
  60. package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
  61. package/dist/collection/components/cat-tab/cat-tab.js +1 -1
  62. package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
  63. package/dist/collection/components/cat-textarea/cat-textarea.js +3 -3
  64. package/dist/collection/components/cat-time/cat-time-locale.js +3 -0
  65. package/dist/collection/components/cat-time/cat-time-locale.js.map +1 -1
  66. package/dist/collection/components/cat-time/cat-time.js +39 -8
  67. package/dist/collection/components/cat-time/cat-time.js.map +1 -1
  68. package/dist/collection/components/cat-toggle/cat-toggle.css +1 -1
  69. package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
  70. package/dist/collection/components/cat-tooltip/cat-tooltip.js +7 -2
  71. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  72. package/dist/collection/scss/_variables.scss +0 -1
  73. package/dist/collection/scss/core/_form.scss +2 -2
  74. package/dist/components/cat-button2.js +1 -1
  75. package/dist/components/cat-button2.js.map +1 -1
  76. package/dist/components/cat-checkbox2.js +1 -1
  77. package/dist/components/cat-checkbox2.js.map +1 -1
  78. package/dist/components/cat-date-inline.d.ts +11 -0
  79. package/dist/components/cat-date-inline.js +8 -0
  80. package/dist/components/cat-date-inline.js.map +1 -0
  81. package/dist/components/cat-date-inline2.js +386 -0
  82. package/dist/components/cat-date-inline2.js.map +1 -0
  83. package/dist/components/cat-date.js +83 -283
  84. package/dist/components/cat-date.js.map +1 -1
  85. package/dist/components/cat-datepicker-inline.js +2 -2
  86. package/dist/components/cat-datepicker.js +2 -2
  87. package/dist/components/cat-dropdown2.js +8 -2
  88. package/dist/components/cat-dropdown2.js.map +1 -1
  89. package/dist/components/cat-form-group.js +1 -1
  90. package/dist/components/cat-form-group.js.map +1 -1
  91. package/dist/components/cat-i18n-registry.js +6 -0
  92. package/dist/components/cat-i18n-registry.js.map +1 -1
  93. package/dist/components/cat-icon-registry.js +4 -2
  94. package/dist/components/cat-icon-registry.js.map +1 -1
  95. package/dist/components/cat-icon2.js +1 -1
  96. package/dist/components/cat-input2.js +4 -4
  97. package/dist/components/cat-pagination.js +2 -2
  98. package/dist/components/cat-radio-group.js +1 -1
  99. package/dist/components/cat-radio.js +2 -2
  100. package/dist/components/cat-radio.js.map +1 -1
  101. package/dist/components/cat-scrollable2.js +8 -6
  102. package/dist/components/cat-scrollable2.js.map +1 -1
  103. package/dist/components/cat-select-demo.js +3 -3
  104. package/dist/components/cat-select-demo.js.map +1 -1
  105. package/dist/components/cat-select2.js.map +1 -1
  106. package/dist/components/cat-skeleton2.js +1 -1
  107. package/dist/components/cat-spinner2.js +2 -2
  108. package/dist/components/cat-tab.js +1 -1
  109. package/dist/components/cat-tabs.js +1 -1
  110. package/dist/components/cat-textarea.js +3 -3
  111. package/dist/components/cat-time.js +37 -8
  112. package/dist/components/cat-time.js.map +1 -1
  113. package/dist/components/cat-toggle.js +2 -2
  114. package/dist/components/cat-toggle.js.map +1 -1
  115. package/dist/components/cat-tooltip.js +2 -2
  116. package/dist/components/cat-tooltip.js.map +1 -1
  117. package/dist/components/floating-ui.dom.esm.js +38 -30
  118. package/dist/components/floating-ui.dom.esm.js.map +1 -1
  119. package/dist/components/from.js +1 -1
  120. package/dist/components/from.js.map +1 -1
  121. package/dist/components/index.js +3 -0
  122. package/dist/components/index.js.map +1 -1
  123. package/dist/components/of.js.map +1 -1
  124. package/dist/esm/{cat-alert_28.entry.js → cat-alert_29.entry.js} +387 -219
  125. package/dist/esm/cat-alert_29.entry.js.map +1 -0
  126. package/dist/esm/catalyst.js +1 -1
  127. package/dist/esm/index.js +5 -2
  128. package/dist/esm/index.js.map +1 -1
  129. package/dist/esm/loader.js +1 -1
  130. package/dist/esm/{of-19888f3b.js → of-53334b95.js} +12 -4
  131. package/dist/esm/of-53334b95.js.map +1 -0
  132. package/dist/types/components/cat-date/cat-date.d.ts +11 -31
  133. package/dist/types/components/cat-date-inline/cat-date-inline.d.ts +81 -0
  134. package/dist/types/components/{cat-date → cat-date-inline}/cat-date-locale.d.ts +5 -0
  135. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +9 -0
  136. package/dist/types/components/cat-form-group/cat-form-group.d.ts +3 -0
  137. package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +6 -0
  138. package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
  139. package/dist/types/components/cat-notification/cat-notification.d.ts +3 -0
  140. package/dist/types/components/cat-time/cat-time-locale.d.ts +1 -0
  141. package/dist/types/components/cat-time/cat-time.d.ts +6 -1
  142. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +5 -0
  143. package/dist/types/components.d.ts +209 -5
  144. package/package.json +2 -2
  145. package/dist/catalyst/p-81800b65.js +0 -2
  146. package/dist/catalyst/p-81800b65.js.map +0 -1
  147. package/dist/catalyst/p-8a1d505d.entry.js +0 -10
  148. package/dist/catalyst/p-8a1d505d.entry.js.map +0 -1
  149. package/dist/cjs/cat-alert_28.cjs.entry.js.map +0 -1
  150. package/dist/cjs/of-45281229.js.map +0 -1
  151. package/dist/collection/components/cat-date/cat-date-locale.js.map +0 -1
  152. package/dist/collection/components/cat-date/cat-date-math.js.map +0 -1
  153. package/dist/esm/cat-alert_28.entry.js.map +0 -1
  154. package/dist/esm/of-19888f3b.js.map +0 -1
  155. /package/dist/collection/components/{cat-date → cat-date-inline}/cat-date-math.js +0 -0
  156. /package/dist/types/components/{cat-date → cat-date-inline}/cat-date-math.d.ts +0 -0
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Auto-generated file. Do not edit directly.
3
+ */
4
+ /* stylelint-disable value-keyword-case */
5
+ /* stylelint-enable value-keyword-case */
6
+ :host {
7
+ display: inline-block;
8
+ }
9
+
10
+ :host([hidden]) {
11
+ display: none;
12
+ }
13
+
14
+ .picker {
15
+ display: flex;
16
+ flex-direction: column;
17
+ min-width: 19.5rem;
18
+ max-width: 30rem;
19
+ }
20
+ .picker.picker-weeks {
21
+ min-width: 17.5rem;
22
+ max-width: 28rem;
23
+ }
24
+ .picker.picker-small {
25
+ min-width: 16rem;
26
+ max-width: 23rem;
27
+ }
28
+ .picker.picker-small.picker-weeks {
29
+ min-width: 14rem;
30
+ max-width: 21rem;
31
+ }
32
+
33
+ .picker-head {
34
+ display: flex;
35
+ gap: 0.5rem;
36
+ align-items: center;
37
+ }
38
+ .picker-head h3 {
39
+ font-size: 1.125rem;
40
+ line-height: 1.5rem;
41
+ font-weight: var(--cat-font-weight-head, 600);
42
+ font-feature-settings: "pnum";
43
+ flex: 1;
44
+ text-align: center;
45
+ margin: 0;
46
+ }
47
+ .picker-small .picker-head {
48
+ gap: 0.25rem;
49
+ }
50
+ .picker-small .picker-head h3 {
51
+ font-size: 0.9375rem;
52
+ line-height: 1.25rem;
53
+ font-weight: var(--cat-font-weight-head, 600);
54
+ font-feature-settings: "pnum";
55
+ }
56
+
57
+ .picker-grid {
58
+ display: grid;
59
+ /* stylelint-disable declaration-block-no-redundant-longhand-properties */
60
+ grid-template-rows: 2rem repeat(6, 1fr);
61
+ grid-template-columns: repeat(7, 1fr);
62
+ grid-template-areas: "h h h h h h h" "d d d d d d d" "d d d d d d d" "d d d d d d d" "d d d d d d d" "d d d d d d d" "d d d d d d d";
63
+ /* stylelint-enable declaration-block-no-redundant-longhand-properties */
64
+ margin: 1rem 0 0.5rem;
65
+ }
66
+ .picker-weeks .picker-grid {
67
+ /* stylelint-disable declaration-block-no-redundant-longhand-properties */
68
+ grid-template-columns: 2rem repeat(7, 1fr);
69
+ grid-template-areas: ". h h h h h h h" "w d d d d d d d" "w d d d d d d d" "w d d d d d d d" "w d d d d d d d" "w d d d d d d d" "w d d d d d d d";
70
+ /* stylelint-enable declaration-block-no-redundant-longhand-properties */
71
+ }
72
+ .picker-small .picker-grid {
73
+ margin: 0.5rem 0;
74
+ }
75
+
76
+ .picker-grid-head {
77
+ grid-area: h;
78
+ display: grid;
79
+ grid-template-columns: repeat(7, 1fr);
80
+ place-items: end center;
81
+ padding-bottom: 0.5rem;
82
+ }
83
+
84
+ .picker-grid-weeks {
85
+ grid-area: w;
86
+ display: grid;
87
+ grid-template-rows: repeat(6, 1fr);
88
+ place-items: center right;
89
+ padding-right: 0.5rem;
90
+ }
91
+
92
+ .picker-grid-days {
93
+ grid-area: d;
94
+ display: grid;
95
+ grid-template-rows: repeat(6, 1fr);
96
+ grid-template-columns: repeat(7, 1fr);
97
+ }
98
+
99
+ .picker-grid-head > *,
100
+ .picker-grid-weeks > * {
101
+ font-size: 0.75rem;
102
+ line-height: 1rem;
103
+ font-weight: 600;
104
+ color: rgb(var(--cat-font-color-muted, 81, 92, 108)) !important;
105
+ text-decoration: none;
106
+ }
107
+
108
+ .date-other {
109
+ opacity: 0.5;
110
+ }
111
+
112
+ .date-disabled {
113
+ opacity: 0.25;
114
+ }
115
+
116
+ .picker-foot {
117
+ display: flex;
118
+ gap: 1rem;
119
+ align-items: center;
120
+ width: min-content;
121
+ min-width: 100%;
122
+ justify-content: space-between;
123
+ }
124
+ .picker-small .picker-foot {
125
+ gap: 0.5rem;
126
+ }
127
+
128
+ .cursor-help {
129
+ margin: 0;
130
+ font-size: 0.875rem;
131
+ line-height: 1.125rem;
132
+ font-weight: var(--cat-font-weight-body, 400);
133
+ color: rgb(var(--cat-font-color-muted, 81, 92, 108)) !important;
134
+ text-align: center;
135
+ flex: 1;
136
+ }
137
+ .cursor-help:first-child {
138
+ text-align: left;
139
+ }
140
+ .cursor-help:last-child {
141
+ text-align: right;
142
+ }
143
+ .cursor-help:only-child {
144
+ text-align: center;
145
+ }
146
+ .picker-small .cursor-help {
147
+ font-size: 0.75rem;
148
+ line-height: 1rem;
149
+ font-weight: var(--cat-font-weight-body, 400);
150
+ }
151
+
152
+ .cursor-aria {
153
+ position: absolute !important;
154
+ width: 1px !important;
155
+ height: 1px !important;
156
+ padding: 0 !important;
157
+ margin: -1px !important;
158
+ overflow: hidden !important;
159
+ clip: rect(0, 0, 0, 0) !important;
160
+ white-space: nowrap !important;
161
+ border: 0 !important;
162
+ }
163
+
164
+ .date-range {
165
+ --cat-border-radius-m: 0;
166
+ }
@@ -0,0 +1,11 @@
1
+ import { newE2EPage } from "@stencil/core/testing";
2
+ describe('cat-date-inline', () => {
3
+ beforeAll(() => (console.error = jest.fn()));
4
+ it('renders', async () => {
5
+ const page = await newE2EPage();
6
+ await page.setContent('<cat-date-inline></cat-date-inline>');
7
+ const element = await page.find('cat-date-inline');
8
+ expect(element).toHaveClass('hydrated');
9
+ });
10
+ });
11
+ //# sourceMappingURL=cat-date-inline.e2e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-date-inline.e2e.js","sourceRoot":"","sources":["../../../src/components/cat-date-inline/cat-date-inline.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAE7C,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,UAAU,CAAC,qCAAqC,CAAC,CAAC;QAE7D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('cat-date-inline', () => {\n beforeAll(() => (console.error = jest.fn()));\n\n it('renders', async () => {\n const page = await newE2EPage();\n await page.setContent('<cat-date-inline></cat-date-inline>');\n\n const element = await page.find('cat-date-inline');\n expect(element).toHaveClass('hydrated');\n });\n});\n"]}
@@ -0,0 +1,505 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { catI18nRegistry as i18n } from "../cat-i18n/cat-i18n-registry";
3
+ import { getLocale } from "./cat-date-locale";
4
+ import { addDays, addMonth, clampDate, isSameDay, isSameMonth, isSameYear } from "./cat-date-math";
5
+ /**
6
+ * An inline date picker component to select a date.
7
+ */
8
+ export class CatDateInline {
9
+ constructor() {
10
+ this.language = i18n.getLocale();
11
+ this.locale = getLocale(this.language);
12
+ // additonally store the focus date to ensure correct focus after potential re-render
13
+ this.focusDate = null;
14
+ this.viewDate = this.locale.now();
15
+ this.noClear = false;
16
+ this.noHint = false;
17
+ this.noToday = false;
18
+ this.noWeeks = false;
19
+ this.size = 'm';
20
+ this.min = undefined;
21
+ this.max = undefined;
22
+ this.range = false;
23
+ this.value = undefined;
24
+ }
25
+ get focusedDate() {
26
+ const [all, year, month, day] = this.hostElement.shadowRoot
27
+ ?.querySelector(`[data-date]:focus`)
28
+ ?.dataset.date?.match(/^(\d{4})-(\d{2})-(\d{2})/) ?? [];
29
+ return all ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
30
+ }
31
+ componentWillLoad() {
32
+ // select the initial value
33
+ const [startDate, endDate] = this.getValue();
34
+ this.select(startDate);
35
+ if (this.range && endDate) {
36
+ this.select(endDate);
37
+ }
38
+ }
39
+ componentDidRender() {
40
+ if (this.focusDate) {
41
+ // re-focus the previously focused date after re-render
42
+ this.hostElement.shadowRoot
43
+ ?.querySelector(`[data-date="${this.locale.toLocalISO(this.focusDate)}"]`)
44
+ ?.doFocus();
45
+ this.focusDate = null;
46
+ }
47
+ }
48
+ onKeyDown(e) {
49
+ if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) {
50
+ return;
51
+ }
52
+ const focusedDate = this.focusedDate;
53
+ if (!focusedDate) {
54
+ e.preventDefault();
55
+ const [startDate] = this.getValue();
56
+ this.focus(startDate || this.locale.now());
57
+ }
58
+ else if (e.key === 'ArrowLeft') {
59
+ e.preventDefault();
60
+ this.focus(e.shiftKey ? addMonth(focusedDate, -1) : addDays(focusedDate, -1));
61
+ }
62
+ else if (e.key === 'ArrowRight') {
63
+ e.preventDefault();
64
+ this.focus(e.shiftKey ? addMonth(focusedDate, 1) : addDays(focusedDate, 1));
65
+ }
66
+ else if (e.key === 'ArrowUp') {
67
+ e.preventDefault();
68
+ this.focus(addDays(focusedDate, -7));
69
+ }
70
+ else if (e.key === 'ArrowDown') {
71
+ e.preventDefault();
72
+ this.focus(addDays(focusedDate, 7));
73
+ }
74
+ }
75
+ /**
76
+ * Select a date in the picker.
77
+ *
78
+ * @param date The date to select.
79
+ */
80
+ async select(date) {
81
+ if (!date) {
82
+ return this.clear();
83
+ }
84
+ const oldValue = this.value;
85
+ const [minDate, maxDate] = this.getMinMaxDate();
86
+ const newDate = clampDate(minDate, new Date(date.getFullYear(), date.getMonth(), date.getDate()), maxDate);
87
+ this.focus(newDate);
88
+ if (this.range) {
89
+ const [startDate, endDate] = this.getValue();
90
+ if (!startDate || endDate || newDate < startDate) {
91
+ this.value = this.toRangeValue(newDate, null);
92
+ }
93
+ else {
94
+ this.value = this.toRangeValue(startDate, newDate);
95
+ }
96
+ }
97
+ else {
98
+ this.value = this.locale.toLocalISO(newDate);
99
+ }
100
+ if (oldValue !== this.value) {
101
+ this.catChange.emit(this.value);
102
+ }
103
+ }
104
+ /**
105
+ * Clear the picker.
106
+ */
107
+ async clear() {
108
+ const oldValue = this.value;
109
+ this.value = undefined;
110
+ if (oldValue !== this.value) {
111
+ this.catChange.emit(this.value);
112
+ }
113
+ }
114
+ /**
115
+ * Resets the view of the picker.
116
+ */
117
+ async resetView() {
118
+ const [minDate, maxDate] = this.getMinMaxDate();
119
+ const [dateStart] = this.getValue();
120
+ this.viewDate = dateStart ?? clampDate(minDate, this.locale.now(), maxDate);
121
+ }
122
+ render() {
123
+ const [minDate, maxDate] = this.getMinMaxDate();
124
+ const dateGrid = this.dateGrid(this.viewDate.getFullYear(), this.viewDate.getMonth());
125
+ const [dateStart, dateEnd] = this.getValue();
126
+ return (h(Host, { key: '2b21e43ebc9a69988b475f2eae1eb2f2aeee97cb' }, h("div", { key: '3f256483614d09440bee07be4e8996bc1c187d2b', class: { picker: true, 'picker-small': this.size === 's', 'picker-weeks': !this.noWeeks } }, h("div", { key: 'c9d82a518d78439164e99240fa13afabcc81e267', class: "picker-head" }, h("cat-button", { key: 'bcc803acb0ac2d7947fa53615ca105d77063e9f9', icon: "$cat:datepicker-year-prev", iconOnly: true, size: "xs", variant: "text", "a11y-label": this.locale.prevYear, disabled: isSameYear(this.viewDate, minDate), onClick: () => this.navigate('prev', 'year'), "data-dropdown-no-close": true }), h("cat-button", { key: '3626bbe3e1a79c08d7a6257cb78ce398ceb1b750', icon: "$cat:datepicker-month-prev", iconOnly: true, size: "xs", variant: "text", "a11y-label": this.locale.prevMonth, disabled: isSameMonth(this.viewDate, minDate), onClick: () => this.navigate('prev', 'month'), "data-dropdown-no-close": true }), h("h3", { key: '92462a6702792afd573c91f0c12e2bae599378ae' }, this.getHeadline()), h("cat-button", { key: '4ce63e1451b820098feea0ff2f45d9b7d0b5cc28', icon: "$cat:datepicker-month-next", iconOnly: true, size: "xs", variant: "text", "a11y-label": this.locale.nextMonth, disabled: isSameMonth(this.viewDate, maxDate), onClick: () => this.navigate('next', 'month'), "data-dropdown-no-close": true }), h("cat-button", { key: '97adedac70ce8f19ba0725ca6a1bb836a1d8c0c3', icon: "$cat:datepicker-year-next", iconOnly: true, size: "xs", variant: "text", "a11y-label": this.locale.nextYear, disabled: isSameYear(this.viewDate, maxDate), onClick: () => this.navigate('next', 'year'), "data-dropdown-no-close": true })), h("div", { key: '9bbc58c07f911e928cd231a784604abada3698ea', class: "picker-grid", onFocusin: () => this.setAriaLive(this.locale.arrowKeys) }, h("div", { key: '2eff946487bfdbce49521b513d6065bd42c78ac0', class: "picker-grid-head" }, Array.from(Array(7), (_, i) => (h("abbr", { title: this.locale.days.long[i] }, this.locale.days.short[i])))), !this.noWeeks && (h("div", { class: "picker-grid-weeks" }, dateGrid
127
+ .filter((_, i) => i % 7 === 0)
128
+ .map(day => (h("div", null, this.getWeekNumber(day)))))), h("div", { key: '48f7b239e8ccb0d56b4f7c80d8892b79c2908990', class: "picker-grid-days" }, dateGrid.map(day => {
129
+ const isStartDate = isSameDay(dateStart, day);
130
+ const isEndDate = isSameDay(dateEnd, day);
131
+ const isRange = !!dateStart && !!dateEnd && day > dateStart && day < dateEnd;
132
+ const isToday = isSameDay(this.locale.now(), day);
133
+ return (h("cat-button", { class: {
134
+ 'cat-date-item': true,
135
+ 'date-other': !isSameMonth(this.viewDate, day),
136
+ 'date-today': isToday,
137
+ 'date-start': this.range && isStartDate,
138
+ 'date-range': this.range && isRange,
139
+ 'date-end': this.range && isEndDate,
140
+ 'date-focusable': this.canFocus(day),
141
+ 'date-disabled': !this.canClick(day)
142
+ }, size: this.size, nativeAttributes: !this.canFocus(day) ? { tabindex: '-1' } : {}, variant: isStartDate || isEndDate ? 'filled' : isToday ? 'outlined' : 'text', a11yLabel: this.locale.toLocalStr(day), active: isStartDate || isEndDate || isRange, color: isStartDate || isEndDate || isToday ? 'primary' : 'secondary', disabled: !this.canClick(day), onClick: () => this.select(day), "data-date": this.locale.toLocalISO(day) }, day.getDate()));
143
+ }))), h("div", { key: 'e6c30b78568d92d3a17936fdff4c7fec1ac4965f', class: "picker-foot" }, !this.noToday && this.canClick(this.locale.now()) && (h("cat-button", { size: "s", "data-dropdown-no-close": true, onClick: () => this.select(this.locale.now()) }, this.locale.today)), !this.noHint && h("p", { class: "cursor-help" }, this.locale.arrowKeys), !this.noClear && (h("cat-button", { size: "s", disabled: !this.value, "data-dropdown-no-close": true, onClick: () => this.clear() }, this.locale.clear)))), h("p", { key: 'e31cabf38ed3545ddd4acc32c2540eb5706bc17c', class: "cursor-aria", "aria-live": "polite" })));
144
+ }
145
+ focus(date) {
146
+ const [minDate, maxDate] = this.getMinMaxDate();
147
+ this.focusDate = clampDate(minDate, date, maxDate);
148
+ this.viewDate = new Date(this.focusDate.getFullYear(), this.focusDate.getMonth());
149
+ this.hostElement.shadowRoot
150
+ ?.querySelector(`[data-date="${this.locale.toLocalISO(this.focusDate)}"]`)
151
+ ?.doFocus();
152
+ }
153
+ navigate(direction, period) {
154
+ this.viewDate = new Date(direction === 'prev'
155
+ ? period === 'year'
156
+ ? this.viewDate.setFullYear(this.viewDate.getFullYear() - 1)
157
+ : this.viewDate.setMonth(this.viewDate.getMonth() - 1)
158
+ : period === 'year'
159
+ ? this.viewDate.setFullYear(this.viewDate.getFullYear() + 1)
160
+ : this.viewDate.setMonth(this.viewDate.getMonth() + 1));
161
+ // announce the new month and year
162
+ this.setAriaLive(this.getHeadline());
163
+ }
164
+ setAriaLive(text) {
165
+ const node = this.hostElement.shadowRoot?.querySelector('.cursor-aria');
166
+ if (node) {
167
+ node.innerHTML = text;
168
+ }
169
+ }
170
+ dateGrid(year, month) {
171
+ const firstDayOfWeek = new Date(year, month, 1).getDay();
172
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
173
+ const days = [...Array(daysInMonth).keys()];
174
+ const daysBefore = [...Array(firstDayOfWeek).keys()].map(day => new Date(year, month, day - firstDayOfWeek).getDate());
175
+ const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];
176
+ return [
177
+ ...daysBefore.map(day => new Date(year, month - 1, day + 1)),
178
+ ...days.map(day => new Date(year, month, day + 1)),
179
+ ...daysAfter.map(day => new Date(year, month + 1, day + 1))
180
+ ];
181
+ }
182
+ getHeadline() {
183
+ return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;
184
+ }
185
+ getWeekNumber(date, iso8601 = true) {
186
+ const currentDate = new Date(date.getTime());
187
+ const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay();
188
+ currentDate.setDate(currentDate.getDate() + 4 - dayNum);
189
+ const yearStart = new Date(currentDate.getFullYear(), 0, 1);
190
+ return Math.ceil(((+currentDate - +yearStart) / 86400000 + 1) / 7);
191
+ }
192
+ canFocus(date) {
193
+ const now = this.locale.now();
194
+ const [minDate] = this.getMinMaxDate();
195
+ const focusedDate = this.focusedDate;
196
+ const [startDate] = this.getValue();
197
+ if (focusedDate && isSameMonth(focusedDate, this.viewDate)) {
198
+ return isSameMonth(focusedDate, date) && isSameDay(focusedDate, date);
199
+ }
200
+ else if (startDate && isSameMonth(startDate, this.viewDate)) {
201
+ return isSameMonth(startDate, date) && isSameDay(startDate, date);
202
+ }
203
+ else if (isSameMonth(this.viewDate, now) && (!minDate || minDate <= now)) {
204
+ return isSameMonth(this.viewDate, date) && isSameDay(now, date);
205
+ }
206
+ const minDay = isSameMonth(date, minDate) ? minDate?.getDate() ?? 1 : 1;
207
+ return isSameMonth(this.viewDate, date) && date.getDate() === minDay;
208
+ }
209
+ canClick(date) {
210
+ const [minDate, maxDate] = this.getMinMaxDate();
211
+ return (!minDate || minDate <= date) && (!maxDate || maxDate >= date);
212
+ }
213
+ getMinMaxDate() {
214
+ const minDate = this.locale.fromLocalISO(this.min);
215
+ const maxDate = this.locale.fromLocalISO(this.max);
216
+ return [minDate, maxDate];
217
+ }
218
+ getValue() {
219
+ if (this.range) {
220
+ const [startDate, endDate] = JSON.parse(this.value || '[]');
221
+ return [this.locale.fromLocalISO(startDate), this.locale.fromLocalISO(endDate)];
222
+ }
223
+ else {
224
+ return [this.locale.fromLocalISO(this.value), null];
225
+ }
226
+ }
227
+ toRangeValue(startDate, endDate) {
228
+ return JSON.stringify([startDate, endDate].map(date => (date ? this.locale.toLocalISO(date) : null)));
229
+ }
230
+ static get is() { return "cat-date-inline"; }
231
+ static get encapsulation() { return "shadow"; }
232
+ static get originalStyleUrls() {
233
+ return {
234
+ "$": ["cat-date-inline.scss"]
235
+ };
236
+ }
237
+ static get styleUrls() {
238
+ return {
239
+ "$": ["cat-date-inline.css"]
240
+ };
241
+ }
242
+ static get properties() {
243
+ return {
244
+ "noClear": {
245
+ "type": "boolean",
246
+ "mutable": false,
247
+ "complexType": {
248
+ "original": "boolean",
249
+ "resolved": "boolean",
250
+ "references": {}
251
+ },
252
+ "required": false,
253
+ "optional": false,
254
+ "docs": {
255
+ "tags": [],
256
+ "text": "Hides the clear button."
257
+ },
258
+ "attribute": "no-clear",
259
+ "reflect": false,
260
+ "defaultValue": "false"
261
+ },
262
+ "noHint": {
263
+ "type": "boolean",
264
+ "mutable": false,
265
+ "complexType": {
266
+ "original": "boolean",
267
+ "resolved": "boolean",
268
+ "references": {}
269
+ },
270
+ "required": false,
271
+ "optional": false,
272
+ "docs": {
273
+ "tags": [],
274
+ "text": "Hides the arrow navigation hint."
275
+ },
276
+ "attribute": "no-hint",
277
+ "reflect": false,
278
+ "defaultValue": "false"
279
+ },
280
+ "noToday": {
281
+ "type": "boolean",
282
+ "mutable": false,
283
+ "complexType": {
284
+ "original": "boolean",
285
+ "resolved": "boolean",
286
+ "references": {}
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "Hides the today button."
293
+ },
294
+ "attribute": "no-today",
295
+ "reflect": false,
296
+ "defaultValue": "false"
297
+ },
298
+ "noWeeks": {
299
+ "type": "boolean",
300
+ "mutable": false,
301
+ "complexType": {
302
+ "original": "boolean",
303
+ "resolved": "boolean",
304
+ "references": {}
305
+ },
306
+ "required": false,
307
+ "optional": false,
308
+ "docs": {
309
+ "tags": [],
310
+ "text": "Hides the week numbers."
311
+ },
312
+ "attribute": "no-weeks",
313
+ "reflect": false,
314
+ "defaultValue": "false"
315
+ },
316
+ "size": {
317
+ "type": "string",
318
+ "mutable": false,
319
+ "complexType": {
320
+ "original": "'s' | 'm'",
321
+ "resolved": "\"m\" | \"s\"",
322
+ "references": {}
323
+ },
324
+ "required": false,
325
+ "optional": false,
326
+ "docs": {
327
+ "tags": [],
328
+ "text": "The size of the date picker."
329
+ },
330
+ "attribute": "size",
331
+ "reflect": false,
332
+ "defaultValue": "'m'"
333
+ },
334
+ "min": {
335
+ "type": "string",
336
+ "mutable": false,
337
+ "complexType": {
338
+ "original": "string",
339
+ "resolved": "string | undefined",
340
+ "references": {}
341
+ },
342
+ "required": false,
343
+ "optional": true,
344
+ "docs": {
345
+ "tags": [],
346
+ "text": "A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD."
347
+ },
348
+ "attribute": "min",
349
+ "reflect": false
350
+ },
351
+ "max": {
352
+ "type": "string",
353
+ "mutable": false,
354
+ "complexType": {
355
+ "original": "string",
356
+ "resolved": "string | undefined",
357
+ "references": {}
358
+ },
359
+ "required": false,
360
+ "optional": true,
361
+ "docs": {
362
+ "tags": [],
363
+ "text": "A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD."
364
+ },
365
+ "attribute": "max",
366
+ "reflect": false
367
+ },
368
+ "range": {
369
+ "type": "boolean",
370
+ "mutable": false,
371
+ "complexType": {
372
+ "original": "boolean",
373
+ "resolved": "boolean",
374
+ "references": {}
375
+ },
376
+ "required": false,
377
+ "optional": false,
378
+ "docs": {
379
+ "tags": [],
380
+ "text": "Allow the selection of a range of dates, i.e. start and end date."
381
+ },
382
+ "attribute": "range",
383
+ "reflect": false,
384
+ "defaultValue": "false"
385
+ },
386
+ "value": {
387
+ "type": "string",
388
+ "mutable": true,
389
+ "complexType": {
390
+ "original": "string",
391
+ "resolved": "string | undefined",
392
+ "references": {}
393
+ },
394
+ "required": false,
395
+ "optional": true,
396
+ "docs": {
397
+ "tags": [],
398
+ "text": "The value of the control, given in local ISO 8601 date format YYYY-MM-DD."
399
+ },
400
+ "attribute": "value",
401
+ "reflect": false
402
+ }
403
+ };
404
+ }
405
+ static get states() {
406
+ return {
407
+ "viewDate": {}
408
+ };
409
+ }
410
+ static get events() {
411
+ return [{
412
+ "method": "catChange",
413
+ "name": "catChange",
414
+ "bubbles": true,
415
+ "cancelable": true,
416
+ "composed": true,
417
+ "docs": {
418
+ "tags": [],
419
+ "text": "Emitted when the value is changed."
420
+ },
421
+ "complexType": {
422
+ "original": "string",
423
+ "resolved": "string",
424
+ "references": {}
425
+ }
426
+ }];
427
+ }
428
+ static get methods() {
429
+ return {
430
+ "select": {
431
+ "complexType": {
432
+ "signature": "(date: Date | null) => Promise<void>",
433
+ "parameters": [{
434
+ "name": "date",
435
+ "type": "Date | null",
436
+ "docs": "The date to select."
437
+ }],
438
+ "references": {
439
+ "Promise": {
440
+ "location": "global",
441
+ "id": "global::Promise"
442
+ },
443
+ "Date": {
444
+ "location": "global",
445
+ "id": "global::Date"
446
+ }
447
+ },
448
+ "return": "Promise<void>"
449
+ },
450
+ "docs": {
451
+ "text": "Select a date in the picker.",
452
+ "tags": [{
453
+ "name": "param",
454
+ "text": "date The date to select."
455
+ }]
456
+ }
457
+ },
458
+ "clear": {
459
+ "complexType": {
460
+ "signature": "() => Promise<void>",
461
+ "parameters": [],
462
+ "references": {
463
+ "Promise": {
464
+ "location": "global",
465
+ "id": "global::Promise"
466
+ }
467
+ },
468
+ "return": "Promise<void>"
469
+ },
470
+ "docs": {
471
+ "text": "Clear the picker.",
472
+ "tags": []
473
+ }
474
+ },
475
+ "resetView": {
476
+ "complexType": {
477
+ "signature": "() => Promise<void>",
478
+ "parameters": [],
479
+ "references": {
480
+ "Promise": {
481
+ "location": "global",
482
+ "id": "global::Promise"
483
+ }
484
+ },
485
+ "return": "Promise<void>"
486
+ },
487
+ "docs": {
488
+ "text": "Resets the view of the picker.",
489
+ "tags": []
490
+ }
491
+ }
492
+ };
493
+ }
494
+ static get elementRef() { return "hostElement"; }
495
+ static get listeners() {
496
+ return [{
497
+ "name": "keydown",
498
+ "method": "onKeyDown",
499
+ "target": undefined,
500
+ "capture": false,
501
+ "passive": false
502
+ }];
503
+ }
504
+ }
505
+ //# sourceMappingURL=cat-date-inline.js.map