@genesislcap/foundation-ui 14.437.3 → 14.437.5-canary.date-picker-updates
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.
- package/dist/custom-elements.json +1252 -849
- package/dist/dts/date-picker/date-picker.d.ts +52 -0
- package/dist/dts/date-picker/date-picker.d.ts.map +1 -1
- package/dist/dts/date-picker/date-picker.template.d.ts.map +1 -1
- package/dist/dts/date-picker/date-picker.util.d.ts +24 -0
- package/dist/dts/date-picker/date-picker.util.d.ts.map +1 -0
- package/dist/dts/date-picker/index.d.ts +1 -0
- package/dist/dts/date-picker/index.d.ts.map +1 -1
- package/dist/dts/react.d.ts +16 -16
- package/dist/esm/date-picker/date-picker.js +186 -14
- package/dist/esm/date-picker/date-picker.template.js +9 -1
- package/dist/esm/date-picker/date-picker.util.js +59 -0
- package/dist/esm/date-picker/index.js +1 -0
- package/dist/react.cjs +10 -10
- package/dist/react.mjs +8 -8
- package/package.json +19 -19
|
@@ -22,6 +22,14 @@ export declare class DatePicker extends FoundationElement {
|
|
|
22
22
|
format: string;
|
|
23
23
|
formatChanged(oldValue: string, newValue: string): void;
|
|
24
24
|
lang: string;
|
|
25
|
+
langChanged(): void;
|
|
26
|
+
/**
|
|
27
|
+
* @attr use-locale-format - when true, `format` is set from dayjs locale `L`.
|
|
28
|
+
* Uses the browser locale (`navigator.language`) unless `lang` is set on the element.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
useLocaleFormat: boolean;
|
|
32
|
+
useLocaleFormatChanged(): void;
|
|
25
33
|
visible: boolean;
|
|
26
34
|
/**
|
|
27
35
|
* @attr inline-calendar - display the calendar beneath the value display.
|
|
@@ -68,6 +76,19 @@ export declare class DatePicker extends FoundationElement {
|
|
|
68
76
|
* ```
|
|
69
77
|
*/
|
|
70
78
|
label: string;
|
|
79
|
+
/**
|
|
80
|
+
* @attr allow-empty - when true, no initial date is selected; the input shows a placeholder until the user picks a date.
|
|
81
|
+
* @default false
|
|
82
|
+
* @example
|
|
83
|
+
* ```html
|
|
84
|
+
* <rapid-date-picker allow-empty format="DD/MM/YYYY"></rapid-date-picker>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
allowEmpty: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* @attr placeholder - hint shown when allow-empty is set and no date is selected. Defaults from `format` (e.g. DD/MM/YYYY → dd/mm/yyyy).
|
|
90
|
+
*/
|
|
91
|
+
placeholder: string;
|
|
71
92
|
/**
|
|
72
93
|
* @attr value - sets the value of the date picker
|
|
73
94
|
* @example
|
|
@@ -116,8 +137,39 @@ export declare class DatePicker extends FoundationElement {
|
|
|
116
137
|
disabledDaysOfWeek: number[];
|
|
117
138
|
calendar: Calendar;
|
|
118
139
|
substringNumber: number;
|
|
140
|
+
disconnectedCallback(): void;
|
|
119
141
|
connectedCallback(): void;
|
|
142
|
+
/**
|
|
143
|
+
* Clears the selected date (only when `allow-empty` is enabled).
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
clear(): void;
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
get inputValue(): string;
|
|
151
|
+
/**
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
get inputPlaceholder(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Locale for display format and calendar labels: explicit `lang`, or browser when using locale format.
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
private get effectiveLang();
|
|
160
|
+
private applyLocaleFormat;
|
|
161
|
+
private initializeEmpty;
|
|
162
|
+
private initializeWithValue;
|
|
163
|
+
private initializeWithDefaultDate;
|
|
164
|
+
private applyValue;
|
|
165
|
+
private clearToEmpty;
|
|
120
166
|
updateHeaderText(): void;
|
|
167
|
+
protected visibleChanged(_prev: boolean, next: boolean): void;
|
|
168
|
+
private clickOutside;
|
|
169
|
+
private keydownOutside;
|
|
170
|
+
private handleKeydownOutside;
|
|
171
|
+
private handleClickOutside;
|
|
172
|
+
private closeCalendar;
|
|
121
173
|
toggleCalendar(): void;
|
|
122
174
|
toggleVisibility(): void;
|
|
123
175
|
isSelectedDate(date: any): boolean;
|
|
@@ -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;
|
|
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;AAQ/D,OAAO,QAAQ,MAAM,YAAY,CAAC;AASlC,OAAO,GAAG,MAAM,OAAO,CAAC;AAGxB,eAAO,MAAM,iCAAiC,EAAE,cAA0B,CAAC;AAE3E,eAAO,MAAM,uBAAuB,IAAK,CAAC;AAE1C;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,iBAAiB;IAC/C;;;;;;;;;OASG;IACG,MAAM,SAAgB;IAC5B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAK1C,IAAI,SAAW;IACrB,WAAW;IAMX;;;;OAIG;IACwD,eAAe,EAAE,OAAO,CAAC;IACpF,sBAAsB;IAMhB,OAAO,UAAS;IAEtB;;;;;;;;;OASG;IACsD,cAAc,EAAE,OAAO,CAAC;IACjF,qBAAqB;IAIrB;;;;;;;;;OASG;IACoD,YAAY,EAAE,OAAO,CAAC;IAC7E,2BAA2B;IAI3B;;;;;;;;;OASG;IACG,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAY;IAE/D;;;;;;;;OAQG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACkD,UAAU,EAAE,OAAO,CAAC;IAEzE;;OAEG;IACG,WAAW,EAAE,MAAM,CAAC;IAE1B;;;;;;;;OAQG;IACG,KAAK,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAY/C;;OAEG;IACS,WAAW,EAAE,GAAG,CAAC;IAC7B;;OAEG;IACS,YAAY,EAAE,MAAM,CAAC;IACjC;;OAEG;IACS,WAAW,EAAE,MAAM,CAAC;IAChC;;OAEG;IACS,uBAAuB,EAAE,MAAM,CAAC;IAC5C;;OAEG;IACS,UAAU,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACS,SAAS,EAAE,GAAG,EAAE,CAAC;IAE7B;;;;;;;;;OASG;IACS,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,EAAE,QAAQ,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IAExB,oBAAoB;IAMpB,iBAAiB;IAwBjB;;;OAGG;IACI,KAAK,IAAI,IAAI;IAOpB;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAK7B;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAKxB;IAED,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,YAAY;IAepB,gBAAgB,IAAI,IAAI;IAKxB,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAa7D,OAAO,CAAC,YAAY,CAAiD;IAErE,OAAO,CAAC,cAAc,CAAsD;IAE5E,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,aAAa;IAQrB,cAAc,IAAI,IAAI;IAUtB,gBAAgB,IAAI,IAAI;IASxB,cAAc,CAAC,IAAI,KAAA,GAAG,OAAO;IAO7B,sBAAsB,IAAI,OAAO;IASjC,SAAS,IAAI,IAAI;IAMjB,SAAS,IAAI,IAAI;IAMjB,SAAS,CAAC,GAAG,KAAA,GAAG,IAAI;IAgBpB,gBAAgB,IAAI,GAAG,EAAE;CAkB1B;AACD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;qBAM/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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;AAOhD,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,
|
|
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;AAOhD,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,oEA0EnD,CAAC;AAEF,eAAO,MAAM,4BAA4B,iEAExC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import 'dayjs/locale/en-gb';
|
|
2
|
+
/**
|
|
3
|
+
* Maps BCP-47 tags to dayjs locale names (dayjs provides `en`, `en-gb`, not `en-US`).
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveDayjsLocale(lang: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Browser BCP-47 locale (e.g. `en-GB`), or `en` when unavailable (SSR/tests).
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function getBrowserLocale(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Display format from dayjs locale `L` (e.g. en / en-US → MM/DD/YYYY, en-gb → DD/MM/YYYY).
|
|
14
|
+
* Falls back to `en` when the locale is not loaded in dayjs.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDisplayFormatForLang(lang?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Maps a dayjs-style display format to a lowercase placeholder hint (e.g. DD/MM/YYYY → dd/mm/yyyy).
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatToPlaceholder(format: string): string;
|
|
23
|
+
export declare function hasDateValue(value: string | null | undefined): boolean;
|
|
24
|
+
//# sourceMappingURL=date-picker.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.util.d.ts","sourceRoot":"","sources":["../../../src/date-picker/date-picker.util.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,CAAC;AAI5B;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAKzC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,MAAa,GAAG,MAAM,CASnE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
package/dist/dts/react.d.ts
CHANGED
|
@@ -120,23 +120,23 @@ interface HTMLWCProps extends React.AriaAttributes {
|
|
|
120
120
|
onInput?(e: Event): void;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export declare const
|
|
123
|
+
export declare const AccordionItem: React.ForwardRefExoticComponent<
|
|
124
124
|
React.PropsWithChildren<
|
|
125
|
-
Omit<PublicOf<
|
|
125
|
+
Omit<PublicOf<AccordionItemWC>, 'children' | 'style'> &
|
|
126
126
|
HTMLWCProps & {
|
|
127
127
|
}
|
|
128
|
-
> & React.RefAttributes<
|
|
128
|
+
> & React.RefAttributes<AccordionItemWC>
|
|
129
129
|
>;
|
|
130
|
-
export type
|
|
130
|
+
export type AccordionItemRef = AccordionItemWC;
|
|
131
131
|
|
|
132
|
-
export declare const
|
|
132
|
+
export declare const ActionsMenu: React.ForwardRefExoticComponent<
|
|
133
133
|
React.PropsWithChildren<
|
|
134
|
-
Omit<PublicOf<
|
|
134
|
+
Omit<PublicOf<ActionsMenuWC>, 'children' | 'style'> &
|
|
135
135
|
HTMLWCProps & {
|
|
136
136
|
}
|
|
137
|
-
> & React.RefAttributes<
|
|
137
|
+
> & React.RefAttributes<ActionsMenuWC>
|
|
138
138
|
>;
|
|
139
|
-
export type
|
|
139
|
+
export type ActionsMenuRef = ActionsMenuWC;
|
|
140
140
|
|
|
141
141
|
export declare const AiCriteriaSearch: React.ForwardRefExoticComponent<
|
|
142
142
|
React.PropsWithChildren<
|
|
@@ -149,23 +149,23 @@ export declare const AiCriteriaSearch: React.ForwardRefExoticComponent<
|
|
|
149
149
|
>;
|
|
150
150
|
export type AiCriteriaSearchRef = AiCriteriaSearchWC;
|
|
151
151
|
|
|
152
|
-
export declare const
|
|
152
|
+
export declare const Accordion: React.ForwardRefExoticComponent<
|
|
153
153
|
React.PropsWithChildren<
|
|
154
|
-
Omit<PublicOf<
|
|
154
|
+
Omit<PublicOf<AccordionWC>, 'children' | 'style'> &
|
|
155
155
|
HTMLWCProps & {
|
|
156
156
|
}
|
|
157
|
-
> & React.RefAttributes<
|
|
157
|
+
> & React.RefAttributes<AccordionWC>
|
|
158
158
|
>;
|
|
159
|
-
export type
|
|
159
|
+
export type AccordionRef = AccordionWC;
|
|
160
160
|
|
|
161
|
-
export declare const
|
|
161
|
+
export declare const AiIndicator: React.ForwardRefExoticComponent<
|
|
162
162
|
React.PropsWithChildren<
|
|
163
|
-
Omit<PublicOf<
|
|
163
|
+
Omit<PublicOf<AiIndicatorWC>, 'children' | 'style'> &
|
|
164
164
|
HTMLWCProps & {
|
|
165
165
|
}
|
|
166
|
-
> & React.RefAttributes<
|
|
166
|
+
> & React.RefAttributes<AiIndicatorWC>
|
|
167
167
|
>;
|
|
168
|
-
export type
|
|
168
|
+
export type AiIndicatorRef = AiIndicatorWC;
|
|
169
169
|
|
|
170
170
|
export declare const Anchor: React.ForwardRefExoticComponent<
|
|
171
171
|
React.PropsWithChildren<
|
|
@@ -6,9 +6,11 @@ import dayjs from 'dayjs';
|
|
|
6
6
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
7
7
|
import localeData from 'dayjs/plugin/localeData';
|
|
8
8
|
import LocalizedFormat from 'dayjs/plugin/localizedFormat';
|
|
9
|
+
import { wasClickOutsideElement } from '../utils';
|
|
9
10
|
import Calendar from './calendar';
|
|
10
11
|
import { foundationDatePickerStyles as styles } from './date-picker.styles';
|
|
11
12
|
import { foundationDatePickerTemplate as template } from './date-picker.template';
|
|
13
|
+
import { formatToPlaceholder, getBrowserLocale, getDisplayFormatForLang, hasDateValue, } from './date-picker.util';
|
|
12
14
|
import Day from './day';
|
|
13
15
|
import { getNextEnabledDay } from './day.util';
|
|
14
16
|
export const foundationDatePickerShadowOptions = undefined;
|
|
@@ -56,12 +58,24 @@ export class DatePicker extends FoundationElement {
|
|
|
56
58
|
* ```
|
|
57
59
|
*/
|
|
58
60
|
this.disabledDaysOfWeek = [];
|
|
61
|
+
this.clickOutside = (e) => this.handleClickOutside(e);
|
|
62
|
+
this.keydownOutside = (e) => this.handleKeydownOutside(e);
|
|
59
63
|
}
|
|
60
64
|
formatChanged(oldValue, newValue) {
|
|
61
|
-
if (newValue && this.calendar) {
|
|
65
|
+
if (newValue && this.calendar && hasDateValue(this.value)) {
|
|
62
66
|
this.formatDate = dayjs(this.currentDate.Date).format(newValue);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
69
|
+
langChanged() {
|
|
70
|
+
if (this.useLocaleFormat) {
|
|
71
|
+
this.applyLocaleFormat();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
useLocaleFormatChanged() {
|
|
75
|
+
if (this.useLocaleFormat) {
|
|
76
|
+
this.applyLocaleFormat();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
65
79
|
inlineCalendarChanged() {
|
|
66
80
|
this.toggleVisibility();
|
|
67
81
|
}
|
|
@@ -69,40 +83,184 @@ export class DatePicker extends FoundationElement {
|
|
|
69
83
|
this.toggleVisibility();
|
|
70
84
|
}
|
|
71
85
|
valueChanged(oldValue, newValue) {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
this.monthList = this.getMonthDaysGrid();
|
|
86
|
+
if (!this.calendar) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (this.allowEmpty && !hasDateValue(newValue)) {
|
|
90
|
+
this.clearToEmpty(false);
|
|
91
|
+
return;
|
|
79
92
|
}
|
|
93
|
+
if (hasDateValue(newValue)) {
|
|
94
|
+
this.applyValue(newValue);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
document.removeEventListener('mousedown', this.clickOutside);
|
|
99
|
+
document.removeEventListener('keydown', this.keydownOutside);
|
|
100
|
+
super.disconnectedCallback();
|
|
80
101
|
}
|
|
81
102
|
connectedCallback() {
|
|
82
|
-
var _a;
|
|
83
103
|
super.connectedCallback();
|
|
84
104
|
dayjs.extend(customParseFormat);
|
|
85
105
|
dayjs.extend(LocalizedFormat);
|
|
86
106
|
dayjs.extend(localeData);
|
|
87
107
|
this.substringNumber = 3;
|
|
108
|
+
if (this.useLocaleFormat) {
|
|
109
|
+
this.applyLocaleFormat();
|
|
110
|
+
}
|
|
88
111
|
const dateString = this.value;
|
|
89
|
-
|
|
90
|
-
|
|
112
|
+
if (this.allowEmpty && !hasDateValue(dateString)) {
|
|
113
|
+
this.initializeEmpty();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (hasDateValue(dateString)) {
|
|
117
|
+
this.initializeWithValue(dateString);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.initializeWithDefaultDate();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Clears the selected date (only when `allow-empty` is enabled).
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
clear() {
|
|
127
|
+
if (!this.allowEmpty) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.clearToEmpty(true);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
get inputValue() {
|
|
136
|
+
return hasDateValue(this.value) ? this.formatDate : '';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
get inputPlaceholder() {
|
|
142
|
+
var _a;
|
|
143
|
+
if (!this.allowEmpty || hasDateValue(this.value)) {
|
|
144
|
+
return '';
|
|
145
|
+
}
|
|
146
|
+
return ((_a = this.placeholder) === null || _a === void 0 ? void 0 : _a.trim()) || formatToPlaceholder(this.format);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Locale for display format and calendar labels: explicit `lang`, or browser when using locale format.
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
get effectiveLang() {
|
|
153
|
+
if (this.useLocaleFormat && !this.hasAttribute('lang')) {
|
|
154
|
+
return getBrowserLocale();
|
|
155
|
+
}
|
|
156
|
+
return this.lang;
|
|
157
|
+
}
|
|
158
|
+
applyLocaleFormat() {
|
|
159
|
+
this.format = getDisplayFormatForLang(this.effectiveLang);
|
|
160
|
+
}
|
|
161
|
+
initializeEmpty() {
|
|
162
|
+
const viewDate = dayjs();
|
|
163
|
+
this.currentDate = new Day(viewDate.toDate(), this.effectiveLang);
|
|
164
|
+
this.calendar = new Calendar(this.currentDate.year, this.currentDate.monthNumber, this.effectiveLang);
|
|
165
|
+
this.formatDate = '';
|
|
166
|
+
this.value = '';
|
|
167
|
+
this.currentMonth = this.calendar.month.name;
|
|
168
|
+
this.currentYear = this.calendar.year;
|
|
169
|
+
this.monthList = this.getMonthDaysGrid();
|
|
170
|
+
}
|
|
171
|
+
initializeWithValue(dateString) {
|
|
172
|
+
this.applyValue(dateString);
|
|
173
|
+
}
|
|
174
|
+
initializeWithDefaultDate() {
|
|
175
|
+
var _a;
|
|
176
|
+
let currentDate = new Day(dayjs().toDate(), this.effectiveLang);
|
|
91
177
|
if ((_a = this.disabledDaysOfWeek) === null || _a === void 0 ? void 0 : _a.length) {
|
|
92
|
-
currentDate = getNextEnabledDay(this.disabledDaysOfWeek, currentDate, this.
|
|
178
|
+
currentDate = getNextEnabledDay(this.disabledDaysOfWeek, currentDate, this.effectiveLang);
|
|
93
179
|
}
|
|
94
180
|
this.currentDate = currentDate;
|
|
95
|
-
this.calendar = new Calendar(this.currentDate.year, this.currentDate.monthNumber, this.
|
|
181
|
+
this.calendar = new Calendar(this.currentDate.year, this.currentDate.monthNumber, this.effectiveLang);
|
|
96
182
|
this.value = dayjs(this.currentDate.Date).format('MM-DD-YYYY');
|
|
97
183
|
this.currentMonth = this.calendar.month.name;
|
|
98
184
|
this.currentYear = this.calendar.year;
|
|
99
185
|
this.formatDate = dayjs(this.currentDate.Date).format(this.format);
|
|
100
186
|
this.monthList = this.getMonthDaysGrid();
|
|
101
187
|
}
|
|
188
|
+
applyValue(dateString) {
|
|
189
|
+
var _a;
|
|
190
|
+
const parsed = dayjs(dateString, this.format, true).isValid()
|
|
191
|
+
? dayjs(dateString, this.format)
|
|
192
|
+
: dayjs(dateString, 'MM-DD-YYYY');
|
|
193
|
+
let currentDate = new Day(parsed.toDate(), this.effectiveLang);
|
|
194
|
+
if ((_a = this.disabledDaysOfWeek) === null || _a === void 0 ? void 0 : _a.length) {
|
|
195
|
+
currentDate = getNextEnabledDay(this.disabledDaysOfWeek, currentDate, this.effectiveLang);
|
|
196
|
+
}
|
|
197
|
+
this.currentDate = currentDate;
|
|
198
|
+
if (!this.calendar) {
|
|
199
|
+
this.calendar = new Calendar(this.currentDate.year, this.currentDate.monthNumber, this.effectiveLang);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.calendar.goToDate(this.currentDate.monthNumber, this.currentDate.year);
|
|
203
|
+
}
|
|
204
|
+
this.formatDate = dayjs(this.currentDate.Date).format(this.format);
|
|
205
|
+
this.value = dayjs(this.currentDate.Date).format('MM-DD-YYYY');
|
|
206
|
+
this.updateHeaderText();
|
|
207
|
+
this.monthList = this.getMonthDaysGrid();
|
|
208
|
+
}
|
|
209
|
+
clearToEmpty(emitEvent) {
|
|
210
|
+
const viewDate = dayjs();
|
|
211
|
+
this.currentDate = new Day(viewDate.toDate(), this.effectiveLang);
|
|
212
|
+
if (this.calendar) {
|
|
213
|
+
this.calendar.goToDate(this.currentDate.monthNumber, this.currentDate.year);
|
|
214
|
+
this.updateHeaderText();
|
|
215
|
+
this.monthList = this.getMonthDaysGrid();
|
|
216
|
+
}
|
|
217
|
+
this.formatDate = '';
|
|
218
|
+
this.value = '';
|
|
219
|
+
if (emitEvent) {
|
|
220
|
+
this.$emit('value-changed', undefined);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
102
223
|
updateHeaderText() {
|
|
103
224
|
this.currentMonth = this.calendar.month.name;
|
|
104
225
|
this.currentYear = this.calendar.year;
|
|
105
226
|
}
|
|
227
|
+
visibleChanged(_prev, next) {
|
|
228
|
+
if (this.inlineCalendar) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (next) {
|
|
232
|
+
document.addEventListener('mousedown', this.clickOutside);
|
|
233
|
+
document.addEventListener('keydown', this.keydownOutside);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
document.removeEventListener('mousedown', this.clickOutside);
|
|
237
|
+
document.removeEventListener('keydown', this.keydownOutside);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
handleKeydownOutside(event) {
|
|
241
|
+
if (this.inlineCalendar || !this.visible) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (event.key === 'Escape') {
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
this.closeCalendar();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
handleClickOutside(event) {
|
|
250
|
+
if (this.inlineCalendar || !this.visible) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (wasClickOutsideElement(event, this)) {
|
|
254
|
+
this.closeCalendar();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
closeCalendar() {
|
|
258
|
+
if (!this.visible) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.visible = false;
|
|
262
|
+
this.toggleVisibility();
|
|
263
|
+
}
|
|
106
264
|
toggleCalendar() {
|
|
107
265
|
this.visible = !this.visible;
|
|
108
266
|
this.toggleVisibility();
|
|
@@ -115,6 +273,9 @@ export class DatePicker extends FoundationElement {
|
|
|
115
273
|
this.calendarDropdownClasses = classNames(['visible', this.visible], this.position, ['inline', this.inlineCalendar], ['hide-weekends', this.hideWeekends]);
|
|
116
274
|
}
|
|
117
275
|
isSelectedDate(date) {
|
|
276
|
+
if (this.allowEmpty && !hasDateValue(this.value)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
118
279
|
return dayjs(date.Date).isSame(this.currentDate.Date, 'day');
|
|
119
280
|
}
|
|
120
281
|
isCurrentCalendarMonth() {
|
|
@@ -135,8 +296,10 @@ export class DatePicker extends FoundationElement {
|
|
|
135
296
|
this.monthList = this.getMonthDaysGrid();
|
|
136
297
|
}
|
|
137
298
|
selectDay(day) {
|
|
138
|
-
|
|
299
|
+
const sameDayAsCurrent = dayjs(day.Date).isSame(this.currentDate.Date, 'day');
|
|
300
|
+
if (sameDayAsCurrent && hasDateValue(this.value)) {
|
|
139
301
|
return;
|
|
302
|
+
}
|
|
140
303
|
this.currentDate = day;
|
|
141
304
|
if (day.monthNumber !== this.calendar.month.number) {
|
|
142
305
|
this.prevMonth();
|
|
@@ -168,6 +331,9 @@ __decorate([
|
|
|
168
331
|
__decorate([
|
|
169
332
|
attr
|
|
170
333
|
], DatePicker.prototype, "lang", void 0);
|
|
334
|
+
__decorate([
|
|
335
|
+
attr({ attribute: 'use-locale-format', mode: 'boolean' })
|
|
336
|
+
], DatePicker.prototype, "useLocaleFormat", void 0);
|
|
171
337
|
__decorate([
|
|
172
338
|
attr
|
|
173
339
|
], DatePicker.prototype, "visible", void 0);
|
|
@@ -183,6 +349,12 @@ __decorate([
|
|
|
183
349
|
__decorate([
|
|
184
350
|
attr
|
|
185
351
|
], DatePicker.prototype, "label", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
attr({ attribute: 'allow-empty', mode: 'boolean' })
|
|
354
|
+
], DatePicker.prototype, "allowEmpty", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
attr
|
|
357
|
+
], DatePicker.prototype, "placeholder", void 0);
|
|
186
358
|
__decorate([
|
|
187
359
|
attr
|
|
188
360
|
], DatePicker.prototype, "value", void 0);
|
|
@@ -6,7 +6,15 @@ const SUNDAY_INDEX = 1;
|
|
|
6
6
|
const SATURDAY_INDEX = 7;
|
|
7
7
|
const WEEKEND_DAY_INDICES = [SUNDAY_INDEX, SATURDAY_INDEX];
|
|
8
8
|
export const getPrefixedDatePicker = (prefix) => html `
|
|
9
|
-
<${prefix}-text-field
|
|
9
|
+
<${prefix}-text-field
|
|
10
|
+
data-test-id="date-picker"
|
|
11
|
+
readonly
|
|
12
|
+
:value="${(x) => x.inputValue}"
|
|
13
|
+
placeholder="${(x) => x.inputPlaceholder}"
|
|
14
|
+
part="date-toggle"
|
|
15
|
+
class="date-toggle"
|
|
16
|
+
@click="${(x) => x.toggleCalendar()}"
|
|
17
|
+
>
|
|
10
18
|
${(x) => x.label}
|
|
11
19
|
<div class="input-icon-container" part="input-icon-container" slot="end"><${prefix}-icon variant="regular" name="calendar-alt" size="sm"></${prefix}-icon></div>
|
|
12
20
|
</${prefix}-text-field>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import localeData from 'dayjs/plugin/localeData';
|
|
3
|
+
import 'dayjs/locale/en-gb';
|
|
4
|
+
dayjs.extend(localeData);
|
|
5
|
+
/**
|
|
6
|
+
* Maps BCP-47 tags to dayjs locale names (dayjs provides `en`, `en-gb`, not `en-US`).
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function resolveDayjsLocale(lang) {
|
|
10
|
+
const normalized = ((lang === null || lang === void 0 ? void 0 : lang.trim()) || 'en').toLowerCase().replace('_', '-');
|
|
11
|
+
if (normalized === 'en-us' || normalized === 'en') {
|
|
12
|
+
return 'en';
|
|
13
|
+
}
|
|
14
|
+
if (normalized === 'en-gb') {
|
|
15
|
+
return 'en-gb';
|
|
16
|
+
}
|
|
17
|
+
return lang.trim();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Browser BCP-47 locale (e.g. `en-GB`), or `en` when unavailable (SSR/tests).
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export function getBrowserLocale() {
|
|
24
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
25
|
+
return navigator.language;
|
|
26
|
+
}
|
|
27
|
+
return 'en';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Display format from dayjs locale `L` (e.g. en / en-US → MM/DD/YYYY, en-gb → DD/MM/YYYY).
|
|
31
|
+
* Falls back to `en` when the locale is not loaded in dayjs.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export function getDisplayFormatForLang(lang = 'en') {
|
|
35
|
+
const locale = resolveDayjsLocale(lang);
|
|
36
|
+
dayjs.locale(locale);
|
|
37
|
+
const format = dayjs.localeData().longDateFormat('L');
|
|
38
|
+
if (format) {
|
|
39
|
+
return format;
|
|
40
|
+
}
|
|
41
|
+
dayjs.locale('en');
|
|
42
|
+
return dayjs.localeData().longDateFormat('L') || 'MM/DD/YYYY';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Maps a dayjs-style display format to a lowercase placeholder hint (e.g. DD/MM/YYYY → dd/mm/yyyy).
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export function formatToPlaceholder(format) {
|
|
49
|
+
return format
|
|
50
|
+
.replace(/YYYY/g, 'yyyy')
|
|
51
|
+
.replace(/YY(?!Y)/g, 'yy')
|
|
52
|
+
.replace(/DD/g, 'dd')
|
|
53
|
+
.replace(/D(?!D)/g, 'd')
|
|
54
|
+
.replace(/MM/g, 'mm')
|
|
55
|
+
.replace(/M(?!M)/g, 'm');
|
|
56
|
+
}
|
|
57
|
+
export function hasDateValue(value) {
|
|
58
|
+
return value !== null && value !== undefined && String(value).trim() !== '';
|
|
59
|
+
}
|
package/dist/react.cjs
CHANGED
|
@@ -102,14 +102,14 @@ function _mergeRefs(...refs) {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
const
|
|
105
|
+
const AccordionItem = React.forwardRef(function AccordionItem(props, ref) {
|
|
106
106
|
const { children, ...rest } = props;
|
|
107
|
-
return React.createElement(customElements.getName(
|
|
107
|
+
return React.createElement(customElements.getName(AccordionItemWC) ?? '%%prefix%%-accordion-item', { ...rest, ref }, children);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
const
|
|
110
|
+
const ActionsMenu = React.forwardRef(function ActionsMenu(props, ref) {
|
|
111
111
|
const { children, ...rest } = props;
|
|
112
|
-
return React.createElement(customElements.getName(
|
|
112
|
+
return React.createElement(customElements.getName(ActionsMenuWC) ?? '%%prefix%%-actions-menu', { ...rest, ref }, children);
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
const AiCriteriaSearch = React.forwardRef(function AiCriteriaSearch(props, ref) {
|
|
@@ -134,14 +134,14 @@ const AiCriteriaSearch = React.forwardRef(function AiCriteriaSearch(props, ref)
|
|
|
134
134
|
return React.createElement(customElements.getName(AiCriteriaSearchWC) ?? '%%prefix%%-ai-criteria-search', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
const
|
|
137
|
+
const Accordion = React.forwardRef(function Accordion(props, ref) {
|
|
138
138
|
const { children, ...rest } = props;
|
|
139
|
-
return React.createElement(customElements.getName(
|
|
139
|
+
return React.createElement(customElements.getName(AccordionWC) ?? '%%prefix%%-accordion', { ...rest, ref }, children);
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
const
|
|
142
|
+
const AiIndicator = React.forwardRef(function AiIndicator(props, ref) {
|
|
143
143
|
const { children, ...rest } = props;
|
|
144
|
-
return React.createElement(customElements.getName(
|
|
144
|
+
return React.createElement(customElements.getName(AiIndicatorWC) ?? '%%prefix%%-ai-indicator', { ...rest, ref }, children);
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
const Anchor = React.forwardRef(function Anchor(props, ref) {
|
|
@@ -877,11 +877,11 @@ const UrlInput = React.forwardRef(function UrlInput(props, ref) {
|
|
|
877
877
|
});
|
|
878
878
|
|
|
879
879
|
module.exports = {
|
|
880
|
-
Accordion,
|
|
881
880
|
AccordionItem,
|
|
881
|
+
ActionsMenu,
|
|
882
882
|
AiCriteriaSearch,
|
|
883
|
+
Accordion,
|
|
883
884
|
AiIndicator,
|
|
884
|
-
ActionsMenu,
|
|
885
885
|
Anchor,
|
|
886
886
|
AnchoredRegion,
|
|
887
887
|
Avatar,
|
package/dist/react.mjs
CHANGED
|
@@ -100,14 +100,14 @@ function _mergeRefs(...refs) {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export const
|
|
103
|
+
export const AccordionItem = React.forwardRef(function AccordionItem(props, ref) {
|
|
104
104
|
const { children, ...rest } = props;
|
|
105
|
-
return React.createElement(customElements.getName(
|
|
105
|
+
return React.createElement(customElements.getName(AccordionItemWC) ?? '%%prefix%%-accordion-item', { ...rest, ref }, children);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
export const
|
|
108
|
+
export const ActionsMenu = React.forwardRef(function ActionsMenu(props, ref) {
|
|
109
109
|
const { children, ...rest } = props;
|
|
110
|
-
return React.createElement(customElements.getName(
|
|
110
|
+
return React.createElement(customElements.getName(ActionsMenuWC) ?? '%%prefix%%-actions-menu', { ...rest, ref }, children);
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
export const AiCriteriaSearch = React.forwardRef(function AiCriteriaSearch(props, ref) {
|
|
@@ -132,14 +132,14 @@ export const AiCriteriaSearch = React.forwardRef(function AiCriteriaSearch(props
|
|
|
132
132
|
return React.createElement(customElements.getName(AiCriteriaSearchWC) ?? '%%prefix%%-ai-criteria-search', { ...rest, ref: _mergeRefs(_innerRef, ref) }, children);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
export const
|
|
135
|
+
export const Accordion = React.forwardRef(function Accordion(props, ref) {
|
|
136
136
|
const { children, ...rest } = props;
|
|
137
|
-
return React.createElement(customElements.getName(
|
|
137
|
+
return React.createElement(customElements.getName(AccordionWC) ?? '%%prefix%%-accordion', { ...rest, ref }, children);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
export const
|
|
140
|
+
export const AiIndicator = React.forwardRef(function AiIndicator(props, ref) {
|
|
141
141
|
const { children, ...rest } = props;
|
|
142
|
-
return React.createElement(customElements.getName(
|
|
142
|
+
return React.createElement(customElements.getName(AiIndicatorWC) ?? '%%prefix%%-ai-indicator', { ...rest, ref }, children);
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
export const Anchor = React.forwardRef(function Anchor(props, ref) {
|