@genesislcap/foundation-ui 14.236.1-alpha-ed0d291.0 → 14.237.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.
@@ -1,8 +1,9 @@
1
+ import Day from './day';
1
2
  import Month from './month';
2
3
  export default class Calendar {
3
- today: any;
4
+ today: Day;
4
5
  year: number;
5
- month: any;
6
+ month: Month;
6
7
  lang: string;
7
8
  weekDays: unknown[];
8
9
  constructor(year?: any, monthNumber?: any, lang?: string);
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/date-picker/calendar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,SAAS,CAAC;AAI5B,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,YAA6B;gBAEzB,IAAI,MAAO,EAAE,WAAW,MAAO,EAAE,IAAI,SAAY;IAW7D,QAAQ,CAAC,WAAW,KAAA;IAIpB,gBAAgB;IAShB,YAAY;IAQZ,QAAQ,CAAC,WAAW,KAAA,EAAE,IAAI,KAAA;IAK1B,YAAY;IAKZ,gBAAgB;IAMhB,aAAa;IAQb,iBAAiB;CAOlB"}
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/date-picker/calendar.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,KAAK,MAAM,SAAS,CAAC;AAI5B,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,YAA6B;gBAEzB,IAAI,MAAO,EAAE,WAAW,MAAO,EAAE,IAAI,SAAY;IAW7D,QAAQ,CAAC,WAAW,KAAA;IAIpB,gBAAgB;IAShB,YAAY;IAQZ,QAAQ,CAAC,WAAW,KAAA,EAAE,IAAI,KAAA;IAK1B,YAAY;IAKZ,gBAAgB;IAMhB,aAAa;IAQb,iBAAiB;CAOlB"}
@@ -1,25 +1,93 @@
1
1
  import { FoundationElement } from '@microsoft/fast-foundation';
2
2
  import Calendar from './calendar';
3
+ import Day from './day';
3
4
  export declare const foundationDatePickerShadowOptions: ShadowRootInit;
4
5
  export declare const defaultDatePickerConfig: {};
5
6
  /**
6
7
  * @tagname %%prefix%%-date-picker
7
8
  */
8
9
  export declare class DatePicker extends FoundationElement {
10
+ /**
11
+ * @attr format - date format that will be displayed.
12
+ * @default 'MM-DD-YYYY
13
+ * @example
14
+ * Date picker with day, month, year
15
+ * ```html
16
+ * <rapid-date-picker format="MM-DD-YYYY">
17
+ * </rapid-date-picker>
18
+ * ```
19
+ */
9
20
  format: string;
10
21
  formatChanged(oldValue: string, newValue: string): void;
11
22
  lang: string;
12
23
  visible: boolean;
13
- position: string;
24
+ /**
25
+ * @attr position - positions the calendar picker relative to the input control.
26
+ * @default bottom
27
+ * @example
28
+ * To position the calendar to the right.
29
+ * ```html
30
+ * <rapid-date-picker position="right">
31
+ * </rapid-date-picker>
32
+ * ```
33
+ */
34
+ position: 'bottom' | 'top' | 'left' | 'right';
35
+ /**
36
+ * @attr label - the label that will be displayed next to the date input text field
37
+ * @example
38
+ * To add a label with the value "Trade Date"
39
+ * ```html
40
+ * <rapid-date-picker label="Trade date">
41
+ * </rapid-date-picker>
42
+ * ```
43
+ */
14
44
  label: string;
45
+ /**
46
+ * @attr value - sets the value of the date picker
47
+ * @example
48
+ * To set a value of January 1st 2025, assuming MM/DD/YYYY date format
49
+ * ```html
50
+ * <rapid-date-picker value="01/20/2025">
51
+ * </rapid-date-picker>
52
+ * ```
53
+ */
15
54
  value: string;
16
55
  valueChanged(oldValue: string, newValue: string): void;
17
- currentDate: any;
18
- currentMonth: Calendar;
56
+ /**
57
+ * @internal
58
+ */
59
+ currentDate: Day;
60
+ /**
61
+ * @internal
62
+ */
63
+ currentMonth: string;
64
+ /**
65
+ * @internal
66
+ */
19
67
  currentYear: number;
68
+ /**
69
+ * @internal
70
+ */
20
71
  calendarDropdownClasses: String;
72
+ /**
73
+ * @internal
74
+ */
21
75
  formatDate: string;
22
- monthList: any;
76
+ /**
77
+ * @internal
78
+ */
79
+ monthList: Day[];
80
+ /**
81
+ * @public disabledDaysOfWeek - an array of numbers disabling days of the week.
82
+ * Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7
83
+ * @example
84
+ * To disable Saturday and Sunday.
85
+ * ```html
86
+ * <rapid-date-picker :disabledDaysOfWeek="${() => [1,7]}">
87
+ * </rapid-date-picker>
88
+ * ```
89
+ */
90
+ disabledDaysOfWeek: number[];
23
91
  calendar: Calendar;
24
92
  toggleButton: HTMLElement;
25
93
  calendarDaysContainer: HTMLElement;
@@ -27,7 +95,6 @@ export declare class DatePicker extends FoundationElement {
27
95
  prevBtn: HTMLElement;
28
96
  nextBtn: HTMLElement;
29
97
  substringNumber: number;
30
- constructor();
31
98
  connectedCallback(): void;
32
99
  updateHeaderText(): void;
33
100
  toggleCalendar(): void;
@@ -37,7 +104,7 @@ export declare class DatePicker extends FoundationElement {
37
104
  prevMonth(): void;
38
105
  nextMonth(): void;
39
106
  selectDay(day: any): void;
40
- getMonthDaysGrid(): unknown[];
107
+ getMonthDaysGrid(): Day[];
41
108
  }
42
109
  /**
43
110
  * The Foundation DatePicker
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAKlC,eAAO,MAAM,iCAAiC,EAAE,cAA0B,CAAC;AAE3E,eAA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AI;IAMjB,SAAS,IAAI,IAAI;IAMjB,SAAS,CAAC,GAAG,KAAA,GAAG,IAAI;IAYpB,gBAAgB,IAAI,GAAG,EAAE;CAkB1B;AACD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;qBAM/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.styles.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,eAAO,MAAM,0BAA0B,EAAE,aA+IxC,CAAC"}
1
+ {"version":3,"file":"date-picker.styles.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,eAAO,MAAM,0BAA0B,EAAE,aAwJxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.template.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.template.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,qBAAqB,WAAY,MAAM,oEA0CnD,CAAC;AAEF,eAAO,MAAM,4BAA4B,iEAExC,CAAC"}
1
+ {"version":3,"file":"date-picker.template.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.template.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,qBAAqB,WAAY,MAAM,oEAqDnD,CAAC;AAEF,eAAO,MAAM,4BAA4B,iEAExC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export default class Day {
2
- Date: Object;
2
+ Date: Date;
3
3
  date: Date;
4
4
  day: string;
5
5
  dayNumber: number;
@@ -1 +1 @@
1
- {"version":3,"file":"day.d.ts","sourceRoot":"","sources":["../../../src/date-picker/day.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,MAAO,EAAE,IAAI,SAAY;CAc1C"}
1
+ {"version":3,"file":"day.d.ts","sourceRoot":"","sources":["../../../src/date-picker/day.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,MAAO,EAAE,IAAI,SAAY;CAc1C"}
@@ -0,0 +1,6 @@
1
+ import Day from './day';
2
+ export declare const getNextDay: (date: Date, numDays?: number) => Date;
3
+ export declare const getPreviousDay: (date: Date, numDays?: number) => Date;
4
+ export declare const isDayEnabled: (disabledDays: number[], day: Day) => boolean;
5
+ export declare const getNextEnabledDay: (disabledDaysOfWeek: number[], currentDate: Day, lang: string) => Day;
6
+ //# sourceMappingURL=day.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"day.util.d.ts","sourceRoot":"","sources":["../../../src/date-picker/day.util.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,eAAO,MAAM,UAAU,SAAU,IAAI,uBAAgB,IAIpD,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,IAAI,uBAAgB,IAIxD,CAAC;AAEF,eAAO,MAAM,YAAY,iBAAkB,MAAM,EAAE,OAAO,GAAG,KAAG,OAE/D,CAAC;AAOF,eAAO,MAAM,iBAAiB,uBACR,MAAM,EAAE,eACf,GAAG,QACV,MAAM,KACX,GAmBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"month.d.ts","sourceRoot":"","sources":["../../../src/date-picker/month.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,OAAO,CAAC;AAIxB,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;gBAET,IAAI,MAAO,EAAE,IAAI,SAAY;IAgBzC,MAAM,CAAC,IAAI,KAAA;CAGZ"}
1
+ {"version":3,"file":"month.d.ts","sourceRoot":"","sources":["../../../src/date-picker/month.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,OAAO,CAAC;AAIxB,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;gBAET,IAAI,MAAO,EAAE,IAAI,SAAY;IAgBzC,MAAM,CAAC,IAAI,KAAA,GAAG,GAAG;CAGlB"}
@@ -10,12 +10,51 @@ import Calendar from './calendar';
10
10
  import { foundationDatePickerStyles as styles } from './date-picker.styles';
11
11
  import { foundationDatePickerTemplate as template } from './date-picker.template';
12
12
  import Day from './day';
13
+ import { getNextEnabledDay } from './day.util';
13
14
  export const foundationDatePickerShadowOptions = undefined;
14
15
  export const defaultDatePickerConfig = {};
15
16
  /**
16
17
  * @tagname %%prefix%%-date-picker
17
18
  */
18
19
  export class DatePicker extends FoundationElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ /**
23
+ * @attr format - date format that will be displayed.
24
+ * @default 'MM-DD-YYYY
25
+ * @example
26
+ * Date picker with day, month, year
27
+ * ```html
28
+ * <rapid-date-picker format="MM-DD-YYYY">
29
+ * </rapid-date-picker>
30
+ * ```
31
+ */
32
+ this.format = 'MM-DD-YYYY';
33
+ this.lang = 'en-US';
34
+ this.visible = false;
35
+ /**
36
+ * @attr position - positions the calendar picker relative to the input control.
37
+ * @default bottom
38
+ * @example
39
+ * To position the calendar to the right.
40
+ * ```html
41
+ * <rapid-date-picker position="right">
42
+ * </rapid-date-picker>
43
+ * ```
44
+ */
45
+ this.position = 'bottom';
46
+ /**
47
+ * @public disabledDaysOfWeek - an array of numbers disabling days of the week.
48
+ * Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7
49
+ * @example
50
+ * To disable Saturday and Sunday.
51
+ * ```html
52
+ * <rapid-date-picker :disabledDaysOfWeek="${() => [1,7]}">
53
+ * </rapid-date-picker>
54
+ * ```
55
+ */
56
+ this.disabledDaysOfWeek = [];
57
+ }
19
58
  formatChanged(oldValue, newValue) {
20
59
  if (newValue && this.calendar) {
21
60
  this.formatDate = dayjs(this.currentDate.Date).format(newValue);
@@ -31,24 +70,22 @@ export class DatePicker extends FoundationElement {
31
70
  this.monthList = this.getMonthDaysGrid();
32
71
  }
33
72
  }
34
- constructor() {
35
- super();
36
- this.format = 'MM-DD-YYYY';
37
- this.lang = 'en-US';
38
- this.visible = false;
39
- this.position = 'bottom';
73
+ connectedCallback() {
74
+ var _a;
75
+ super.connectedCallback();
40
76
  dayjs.extend(customParseFormat);
41
77
  dayjs.extend(LocalizedFormat);
42
78
  dayjs.extend(localeData);
43
79
  this.substringNumber = 3;
44
80
  const dateString = this.getAttribute('value');
45
81
  const dayjsDate = dateString ? dayjs(dateString, 'MM-DD-YYYY') : dayjs();
46
- this.currentDate = new Day(dayjsDate.toDate(), this.lang);
82
+ let currentDate = new Day(dayjsDate.toDate(), this.lang);
83
+ if ((_a = this.disabledDaysOfWeek) === null || _a === void 0 ? void 0 : _a.length) {
84
+ currentDate = getNextEnabledDay(this.disabledDaysOfWeek, currentDate, this.lang);
85
+ }
86
+ this.currentDate = currentDate;
47
87
  this.calendar = new Calendar(this.currentDate.year, this.currentDate.monthNumber, this.lang);
48
88
  this.value = dayjs(this.currentDate.Date).format('MM-DD-YYYY');
49
- }
50
- connectedCallback() {
51
- super.connectedCallback();
52
89
  this.currentMonth = this.calendar.month.name;
53
90
  this.currentYear = this.calendar.year;
54
91
  this.formatDate = dayjs(this.currentDate.Date).format(this.format);
@@ -76,7 +113,10 @@ export class DatePicker extends FoundationElement {
76
113
  return dayjs(date.Date).isSame(this.currentDate.Date, 'day');
77
114
  }
78
115
  isCurrentCalendarMonth() {
79
- return (this.currentMonth === this.currentDate.monthNumber &&
116
+ return (
117
+ // ToDo FUI-2290 adding types. Investigate is currentMonth can be a number or is this a bug
118
+ // @ts-ignore
119
+ this.currentMonth === this.currentDate.monthNumber &&
80
120
  this.currentYear === this.currentDate.year);
81
121
  }
82
122
  prevMonth() {
@@ -152,6 +192,12 @@ __decorate([
152
192
  __decorate([
153
193
  observable
154
194
  ], DatePicker.prototype, "monthList", void 0);
195
+ __decorate([
196
+ observable
197
+ ], DatePicker.prototype, "disabledDaysOfWeek", void 0);
198
+ __decorate([
199
+ observable
200
+ ], DatePicker.prototype, "calendar", void 0);
155
201
  /**
156
202
  * The Foundation DatePicker
157
203
  *
@@ -106,6 +106,10 @@ export const foundationDatePickerStyles = css `
106
106
  text-transform: capitalize;
107
107
  }
108
108
 
109
+ .week-days span.disabled {
110
+ opacity: 50%;
111
+ }
112
+
109
113
  .month-days {
110
114
  display: grid;
111
115
  grid-template-columns: repeat(7, 1fr);
@@ -134,11 +138,16 @@ export const foundationDatePickerStyles = css `
134
138
  color: var(--neutral-foreground-rest);
135
139
  }
136
140
 
137
- .month-day:hover {
141
+ .month-day:hover:not(:disabled) {
138
142
  background: var(--neutral-stroke-hover);
139
143
  color: (--neutral-foreground-rest);
140
144
  }
141
145
 
146
+ .month-day[disabled] {
147
+ opacity: 50%;
148
+ cursor: not-allowed;
149
+ }
150
+
142
151
  .date-toggle[readonly] .label {
143
152
  cursor: pointer;
144
153
  }
@@ -1,5 +1,6 @@
1
1
  import { html } from '@microsoft/fast-element';
2
2
  import { ref, repeat } from '@microsoft/fast-element';
3
+ import { classNames } from '@microsoft/fast-web-utilities';
3
4
  import { getPrefix } from '../utils/dom';
4
5
  export const getPrefixedDatePicker = (prefix) => html `
5
6
  <${prefix}-text-field data-test-id="date-picker" readonly :value="${(x) => x.formatDate}" part="date-toggle" class="date-toggle" ${ref('toggleButton')}>
@@ -19,13 +20,21 @@ export const getPrefixedDatePicker = (prefix) => html `
19
20
  </div>
20
21
  </div>
21
22
  <div class="week-days">
22
- ${repeat((x) => x.calendar.weekDays, html `
23
- <span>${(x, c) => x.substring(0, c.parent.substringNumber)}</span>
24
- `)}
23
+ ${repeat((x) => { var _a; return (_a = x.calendar) === null || _a === void 0 ? void 0 : _a.weekDays; }, html `
24
+ <span
25
+ class="${(x, ctx) => classNames([
26
+ 'disabled',
27
+ ctx.parent.disabledDaysOfWeek.indexOf(ctx.index + 1) !== -1,
28
+ ])}"
29
+ >
30
+ ${(x, c) => x.substring(0, c.parent.substringNumber)}
31
+ </span>
32
+ `, { positioning: true })}
25
33
  </div>
26
34
  <div class="month-days" ${ref('calendarDaysContainer')}>
27
35
  ${repeat((x) => x.monthList, html `
28
36
  <button
37
+ ?disabled="${(x, ctx) => ctx.parent.disabledDaysOfWeek.indexOf(x.dayNumber) !== -1}"
29
38
  class="month-day
30
39
  ${(x, c) => (c.parent.isSelectedDate(x) ? 'selected' : '')}
31
40
  ${(x, c) => (x.monthNumber === c.parent.calendar.month.number ? 'current' : '')}"
@@ -0,0 +1,38 @@
1
+ import { logger } from '@genesislcap/foundation-utils';
2
+ import Day from './day';
3
+ export const getNextDay = (date, numDays = 1) => {
4
+ const tomorrow = new Date();
5
+ tomorrow.setDate(date.getDate() + numDays);
6
+ return tomorrow;
7
+ };
8
+ export const getPreviousDay = (date, numDays = 1) => {
9
+ const yesterday = new Date();
10
+ yesterday.setDate(date.getDate() - numDays);
11
+ return yesterday;
12
+ };
13
+ export const isDayEnabled = (disabledDays, day) => {
14
+ return disabledDays.indexOf(day.dayNumber) === -1;
15
+ };
16
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
17
+ const daysOfWeek = [1, 2, 3, 4, 5, 6, 7];
18
+ const NUM_DAYS_OF_WEEK = 7;
19
+ export const getNextEnabledDay = (disabledDaysOfWeek, currentDate, lang) => {
20
+ if (isDayEnabled(disabledDaysOfWeek, currentDate)) {
21
+ return currentDate;
22
+ }
23
+ const enabledDays = daysOfWeek.filter((d) => disabledDaysOfWeek.indexOf(d) === -1);
24
+ let nextDayNumber = enabledDays.find((d) => d > currentDate.dayNumber);
25
+ if (!nextDayNumber) {
26
+ nextDayNumber = Math.min(...enabledDays);
27
+ }
28
+ const rollDays = currentDate.dayNumber < nextDayNumber
29
+ ? nextDayNumber - currentDate.dayNumber
30
+ : nextDayNumber - currentDate.dayNumber + NUM_DAYS_OF_WEEK;
31
+ if (enabledDays.length) {
32
+ return new Day(getNextDay(currentDate.Date, rollDays), lang);
33
+ }
34
+ else {
35
+ logger.warn('Date picker disabled days - all days of week have been disabled');
36
+ return currentDate;
37
+ }
38
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.236.1-alpha-ed0d291.0",
4
+ "version": "14.237.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.236.1-alpha-ed0d291.0",
87
- "@genesislcap/genx": "14.236.1-alpha-ed0d291.0",
88
- "@genesislcap/rollup-builder": "14.236.1-alpha-ed0d291.0",
89
- "@genesislcap/ts-builder": "14.236.1-alpha-ed0d291.0",
90
- "@genesislcap/uvu-playwright-builder": "14.236.1-alpha-ed0d291.0",
91
- "@genesislcap/vite-builder": "14.236.1-alpha-ed0d291.0",
92
- "@genesislcap/webpack-builder": "14.236.1-alpha-ed0d291.0",
86
+ "@genesislcap/foundation-testing": "14.237.0",
87
+ "@genesislcap/genx": "14.237.0",
88
+ "@genesislcap/rollup-builder": "14.237.0",
89
+ "@genesislcap/ts-builder": "14.237.0",
90
+ "@genesislcap/uvu-playwright-builder": "14.237.0",
91
+ "@genesislcap/vite-builder": "14.237.0",
92
+ "@genesislcap/webpack-builder": "14.237.0",
93
93
  "copyfiles": "^2.4.1",
94
94
  "rimraf": "^5.0.0",
95
95
  "rxjs": "^7.5.4"
@@ -100,13 +100,13 @@
100
100
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
101
101
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
102
102
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
103
- "@genesislcap/foundation-comms": "14.236.1-alpha-ed0d291.0",
104
- "@genesislcap/foundation-criteria": "14.236.1-alpha-ed0d291.0",
105
- "@genesislcap/foundation-errors": "14.236.1-alpha-ed0d291.0",
106
- "@genesislcap/foundation-logger": "14.236.1-alpha-ed0d291.0",
107
- "@genesislcap/foundation-notifications": "14.236.1-alpha-ed0d291.0",
108
- "@genesislcap/foundation-user": "14.236.1-alpha-ed0d291.0",
109
- "@genesislcap/foundation-utils": "14.236.1-alpha-ed0d291.0",
103
+ "@genesislcap/foundation-comms": "14.237.0",
104
+ "@genesislcap/foundation-criteria": "14.237.0",
105
+ "@genesislcap/foundation-errors": "14.237.0",
106
+ "@genesislcap/foundation-logger": "14.237.0",
107
+ "@genesislcap/foundation-notifications": "14.237.0",
108
+ "@genesislcap/foundation-user": "14.237.0",
109
+ "@genesislcap/foundation-utils": "14.237.0",
110
110
  "@microsoft/fast-colors": "5.3.1",
111
111
  "@microsoft/fast-components": "2.30.6",
112
112
  "@microsoft/fast-element": "1.14.0",
@@ -128,5 +128,5 @@
128
128
  "access": "public"
129
129
  },
130
130
  "customElements": "dist/custom-elements.json",
131
- "gitHead": "56cfffe113d26fcbbad5d901393695501b81688a"
131
+ "gitHead": "cf9e69d5468bebebfa4be788ce5b02ed8fa409a5"
132
132
  }