@gooddata/sdk-ui-filters 11.58.0-alpha.0 → 11.58.0-alpha.2
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/esm/DateFilter/DateFilterButtonLocalized/DateFilterButtonLocalized.d.ts +3 -1
- package/esm/DateFilter/DateFilterButtonLocalized/DateFilterButtonLocalized.d.ts.map +1 -1
- package/esm/DateFilter/DateFilterButtonLocalized/DateFilterButtonLocalized.js +8 -3
- package/esm/DateFilter/DateFilterCore.d.ts.map +1 -1
- package/esm/DateFilter/DateFilterCore.js +1 -1
- package/esm/DateFilter/DateFilterTextLocalized/DateFilterTextLocalized.d.ts +9 -2
- package/esm/DateFilter/DateFilterTextLocalized/DateFilterTextLocalized.d.ts.map +1 -1
- package/esm/DateFilter/DateFilterTextLocalized/DateFilterTextLocalized.js +4 -4
- package/esm/DateFilter/PeriodRangePicker/AccessibleFieldInput.d.ts +11 -8
- package/esm/DateFilter/PeriodRangePicker/AccessibleFieldInput.d.ts.map +1 -1
- package/esm/DateFilter/PeriodRangePicker/AccessibleFieldInput.js +13 -10
- package/esm/DateFilter/PeriodRangePicker/PeriodRangePickerImpl.d.ts +4 -3
- package/esm/DateFilter/PeriodRangePicker/PeriodRangePickerImpl.d.ts.map +1 -1
- package/esm/DateFilter/PeriodRangePicker/PeriodRangePickerImpl.js +87 -25
- package/esm/DateFilter/PeriodRangePicker/PreviewAnnouncer.d.ts +22 -0
- package/esm/DateFilter/PeriodRangePicker/PreviewAnnouncer.d.ts.map +1 -0
- package/esm/DateFilter/PeriodRangePicker/PreviewAnnouncer.js +40 -0
- package/esm/DateFilter/PeriodRangePicker/dateFnsRangePicker.js +1 -1
- package/esm/DateFilter/PeriodRangePicker/types.d.ts +4 -1
- package/esm/DateFilter/PeriodRangePicker/types.d.ts.map +1 -1
- package/esm/DateFilter/index.d.ts +2 -1
- package/esm/DateFilter/index.d.ts.map +1 -1
- package/esm/DateFilter/index.js +2 -1
- package/esm/DateFilter/utils/FormattingUtils.d.ts +4 -0
- package/esm/DateFilter/utils/FormattingUtils.d.ts.map +1 -1
- package/esm/DateFilter/utils/FormattingUtils.js +54 -0
- package/esm/DateFilter/utils/Translations/DateFilterTitle.d.ts +3 -8
- package/esm/DateFilter/utils/Translations/DateFilterTitle.d.ts.map +1 -1
- package/esm/DateFilter/utils/Translations/DateFilterTitle.js +42 -69
- package/esm/DateFilter/{PeriodRangePicker → utils}/weekStartDateFnsLocale.d.ts +1 -2
- package/esm/DateFilter/utils/weekStartDateFnsLocale.d.ts.map +1 -0
- package/esm/DateFilter/{PeriodRangePicker → utils}/weekStartDateFnsLocale.js +3 -4
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -2
- package/esm/sdk-ui-filters.d.ts +6 -3
- package/package.json +13 -13
- package/styles/css/components/PeriodRangePicker.css +18 -8
- package/styles/css/components/PeriodRangePicker.css.map +1 -1
- package/styles/css/dateFilter.css +18 -8
- package/styles/css/dateFilter.css.map +1 -1
- package/styles/css/main.css +18 -8
- package/styles/css/main.css.map +1 -1
- package/styles/scss/components/PeriodRangePicker.scss +37 -12
- package/esm/DateFilter/PeriodRangePicker/weekStartDateFnsLocale.d.ts.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// (C) 2019-2026 GoodData Corporation
|
|
2
|
+
import { format } from "date-fns";
|
|
2
3
|
import moment from "moment";
|
|
3
4
|
import { sanitizeLocaleForMoment } from "@gooddata/util";
|
|
5
|
+
import { DAY_END_TIME, DAY_START_TIME, TIME_FORMAT, TIME_FORMAT_WITH_SECONDS, TIME_FORMAT_WITH_SECONDS_WITH_SEPARATOR, TIME_FORMAT_WITH_SEPARATOR, } from "../constants/Platform.js";
|
|
6
|
+
import { convertPlatformDateStringToDate } from "./DateConversions.js";
|
|
4
7
|
export const getLocalizedDateFormat = (locale) => {
|
|
5
8
|
const localizedMoment = moment().locale(sanitizeLocaleForMoment(locale));
|
|
6
9
|
const localeData = localizedMoment?.localeData && localizedMoment.localeData();
|
|
@@ -49,3 +52,54 @@ export const localizedIcuDateFormatPatterns = {
|
|
|
49
52
|
* @internal
|
|
50
53
|
*/
|
|
51
54
|
export const getLocalizedIcuDateFormatPattern = (locale) => localizedIcuDateFormatPatterns[locale] ?? localizedIcuDateFormatPatterns[DEFAULT_LOCALE];
|
|
55
|
+
const getTimeRange = (dateFrom, dateTo, splitter = "\u2013", timeFormat = TIME_FORMAT) => {
|
|
56
|
+
const fromTime = format(dateFrom, timeFormat);
|
|
57
|
+
const toTime = format(dateTo, timeFormat);
|
|
58
|
+
return fromTime === toTime ? fromTime : `${fromTime} ${splitter} ${toTime}`;
|
|
59
|
+
};
|
|
60
|
+
const isTimeForWholeDay = (dateFrom, dateTo) => dateFrom.getHours() === 0 &&
|
|
61
|
+
dateFrom.getMinutes() === 0 &&
|
|
62
|
+
dateFrom.getSeconds() === 0 &&
|
|
63
|
+
dateTo.getHours() === 23 &&
|
|
64
|
+
dateTo.getMinutes() === 59 &&
|
|
65
|
+
(dateTo.getSeconds() === 0 || dateTo.getSeconds() === 59);
|
|
66
|
+
const adjustDatetime = (date, isTimeEnabled, defaultTime = DAY_START_TIME) => {
|
|
67
|
+
if (!(typeof date === "string")) {
|
|
68
|
+
return date;
|
|
69
|
+
}
|
|
70
|
+
if (isTimeEnabled && date.split(" ").length === 1) {
|
|
71
|
+
return `${date} ${defaultTime}`;
|
|
72
|
+
}
|
|
73
|
+
return date;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* @beta
|
|
77
|
+
*/
|
|
78
|
+
export const formatAbsoluteDateRange = (from, to, dateFormat, splitter = "\u2013") => {
|
|
79
|
+
const isTimeEnabled = dateFormat.includes(TIME_FORMAT);
|
|
80
|
+
const isSecondsEnabled = dateFormat.includes(TIME_FORMAT_WITH_SECONDS);
|
|
81
|
+
const timeFormat = isSecondsEnabled ? TIME_FORMAT_WITH_SECONDS : TIME_FORMAT;
|
|
82
|
+
const timeFormatWithSeparator = isSecondsEnabled
|
|
83
|
+
? TIME_FORMAT_WITH_SECONDS_WITH_SEPARATOR
|
|
84
|
+
: TIME_FORMAT_WITH_SEPARATOR;
|
|
85
|
+
const dateFormatWithoutTime = dateFormat.replace(timeFormatWithSeparator, "");
|
|
86
|
+
// append start and end times if necessary
|
|
87
|
+
const adjustedFrom = adjustDatetime(from, isTimeEnabled, DAY_START_TIME);
|
|
88
|
+
const adjustedTo = adjustDatetime(to, isTimeEnabled, DAY_END_TIME);
|
|
89
|
+
const fromDate = convertPlatformDateStringToDate(adjustedFrom) ?? undefined;
|
|
90
|
+
const toDate = convertPlatformDateStringToDate(adjustedTo) ?? undefined;
|
|
91
|
+
const coversWholeDay = fromDate && toDate ? isTimeForWholeDay(fromDate, toDate) : false;
|
|
92
|
+
if (fromDate && toDate && moment(fromDate).isSame(toDate, "day")) {
|
|
93
|
+
if (isTimeEnabled && !coversWholeDay) {
|
|
94
|
+
return `${format(fromDate, dateFormatWithoutTime)}, ${getTimeRange(fromDate, toDate, splitter, timeFormat)}`;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return format(fromDate, dateFormatWithoutTime);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// do not show time in case of whole day coverage
|
|
101
|
+
const displayDateFormat = coversWholeDay ? dateFormatWithoutTime : dateFormat;
|
|
102
|
+
const fromTitle = fromDate ? format(fromDate, displayDateFormat) : "";
|
|
103
|
+
const toTitle = toDate ? format(toDate, displayDateFormat) : "";
|
|
104
|
+
return `${fromTitle} ${splitter} ${toTitle}`;
|
|
105
|
+
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { type DateFilterGranularity, type ILocale, type ILowerBoundedFilter, type IUpperBoundedFilter } from "@gooddata/sdk-model";
|
|
1
|
+
import { type DateFilterGranularity, type ILocale, type ILowerBoundedFilter, type IUpperBoundedFilter, type WeekStart } from "@gooddata/sdk-model";
|
|
2
2
|
import { type ITranslations } from "@gooddata/sdk-ui";
|
|
3
3
|
import { type DateFilterLabelMode } from "../../constants/i18n.js";
|
|
4
4
|
import { type DateFilterOption } from "../../interfaces/index.js";
|
|
5
5
|
import { type IDateAndMessageTranslator } from "./Translators.js";
|
|
6
|
-
export declare const getTimeRange: (dateFrom: Date, dateTo: Date, splitter?: string, timeFormat?: string) => string;
|
|
7
|
-
/**
|
|
8
|
-
* @beta
|
|
9
|
-
*/
|
|
10
|
-
export declare const formatAbsoluteDateRange: (from: Date | string, to: Date | string, dateFormat: string, splitter?: string) => string;
|
|
11
6
|
/**
|
|
12
7
|
* @beta
|
|
13
8
|
*/
|
|
@@ -29,9 +24,9 @@ export declare const formatRelativeDateRange: (from: number, to: number, granula
|
|
|
29
24
|
* @returns Representation of the filter (e.g. "My preset", "From 2 weeks ago to 1 week ahead")
|
|
30
25
|
* @beta
|
|
31
26
|
*/
|
|
32
|
-
export declare const getDateFilterTitleUsingTranslator: (filter: DateFilterOption, translator: IDateAndMessageTranslator, labelMode: DateFilterLabelMode, dateFormat?: string) => string;
|
|
27
|
+
export declare const getDateFilterTitleUsingTranslator: (filter: DateFilterOption, translator: IDateAndMessageTranslator, labelMode: DateFilterLabelMode, dateFormat?: string, weekStart?: WeekStart) => string;
|
|
33
28
|
/**
|
|
34
29
|
* @beta
|
|
35
30
|
*/
|
|
36
|
-
export declare const getDateFilterRepresentation: (filter: DateFilterOption, locale: ILocale, messages: ITranslations, labelMode: DateFilterLabelMode, dateFormat?: string) => string;
|
|
31
|
+
export declare const getDateFilterRepresentation: (filter: DateFilterOption, locale: ILocale, messages: ITranslations, labelMode: DateFilterLabelMode, dateFormat?: string, weekStart?: WeekStart) => string;
|
|
37
32
|
//# sourceMappingURL=DateFilterTitle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateFilterTitle.d.ts","sourceRoot":"","sources":["../../../../src/DateFilter/utils/Translations/DateFilterTitle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateFilterTitle.d.ts","sourceRoot":"","sources":["../../../../src/DateFilter/utils/Translations/DateFilterTitle.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,KAAK,qBAAqB,EAE1B,KAAK,OAAO,EACZ,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,SAAS,EAQjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EACH,KAAK,mBAAmB,EAG3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACH,KAAK,gBAAgB,EAGxB,MAAM,2BAA2B,CAAC;AAMnC,OAAO,EAAE,KAAK,yBAAyB,EAA2B,MAAM,kBAAkB,CAAC;AA+J3F;;GAEG;AACH,eAAO,MAAM,uBAAuB,SAC1B,MAAM,MACR,MAAM,eACG,qBAAqB,cACtB,yBAAyB,aAC1B,mBAAmB,kBACd,mBAAmB,GAAG,mBAAmB,KAC1D,MAWF,CAAC;AA2GF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iCAAiC,WAClC,gBAAgB,cACZ,yBAAyB,aAC1B,mBAAmB,eAClB,MAAM,cACN,SAAS,KACtB,MAuBF,CAAC;AA8BF;;GAEG;AACH,eAAO,MAAM,2BAA2B,WAC5B,gBAAgB,UAChB,OAAO,YACL,aAAa,aACZ,mBAAmB,eAClB,MAAM,cACN,SAAS,KACtB,MAIF,CAAC"}
|
|
@@ -1,65 +1,15 @@
|
|
|
1
1
|
// (C) 2019-2026 GoodData Corporation
|
|
2
2
|
import { format } from "date-fns";
|
|
3
3
|
import { capitalize } from "lodash-es";
|
|
4
|
-
import moment from "moment";
|
|
5
4
|
import { isAbsoluteDateFilterForm, isAbsoluteDateFilterPreset, isAllTimeDateFilterOption, isEmptyValuesDateFilterOption, isRelativeDateFilterForm, isRelativeDateFilterPreset, isUpperBound, } from "@gooddata/sdk-model";
|
|
6
5
|
import { getIntl } from "@gooddata/sdk-ui";
|
|
7
6
|
import { messages } from "../../../locales.js";
|
|
8
7
|
import { granularityIntlCodes, granularityIntlCodesFull, } from "../../constants/i18n.js";
|
|
9
|
-
import {
|
|
8
|
+
import { DEFAULT_DATE_FORMAT } from "../../constants/Platform.js";
|
|
10
9
|
import { convertPlatformDateStringToDate } from "../DateConversions.js";
|
|
11
10
|
import { convertLocale } from "../dateFnsLocale.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const toTime = format(dateTo, timeFormat);
|
|
15
|
-
return fromTime === toTime ? fromTime : `${fromTime} ${splitter} ${toTime}`;
|
|
16
|
-
};
|
|
17
|
-
const isTimeForWholeDay = (dateFrom, dateTo) => dateFrom.getHours() === 0 &&
|
|
18
|
-
dateFrom.getMinutes() === 0 &&
|
|
19
|
-
dateFrom.getSeconds() === 0 &&
|
|
20
|
-
dateTo.getHours() === 23 &&
|
|
21
|
-
dateTo.getMinutes() === 59 &&
|
|
22
|
-
(dateTo.getSeconds() === 0 || dateTo.getSeconds() === 59);
|
|
23
|
-
const adjustDatetime = (date, isTimeEnabled, defaultTime = DAY_START_TIME) => {
|
|
24
|
-
if (!(typeof date === "string")) {
|
|
25
|
-
return date;
|
|
26
|
-
}
|
|
27
|
-
if (isTimeEnabled && date.split(" ").length === 1) {
|
|
28
|
-
return `${date} ${defaultTime}`;
|
|
29
|
-
}
|
|
30
|
-
return date;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* @beta
|
|
34
|
-
*/
|
|
35
|
-
export const formatAbsoluteDateRange = (from, to, dateFormat, splitter = "\u2013") => {
|
|
36
|
-
const isTimeEnabled = dateFormat.includes(TIME_FORMAT);
|
|
37
|
-
const isSecondsEnabled = dateFormat.includes(TIME_FORMAT_WITH_SECONDS);
|
|
38
|
-
const timeFormat = isSecondsEnabled ? TIME_FORMAT_WITH_SECONDS : TIME_FORMAT;
|
|
39
|
-
const timeFormatWithSeparator = isSecondsEnabled
|
|
40
|
-
? TIME_FORMAT_WITH_SECONDS_WITH_SEPARATOR
|
|
41
|
-
: TIME_FORMAT_WITH_SEPARATOR;
|
|
42
|
-
const dateFormatWithoutTime = dateFormat.replace(timeFormatWithSeparator, "");
|
|
43
|
-
// append start and end times if necessary
|
|
44
|
-
const adjustedFrom = adjustDatetime(from, isTimeEnabled, DAY_START_TIME);
|
|
45
|
-
const adjustedTo = adjustDatetime(to, isTimeEnabled, DAY_END_TIME);
|
|
46
|
-
const fromDate = convertPlatformDateStringToDate(adjustedFrom) ?? undefined;
|
|
47
|
-
const toDate = convertPlatformDateStringToDate(adjustedTo) ?? undefined;
|
|
48
|
-
const coversWholeDay = fromDate && toDate ? isTimeForWholeDay(fromDate, toDate) : false;
|
|
49
|
-
if (fromDate && toDate && moment(fromDate).isSame(toDate, "day")) {
|
|
50
|
-
if (isTimeEnabled && !coversWholeDay) {
|
|
51
|
-
return `${format(fromDate, dateFormatWithoutTime)}, ${getTimeRange(fromDate, toDate, splitter, timeFormat)}`;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return format(fromDate, dateFormatWithoutTime);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// do not show time in case of whole day coverage
|
|
58
|
-
const displayDateFormat = coversWholeDay ? dateFormatWithoutTime : dateFormat;
|
|
59
|
-
const fromTitle = fromDate ? format(fromDate, displayDateFormat) : "";
|
|
60
|
-
const toTitle = toDate ? format(toDate, displayDateFormat) : "";
|
|
61
|
-
return `${fromTitle} ${splitter} ${toTitle}`;
|
|
62
|
-
};
|
|
11
|
+
import { DEFAULT_LOCALE, formatAbsoluteDateRange } from "../FormattingUtils.js";
|
|
12
|
+
import { getWeekStartDateFnsLocale, resolveWeekStartLocale } from "../weekStartDateFnsLocale.js";
|
|
63
13
|
// Intl.DateTimeFormat options for Month/Year period labels; Quarter is handled separately below.
|
|
64
14
|
const MONTH_AND_YEAR_INTL_OPTIONS = {
|
|
65
15
|
"GDC.time.month": { month: "long", year: "numeric" },
|
|
@@ -67,20 +17,37 @@ const MONTH_AND_YEAR_INTL_OPTIONS = {
|
|
|
67
17
|
};
|
|
68
18
|
// Intl.DateTimeFormat has no "quarter" field, so format it with date-fns instead, localized.
|
|
69
19
|
const formatQuarterLabel = (date, locale) => format(date, "QQQ y", { locale: convertLocale(locale) });
|
|
20
|
+
// A week's number depends on which day the workspace starts weeks on, so both parts come from a date-fns
|
|
21
|
+
// locale carrying that week start. The message places them, so the word and its position stay translatable.
|
|
22
|
+
const formatWeekLabel = (date, weekStart, translator) => {
|
|
23
|
+
const weekLocale = resolveWeekStartLocale(getWeekStartDateFnsLocale(translator.locale ?? DEFAULT_LOCALE, weekStart));
|
|
24
|
+
return translator.formatMessage({ id: "filters.staticPeriod.weekLabel" }, {
|
|
25
|
+
// Strings rather than numbers, so the year does not come back group-separated. "Y" is the
|
|
26
|
+
// week-numbering year, which date-fns guards behind a flag as a likely typo for "y".
|
|
27
|
+
week: format(date, "w", { locale: weekLocale }),
|
|
28
|
+
year: format(date, "Y", { locale: weekLocale, useAdditionalWeekYearTokens: true }),
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
// Week is absent: its label cannot be derived from the date alone, it also needs the week start.
|
|
70
32
|
const STATIC_PERIOD_LABEL_GRANULARITIES = new Set([
|
|
71
33
|
"GDC.time.month",
|
|
72
34
|
"GDC.time.quarter",
|
|
73
35
|
"GDC.time.year",
|
|
74
36
|
]);
|
|
75
|
-
|
|
76
|
-
const
|
|
37
|
+
const formatMonthQuarterOrYearLabel = (date, granularity, translator) => {
|
|
38
|
+
const intlOptions = MONTH_AND_YEAR_INTL_OPTIONS[granularity];
|
|
39
|
+
return intlOptions
|
|
40
|
+
? translator.formatDate(date, intlOptions)
|
|
41
|
+
: formatQuarterLabel(date, translator.locale);
|
|
42
|
+
};
|
|
43
|
+
// Formats a static from/to range as period labels, collapsing a single-period range to one label. The
|
|
44
|
+
// boundary label is passed in, so a week label can carry the week start the other granularities ignore.
|
|
45
|
+
const formatStaticPeriodDateRange = (from, to, formatPeriodBoundaryLabel) => {
|
|
77
46
|
const fromDate = convertPlatformDateStringToDate(from) ?? undefined;
|
|
78
47
|
const toDate = convertPlatformDateStringToDate(to) ?? undefined;
|
|
79
48
|
if (!fromDate || !toDate) {
|
|
80
49
|
return "";
|
|
81
50
|
}
|
|
82
|
-
const intlOptions = MONTH_AND_YEAR_INTL_OPTIONS[granularity];
|
|
83
|
-
const formatPeriodBoundaryLabel = (date) => intlOptions ? translator.formatDate(date, intlOptions) : formatQuarterLabel(date, translator.locale);
|
|
84
51
|
const fromLabel = formatPeriodBoundaryLabel(fromDate);
|
|
85
52
|
const toLabel = formatPeriodBoundaryLabel(toDate);
|
|
86
53
|
return fromLabel === toLabel ? fromLabel : `${fromLabel} \u2013 ${toLabel}`;
|
|
@@ -176,12 +143,18 @@ export const formatRelativeDateRange = (from, to, granularity, translator, label
|
|
|
176
143
|
};
|
|
177
144
|
const getAllTimeFilterRepresentation = (translator) => translator.formatMessage({ id: "filters.allTime.title" });
|
|
178
145
|
const getEmptyValuesFilterRepresentation = (translator) => translator.formatMessage({ id: "filters.emptyValues.title" });
|
|
179
|
-
const getAbsoluteFormFilterRepresentation = (filter, translator, dateFormat) => {
|
|
146
|
+
const getAbsoluteFormFilterRepresentation = (filter, translator, dateFormat, weekStart) => {
|
|
180
147
|
if (!filter.from || !filter.to) {
|
|
181
148
|
return "";
|
|
182
149
|
}
|
|
183
|
-
|
|
184
|
-
|
|
150
|
+
const granularity = filter.granularity;
|
|
151
|
+
// Which week a day falls in depends on the workspace's week start, so with none given, fall through to
|
|
152
|
+
// the day range rather than name a week that the rest of the workspace numbers differently.
|
|
153
|
+
if (granularity === "GDC.time.week_us" && weekStart) {
|
|
154
|
+
return formatStaticPeriodDateRange(filter.from, filter.to, (date) => formatWeekLabel(date, weekStart, translator));
|
|
155
|
+
}
|
|
156
|
+
if (granularity && STATIC_PERIOD_LABEL_GRANULARITIES.has(granularity)) {
|
|
157
|
+
return formatStaticPeriodDateRange(filter.from, filter.to, (date) => formatMonthQuarterOrYearLabel(date, granularity, translator));
|
|
185
158
|
}
|
|
186
159
|
return formatAbsoluteDateRange(filter.from, filter.to, dateFormat);
|
|
187
160
|
};
|
|
@@ -190,9 +163,9 @@ const getRelativeFormFilterRepresentation = (filter, translator, labelMode) => t
|
|
|
190
163
|
? formatRelativeDateRange(filter.from, filter.to, filter.granularity, translator, labelMode, filter.boundedFilter)
|
|
191
164
|
: "";
|
|
192
165
|
const getRelativePresetFilterRepresentation = (filter, translator, labelMode) => formatRelativeDateRange(filter.from, filter.to, filter.granularity, translator, labelMode, filter.boundedFilter);
|
|
193
|
-
const getDateFilterRepresentationByFilterType = (filter, translator, dateFormat, labelMode) => {
|
|
166
|
+
const getDateFilterRepresentationByFilterType = (filter, translator, dateFormat, labelMode, weekStart) => {
|
|
194
167
|
if (isAbsoluteDateFilterForm(filter) || isRelativeDateFilterForm(filter)) {
|
|
195
|
-
return getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode);
|
|
168
|
+
return getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode, weekStart);
|
|
196
169
|
}
|
|
197
170
|
else if (isEmptyValuesDateFilterOption(filter)) {
|
|
198
171
|
return filter.name || getEmptyValuesFilterRepresentation(translator);
|
|
@@ -201,7 +174,7 @@ const getDateFilterRepresentationByFilterType = (filter, translator, dateFormat,
|
|
|
201
174
|
isAbsoluteDateFilterPreset(filter) ||
|
|
202
175
|
isRelativeDateFilterPreset(filter)) {
|
|
203
176
|
return (filter.name ||
|
|
204
|
-
getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode));
|
|
177
|
+
getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode, weekStart));
|
|
205
178
|
}
|
|
206
179
|
else {
|
|
207
180
|
throw new Error("Unknown DateFilterOption type");
|
|
@@ -232,11 +205,11 @@ const getDateFilterRepresentationByFilterType = (filter, translator, dateFormat,
|
|
|
232
205
|
* @returns Representation of the filter (e.g. "My preset", "From 2 weeks ago to 1 week ahead")
|
|
233
206
|
* @beta
|
|
234
207
|
*/
|
|
235
|
-
export const getDateFilterTitleUsingTranslator = (filter, translator, labelMode, dateFormat = DEFAULT_DATE_FORMAT) => {
|
|
208
|
+
export const getDateFilterTitleUsingTranslator = (filter, translator, labelMode, dateFormat = DEFAULT_DATE_FORMAT, weekStart) => {
|
|
236
209
|
if (isAllTimeDateFilterOption(filter) && filter.emptyValueHandling === "exclude") {
|
|
237
210
|
return translator.formatMessage({ id: "filters.allTime.exceptEmptyValues.title" });
|
|
238
211
|
}
|
|
239
|
-
const baseTitle = getDateFilterRepresentationByFilterType(filter, translator, dateFormat, labelMode);
|
|
212
|
+
const baseTitle = getDateFilterRepresentationByFilterType(filter, translator, dateFormat, labelMode, weekStart);
|
|
240
213
|
// Special case for that can potentially be persisted but is equal to regular "All time"
|
|
241
214
|
if (isAllTimeDateFilterOption(filter) && filter.emptyValueHandling === "include") {
|
|
242
215
|
return baseTitle;
|
|
@@ -250,9 +223,9 @@ export const getDateFilterTitleUsingTranslator = (filter, translator, labelMode,
|
|
|
250
223
|
* Gets the filter representation regardless of custom name.
|
|
251
224
|
* @returns Representation of the filter (e.g. "From 2 weeks ago to 1 week ahead")
|
|
252
225
|
*/
|
|
253
|
-
const getDateFilterRepresentationUsingTranslator = (filter, translator, dateFormat, labelMode) => {
|
|
226
|
+
const getDateFilterRepresentationUsingTranslator = (filter, translator, dateFormat, labelMode, weekStart) => {
|
|
254
227
|
if (isAbsoluteDateFilterForm(filter)) {
|
|
255
|
-
return getAbsoluteFormFilterRepresentation(filter, translator, dateFormat);
|
|
228
|
+
return getAbsoluteFormFilterRepresentation(filter, translator, dateFormat, weekStart);
|
|
256
229
|
}
|
|
257
230
|
else if (isAbsoluteDateFilterPreset(filter)) {
|
|
258
231
|
return getAbsolutePresetFilterRepresentation(filter, dateFormat);
|
|
@@ -276,7 +249,7 @@ const getDateFilterRepresentationUsingTranslator = (filter, translator, dateForm
|
|
|
276
249
|
/**
|
|
277
250
|
* @beta
|
|
278
251
|
*/
|
|
279
|
-
export const getDateFilterRepresentation = (filter, locale, messages, labelMode, dateFormat = DEFAULT_DATE_FORMAT) => {
|
|
252
|
+
export const getDateFilterRepresentation = (filter, locale, messages, labelMode, dateFormat = DEFAULT_DATE_FORMAT, weekStart) => {
|
|
280
253
|
const translator = getIntl(locale, messages);
|
|
281
|
-
return getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode);
|
|
254
|
+
return getDateFilterRepresentationUsingTranslator(filter, translator, dateFormat, labelMode, weekStart);
|
|
282
255
|
};
|
|
@@ -11,8 +11,7 @@ import { type WeekStart } from "@gooddata/sdk-model";
|
|
|
11
11
|
*
|
|
12
12
|
* Registers (once per locale+weekStart pair) a clone of `baseLocaleKey`'s date-fns `Locale` with
|
|
13
13
|
* `options.weekStartsOn` and `options.firstWeekContainsDate` overridden, under a synthetic key, and returns
|
|
14
|
-
* that key for use as the picker's `locale.locale` field
|
|
15
|
-
* looks it back up.
|
|
14
|
+
* that key for use as the picker's `locale.locale` field.
|
|
16
15
|
*
|
|
17
16
|
* @param baseLocaleKey - the display locale (this app's `ILocale` code, e.g. "en-US") to inherit everything
|
|
18
17
|
* else (month names, formats, ...) from
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weekStartDateFnsLocale.d.ts","sourceRoot":"","sources":["../../../src/DateFilter/utils/weekStartDateFnsLocale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAkB7F;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
|
-
import { convertLocale } from "
|
|
2
|
+
import { convertLocale } from "./dateFnsLocale.js";
|
|
3
3
|
const LOCALE_KEY_NAMESPACE = "gdc-period-range-picker-week-start";
|
|
4
4
|
const overriddenLocales = new Map();
|
|
5
5
|
/**
|
|
@@ -13,8 +13,7 @@ const overriddenLocales = new Map();
|
|
|
13
13
|
*
|
|
14
14
|
* Registers (once per locale+weekStart pair) a clone of `baseLocaleKey`'s date-fns `Locale` with
|
|
15
15
|
* `options.weekStartsOn` and `options.firstWeekContainsDate` overridden, under a synthetic key, and returns
|
|
16
|
-
* that key for use as the picker's `locale.locale` field
|
|
17
|
-
* looks it back up.
|
|
16
|
+
* that key for use as the picker's `locale.locale` field.
|
|
18
17
|
*
|
|
19
18
|
* @param baseLocaleKey - the display locale (this app's `ILocale` code, e.g. "en-US") to inherit everything
|
|
20
19
|
* else (month names, formats, ...) from
|
|
@@ -26,7 +25,7 @@ export function getWeekStartDateFnsLocale(baseLocaleKey, weekStart) {
|
|
|
26
25
|
const weekStartsOn = weekStart === "Monday" ? 1 : 0;
|
|
27
26
|
// Paired with weekStartsOn using the same convention date-fns's own locales follow: ISO-8601 numbering
|
|
28
27
|
// (the week containing Jan 4th is week 1) for a Monday-start week, the US convention (the week containing
|
|
29
|
-
// Jan 1st is week 1) for a Sunday-start week - keeps the locale internally consistent so "Y
|
|
28
|
+
// Jan 1st is week 1) for a Sunday-start week - keeps the locale internally consistent so "w/Y" week
|
|
30
29
|
// numbers round-trip correctly across year boundaries instead of inheriting an unrelated base-locale value.
|
|
31
30
|
const firstWeekContainsDate = weekStartsOn === 1 ? 4 : 1;
|
|
32
31
|
const localeKey = `${LOCALE_KEY_NAMESPACE}-${baseLocaleKey.toLowerCase()}-${weekStartsOn}`;
|
package/esm/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export { filterVisibleDateFilterOptions } from "./DateFilter/utils/OptionUtils.j
|
|
|
17
17
|
export { validateFilterOption } from "./DateFilter/validation/OptionValidation.js";
|
|
18
18
|
export { mapOptionToAfm } from "./DateFilter/utils/AFMConversions.js";
|
|
19
19
|
export { applyExcludeCurrentPeriod, canExcludeCurrentPeriod, excludeCurrentPeriodFromRange, revertExcludedCurrentPeriodRange, } from "./DateFilter/utils/PeriodExclusion.js";
|
|
20
|
-
export {
|
|
21
|
-
export { getLocalizedIcuDateFormatPattern } from "./DateFilter/utils/FormattingUtils.js";
|
|
20
|
+
export { formatRelativeDateRange, getDateFilterRepresentation, getDateFilterTitleUsingTranslator, } from "./DateFilter/utils/Translations/DateFilterTitle.js";
|
|
21
|
+
export { formatAbsoluteDateRange, getLocalizedIcuDateFormatPattern, } from "./DateFilter/utils/FormattingUtils.js";
|
|
22
22
|
export { convertDateFilterConfigToDateFilterOptions } from "./DateFilter/utils/DateFilterConfigConversions.js";
|
|
23
23
|
export { DEFAULT_DATE_FILTER_PRESET, DEFAULT_FISCAL_DATE_FILTER_PRESET, defaultDateFilterConfig, } from "./DateFilter/utils/DefaultDateFilterConfig.js";
|
|
24
24
|
export { type IDateFilterOptionInfo, findDateFilterOptionByValue, flattenDateFilterOptions, matchDateFilterToDateFilterOption, matchDateFilterToDateFilterOptionWithPreference, } from "./DateFilter/utils/DateFilterOptionMapping.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAGH,OAAO,EACH,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iCAAiC,GACzC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAA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DAA6D,CAAC;AACrE,OAAO,EACH,KAAK,iCAAiC,EACtC,2BAA2B,GAC9B,MAAM,oEAAoE,CAAC;AAC5E,OAAO,EAAE,wCAAwC,EAAE,MAAM,uFAAuF,CAAC;AACjJ,OAAO,EAAE,uCAAuC,EAAE,MAAM,sFAAsF,CAAC;AAC/I,OAAO,EACH,KAAK,sCAAsC,EAC3C,gCAAgC,GACnC,MAAM,yEAAyE,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7G,YAAY,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EACH,sBAAsB,EACtB,KAAK,4BAA4B,GACpC,MAAM,wDAAwD,CAAC;AAEhE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -21,8 +21,8 @@ export { filterVisibleDateFilterOptions } from "./DateFilter/utils/OptionUtils.j
|
|
|
21
21
|
export { validateFilterOption } from "./DateFilter/validation/OptionValidation.js";
|
|
22
22
|
export { mapOptionToAfm } from "./DateFilter/utils/AFMConversions.js";
|
|
23
23
|
export { applyExcludeCurrentPeriod, canExcludeCurrentPeriod, excludeCurrentPeriodFromRange, revertExcludedCurrentPeriodRange, } from "./DateFilter/utils/PeriodExclusion.js";
|
|
24
|
-
export {
|
|
25
|
-
export { getLocalizedIcuDateFormatPattern } from "./DateFilter/utils/FormattingUtils.js";
|
|
24
|
+
export { formatRelativeDateRange, getDateFilterRepresentation, getDateFilterTitleUsingTranslator, } from "./DateFilter/utils/Translations/DateFilterTitle.js";
|
|
25
|
+
export { formatAbsoluteDateRange, getLocalizedIcuDateFormatPattern, } from "./DateFilter/utils/FormattingUtils.js";
|
|
26
26
|
export { convertDateFilterConfigToDateFilterOptions } from "./DateFilter/utils/DateFilterConfigConversions.js";
|
|
27
27
|
export { DEFAULT_DATE_FILTER_PRESET, DEFAULT_FISCAL_DATE_FILTER_PRESET, defaultDateFilterConfig, } from "./DateFilter/utils/DefaultDateFilterConfig.js";
|
|
28
28
|
export { findDateFilterOptionByValue, flattenDateFilterOptions, matchDateFilterToDateFilterOption, matchDateFilterToDateFilterOptionWithPreference, } from "./DateFilter/utils/DateFilterOptionMapping.js";
|
package/esm/sdk-ui-filters.d.ts
CHANGED
|
@@ -908,7 +908,7 @@ export declare function getAvailableTextSelectionTypes(selectionTypes: Attribute
|
|
|
908
908
|
/**
|
|
909
909
|
* @beta
|
|
910
910
|
*/
|
|
911
|
-
export declare const getDateFilterRepresentation: (filter: DateFilterOption, locale: ILocale, messages: ITranslations, labelMode: DateFilterLabelMode, dateFormat?: string) => string;
|
|
911
|
+
export declare const getDateFilterRepresentation: (filter: DateFilterOption, locale: ILocale, messages: ITranslations, labelMode: DateFilterLabelMode, dateFormat?: string, weekStart?: WeekStart) => string;
|
|
912
912
|
|
|
913
913
|
/**
|
|
914
914
|
* Gets the filter title using provided intl object.
|
|
@@ -927,7 +927,7 @@ export declare const getDateFilterRepresentation: (filter: DateFilterOption, loc
|
|
|
927
927
|
* @returns Representation of the filter (e.g. "My preset", "From 2 weeks ago to 1 week ahead")
|
|
928
928
|
* @beta
|
|
929
929
|
*/
|
|
930
|
-
export declare const getDateFilterTitleUsingTranslator: (filter: DateFilterOption, translator: IDateAndMessageTranslator, labelMode: DateFilterLabelMode, dateFormat?: string) => string;
|
|
930
|
+
export declare const getDateFilterTitleUsingTranslator: (filter: DateFilterOption, translator: IDateAndMessageTranslator, labelMode: DateFilterLabelMode, dateFormat?: string, weekStart?: WeekStart) => string;
|
|
931
931
|
|
|
932
932
|
/**
|
|
933
933
|
* Determine the default calendar tab based on active calendars configuration.
|
|
@@ -4225,7 +4225,10 @@ export declare interface IPeriodRangePickerProps {
|
|
|
4225
4225
|
weekStart?: WeekStart;
|
|
4226
4226
|
withoutApply?: boolean;
|
|
4227
4227
|
submitForm: () => void;
|
|
4228
|
-
/**
|
|
4228
|
+
/**
|
|
4229
|
+
* Date format (date-fns tokens). Formats the input fields for the "GDC.time.date" granularity, and the
|
|
4230
|
+
* day-level range preview for all the others.
|
|
4231
|
+
*/
|
|
4229
4232
|
dateFormat?: string;
|
|
4230
4233
|
/** Extra content rendered after the built-in format hint. */
|
|
4231
4234
|
customRangeHint?: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-filters",
|
|
3
|
-
"version": "11.58.0-alpha.
|
|
3
|
+
"version": "11.58.0-alpha.2",
|
|
4
4
|
"description": "GoodData.UI SDK - Filter Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData Corporation",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"ts-invariant": "0.10.3",
|
|
48
48
|
"tslib": "2.8.1",
|
|
49
49
|
"uuid": "11.1.1",
|
|
50
|
-
"@gooddata/sdk-backend-spi": "11.58.0-alpha.
|
|
51
|
-
"@gooddata/sdk-
|
|
52
|
-
"@gooddata/sdk-
|
|
53
|
-
"@gooddata/util": "11.58.0-alpha.
|
|
54
|
-
"@gooddata/sdk-ui": "11.58.0-alpha.
|
|
50
|
+
"@gooddata/sdk-backend-spi": "11.58.0-alpha.2",
|
|
51
|
+
"@gooddata/sdk-model": "11.58.0-alpha.2",
|
|
52
|
+
"@gooddata/sdk-ui": "11.58.0-alpha.2",
|
|
53
|
+
"@gooddata/util": "11.58.0-alpha.2",
|
|
54
|
+
"@gooddata/sdk-ui-kit": "11.58.0-alpha.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@microsoft/api-documenter": "7.30.10",
|
|
@@ -87,14 +87,14 @@
|
|
|
87
87
|
"sass": "1.104.1",
|
|
88
88
|
"stylelint": "16.26.1",
|
|
89
89
|
"typescript": "7.0.2",
|
|
90
|
-
"vitest": "4.1.
|
|
90
|
+
"vitest": "4.1.11",
|
|
91
91
|
"vitest-dom": "0.1.1",
|
|
92
|
-
"@gooddata/eslint-config": "11.58.0-alpha.
|
|
93
|
-
"@gooddata/oxlint-config": "11.58.0-alpha.
|
|
94
|
-
"@gooddata/
|
|
95
|
-
"@gooddata/
|
|
96
|
-
"@gooddata/
|
|
97
|
-
"@gooddata/
|
|
92
|
+
"@gooddata/eslint-config": "11.58.0-alpha.2",
|
|
93
|
+
"@gooddata/oxlint-config": "11.58.0-alpha.2",
|
|
94
|
+
"@gooddata/sdk-backend-mockingbird": "11.58.0-alpha.2",
|
|
95
|
+
"@gooddata/reference-workspace": "11.58.0-alpha.2",
|
|
96
|
+
"@gooddata/sdk-ui-theme-provider": "11.58.0-alpha.2",
|
|
97
|
+
"@gooddata/stylelint-config": "11.58.0-alpha.2"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
border-color: var(--gd-palette-error-base, #e54d42);
|
|
36
36
|
}
|
|
37
37
|
.gd-period-range-picker .rc-picker-input > input {
|
|
38
|
+
box-sizing: border-box;
|
|
38
39
|
width: 100%;
|
|
40
|
+
min-width: 0;
|
|
39
41
|
height: 28px;
|
|
40
|
-
padding: 0;
|
|
42
|
+
padding: 0 0 0 20px;
|
|
41
43
|
border: 0;
|
|
42
44
|
outline: none;
|
|
43
45
|
background: transparent;
|
|
@@ -50,19 +52,20 @@
|
|
|
50
52
|
.gd-period-range-picker .rc-picker-input > input::placeholder {
|
|
51
53
|
color: var(--gd-palette-complementary-6, #94a1ad);
|
|
52
54
|
}
|
|
53
|
-
.gd-period-range-picker .rc-picker-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.gd-period-range-picker .rc-picker-suffix {
|
|
55
|
+
.gd-period-range-picker .rc-picker-input .gd-icon-calendar {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 0;
|
|
58
|
+
left: 10px;
|
|
58
59
|
display: flex;
|
|
59
|
-
flex: none;
|
|
60
60
|
align-items: center;
|
|
61
|
-
|
|
61
|
+
height: 100%;
|
|
62
62
|
color: var(--gd-palette-primary-base, #14b2e2);
|
|
63
63
|
font-size: 14px;
|
|
64
64
|
pointer-events: none;
|
|
65
65
|
}
|
|
66
|
+
.gd-period-range-picker .rc-picker-range-separator {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
66
69
|
.gd-period-range-picker .rc-picker-active-bar {
|
|
67
70
|
position: absolute;
|
|
68
71
|
bottom: -1px;
|
|
@@ -287,6 +290,13 @@
|
|
|
287
290
|
font-size: 12px;
|
|
288
291
|
padding-top: 10px;
|
|
289
292
|
}
|
|
293
|
+
.gd-period-range-picker__preview {
|
|
294
|
+
margin-top: 10px;
|
|
295
|
+
padding-top: 10px;
|
|
296
|
+
border-top: 1px solid var(--gd-palette-complementary-3, #dde4eb);
|
|
297
|
+
color: var(--gd-palette-complementary-7-from-theme, #687581);
|
|
298
|
+
font-size: 12px;
|
|
299
|
+
}
|
|
290
300
|
.gd-period-range-picker.gd-period-range-picker-mobile .rc-picker-input > input {
|
|
291
301
|
font-size: 16px;
|
|
292
302
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../../scss/components/PeriodRangePicker.scss","../../../node_modules/@gooddata/sdk-ui-kit/styles/scss/variables.scss"],"names":[],"mappings":"AAaA;EACI;EACA;EACA,aCqFc;EDpFd;EACA,OCmBY;;ADVZ;EACI;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAlCe;EAmCf,YCrBS;EDsBT;;AAEA;EACI,cCnBW;;ADwBf;EACI,cCPc;;ADYlB;EACI,cCIY;;ADDhB;
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../scss/components/PeriodRangePicker.scss","../../../node_modules/@gooddata/sdk-ui-kit/styles/scss/variables.scss"],"names":[],"mappings":"AAaA;EACI;EACA;EACA,a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AAGJ;EACI,OC1RQ;ED2RR;EACA;;AAUJ;AAAA;EACI;;AAIR;EACI;;AAOA;AAAA;AAAA;AAAA;EACI;;AAGJ;AAAA;AAAA;AAAA;EACI;EACA;;AAIR;EACI;;AAQA;EACI,OCrUW;EDsUX;;AAIJ;AAAA;AAAA;AAAA;AAAA;EAKI,eAnWW;EAoWX;EACA;EACA;;AAIA;EACI;;AAGJ;EACI,YCrQQ;;ADwQZ;EACI,YC1UY;;ADgVZ;EACI,YCpVM;;ADuVV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAGI,OCjWE;;ADqWV;EACI,2BArYO;EAsYP,yBAtYO;;AAyYX;EACI,yBA1YO;EA2YP,uBA3YO;;AAsZnB;EACI;EACA;EACA,OCrNS;EDsNT;EACA;;AAMJ;EACI;EACA;EACA;EACA,OCjOS;EDkOT;;AAQA;EACI","file":"PeriodRangePicker.css"}
|
|
@@ -4598,9 +4598,11 @@ a.gd-button-link:hover .gd-button-text, a.gd-button-link-dimmed:hover .gd-button
|
|
|
4598
4598
|
border-color: var(--gd-palette-error-base, #e54d42);
|
|
4599
4599
|
}
|
|
4600
4600
|
.gd-period-range-picker .rc-picker-input > input {
|
|
4601
|
+
box-sizing: border-box;
|
|
4601
4602
|
width: 100%;
|
|
4603
|
+
min-width: 0;
|
|
4602
4604
|
height: 28px;
|
|
4603
|
-
padding: 0;
|
|
4605
|
+
padding: 0 0 0 20px;
|
|
4604
4606
|
border: 0;
|
|
4605
4607
|
outline: none;
|
|
4606
4608
|
background: transparent;
|
|
@@ -4613,19 +4615,20 @@ a.gd-button-link:hover .gd-button-text, a.gd-button-link-dimmed:hover .gd-button
|
|
|
4613
4615
|
.gd-period-range-picker .rc-picker-input > input::placeholder {
|
|
4614
4616
|
color: var(--gd-palette-complementary-6, #94a1ad);
|
|
4615
4617
|
}
|
|
4616
|
-
.gd-period-range-picker .rc-picker-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
.gd-period-range-picker .rc-picker-suffix {
|
|
4618
|
+
.gd-period-range-picker .rc-picker-input .gd-icon-calendar {
|
|
4619
|
+
position: absolute;
|
|
4620
|
+
top: 0;
|
|
4621
|
+
left: 10px;
|
|
4621
4622
|
display: flex;
|
|
4622
|
-
flex: none;
|
|
4623
4623
|
align-items: center;
|
|
4624
|
-
|
|
4624
|
+
height: 100%;
|
|
4625
4625
|
color: var(--gd-palette-primary-base, #14b2e2);
|
|
4626
4626
|
font-size: 14px;
|
|
4627
4627
|
pointer-events: none;
|
|
4628
4628
|
}
|
|
4629
|
+
.gd-period-range-picker .rc-picker-range-separator {
|
|
4630
|
+
display: none;
|
|
4631
|
+
}
|
|
4629
4632
|
.gd-period-range-picker .rc-picker-active-bar {
|
|
4630
4633
|
position: absolute;
|
|
4631
4634
|
bottom: -1px;
|
|
@@ -4850,6 +4853,13 @@ a.gd-button-link:hover .gd-button-text, a.gd-button-link-dimmed:hover .gd-button
|
|
|
4850
4853
|
font-size: 12px;
|
|
4851
4854
|
padding-top: 10px;
|
|
4852
4855
|
}
|
|
4856
|
+
.gd-period-range-picker__preview {
|
|
4857
|
+
margin-top: 10px;
|
|
4858
|
+
padding-top: 10px;
|
|
4859
|
+
border-top: 1px solid var(--gd-palette-complementary-3, #dde4eb);
|
|
4860
|
+
color: var(--gd-palette-complementary-7-from-theme, #687581);
|
|
4861
|
+
font-size: 12px;
|
|
4862
|
+
}
|
|
4853
4863
|
.gd-period-range-picker.gd-period-range-picker-mobile .rc-picker-input > input {
|
|
4854
4864
|
font-size: 16px;
|
|
4855
4865
|
}
|