@haiilo/catalyst 10.8.0 → 10.9.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.
@@ -1751,24 +1751,29 @@ const CatDateInline = class {
1751
1751
  const [minDate, maxDate] = this.getMinMaxDate();
1752
1752
  const dateGrid = this.dateGrid(this.viewDate.getFullYear(), this.viewDate.getMonth());
1753
1753
  const [dateStart, dateEnd] = this.getValue();
1754
- return (index.h(index.Host, { key: 'c48f887b0942699c3f319922df98b2d0f28851a0' }, index.h("div", { key: 'fb3eff378bb846effd327fb589d1e006cba78c87', class: { picker: true, 'picker-weeks': this.weeks } }, index.h("div", { key: '6b7b3c2d9ccbf8f5e247c4ddfa519e6e31a3a312', class: "picker-head" }, index.h("cat-button", { key: '755823de9dbee2dc7e52e1792d20ff3c56ccef8d', 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 }), index.h("cat-button", { key: '90e7420d4bc9c474d322d303413bc7e0bc4ac33d', 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 }), index.h("h3", { key: 'e6a39d6e56a360a14bd5db15d53d12b5743071fc' }, this.getHeadline()), index.h("cat-button", { key: '18bbfccbef72377967d96d1481196a0dfd1297fb', 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 }), index.h("cat-button", { key: 'e0773fe064c5b70a59437b388e9c4877a4ff66cd', 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 })), index.h("div", { key: 'f6d969e0cbfc0700f3db9931ab8087ea9cab9c30', class: "picker-grid", onFocusin: () => this.setAriaLive(this.locale.arrowKeys) }, index.h("div", { key: 'ecf39be602c6538f97ccbea7d5060c8e4b0b7f9f', class: "picker-grid-head" }, Array.from(Array(7), (_, i) => (index.h("abbr", { title: this.locale.days.long[i] }, this.locale.days.short[i])))), this.weeks && (index.h("div", { class: "picker-grid-weeks" }, dateGrid
1754
+ return (index.h(index.Host, { key: 'c48f887b0942699c3f319922df98b2d0f28851a0' }, index.h("div", { key: 'fb3eff378bb846effd327fb589d1e006cba78c87', class: { picker: true, 'picker-weeks': this.weeks } }, index.h("div", { key: '6b7b3c2d9ccbf8f5e247c4ddfa519e6e31a3a312', class: "picker-head" }, index.h("cat-button", { key: '755823de9dbee2dc7e52e1792d20ff3c56ccef8d', 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 }), index.h("cat-button", { key: '90e7420d4bc9c474d322d303413bc7e0bc4ac33d', 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 }), index.h("h3", { key: 'e6a39d6e56a360a14bd5db15d53d12b5743071fc' }, this.getHeadline()), index.h("cat-button", { key: '18bbfccbef72377967d96d1481196a0dfd1297fb', 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 }), index.h("cat-button", { key: 'e0773fe064c5b70a59437b388e9c4877a4ff66cd', 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 })), index.h("div", { key: 'f6d969e0cbfc0700f3db9931ab8087ea9cab9c30', class: "picker-grid", onFocusin: () => this.setAriaLive(this.locale.arrowKeys) }, index.h("div", { key: 'ecf39be602c6538f97ccbea7d5060c8e4b0b7f9f', class: "picker-grid-head" }, Array.from(Array(7), (_, i) => {
1755
+ const day = (i + this.locale.weekInfo.firstDay) % 7;
1756
+ return index.h("abbr", { title: this.locale.days.long[day] }, this.locale.days.short[day]);
1757
+ })), this.weeks && (index.h("div", { class: "picker-grid-weeks" }, dateGrid
1755
1758
  .filter((_, i) => i % 7 === 0)
1756
- .map(day => (index.h("div", null, this.getWeekNumber(day)))))), index.h("div", { key: '1a8ace7365879688d6952bd68eaefe73b81683de', class: "picker-grid-days" }, dateGrid.map(day => {
1759
+ .map(day => (index.h("div", null, this.getWeekNumber(day)))))), index.h("div", { key: 'ce3f468736a76aa772bd2f16ea407a4a890fd02c', class: "picker-grid-days" }, dateGrid.map(day => {
1757
1760
  const isStartDate = isSameDay(dateStart, day);
1758
1761
  const isEndDate = isSameDay(dateEnd, day);
1759
1762
  const isRange = !!dateStart && !!dateEnd && day > dateStart && day < dateEnd;
1760
1763
  const isToday = isSameDay(this.locale.now(), day);
1764
+ const isWeekend = this.locale.weekInfo.weekend.includes(day.getDay() || 7);
1761
1765
  return (index.h("cat-button", { class: {
1762
1766
  'cat-date-item': true,
1763
1767
  'date-other': !isSameMonth(this.viewDate, day),
1764
1768
  'date-today': isToday,
1769
+ 'date-weekend': isWeekend,
1765
1770
  'date-start': this.range && isStartDate,
1766
1771
  'date-range': this.range && isRange,
1767
1772
  'date-end': this.range && isEndDate,
1768
1773
  'date-focusable': this.canFocus(day),
1769
1774
  'date-disabled': !this.canClick(day)
1770
1775
  }, 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()));
1771
- }))), index.h("div", { key: '62d01f9063d213411a12315637d4835cedb975e3', class: "picker-foot" }, !this.noToday && this.canClick(this.locale.now()) && (index.h("cat-button", { size: "s", "data-dropdown-no-close": true, onClick: () => this.select(this.locale.now()) }, this.locale.today)), this.hint && index.h("p", { class: "cursor-help" }, this.locale.arrowKeys), !this.noClear && (index.h("cat-button", { size: "s", disabled: !this.value, "data-dropdown-no-close": true, onClick: () => this.clear() }, this.locale.clear)))), index.h("p", { key: '5709adcbf7b1bb39ef9a2ae2525a28afc23c766d', class: "cursor-aria", "aria-live": "polite" })));
1776
+ }))), index.h("div", { key: '3c542e87fed7a18360871f0bc9b96658c6e6cfeb', class: "picker-foot" }, !this.noToday && this.canClick(this.locale.now()) && (index.h("cat-button", { size: "s", "data-dropdown-no-close": true, onClick: () => this.select(this.locale.now()) }, this.locale.today)), this.hint && index.h("p", { class: "cursor-help" }, this.locale.arrowKeys), !this.noClear && (index.h("cat-button", { size: "s", disabled: !this.value, "data-dropdown-no-close": true, onClick: () => this.clear() }, this.locale.clear)))), index.h("p", { key: 'f90c2947cdf67dc7a2bed883884133df2cc79380', class: "cursor-aria", "aria-live": "polite" })));
1772
1777
  }
1773
1778
  focus(date) {
1774
1779
  const [minDate, maxDate] = this.getMinMaxDate();
@@ -1796,10 +1801,10 @@ const CatDateInline = class {
1796
1801
  }
1797
1802
  }
1798
1803
  dateGrid(year, month) {
1799
- const firstDayOfWeek = new Date(year, month, 1).getDay();
1804
+ const daysOffset = (new Date(year, month, 1).getDay() - this.locale.weekInfo.firstDay + 7) % 7;
1800
1805
  const daysInMonth = new Date(year, month + 1, 0).getDate();
1801
1806
  const days = [...Array(daysInMonth).keys()];
1802
- const daysBefore = [...Array(firstDayOfWeek).keys()].map(day => new Date(year, month, day - firstDayOfWeek).getDate());
1807
+ const daysBefore = this.getLastDaysOfMonth(year, month, daysOffset);
1803
1808
  const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];
1804
1809
  return [
1805
1810
  ...daysBefore.map(day => new Date(year, month - 1, day + 1)),
@@ -1807,6 +1812,11 @@ const CatDateInline = class {
1807
1812
  ...daysAfter.map(day => new Date(year, month + 1, day + 1))
1808
1813
  ];
1809
1814
  }
1815
+ getLastDaysOfMonth(year, month, x) {
1816
+ const lastDayOfMonth = new Date(year, month, 0).getDate();
1817
+ const daysOfMonth = Array.from({ length: lastDayOfMonth }, (_, index) => index);
1818
+ return x ? daysOfMonth.slice(-x) : [];
1819
+ }
1810
1820
  getHeadline() {
1811
1821
  return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;
1812
1822
  }