@gooddata/sdk-ui-analytical-designer 11.71.0-alpha.3 → 11.71.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/NOTICE +45 -45
  2. package/esm/components/buckets/MeasureDateFilter.d.ts +4 -2
  3. package/esm/components/buckets/MeasureDateFilter.d.ts.map +1 -1
  4. package/esm/components/buckets/MeasureDateFilter.js +5 -3
  5. package/esm/components/buckets/MeasureDateFilterPicker.d.ts +4 -2
  6. package/esm/components/buckets/MeasureDateFilterPicker.d.ts.map +1 -1
  7. package/esm/components/buckets/MeasureDateFilterPicker.js +2 -2
  8. package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.d.ts.map +1 -1
  9. package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.js +32 -17
  10. package/esm/components/filterBar/dateFilter/DateFilter.d.ts.map +1 -1
  11. package/esm/components/filterBar/dateFilter/DateFilter.js +3 -4
  12. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.d.ts +8 -4
  13. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.d.ts.map +1 -1
  14. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.js +13 -6
  15. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.d.ts +4 -3
  16. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.d.ts.map +1 -1
  17. package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.js +2 -2
  18. package/esm/components/filterBar/dateFilter/PresetSection/PresetsSection.d.ts +6 -2
  19. package/esm/components/filterBar/dateFilter/PresetSection/PresetsSection.d.ts.map +1 -1
  20. package/esm/components/filterBar/dateFilter/PresetSection/PresetsSection.js +16 -5
  21. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonSection.d.ts +4 -2
  22. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonSection.d.ts.map +1 -1
  23. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonSection.js +2 -2
  24. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdown.d.ts +4 -2
  25. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdown.d.ts.map +1 -1
  26. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdown.js +2 -2
  27. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdownItem.d.ts +4 -2
  28. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdownItem.d.ts.map +1 -1
  29. package/esm/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdownItem.js +11 -11
  30. package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.d.ts +6 -1
  31. package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.d.ts.map +1 -1
  32. package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.js +14 -0
  33. package/esm/components/filterBar/dateFilter/selectors.d.ts +94 -3
  34. package/esm/components/filterBar/dateFilter/selectors.d.ts.map +1 -1
  35. package/esm/components/filterBar/dateFilter/selectors.js +3 -0
  36. package/esm/components/filterBar/dateFilter/types.d.ts +3 -1
  37. package/esm/components/filterBar/dateFilter/types.d.ts.map +1 -1
  38. package/esm/models/metadata.d.ts.map +1 -1
  39. package/esm/models/metadata.js +3 -9
  40. package/esm/models/period.d.ts +6 -0
  41. package/esm/models/period.d.ts.map +1 -1
  42. package/esm/models/period.js +14 -0
  43. package/esm/postMessageApi/sagas/control_filtering_saga.d.ts +2 -2
  44. package/esm/postMessageApi/sagas/control_filtering_saga.d.ts.map +1 -1
  45. package/esm/postMessageApi/sagas/control_filtering_saga.js +22 -5
  46. package/esm/store/bucket_filters/bucket_filters_operations.d.ts.map +1 -1
  47. package/esm/store/bucket_filters/bucket_filters_operations.js +9 -8
  48. package/esm/translations/en-US.json +12 -0
  49. package/package.json +21 -21
  50. package/esm/components/dialog_utils.d.ts +0 -19
  51. package/esm/components/dialog_utils.d.ts.map +0 -1
  52. package/esm/components/dialog_utils.js +0 -25
  53. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/fragments/AdditionalDateAttributes.d.ts +0 -22
  54. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/fragments/AdditionalDateAttributes.d.ts.map +0 -1
  55. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/fragments/AdditionalDateAttributes.js +0 -85
  56. package/esm/components/sort/fragments/ChartSortFragment.d.ts +0 -24
  57. package/esm/components/sort/fragments/ChartSortFragment.d.ts.map +0 -1
  58. package/esm/components/sort/fragments/ChartSortFragment.js +0 -49
@@ -2,31 +2,38 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // (C) 2007-2026 GoodData Corporation
3
3
  import { useRef } from "react";
4
4
  import { defineMessage, useIntl } from "react-intl";
5
+ import { areObjRefsEqual } from "@gooddata/sdk-model";
5
6
  import { IntlWrapper } from "@gooddata/sdk-ui";
6
7
  import { getFilteredPresets, getFiscalTabsConfig, } from "@gooddata/sdk-ui-filters";
7
8
  import { CalendarTypeTabs, RelativePresetFilterItems } from "@gooddata/sdk-ui-filters/internal";
8
9
  import { Dropdown } from "@gooddata/sdk-ui-kit";
10
+ import { periodGranularityToGranularity } from "../../../../models/granularity.js";
9
11
  import { DROPDOWN_ALIGN_POINTS } from "../../../../utils/dropdown.js";
10
12
  import { useDropdownHeight } from "../../../shared/DropdownWrapperHook.js";
11
13
  import { ALL_TIME_FILTER_OPTION, RELATIVE_PERIOD_FILTER_OPTION, STATIC_PERIOD_FILTER_OPTION, } from "../defaultFilterOptions.js";
12
14
  import { DatePresetDropdownItem } from "./DatePresetDropdownItem.js";
13
15
  import { DatePresetsDropdownButton } from "./DatePresetsDropdownButton.js";
14
- // matches no item: with a period selected, no preset is
16
+ // matches no item: a selected period that is not listed selects nothing
15
17
  const NO_SELECTED_PRESET = { ...ALL_TIME_FILTER_OPTION, localIdentifier: "" };
16
- function DatePresetsDropdownBody({ buttonNode, selectedPreset: selectedPresetProp, selectedPeriodTitle, relativeDateFilterPresets, onChange, closeDropdown, dateFormat, contextWindow = window, selectedTab, onTabChange, activeCalendars, }) {
18
+ function DatePresetsDropdownBody({ buttonNode, selectedPreset: selectedPresetProp, selectedPeriod, relativeDateFilterPresets, periodPresets, weekStart, onChange, closeDropdown, dateFormat, contextWindow = window, selectedTab, onTabChange, activeCalendars, }) {
17
19
  const intl = useIntl();
18
20
  const dialogHeight = useDropdownHeight(buttonNode, 100, 600, 0, 30, contextWindow);
19
- const selectedPreset = selectedPeriodTitle === undefined ? selectedPresetProp : NO_SELECTED_PRESET;
20
21
  const fiscalTabsConfig = getFiscalTabsConfig(relativeDateFilterPresets, activeCalendars);
21
22
  const filteredPresets = getFilteredPresets(relativeDateFilterPresets, fiscalTabsConfig, selectedTab);
23
+ // the presets are already narrowed to the date dataset's granularities and the calendar tab
24
+ const listedPeriodPresets = periodPresets.filter((preset) => preset.period &&
25
+ periodGranularityToGranularity(preset.period.granularity) in (filteredPresets ?? {}));
26
+ const selectedPreset = selectedPeriod
27
+ ? (listedPeriodPresets.find((preset) => areObjRefsEqual(preset.parameter, selectedPeriod.config.parameterRef)) ?? NO_SELECTED_PRESET)
28
+ : selectedPresetProp;
22
29
  const handleOnChange = (option) => {
23
30
  onChange(option);
24
31
  closeDropdown();
25
32
  };
26
- return (_jsxs("div", { className: "gd-extended-date-filter-body gd-date-filter-preset-dropdown s-date-presets-list", style: { maxHeight: dialogHeight }, children: [fiscalTabsConfig.showTabs && onTabChange ? (_jsx(CalendarTypeTabs, { selectedTab: selectedTab, onTabSelect: onTabChange })) : null, _jsx(DatePresetDropdownItem, { titleIntlKey: "all_time", item: ALL_TIME_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange }), _jsx(DatePresetDropdownItem, { titleIntlKey: "static_period", item: STATIC_PERIOD_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange }), _jsx(DatePresetDropdownItem, { titleIntlKey: "floating_period", item: RELATIVE_PERIOD_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange, tooltipSdkIntlKey: defineMessage({ id: "filters.floatingRange.tooltip" }).id }), _jsx(IntlWrapper, { locale: intl.locale, children: _jsx(RelativePresetFilterItems, { onSelectedFilterOptionChange: handleOnChange, selectedFilterOption: selectedPreset, filterOption: filteredPresets, dateFormat: dateFormat }) })] }));
33
+ return (_jsxs("div", { className: "gd-extended-date-filter-body gd-date-filter-preset-dropdown s-date-presets-list", style: { maxHeight: dialogHeight }, children: [fiscalTabsConfig.showTabs && onTabChange ? (_jsx(CalendarTypeTabs, { selectedTab: selectedTab, onTabSelect: onTabChange })) : null, _jsx(DatePresetDropdownItem, { titleIntlKey: "all_time", item: ALL_TIME_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange }), _jsx(DatePresetDropdownItem, { titleIntlKey: "static_period", item: STATIC_PERIOD_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange }), _jsx(DatePresetDropdownItem, { titleIntlKey: "floating_period", item: RELATIVE_PERIOD_FILTER_OPTION, selectedItem: selectedPreset, onChange: handleOnChange, tooltipSdkIntlKey: defineMessage({ id: "filters.floatingRange.tooltip" }).id }), _jsx(IntlWrapper, { locale: intl.locale, children: _jsx(RelativePresetFilterItems, { onSelectedFilterOptionChange: handleOnChange, selectedFilterOption: selectedPreset, filterOption: filteredPresets, periodPreset: listedPeriodPresets, dateFormat: dateFormat, weekStart: weekStart }) })] }));
27
34
  }
28
35
  export function DatePresetsDropdown(props) {
29
36
  const buttonRef = useRef(null);
30
- const { selectedPreset, selectedPeriodTitle, dateFormat } = props;
31
- return (_jsx(Dropdown, { className: "s-filter-date-preset-switch adi-date-preset-select-dropdown s-date-dataset-switch", renderButton: (props) => (_jsx(DatePresetsDropdownButton, { ...props, selectedPreset: selectedPreset, selectedPeriodTitle: selectedPeriodTitle, buttonWrapperRef: buttonRef, dateFormat: dateFormat })), alignPoints: DROPDOWN_ALIGN_POINTS, closeOnParentScroll: true, closeOnMouseDrag: true, renderBody: ({ closeDropdown }) => (_jsx(DatePresetsDropdownBody, { ...props, buttonNode: buttonRef.current, closeDropdown: closeDropdown })) }));
37
+ const { selectedPreset, selectedPeriod, dateFormat } = props;
38
+ return (_jsx(Dropdown, { className: "s-filter-date-preset-switch adi-date-preset-select-dropdown s-date-dataset-switch", renderButton: (props) => (_jsx(DatePresetsDropdownButton, { ...props, selectedPreset: selectedPreset, selectedPeriod: selectedPeriod, buttonWrapperRef: buttonRef, dateFormat: dateFormat })), alignPoints: DROPDOWN_ALIGN_POINTS, closeOnParentScroll: true, closeOnMouseDrag: true, renderBody: ({ closeDropdown }) => (_jsx(DatePresetsDropdownBody, { ...props, buttonNode: buttonRef.current, closeDropdown: closeDropdown })) }));
32
39
  }
@@ -1,12 +1,13 @@
1
1
  import { type Ref } from "react";
2
2
  import { type DateFilterOption } from "@gooddata/sdk-ui-filters";
3
3
  import { type IDropdownButtonRenderProps } from "@gooddata/sdk-ui-kit";
4
+ import { type IDateFilterOptionPeriod } from "../dateFilterOptionFactory.js";
4
5
  export interface IDatePresetsDropdownButtonProps extends IDropdownButtonRenderProps {
5
6
  selectedPreset: DateFilterOption;
6
- /** the title of the period the filter references, shown instead of the preset */
7
- selectedPeriodTitle?: string;
7
+ /** the period the filter references, whose title is shown instead of the preset */
8
+ selectedPeriod?: IDateFilterOptionPeriod;
8
9
  buttonWrapperRef: Ref<HTMLDivElement>;
9
10
  dateFormat: string;
10
11
  }
11
- export declare function DatePresetsDropdownButton({ isOpen, toggleDropdown, selectedPreset, selectedPeriodTitle, buttonWrapperRef, dateFormat, }: IDatePresetsDropdownButtonProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function DatePresetsDropdownButton({ isOpen, toggleDropdown, selectedPreset, selectedPeriod, buttonWrapperRef, dateFormat, }: IDatePresetsDropdownButtonProps): import("react/jsx-runtime").JSX.Element;
12
13
  //# sourceMappingURL=DatePresetsDropdownButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePresetsDropdownButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAOjC,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAkB,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAkCvF,MAAM,WAAW,+BAAgC,SAAQ,0BAA0B;IAC/E,cAAc,EAAE,gBAAgB,CAAC;IACjC,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,yBAAyB,CAAC,EACtC,MAAM,EACN,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,GACb,EAAE,+BAA+B,2CAqBjC"}
1
+ {"version":3,"file":"DatePresetsDropdownButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAOjC,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAkB,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAgC7E,MAAM,WAAW,+BAAgC,SAAQ,0BAA0B;IAC/E,cAAc,EAAE,gBAAgB,CAAC;IACjC,mFAAmF;IACnF,cAAc,CAAC,EAAE,uBAAuB,CAAC;IACzC,gBAAgB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,yBAAyB,CAAC,EACtC,MAAM,EACN,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,UAAU,GACb,EAAE,+BAA+B,2CAqBjC"}
@@ -24,10 +24,10 @@ function ButtonTitle({ preset, dateFormat }) {
24
24
  }
25
25
  return _jsx(PresetTitle, { preset: preset, dateFormat: dateFormat });
26
26
  }
27
- export function DatePresetsDropdownButton({ isOpen, toggleDropdown, selectedPreset, selectedPeriodTitle, buttonWrapperRef, dateFormat, }) {
27
+ export function DatePresetsDropdownButton({ isOpen, toggleDropdown, selectedPreset, selectedPeriod, buttonWrapperRef, dateFormat, }) {
28
28
  const buttonClassName = classNames("s-date-preset-button", {
29
29
  "s-expanded": isOpen,
30
30
  "s-collapsed": !isOpen,
31
31
  });
32
- return (_jsx(DropdownButtonWrapper, { setRef: buttonWrapperRef, children: _jsx(DropdownButton, { id: "preset-dropdown", className: buttonClassName, value: selectedPeriodTitle === undefined ? (_jsx(ButtonTitle, { preset: selectedPreset, dateFormat: dateFormat })) : (selectedPeriodTitle), onClick: toggleDropdown }) }));
32
+ return (_jsx(DropdownButtonWrapper, { setRef: buttonWrapperRef, children: _jsx(DropdownButton, { id: "preset-dropdown", className: buttonClassName, value: selectedPeriod ? (selectedPeriod.title) : (_jsx(ButtonTitle, { preset: selectedPreset, dateFormat: dateFormat })), onClick: toggleDropdown }) }));
33
33
  }
@@ -1,10 +1,12 @@
1
1
  import { type IActiveCalendars, type WeekStart } from "@gooddata/sdk-model";
2
- import { type DateFilterRelativeOptionGroup } from "@gooddata/sdk-ui-filters";
2
+ import { type DateFilterRelativeOptionGroup, type IUiPeriodPreset } from "@gooddata/sdk-ui-filters";
3
3
  import { type IDecoratedDateDataset } from "../../../../models/decorated_date_dataset.js";
4
4
  import { type IDateDatasetRefWithGranularities } from "../../../../typings/datasets.js";
5
5
  import { type IDateFilterOption } from "../dateFilterOptionFactory.js";
6
6
  export interface IPresetsSectionProps {
7
7
  filter: IDateFilterOption;
8
+ /** the local identifier saved with the stored filter's period, which as-code keys the filter by */
9
+ storedPeriodLocalIdentifier?: string;
8
10
  onChange: (filter: IDateFilterOption) => void;
9
11
  /**
10
12
  * Called after `onChange` for a change the user made, not for the automatic reset of a period the
@@ -12,6 +14,8 @@ export interface IPresetsSectionProps {
12
14
  */
13
15
  onEdit?: () => void;
14
16
  relativeDateFilterPresets: DateFilterRelativeOptionGroup;
17
+ /** the periods (DATE_RANGE parameters) to offer; the list narrows them like the presets */
18
+ periodPresets: readonly IUiPeriodPreset[];
15
19
  dateDataset: IDecoratedDateDataset;
16
20
  dateDatasetRefsWithGranularities: IDateDatasetRefWithGranularities[];
17
21
  dateFormat: string;
@@ -23,5 +27,5 @@ export interface IPresetsSectionProps {
23
27
  isDisabled?: boolean;
24
28
  activeCalendars?: IActiveCalendars;
25
29
  }
26
- export declare function PresetsSection({ filter, relativeDateFilterPresets, onChange, onEdit, dateDataset, dateDatasetRefsWithGranularities, dateFormat, isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled, weekStart, submitForm, isDisabled, activeCalendars, }: IPresetsSectionProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function PresetsSection({ filter, storedPeriodLocalIdentifier, relativeDateFilterPresets, periodPresets, onChange, onEdit, dateDataset, dateDatasetRefsWithGranularities, dateFormat, isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled, weekStart, submitForm, isDisabled, activeCalendars, }: IPresetsSectionProps): import("react/jsx-runtime").JSX.Element;
27
31
  //# sourceMappingURL=PresetsSection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PresetsSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/PresetSection/PresetsSection.tsx"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAGjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIH,KAAK,6BAA6B,EASrC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAExF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AA8BvE,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,yBAAyB,EAAE,6BAA6B,CAAC;IACzD,WAAW,EAAE,qBAAqB,CAAC;IACnC,gCAAgC,EAAE,gCAAgC,EAAE,CAAC;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B,EAAE,OAAO,CAAC;IACvC,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACtC;AAED,wBAAgB,cAAc,CAAC,EAC3B,MAAM,EACN,yBAAyB,EACzB,QAAQ,EACR,MAAM,EACN,WAAW,EACX,gCAAgC,EAChC,UAAU,EACV,6BAA6B,EAC7B,gCAAgC,EAChC,2BAAmC,EACnC,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,GAClB,EAAE,oBAAoB,2CAoItB"}
1
+ {"version":3,"file":"PresetsSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/PresetSection/PresetsSection.tsx"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAIjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIH,KAAK,6BAA6B,EAElC,KAAK,eAAe,EASvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAExF,OAAO,EAAE,KAAK,iBAAiB,EAAyC,MAAM,+BAA+B,CAAC;AA8B9G,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,mGAAmG;IACnG,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,yBAAyB,EAAE,6BAA6B,CAAC;IACzD,2FAA2F;IAC3F,aAAa,EAAE,SAAS,eAAe,EAAE,CAAC;IAC1C,WAAW,EAAE,qBAAqB,CAAC;IACnC,gCAAgC,EAAE,gCAAgC,EAAE,CAAC;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B,EAAE,OAAO,CAAC;IACvC,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACtC;AAED,wBAAgB,cAAc,CAAC,EAC3B,MAAM,EACN,2BAA2B,EAC3B,yBAAyB,EACzB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,WAAW,EACX,gCAAgC,EAChC,UAAU,EACV,6BAA6B,EAC7B,gCAAgC,EAChC,2BAAmC,EACnC,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,GAClB,EAAE,oBAAoB,2CAkJtB"}
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // (C) 2022-2026 GoodData Corporation
3
3
  import { useState } from "react";
4
4
  import { FormattedMessage } from "react-intl";
5
- import { isAbsoluteDateFilterForm, isRelativeDateFilterForm, } from "@gooddata/sdk-model";
6
- import { DateFilterHelpers, ensureCompatibleGranularity, filterFiscalPresets, filterStandardPresets, getDefaultCalendarTab, getFilteredGranularities, getFiscalTabsConfig, } from "@gooddata/sdk-ui-filters";
5
+ import { areObjRefsEqual, isAbsoluteDateFilterForm, isRelativeDateFilterForm, } from "@gooddata/sdk-model";
6
+ import { DateFilterHelpers, ensureCompatibleGranularity, filterFiscalPresets, filterStandardPresets, getDefaultCalendarTab, getFilteredGranularities, getFiscalTabsConfig, isUiPeriodPreset, } from "@gooddata/sdk-ui-filters";
7
7
  import { DisableableFilterWrapper } from "../AdditionalFiltersSection/DisableableFilterWrapper.js";
8
+ import { buildPeriodDateFilterOptionFromPreset } from "../dateFilterOptionFactory.js";
8
9
  import { DatePresetsDropdown } from "./DatePresetsDropdown.js";
9
10
  import { ExcludeCurrentPeriod } from "./ExcludeCurrentPeriod.js";
10
11
  import { RelativeDateRange } from "./RelativeDateRange.js";
@@ -23,7 +24,7 @@ function getFilteredCalendarPresets(presets, config) {
23
24
  }
24
25
  return presets;
25
26
  }
26
- export function PresetsSection({ filter, relativeDateFilterPresets, onChange, onEdit, dateDataset, dateDatasetRefsWithGranularities, dateFormat, isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled = false, weekStart, submitForm, isDisabled, activeCalendars, }) {
27
+ export function PresetsSection({ filter, storedPeriodLocalIdentifier, relativeDateFilterPresets, periodPresets, onChange, onEdit, dateDataset, dateDatasetRefsWithGranularities, dateFormat, isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled = false, weekStart, submitForm, isDisabled, activeCalendars, }) {
27
28
  const { filterOption: currentFilterOption } = filter;
28
29
  const { supportedDateFilterPresets, supportedChronologicalGranularities } = useSupportedDateFilterPresets(relativeDateFilterPresets, dateDataset, dateDatasetRefsWithGranularities, isSecondsGranularityEnabled);
29
30
  const fiscalTabsConfig = getFiscalTabsConfig(supportedDateFilterPresets, activeCalendars);
@@ -32,7 +33,9 @@ export function PresetsSection({ filter, relativeDateFilterPresets, onChange, on
32
33
  onChange(option);
33
34
  onEdit?.();
34
35
  };
35
- const [selectedTab, setSelectedTab] = useState(() => getDefaultCalendarTab(activeCalendars, currentFilterOption));
36
+ // a period is a standard-calendar range, as getDefaultCalendarTab treats a period preset; the All time
37
+ // option underneath it would open the default calendar's tab instead
38
+ const [selectedTab, setSelectedTab] = useState(() => filter.period ? "standard" : getDefaultCalendarTab(activeCalendars, currentFilterOption));
36
39
  const handleTabChange = (newTab) => {
37
40
  setSelectedTab(newTab);
38
41
  // If relative form is currently displayed, correct its granularity for the new tab
@@ -56,6 +59,14 @@ export function PresetsSection({ filter, relativeDateFilterPresets, onChange, on
56
59
  onUserChange({ filterOption: updatedFilter, excludeCurrentPeriod });
57
60
  };
58
61
  const onPresetSelectionChange = (newlySelectedPreset) => {
62
+ if (isUiPeriodPreset(newlySelectedPreset)) {
63
+ // any period picked keeps the stored local identifier, also after All time, which has none;
64
+ // picking the saved period back is then no change
65
+ if (!areObjRefsEqual(newlySelectedPreset.parameter, filter.period?.config.parameterRef)) {
66
+ onUserChange(buildPeriodDateFilterOptionFromPreset(newlySelectedPreset, storedPeriodLocalIdentifier));
67
+ }
68
+ return;
69
+ }
59
70
  // with a period, its All time base is not a choice the user made, so All time replaces the period too
60
71
  if (filter.period || newlySelectedPreset.localIdentifier !== currentFilterOption.localIdentifier) {
61
72
  // If switching to relative form, ensure granularity is compatible
@@ -72,5 +83,5 @@ export function PresetsSection({ filter, relativeDateFilterPresets, onChange, on
72
83
  const onExcludePeriodChange = (excludeCurrentPeriod) => {
73
84
  onPresetValueChange(currentFilterOption, excludeCurrentPeriod);
74
85
  };
75
- return (_jsxs(DisableableFilterWrapper, { isDisabled: isDisabled, className: "section adi-date-dropdown adi-date-preset-select s-preset-section", children: [_jsx("label", { htmlFor: "preset-dropdown", children: _jsx(FormattedMessage, { id: "filter.date.period" }) }), _jsx(DatePresetsDropdown, { relativeDateFilterPresets: enabledCalendarPresets, selectedPreset: currentFilterOption, selectedPeriodTitle: filter.period?.title, onChange: onPresetSelectionChange, dateFormat: dateFormat, selectedTab: selectedTab, onTabChange: handleTabChange, activeCalendars: activeCalendars }), displayDateRange ? (_jsx(StaticDateRange, { selectedFilter: currentFilterOption, onChange: onPresetValueChange, dateFormat: dateFormat, isTimeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsEnabled: isSecondsForAbsoluteRangeEnabled, weekStart: weekStart, submitForm: submitForm })) : null, displayFloatingRange ? (_jsx(RelativeDateRange, { granularities: filteredGranularities, selectedFilter: currentFilterOption, onChange: onPresetValueChange })) : null, displayExcludePeriod ? (_jsx(ExcludeCurrentPeriod, { selectedFilter: filter, onChange: onExcludePeriodChange })) : null] }));
86
+ return (_jsxs(DisableableFilterWrapper, { isDisabled: isDisabled, className: "section adi-date-dropdown adi-date-preset-select s-preset-section", children: [_jsx("label", { htmlFor: "preset-dropdown", children: _jsx(FormattedMessage, { id: "filter.date.period" }) }), _jsx(DatePresetsDropdown, { relativeDateFilterPresets: enabledCalendarPresets, selectedPreset: currentFilterOption, selectedPeriod: filter.period, periodPresets: periodPresets, weekStart: weekStart, onChange: onPresetSelectionChange, dateFormat: dateFormat, selectedTab: selectedTab, onTabChange: handleTabChange, activeCalendars: activeCalendars }), displayDateRange ? (_jsx(StaticDateRange, { selectedFilter: currentFilterOption, onChange: onPresetValueChange, dateFormat: dateFormat, isTimeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsEnabled: isSecondsForAbsoluteRangeEnabled, weekStart: weekStart, submitForm: submitForm })) : null, displayFloatingRange ? (_jsx(RelativeDateRange, { granularities: filteredGranularities, selectedFilter: currentFilterOption, onChange: onPresetValueChange })) : null, displayExcludePeriod ? (_jsx(ExcludeCurrentPeriod, { selectedFilter: filter, onChange: onExcludePeriodChange })) : null] }));
76
87
  }
@@ -1,4 +1,5 @@
1
1
  import { type OverTimeComparisonType } from "@gooddata/sdk-ui";
2
+ import { type UncomparableDateFilter } from "../dateFilterOptionFactory.js";
2
3
  import { type IComparisonCompatibleMeasure } from "../types.js";
3
4
  interface IComparedMeasuresSection {
4
5
  selectedType: OverTimeComparisonType;
@@ -10,10 +11,11 @@ export interface ITimeComparisonSectionProps extends IComparedMeasuresSection {
10
11
  supportedTypes: OverTimeComparisonType[];
11
12
  onTypeSelected: (selectedType: OverTimeComparisonType) => void;
12
13
  isPoPAvailable: boolean;
13
- isAllTimeDateFilter: boolean;
14
+ /** the selected date filter, when the comparison does not work with it */
15
+ uncomparableDateFilter?: UncomparableDateFilter;
14
16
  isSectionHidden: boolean;
15
17
  isDisabled?: boolean;
16
18
  }
17
- export declare function TimeComparisonSection({ selectedType, supportedTypes, selectedMeasureIds, compatibleMeasures, onTypeSelected, onMeasuresSelected, isAllTimeDateFilter, isPoPAvailable, isSectionHidden, isDisabled, }: ITimeComparisonSectionProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function TimeComparisonSection({ selectedType, supportedTypes, selectedMeasureIds, compatibleMeasures, onTypeSelected, onMeasuresSelected, uncomparableDateFilter, isPoPAvailable, isSectionHidden, isDisabled, }: ITimeComparisonSectionProps): import("react/jsx-runtime").JSX.Element;
18
20
  export {};
19
21
  //# sourceMappingURL=TimeComparisonSection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeComparisonSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonSection.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAKxF,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAUhE,UAAU,wBAAwB;IAC9B,YAAY,EAAE,sBAAsB,CAAC;IACrC,kBAAkB,EAAE,4BAA4B,EAAE,CAAC;IACnD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,kBAAkB,EAAE,CAAC,+BAA+B,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB;IACzE,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,cAAc,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC/D,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAgCD,wBAAgB,qBAAqB,CAAC,EAClC,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,UAAU,GACb,EAAE,2BAA2B,2CA4C7B"}
1
+ {"version":3,"file":"TimeComparisonSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonSection.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAKxF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAUhE,UAAU,wBAAwB;IAC9B,YAAY,EAAE,sBAAsB,CAAC;IACrC,kBAAkB,EAAE,4BAA4B,EAAE,CAAC;IACnD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,kBAAkB,EAAE,CAAC,+BAA+B,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,2BAA4B,SAAQ,wBAAwB;IACzE,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,cAAc,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC/D,cAAc,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAgCD,wBAAgB,qBAAqB,CAAC,EAClC,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,UAAU,GACb,EAAE,2BAA2B,2CA4C7B"}
@@ -14,7 +14,7 @@ function ComparedMeasuresSection({ compatibleMeasures, selectedType, selectedMea
14
14
  }
15
15
  return (_jsx("div", { className: "subsection-wrap", children: _jsxs("div", { className: "subsection", children: [_jsx("label", { className: "adi-compare-apply-label", htmlFor: "time-comparison-measures-dropdown", children: _jsx(FormattedMessage, { id: "filter.compare.apply_on" }) }), _jsx(ComparedMeasuresDropdown, { listItemHeight: DROPDOWN_ITEM_HEIGHT, selectedMeasures: selectedMeasureIds, compatibleMeasures: compatibleMeasures, selectedAllCompatible: areAllCompatibleMeasuresSelected(compatibleMeasures, selectedMeasureIds), onSelectionApplied: onMeasuresSelected })] }) }));
16
16
  }
17
- export function TimeComparisonSection({ selectedType, supportedTypes, selectedMeasureIds, compatibleMeasures, onTypeSelected, onMeasuresSelected, isAllTimeDateFilter, isPoPAvailable, isSectionHidden, isDisabled, }) {
17
+ export function TimeComparisonSection({ selectedType, supportedTypes, selectedMeasureIds, compatibleMeasures, onTypeSelected, onMeasuresSelected, uncomparableDateFilter, isPoPAvailable, isSectionHidden, isDisabled, }) {
18
18
  const intl = useIntl();
19
19
  if (isSectionHidden) {
20
20
  return (_jsx(Message, { type: "progress", className: "s-date-filter-error-message date-filter-error-message", children: intl.formatMessage({ id: "filter.date.comparing_only_on_first_warning" }) }));
@@ -22,5 +22,5 @@ export function TimeComparisonSection({ selectedType, supportedTypes, selectedMe
22
22
  if (supportedTypes.length === 0) {
23
23
  return (_jsx(Message, { type: "progress", className: "s-date-filter-error-message date-filter-error-message", children: intl.formatMessage({ id: "filter.date.comparing_not_supported_by_visualization" }) }));
24
24
  }
25
- return (_jsxs(DisableableFilterWrapper, { isDisabled: isDisabled, className: "section adi-date-dropdown adi-compare-apply-select", children: [_jsx("label", { htmlFor: "time-comparison-dropdown", children: _jsx(FormattedMessage, { id: "filter.date.compare_period_with" }) }), _jsx(TimeComparisonTypesDropdown, { className: "s-filter-date-compare-switch adi-date-preset-select-dropdown", supportedTypes: supportedTypes, isAllTimeDateFilter: isAllTimeDateFilter, selectedType: selectedType, onSelect: onTypeSelected, itemHeight: DROPDOWN_ITEM_HEIGHT, isPoPAvailable: isPoPAvailable }), _jsx(ComparedMeasuresSection, { selectedType: selectedType, compatibleMeasures: compatibleMeasures, selectedMeasureIds: selectedMeasureIds, onMeasuresSelected: onMeasuresSelected })] }));
25
+ return (_jsxs(DisableableFilterWrapper, { isDisabled: isDisabled, className: "section adi-date-dropdown adi-compare-apply-select", children: [_jsx("label", { htmlFor: "time-comparison-dropdown", children: _jsx(FormattedMessage, { id: "filter.date.compare_period_with" }) }), _jsx(TimeComparisonTypesDropdown, { className: "s-filter-date-compare-switch adi-date-preset-select-dropdown", supportedTypes: supportedTypes, uncomparableDateFilter: uncomparableDateFilter, selectedType: selectedType, onSelect: onTypeSelected, itemHeight: DROPDOWN_ITEM_HEIGHT, isPoPAvailable: isPoPAvailable }), _jsx(ComparedMeasuresSection, { selectedType: selectedType, compatibleMeasures: compatibleMeasures, selectedMeasureIds: selectedMeasureIds, onMeasuresSelected: onMeasuresSelected })] }));
26
26
  }
@@ -1,4 +1,5 @@
1
1
  import { type OverTimeComparisonType } from "@gooddata/sdk-ui";
2
+ import { type UncomparableDateFilter } from "../dateFilterOptionFactory.js";
2
3
  export interface ITimeComparisonTypesDropdownProps {
3
4
  supportedTypes: OverTimeComparisonType[];
4
5
  selectedType: OverTimeComparisonType;
@@ -6,8 +7,9 @@ export interface ITimeComparisonTypesDropdownProps {
6
7
  itemHeight: number;
7
8
  className?: string;
8
9
  defaultDialogHeight?: number;
9
- isAllTimeDateFilter: boolean;
10
+ /** the selected date filter, when the comparison does not work with it */
11
+ uncomparableDateFilter?: UncomparableDateFilter;
10
12
  isPoPAvailable: boolean;
11
13
  }
12
- export declare function TimeComparisonTypesDropdown({ onSelect, selectedType, itemHeight, className, defaultDialogHeight, isAllTimeDateFilter, isPoPAvailable, supportedTypes, }: ITimeComparisonTypesDropdownProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function TimeComparisonTypesDropdown({ onSelect, selectedType, itemHeight, className, defaultDialogHeight, uncomparableDateFilter, isPoPAvailable, supportedTypes, }: ITimeComparisonTypesDropdownProps): import("react/jsx-runtime").JSX.Element;
13
15
  //# sourceMappingURL=TimeComparisonTypesDropdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeComparisonTypesDropdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdown.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAcxF,MAAM,WAAW,iCAAiC;IAC9C,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,YAAY,EAAE,sBAAsB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CAC3B;AAeD,wBAAgB,2BAA2B,CAAC,EACxC,QAAmB,EACnB,YAAY,EACZ,UAAU,EACV,SAAsC,EACtC,mBAAyC,EACzC,mBAAmB,EACnB,cAAc,EACd,cAAc,GACjB,EAAE,iCAAiC,2CA4HnC"}
1
+ {"version":3,"file":"TimeComparisonTypesDropdown.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdown.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAWxF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI5E,MAAM,WAAW,iCAAiC;IAC9C,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,YAAY,EAAE,sBAAsB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0EAA0E;IAC1E,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,cAAc,EAAE,OAAO,CAAC;CAC3B;AAeD,wBAAgB,2BAA2B,CAAC,EACxC,QAAmB,EACnB,YAAY,EACZ,UAAU,EACV,SAAsC,EACtC,mBAAyC,EACzC,sBAAsB,EACtB,cAAc,EACd,cAAc,GACjB,EAAE,iCAAiC,2CA4HnC"}
@@ -20,7 +20,7 @@ function getComparisonTypeDropdownMessageId(type) {
20
20
  return `filter.compare.type.dropdown.${type}`;
21
21
  }
22
22
  }
23
- export function TimeComparisonTypesDropdown({ onSelect = () => { }, selectedType, itemHeight, className = "s-compare-types-dropdown", defaultDialogHeight = DROPDOWN_MIN_HEIGHT, isAllTimeDateFilter, isPoPAvailable, supportedTypes, }) {
23
+ export function TimeComparisonTypesDropdown({ onSelect = () => { }, selectedType, itemHeight, className = "s-compare-types-dropdown", defaultDialogHeight = DROPDOWN_MIN_HEIGHT, uncomparableDateFilter, isPoPAvailable, supportedTypes, }) {
24
24
  const intl = useIntl();
25
25
  const [state, setState] = useState({
26
26
  opened: false,
@@ -90,5 +90,5 @@ export function TimeComparisonTypesDropdown({ onSelect = () => { }, selectedType
90
90
  return (_jsx(Dropdown, { className: className, renderButton: ({ toggleDropdown }) => renderDropdownButton(toggleDropdown), onOpenStateChanged: onOpenStateChanged, alignPoints: DROPDOWN_ALIGN_POINTS, closeOnParentScroll: true, closeOnMouseDrag: true, renderBody: ({ closeDropdown }) => (_jsx(DropdownList, { className: "adi-compare-types-list s-compare-types-list", itemHeight: itemHeight, height: height, width: width, items: itemsRef.current, renderItem: ({ item }) => (_jsx(TimeComparisonTypesDropdownItem, { item: item, selected: selectedType, onClick: () => {
91
91
  onSelect(item);
92
92
  closeDropdown();
93
- }, isAllTimeDateFilter: isAllTimeDateFilter, isPoPAvailable: isPoPAvailable })) })) }));
93
+ }, uncomparableDateFilter: uncomparableDateFilter, isPoPAvailable: isPoPAvailable })) })) }));
94
94
  }
@@ -1,10 +1,12 @@
1
1
  import { type OverTimeComparisonType } from "@gooddata/sdk-ui";
2
+ import { type UncomparableDateFilter } from "../dateFilterOptionFactory.js";
2
3
  export interface ITypesDropdownItemProps {
3
4
  selected: OverTimeComparisonType;
4
5
  item?: OverTimeComparisonType;
5
6
  onClick?: (selectedType: OverTimeComparisonType) => void;
6
- isAllTimeDateFilter: boolean;
7
+ /** the selected date filter, when the comparison does not work with it */
8
+ uncomparableDateFilter?: UncomparableDateFilter;
7
9
  isPoPAvailable: boolean;
8
10
  }
9
- export declare function TimeComparisonTypesDropdownItem({ item, onClick, selected, isAllTimeDateFilter, isPoPAvailable, }: ITypesDropdownItemProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function TimeComparisonTypesDropdownItem({ item, onClick, selected, uncomparableDateFilter, isPoPAvailable, }: ITypesDropdownItemProps): import("react/jsx-runtime").JSX.Element;
10
12
  //# sourceMappingURL=TimeComparisonTypesDropdownItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeComparisonTypesDropdownItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdownItem.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAgBxF,MAAM,WAAW,uBAAuB;IACpC,QAAQ,EAAE,sBAAsB,CAAC;IACjC,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,+BAA+B,CAAC,EAC5C,IAAW,EACX,OAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,cAAc,GACjB,EAAE,uBAAuB,2CAoEzB"}
1
+ {"version":3,"file":"TimeComparisonTypesDropdownItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/TimeComparisonSection/TimeComparisonTypesDropdownItem.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,sBAAsB,EAA2B,MAAM,kBAAkB,CAAC;AAGxF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAoB5E,MAAM,WAAW,uBAAuB;IACpC,QAAQ,EAAE,sBAAsB,CAAC;IACjC,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,0EAA0E;IAC1E,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,+BAA+B,CAAC,EAC5C,IAAW,EACX,OAAkB,EAClB,QAAQ,EACR,sBAAsB,EACtB,cAAc,GACjB,EAAE,uBAAuB,2CAgEzB"}
@@ -5,6 +5,10 @@ import classNames from "classnames";
5
5
  import { defineMessage, useIntl } from "react-intl";
6
6
  import { OverTimeComparisonTypes } from "@gooddata/sdk-ui";
7
7
  import { Bubble, BubbleHoverTrigger } from "@gooddata/sdk-ui-kit";
8
+ const UNCOMPARABLE_DATE_FILTER_TOOLTIPS = {
9
+ allTime: defineMessage({ id: "filter.compare.type.dropdown.disabled_for_all_time_period_tooltip" }),
10
+ period: defineMessage({ id: "filter.compare.type.dropdown.disabled_for_named_period_tooltip" }),
11
+ };
8
12
  function getComparisonTypeDropdownMessageId(type) {
9
13
  switch (type) {
10
14
  case OverTimeComparisonTypes.NOTHING:
@@ -17,14 +21,14 @@ function getComparisonTypeDropdownMessageId(type) {
17
21
  return `filter.compare.type.dropdown.${type}`;
18
22
  }
19
23
  }
20
- export function TimeComparisonTypesDropdownItem({ item = null, onClick = () => { }, selected, isAllTimeDateFilter, isPoPAvailable, }) {
24
+ export function TimeComparisonTypesDropdownItem({ item = null, onClick = () => { }, selected, uncomparableDateFilter, isPoPAvailable, }) {
21
25
  const intl = useIntl();
22
26
  const isIncompatible = useCallback(() => {
23
- const disabledAllTime = isAllTimeDateFilter &&
27
+ const disabledForDateFilter = uncomparableDateFilter !== undefined &&
24
28
  (item === OverTimeComparisonTypes.PREVIOUS_PERIOD ||
25
29
  item === OverTimeComparisonTypes.SAME_PERIOD_PREVIOUS_YEAR);
26
- return disabledAllTime || !isPoPAvailable;
27
- }, [item, isAllTimeDateFilter, isPoPAvailable]);
30
+ return disabledForDateFilter || !isPoPAvailable;
31
+ }, [item, uncomparableDateFilter, isPoPAvailable]);
28
32
  const isSelected = useCallback(() => {
29
33
  return item === selected;
30
34
  }, [item, selected]);
@@ -32,16 +36,12 @@ export function TimeComparisonTypesDropdownItem({ item = null, onClick = () => {
32
36
  return isIncompatible() && item !== OverTimeComparisonTypes.NOTHING;
33
37
  }, [item, isIncompatible]);
34
38
  const getBubbleText = useCallback(() => {
35
- return isPoPAvailable
36
- ? intl.formatMessage({
37
- id: defineMessage({
38
- id: "filter.compare.type.dropdown.disabled_for_all_time_period_tooltip",
39
- }).id,
40
- })
39
+ return isPoPAvailable && uncomparableDateFilter
40
+ ? intl.formatMessage(UNCOMPARABLE_DATE_FILTER_TOOLTIPS[uncomparableDateFilter])
41
41
  : intl.formatMessage({
42
42
  id: defineMessage({ id: "filter.compare.type.dropdown.disabled_for_pop" }).id,
43
43
  });
44
- }, [intl, isPoPAvailable]);
44
+ }, [intl, isPoPAvailable, uncomparableDateFilter]);
45
45
  const handleClick = useCallback((e) => {
46
46
  e.preventDefault();
47
47
  const isResettable = item === OverTimeComparisonTypes.NOTHING;
@@ -1,4 +1,4 @@
1
- import { type DateFilterOption } from "@gooddata/sdk-ui-filters";
1
+ import { type DateFilterOption, type IUiPeriodPreset } from "@gooddata/sdk-ui-filters";
2
2
  import { type IDateFilterConfig, type IParameterizedDateFilterConfig } from "../../../store/filter_bar/filter_bar_types.js";
3
3
  export interface IDateFilterOption {
4
4
  filterOption: DateFilterOption;
@@ -19,6 +19,11 @@ export interface IDateFilterOptionPeriod {
19
19
  export declare const isAllTimeOption: ({ filterOption, period }: IDateFilterOption) => boolean;
20
20
  /** The option of a filter with a period. */
21
21
  export declare const buildPeriodDateFilterOption: (config: IParameterizedDateFilterConfig, title: string) => IDateFilterOption;
22
+ /** The option of a period picked from the list of periods, in the filter with the given local identifier. */
23
+ export declare const buildPeriodDateFilterOptionFromPreset: ({ parameter, period, name }: IUiPeriodPreset, localIdentifier?: string) => IDateFilterOption;
24
+ /** A date filter the comparison over time does not work with: it has no previous period to compare to. */
25
+ export type UncomparableDateFilter = "allTime" | "period";
26
+ export declare const getUncomparableDateFilter: (option: IDateFilterOption) => UncomparableDateFilter | undefined;
22
27
  /**
23
28
  * Tries to match a preset or a form with the provided value. Prioritizes preset over form.
24
29
  * @param dateFilterValue - Value to match against.
@@ -1 +1 @@
1
- {"version":3,"file":"dateFilterOptionFactory.d.ts","sourceRoot":"","sources":["../../../../src/components/filterBar/dateFilter/dateFilterOptionFactory.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,gBAAgB,EAIxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACtC,MAAM,+CAA+C,CAAC;AAKvD,MAAM,WAAW,iBAAiB;IAC9B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,8BAA8B,CAAC;IACvC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,eAAO,MAAM,eAAe,6BAA8B,iBAAiB,KAAG,OACxB,CAAC;AAEvD,4CAA4C;AAC5C,eAAO,MAAM,2BAA2B,WAC5B,8BAA8B,SAC/B,MAAM,KACd,iBAID,CAAC;AAkDH;;;GAGG;AACH,eAAO,MAAM,sCAAsC,oBAC9B,iBAAiB,KACnC,iBAAiB,GAAG,SAyBtB,CAAC;AAEF,eAAO,MAAM,wCAAwC,WACzC,gBAAgB,KACzB,iBAAiB,GAAG,SA0BtB,CAAC"}
1
+ {"version":3,"file":"dateFilterOptionFactory.d.ts","sourceRoot":"","sources":["../../../../src/components/filterBar/dateFilter/dateFilterOptionFactory.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,gBAAgB,EAErB,KAAK,eAAe,EAGvB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACtC,MAAM,+CAA+C,CAAC;AAKvD,MAAM,WAAW,iBAAiB;IAC9B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,8BAA8B,CAAC;IACvC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,eAAO,MAAM,eAAe,6BAA8B,iBAAiB,KAAG,OACxB,CAAC;AAEvD,4CAA4C;AAC5C,eAAO,MAAM,2BAA2B,WAC5B,8BAA8B,SAC/B,MAAM,KACd,iBAID,CAAC;AAEH,6GAA6G;AAC7G,eAAO,MAAM,qCAAqC,gCACjB,eAAe,oBAC1B,MAAM,KACzB,iBASE,CAAC;AAEN,0GAA0G;AAC1G,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1D,eAAO,MAAM,yBAAyB,WAAY,iBAAiB,KAAG,sBAAsB,GAAG,SAK9F,CAAC;AAkDF;;;GAGG;AACH,eAAO,MAAM,sCAAsC,oBAC9B,iBAAiB,KACnC,iBAAiB,GAAG,SAyBtB,CAAC;AAEF,eAAO,MAAM,wCAAwC,WACzC,gBAAgB,KACzB,iBAAiB,GAAG,SA0BtB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import { isAbsoluteDateFilterForm, isAllTimeDateFilterOption, isRelativeDateFilterPreset, } from "@gooddata/sdk-model";
3
3
  import { isUiRelativeDateFilterForm, } from "@gooddata/sdk-ui-filters";
4
4
  import { ALL_TIME } from "../../../constants/presets.js";
5
+ import { periodGranularityToGranularity } from "../../../models/granularity.js";
5
6
  import { ALL_TIME_FILTER_OPTION } from "./defaultFilterOptions.js";
6
7
  import { findRelativePresetByValue } from "./presets.js";
7
8
  /** The option is All time, not a period, which is All time underneath. */
@@ -12,6 +13,19 @@ export const buildPeriodDateFilterOption = (config, title) => ({
12
13
  excludeCurrentPeriod: false,
13
14
  period: { config, title },
14
15
  });
16
+ /** The option of a period picked from the list of periods, in the filter with the given local identifier. */
17
+ export const buildPeriodDateFilterOptionFromPreset = ({ parameter, period, name }, localIdentifier) => buildPeriodDateFilterOption({
18
+ type: "parameterized",
19
+ parameterRef: parameter,
20
+ ...(period ? { granularity: periodGranularityToGranularity(period.granularity) } : {}),
21
+ ...(localIdentifier ? { localIdentifier } : {}),
22
+ }, name);
23
+ export const getUncomparableDateFilter = (option) => {
24
+ if (option.period) {
25
+ return "period";
26
+ }
27
+ return isAllTimeOption(option) ? "allTime" : undefined;
28
+ };
15
29
  const virtualPresetBase = {
16
30
  name: "",
17
31
  visible: true,