@ultraviolet/ui 3.18.2 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/SelectInput/components/SelectBar/selectBar.css.d.ts.map +1 -1
- package/dist/composition.js +5 -1
- package/dist/compositions/Filters/Filters.d.ts +9 -0
- package/dist/compositions/Filters/Filters.d.ts.map +1 -0
- package/dist/compositions/Filters/Filters.js +36 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/Dropdown.d.ts +16 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/Dropdown.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/Dropdown.js +137 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/FilterDatetimeRange.d.ts +6 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/FilterDatetimeRange.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/FilterDatetimeRange.js +74 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/filterDatetimeRange.styles.css.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/filterDatetimeRange.styles.css.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/filterDatetimeRange.styles.css.js +16 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/filterDatetimeRange.styles.css.ts.vanilla.js +8 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/type.d.ts +16 -0
- package/dist/compositions/Filters/filterTypes/FilterDatetimeRange/type.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterMultiSelect.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterMultiSelect.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterMultiSelect.js +53 -0
- package/dist/compositions/Filters/filterTypes/FilterNumber.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterNumber.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterNumber.js +24 -0
- package/dist/compositions/Filters/filterTypes/FilterSearch.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterSearch.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterSearch.js +42 -0
- package/dist/compositions/Filters/filterTypes/FilterSelect.d.ts +6 -0
- package/dist/compositions/Filters/filterTypes/FilterSelect.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterSelect.js +46 -0
- package/dist/compositions/Filters/filterTypes/FilterSlider.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterSlider.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterSlider.js +31 -0
- package/dist/compositions/Filters/filterTypes/FilterText.d.ts +5 -0
- package/dist/compositions/Filters/filterTypes/FilterText.d.ts.map +1 -0
- package/dist/compositions/Filters/filterTypes/FilterText.js +42 -0
- package/dist/compositions/Filters/index.d.ts +7 -0
- package/dist/compositions/Filters/index.d.ts.map +1 -0
- package/dist/compositions/Filters/index.js +12 -0
- package/dist/compositions/Filters/parts/AbstractFilter.d.ts +8 -0
- package/dist/compositions/Filters/parts/AbstractFilter.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/AbstractFilter.js +54 -0
- package/dist/compositions/Filters/parts/ExpandableFilterGroup.d.ts +9 -0
- package/dist/compositions/Filters/parts/ExpandableFilterGroup.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/ExpandableFilterGroup.js +59 -0
- package/dist/compositions/Filters/parts/FiltersDrawer.d.ts +13 -0
- package/dist/compositions/Filters/parts/FiltersDrawer.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/FiltersDrawer.js +100 -0
- package/dist/compositions/Filters/parts/FiltersMainRow.d.ts +19 -0
- package/dist/compositions/Filters/parts/FiltersMainRow.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/FiltersMainRow.js +85 -0
- package/dist/compositions/Filters/parts/FiltersProvider.d.ts +17 -0
- package/dist/compositions/Filters/parts/FiltersProvider.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/FiltersProvider.js +55 -0
- package/dist/compositions/Filters/parts/helpers.d.ts +5 -0
- package/dist/compositions/Filters/parts/helpers.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/helpers.js +38 -0
- package/dist/compositions/Filters/parts/reducer.d.ts +40 -0
- package/dist/compositions/Filters/parts/reducer.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/reducer.js +50 -0
- package/dist/compositions/Filters/parts/styles.css.d.ts +4 -0
- package/dist/compositions/Filters/parts/styles.css.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/styles.css.js +13 -0
- package/dist/compositions/Filters/parts/styles.css.ts.vanilla.js +8 -0
- package/dist/compositions/Filters/parts/useFilters.d.ts +28 -0
- package/dist/compositions/Filters/parts/useFilters.d.ts.map +1 -0
- package/dist/compositions/Filters/parts/useFilters.js +100 -0
- package/dist/compositions/Filters/types.d.ts +80 -0
- package/dist/compositions/Filters/types.d.ts.map +1 -0
- package/dist/compositions/OfferList/components/Row.d.ts +1 -1
- package/dist/compositions/OfferList/components/Row.d.ts.map +1 -1
- package/dist/compositions/OfferList/components/Row.js +3 -2
- package/dist/compositions/OfferList/index.d.ts +1 -1
- package/dist/compositions/index.d.ts +2 -0
- package/dist/compositions/index.d.ts.map +1 -1
- package/dist/compositions/index.js +6 -0
- package/dist/ui.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { _objectSpread2, init_objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
|
|
3
|
+
import { Slider, init_Slider } from "../../../components/Slider/index.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/compositions/Filters/filterTypes/FilterSlider.tsx
|
|
7
|
+
var FilterSlider;
|
|
8
|
+
var init_FilterSlider = __esmMin(() => {
|
|
9
|
+
init_Slider();
|
|
10
|
+
init_objectSpread2();
|
|
11
|
+
FilterSlider = ({ value, onChange, config, hideLabel }) => {
|
|
12
|
+
const sliderProps = {
|
|
13
|
+
input: true,
|
|
14
|
+
"aria-label": hideLabel ? config.label : void 0,
|
|
15
|
+
label: hideLabel ? void 0 : config.label,
|
|
16
|
+
max: config.max,
|
|
17
|
+
min: config.min,
|
|
18
|
+
name: config.name,
|
|
19
|
+
onChange,
|
|
20
|
+
options: config.options,
|
|
21
|
+
step: config.step,
|
|
22
|
+
unit: config.unit
|
|
23
|
+
};
|
|
24
|
+
if (config.double) return /* @__PURE__ */ jsx(Slider, _objectSpread2(_objectSpread2({ double: true }, sliderProps), {}, { value }));
|
|
25
|
+
return /* @__PURE__ */ jsx(Slider, _objectSpread2(_objectSpread2({}, sliderProps), {}, { value }));
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
init_FilterSlider();
|
|
31
|
+
export { FilterSlider, init_FilterSlider };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FilterConfigItemText, FilterComponentProps } from '../types';
|
|
2
|
+
type FilterTextProps = FilterComponentProps<string, FilterConfigItemText>;
|
|
3
|
+
export declare const FilterText: ({ config, hideLabel, onChange, value, size }: FilterTextProps) => import("react").JSX.Element;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=FilterText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterText.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/filterTypes/FilterText.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE1E,KAAK,eAAe,GAAG,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;AAEzE,eAAO,MAAM,UAAU,iDAAkD,eAAe,gCA8BvF,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { TextInput, init_TextInput } from "../../../components/TextInput/index.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useDebouncedCallback } from "@ultraviolet/utils";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/compositions/Filters/filterTypes/FilterText.tsx
|
|
8
|
+
var FilterText;
|
|
9
|
+
var init_FilterText = __esmMin(() => {
|
|
10
|
+
init_TextInput();
|
|
11
|
+
FilterText = ({ config, hideLabel, onChange, value, size }) => {
|
|
12
|
+
var _config$debounceDurat;
|
|
13
|
+
const [tempValue, setTempValue] = useState(value);
|
|
14
|
+
const onSetValueLater = useDebouncedCallback(onChange, (_config$debounceDurat = config.debounceDuration) !== null && _config$debounceDurat !== void 0 ? _config$debounceDurat : 600);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setTempValue(value);
|
|
17
|
+
}, [value]);
|
|
18
|
+
return /* @__PURE__ */ jsx(TextInput, {
|
|
19
|
+
"aria-label": hideLabel ? config.label : void 0,
|
|
20
|
+
label: hideLabel ? void 0 : config.label,
|
|
21
|
+
loading: tempValue !== value,
|
|
22
|
+
name: config.name,
|
|
23
|
+
size,
|
|
24
|
+
onChange: (event) => {
|
|
25
|
+
setTempValue(event.target.value);
|
|
26
|
+
onSetValueLater(event.target.value);
|
|
27
|
+
},
|
|
28
|
+
onKeyDown: (event) => {
|
|
29
|
+
if (event.key === "Enter") {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
placeholder: config.placeholder,
|
|
35
|
+
value: tempValue
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
init_FilterText();
|
|
42
|
+
export { FilterText, init_FilterText };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Filters } from './Filters';
|
|
2
|
+
export type { FiltersProps } from './Filters';
|
|
3
|
+
export { useFiltersContext, FiltersProvider } from './parts/FiltersProvider';
|
|
4
|
+
export { FiltersMainRow } from './parts/FiltersMainRow';
|
|
5
|
+
export { FiltersDrawer } from './parts/FiltersDrawer';
|
|
6
|
+
export type { FilterConfig, FilterConfigGroup, FilterConfigItemBase, FilterConfigItem, FilterConfigItemDatetimeRange, FilterConfigItemMultiSelect, FilterConfigItemNumber, FilterConfigItemSelect, FilterConfigItemSlider, FilterConfigItemText, FilterComponentProps, } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compositions/Filters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { FiltersProvider, init_FiltersProvider, useFiltersContext } from "./parts/FiltersProvider.js";
|
|
3
|
+
import { FiltersDrawer, init_FiltersDrawer } from "./parts/FiltersDrawer.js";
|
|
4
|
+
import { FiltersMainRow, init_FiltersMainRow } from "./parts/FiltersMainRow.js";
|
|
5
|
+
import { Filters, init_Filters as init_Filters$1 } from "./Filters.js";
|
|
6
|
+
|
|
7
|
+
//#region src/compositions/Filters/index.ts
|
|
8
|
+
var init_Filters = __esmMin(() => {});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
init_Filters();
|
|
12
|
+
export { init_Filters };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { FilterComponentProps } from '../types';
|
|
3
|
+
type AbstractFilterProps = FilterComponentProps & {
|
|
4
|
+
customComponents?: Record<string, ComponentType<FilterComponentProps>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const AbstractFilter: ({ hideLabel, config, directionContext, onChange, value, values, customComponents, size, }: AbstractFilterProps) => import("react").JSX.Element | null;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=AbstractFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractFilter.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/AbstractFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAQ1C,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,UAAU,CAAA;AAElE,KAAK,mBAAmB,GAAG,oBAAoB,GAAG;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAA;CACvE,CAAA;AAYD,eAAO,MAAM,cAAc,8FASxB,mBAAmB,uCAwBrB,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { _objectSpread2, init_objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
|
|
3
|
+
import { FilterDatetimeRange, init_FilterDatetimeRange } from "../filterTypes/FilterDatetimeRange/FilterDatetimeRange.js";
|
|
4
|
+
import { FilterSelect, init_FilterSelect } from "../filterTypes/FilterSelect.js";
|
|
5
|
+
import { FilterMultiSelect, init_FilterMultiSelect } from "../filterTypes/FilterMultiSelect.js";
|
|
6
|
+
import { FilterNumber, init_FilterNumber } from "../filterTypes/FilterNumber.js";
|
|
7
|
+
import { FilterSearch, init_FilterSearch } from "../filterTypes/FilterSearch.js";
|
|
8
|
+
import { FilterSlider, init_FilterSlider } from "../filterTypes/FilterSlider.js";
|
|
9
|
+
import { FilterText, init_FilterText } from "../filterTypes/FilterText.js";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
//#region src/compositions/Filters/parts/AbstractFilter.tsx
|
|
13
|
+
var defaultFieldComponents, AbstractFilter;
|
|
14
|
+
var init_AbstractFilter = __esmMin(() => {
|
|
15
|
+
init_FilterDatetimeRange();
|
|
16
|
+
init_FilterMultiSelect();
|
|
17
|
+
init_FilterNumber();
|
|
18
|
+
init_FilterSearch();
|
|
19
|
+
init_FilterSelect();
|
|
20
|
+
init_FilterSlider();
|
|
21
|
+
init_FilterText();
|
|
22
|
+
init_objectSpread2();
|
|
23
|
+
defaultFieldComponents = {
|
|
24
|
+
text: FilterText,
|
|
25
|
+
search: FilterSearch,
|
|
26
|
+
select: FilterSelect,
|
|
27
|
+
multiselect: FilterMultiSelect,
|
|
28
|
+
slider: FilterSlider,
|
|
29
|
+
datetimeRange: FilterDatetimeRange,
|
|
30
|
+
number: FilterNumber
|
|
31
|
+
};
|
|
32
|
+
AbstractFilter = ({ hideLabel, config, directionContext, onChange, value, values, customComponents = {}, size }) => {
|
|
33
|
+
const shouldHideLabel = directionContext === "column" && hideLabel;
|
|
34
|
+
const availableComponents = _objectSpread2(_objectSpread2({}, defaultFieldComponents), customComponents);
|
|
35
|
+
const isAvailableType = (configItem) => configItem.type in availableComponents;
|
|
36
|
+
if (isAvailableType(config)) {
|
|
37
|
+
const Component = availableComponents[config.type];
|
|
38
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
39
|
+
config,
|
|
40
|
+
size,
|
|
41
|
+
directionContext,
|
|
42
|
+
onChange,
|
|
43
|
+
hideLabel: shouldHideLabel,
|
|
44
|
+
value,
|
|
45
|
+
values
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
init_AbstractFilter();
|
|
54
|
+
export { AbstractFilter, init_AbstractFilter };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare const ExpandableFilterGroup: ({ label, children, defaultExpanded, onReset, clearText, }: {
|
|
3
|
+
label: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
defaultExpanded?: boolean;
|
|
6
|
+
onReset?: () => void;
|
|
7
|
+
clearText: string;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ExpandableFilterGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandableFilterGroup.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/ExpandableFilterGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQtC,eAAO,MAAM,qBAAqB,8DAM/B;IACD,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,SAAS,CAAA;IACnB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB,gCA8BA,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Stack, init_Stack } from "../../../components/Stack/index.js";
|
|
3
|
+
import { Text, init_Text } from "../../../components/Text/index.js";
|
|
4
|
+
import { Button, init_Button } from "../../../components/Button/index.js";
|
|
5
|
+
import { Label, init_Label } from "../../../components/Label/index.js";
|
|
6
|
+
import { Row, init_Row } from "../../../components/Row/index.js";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ArrowDownIcon, ArrowUpIcon } from "@ultraviolet/icons";
|
|
10
|
+
|
|
11
|
+
//#region src/compositions/Filters/parts/ExpandableFilterGroup.tsx
|
|
12
|
+
var ExpandableFilterGroup;
|
|
13
|
+
var init_ExpandableFilterGroup = __esmMin(() => {
|
|
14
|
+
init_Button();
|
|
15
|
+
init_Label();
|
|
16
|
+
init_Row();
|
|
17
|
+
init_Stack();
|
|
18
|
+
init_Text();
|
|
19
|
+
ExpandableFilterGroup = ({ label, children, defaultExpanded = true, onReset, clearText }) => {
|
|
20
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
21
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
22
|
+
gap: 2,
|
|
23
|
+
children: [/* @__PURE__ */ jsxs(Row, {
|
|
24
|
+
gap: 1,
|
|
25
|
+
templateColumns: "1fr auto",
|
|
26
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
27
|
+
size: "medium",
|
|
28
|
+
children: label
|
|
29
|
+
}), /* @__PURE__ */ jsxs(Stack, {
|
|
30
|
+
direction: "row",
|
|
31
|
+
gap: 1,
|
|
32
|
+
children: [typeof onReset === "function" ? /* @__PURE__ */ jsx(Button, {
|
|
33
|
+
onClick: onReset,
|
|
34
|
+
sentiment: "neutral",
|
|
35
|
+
size: "xsmall",
|
|
36
|
+
variant: "ghost",
|
|
37
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
38
|
+
as: "span",
|
|
39
|
+
variant: "captionStrong",
|
|
40
|
+
children: clearText
|
|
41
|
+
})
|
|
42
|
+
}) : null, /* @__PURE__ */ jsx(Button, {
|
|
43
|
+
onClick: () => {
|
|
44
|
+
setExpanded((current) => !current);
|
|
45
|
+
},
|
|
46
|
+
sentiment: "neutral",
|
|
47
|
+
size: "xsmall",
|
|
48
|
+
variant: "ghost",
|
|
49
|
+
children: expanded ? /* @__PURE__ */ jsx(ArrowUpIcon, {}) : /* @__PURE__ */ jsx(ArrowDownIcon, {})
|
|
50
|
+
})]
|
|
51
|
+
})]
|
|
52
|
+
}), expanded ? /* @__PURE__ */ jsx(Stack, { children }) : null]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
init_ExpandableFilterGroup();
|
|
59
|
+
export { ExpandableFilterGroup, init_ExpandableFilterGroup };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { AnyObject, FilterComponentProps, FilterConfig } from '../types';
|
|
3
|
+
export type DrawerProps<V extends AnyObject = AnyObject> = {
|
|
4
|
+
config: FilterConfig<V>[];
|
|
5
|
+
components?: Record<string, ComponentType<FilterComponentProps>>;
|
|
6
|
+
labels: {
|
|
7
|
+
submit: string;
|
|
8
|
+
clear: string;
|
|
9
|
+
drawerHeader: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const FiltersDrawer: <V extends AnyObject>({ config, components, labels }: DrawerProps<V>) => import("react").JSX.Element | null;
|
|
13
|
+
//# sourceMappingURL=FiltersDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersDrawer.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/FiltersDrawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,OAAO,CAAA;AAKvD,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAA;AAM/F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACzD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAChE,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,SAAS,kCAAkC,WAAW,CAAC,CAAC,CAAC,uCAwFhG,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Stack, init_Stack } from "../../../components/Stack/index.js";
|
|
3
|
+
import { Button, init_Button } from "../../../components/Button/index.js";
|
|
4
|
+
import { Separator, init_Separator } from "../../../components/Separator/index.js";
|
|
5
|
+
import { Drawer, init_Drawer } from "../../../components/Drawer/index.js";
|
|
6
|
+
import { AbstractFilter, init_AbstractFilter } from "./AbstractFilter.js";
|
|
7
|
+
import { ExpandableFilterGroup, init_ExpandableFilterGroup } from "./ExpandableFilterGroup.js";
|
|
8
|
+
import { init_helpers, isFilterConfigGroup } from "./helpers.js";
|
|
9
|
+
import { init_FiltersProvider, useFiltersContext } from "./FiltersProvider.js";
|
|
10
|
+
import { useId } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
//#region src/compositions/Filters/parts/FiltersDrawer.tsx
|
|
14
|
+
var FiltersDrawer;
|
|
15
|
+
var init_FiltersDrawer = __esmMin(() => {
|
|
16
|
+
init_Button();
|
|
17
|
+
init_Drawer();
|
|
18
|
+
init_Separator();
|
|
19
|
+
init_Stack();
|
|
20
|
+
init_AbstractFilter();
|
|
21
|
+
init_ExpandableFilterGroup();
|
|
22
|
+
init_FiltersProvider();
|
|
23
|
+
init_helpers();
|
|
24
|
+
FiltersDrawer = ({ config, components, labels }) => {
|
|
25
|
+
const formId = useId();
|
|
26
|
+
const { filters, closeDrawer, isDrawerOpen } = useFiltersContext();
|
|
27
|
+
const drawerFilters = config.filter((item) => !item.hideInDrawer);
|
|
28
|
+
const createResetHandler = (configItem) => {
|
|
29
|
+
let fieldsToReset = [];
|
|
30
|
+
if (isFilterConfigGroup(configItem)) fieldsToReset = configItem.items.map((item) => item.name).filter((name) => filters.dirtyFilters.includes(name));
|
|
31
|
+
else if (filters.dirtyFilters.includes(configItem.name)) fieldsToReset = [configItem.name];
|
|
32
|
+
return fieldsToReset.length > 0 ? () => filters.resetFields(fieldsToReset) : void 0;
|
|
33
|
+
};
|
|
34
|
+
if (drawerFilters.length === 0) return null;
|
|
35
|
+
return /* @__PURE__ */ jsx(Drawer, {
|
|
36
|
+
footer: /* @__PURE__ */ jsx(Button, {
|
|
37
|
+
render: /* @__PURE__ */ jsx("button", {
|
|
38
|
+
form: formId,
|
|
39
|
+
type: "submit"
|
|
40
|
+
}),
|
|
41
|
+
children: labels.submit
|
|
42
|
+
}),
|
|
43
|
+
header: labels.drawerHeader,
|
|
44
|
+
hideOnClickOutside: false,
|
|
45
|
+
onClose: () => {
|
|
46
|
+
filters.discard();
|
|
47
|
+
closeDrawer();
|
|
48
|
+
},
|
|
49
|
+
open: isDrawerOpen,
|
|
50
|
+
separator: true,
|
|
51
|
+
size: "small",
|
|
52
|
+
children: /* @__PURE__ */ jsx("form", {
|
|
53
|
+
id: formId,
|
|
54
|
+
onSubmit: (event) => {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
filters.submit();
|
|
58
|
+
closeDrawer();
|
|
59
|
+
},
|
|
60
|
+
children: /* @__PURE__ */ jsx(Stack, {
|
|
61
|
+
gap: 2,
|
|
62
|
+
children: drawerFilters.map((configItem, index) => /* @__PURE__ */ jsxs(Stack, {
|
|
63
|
+
gap: 2,
|
|
64
|
+
children: [index > 0 ? /* @__PURE__ */ jsx(Separator, {}) : null, /* @__PURE__ */ jsx(ExpandableFilterGroup, {
|
|
65
|
+
clearText: labels.clear,
|
|
66
|
+
label: configItem.label,
|
|
67
|
+
defaultExpanded: configItem.expanded,
|
|
68
|
+
onReset: createResetHandler(configItem),
|
|
69
|
+
children: isFilterConfigGroup(configItem) ? /* @__PURE__ */ jsx(Stack, {
|
|
70
|
+
gap: 2,
|
|
71
|
+
children: configItem.items.filter((item) => !item.hideInDrawer).map((subConfigItem) => /* @__PURE__ */ jsx(AbstractFilter, {
|
|
72
|
+
config: subConfigItem,
|
|
73
|
+
directionContext: "column",
|
|
74
|
+
size: "large",
|
|
75
|
+
onChange: (value) => filters.setValue(subConfigItem.name, value),
|
|
76
|
+
value: filters.values[subConfigItem.name],
|
|
77
|
+
values: filters.values,
|
|
78
|
+
customComponents: components
|
|
79
|
+
}, subConfigItem.name))
|
|
80
|
+
}) : /* @__PURE__ */ jsx(AbstractFilter, {
|
|
81
|
+
config: configItem,
|
|
82
|
+
directionContext: "column",
|
|
83
|
+
size: "large",
|
|
84
|
+
hideLabel: true,
|
|
85
|
+
onChange: (value) => filters.setValue(configItem.name, value),
|
|
86
|
+
value: filters.values[configItem.name],
|
|
87
|
+
values: filters.values,
|
|
88
|
+
customComponents: components
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
}, isFilterConfigGroup(configItem) ? configItem.label : configItem.name))
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
init_FiltersDrawer();
|
|
100
|
+
export { FiltersDrawer, init_FiltersDrawer };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType } from 'react';
|
|
2
|
+
import { Row } from '../../../components/Row';
|
|
3
|
+
import type { AnyObject, FilterComponentProps, FilterConfig } from '../types';
|
|
4
|
+
export type MainRowProps<V extends AnyObject = AnyObject> = {
|
|
5
|
+
config: FilterConfig<V>[];
|
|
6
|
+
components?: Record<string, ComponentType<FilterComponentProps>>;
|
|
7
|
+
labels: {
|
|
8
|
+
seeAll?: string;
|
|
9
|
+
clearAll: string;
|
|
10
|
+
};
|
|
11
|
+
layout?: {
|
|
12
|
+
mainFilters?: (keyof V)[];
|
|
13
|
+
size?: 'large' | 'medium';
|
|
14
|
+
templateColumns?: ComponentProps<typeof Row>['templateColumns'];
|
|
15
|
+
};
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const FiltersMainRow: <V extends AnyObject>({ config, components, labels, layout, className, }: MainRowProps<V>) => import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=FiltersMainRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersMainRow.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/FiltersMainRow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1D,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAM7E,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IAC1D,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAChE,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,MAAM,CAAC,EAAE;QACP,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;QACzB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;QACzB,eAAe,CAAC,EAAE,cAAc,CAAC,OAAO,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAA;KAChE,CAAA;IACD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,SAAS,sDAM/C,YAAY,CAAC,CAAC,CAAC,gCA4DjB,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Stack, init_Stack } from "../../../components/Stack/index.js";
|
|
3
|
+
import { Button, init_Button } from "../../../components/Button/index.js";
|
|
4
|
+
import { Row, init_Row } from "../../../components/Row/index.js";
|
|
5
|
+
import { AbstractFilter, init_AbstractFilter } from "./AbstractFilter.js";
|
|
6
|
+
import { init_helpers, isFilterConfigGroup } from "./helpers.js";
|
|
7
|
+
import { init_FiltersProvider, useFiltersContext } from "./FiltersProvider.js";
|
|
8
|
+
import { filterStyles, init_styles_css } from "./styles.css.js";
|
|
9
|
+
import { useMemo } from "react";
|
|
10
|
+
import { cn } from "@ultraviolet/utils";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { AdjustmentsHorizontalIcon } from "@ultraviolet/icons";
|
|
13
|
+
|
|
14
|
+
//#region src/compositions/Filters/parts/FiltersMainRow.tsx
|
|
15
|
+
var FiltersMainRow;
|
|
16
|
+
var init_FiltersMainRow = __esmMin(() => {
|
|
17
|
+
init_Button();
|
|
18
|
+
init_Row();
|
|
19
|
+
init_Stack();
|
|
20
|
+
init_AbstractFilter();
|
|
21
|
+
init_FiltersProvider();
|
|
22
|
+
init_helpers();
|
|
23
|
+
init_styles_css();
|
|
24
|
+
FiltersMainRow = ({ config, components, labels, layout, className }) => {
|
|
25
|
+
var _layout$size;
|
|
26
|
+
var _layout$templateColum;
|
|
27
|
+
const { filters, openDrawer } = useFiltersContext();
|
|
28
|
+
const configItems = useMemo(() => config.flatMap((item) => isFilterConfigGroup(item) ? item.items : [item]), [config]);
|
|
29
|
+
const mainFiltersNames = useMemo(() => {
|
|
30
|
+
var _layout$mainFilters;
|
|
31
|
+
return (_layout$mainFilters = layout === null || layout === void 0 ? void 0 : layout.mainFilters) !== null && _layout$mainFilters !== void 0 ? _layout$mainFilters : configItems.map((item) => item.name).slice(0, 3);
|
|
32
|
+
}, [configItems, layout]);
|
|
33
|
+
const mainFilters = useMemo(() => mainFiltersNames.map((name) => configItems.find((item) => item.name === name)).filter((item) => item !== void 0), [mainFiltersNames, configItems]);
|
|
34
|
+
const shouldDisplayDrawer = configItems.some((item) => !mainFiltersNames.includes(item.name));
|
|
35
|
+
const defaultSize = mainFilters.some((item) => item.type === "slider") ? "large" : "medium";
|
|
36
|
+
const filterSize = (_layout$size = layout === null || layout === void 0 ? void 0 : layout.size) !== null && _layout$size !== void 0 ? _layout$size : defaultSize;
|
|
37
|
+
const handleMainFilterChange = (key, value) => {
|
|
38
|
+
filters.setValue(key, value);
|
|
39
|
+
filters.submit({ [key]: value });
|
|
40
|
+
};
|
|
41
|
+
const handleReset = () => {
|
|
42
|
+
filters.reset();
|
|
43
|
+
filters.submit(filters.defaultValues);
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ jsxs(Row, {
|
|
46
|
+
className: cn(filterStyles.mainRow, className),
|
|
47
|
+
alignItems: "end",
|
|
48
|
+
gap: 2,
|
|
49
|
+
templateColumns: (_layout$templateColum = layout === null || layout === void 0 ? void 0 : layout.templateColumns) !== null && _layout$templateColum !== void 0 ? _layout$templateColum : "repeat(auto-fit, minmax(200px, 1fr))",
|
|
50
|
+
children: [mainFilters.map((configItem) => /* @__PURE__ */ jsx(AbstractFilter, {
|
|
51
|
+
value: filters.lastSubmittedValues[configItem.name],
|
|
52
|
+
values: filters.lastSubmittedValues,
|
|
53
|
+
config: configItem,
|
|
54
|
+
size: filterSize,
|
|
55
|
+
directionContext: "row",
|
|
56
|
+
onChange: (value) => handleMainFilterChange(configItem.name, value),
|
|
57
|
+
customComponents: components
|
|
58
|
+
}, configItem.name)), /* @__PURE__ */ jsxs(Stack, {
|
|
59
|
+
direction: "row",
|
|
60
|
+
gap: 2,
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
children: [shouldDisplayDrawer ? /* @__PURE__ */ jsxs(Button, {
|
|
63
|
+
onClick: openDrawer,
|
|
64
|
+
size: filterSize,
|
|
65
|
+
variant: "outlined",
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(AdjustmentsHorizontalIcon, { "aria-hidden": "true" }),
|
|
68
|
+
" ",
|
|
69
|
+
labels.seeAll,
|
|
70
|
+
filters.appliedFilters.length > 0 ? ` (${filters.appliedFilters.length})` : null
|
|
71
|
+
]
|
|
72
|
+
}) : null, /* @__PURE__ */ jsx(Button, {
|
|
73
|
+
onClick: handleReset,
|
|
74
|
+
size: filterSize,
|
|
75
|
+
variant: "ghost",
|
|
76
|
+
children: labels.clearAll
|
|
77
|
+
})]
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
init_FiltersMainRow();
|
|
85
|
+
export { FiltersMainRow, init_FiltersMainRow };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AnyObject } from '../types';
|
|
3
|
+
import type { UseFiltersParams, UseFiltersReturn } from './useFilters';
|
|
4
|
+
export type FiltersProviderProps<V extends AnyObject = AnyObject> = UseFiltersParams<V> & {
|
|
5
|
+
onDrawerOpen?: (values: V) => void;
|
|
6
|
+
};
|
|
7
|
+
export type FiltersContextValue<V extends AnyObject = AnyObject> = {
|
|
8
|
+
filters: UseFiltersReturn<V>;
|
|
9
|
+
isDrawerOpen: boolean;
|
|
10
|
+
openDrawer: () => void;
|
|
11
|
+
closeDrawer: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const FiltersProvider: <V extends AnyObject = AnyObject>({ children, defaultValues: initialDefaultValues, initialValues, onChange, onSubmit, onDrawerOpen, }: FiltersProviderProps<V> & {
|
|
14
|
+
children: ReactNode | ((ctx: FiltersContextValue<V>) => ReactNode);
|
|
15
|
+
}) => import("react").JSX.Element;
|
|
16
|
+
export declare const useFiltersContext: <V extends AnyObject>() => FiltersContextValue<V>;
|
|
17
|
+
//# sourceMappingURL=FiltersProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersProvider.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/FiltersProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEtE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IACxF,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACjE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC5B,YAAY,EAAE,OAAO,CAAA;IACrB,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,uGAO5D,oBAAoB,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAA;CAAE,gCA6BlG,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,SAAS,OAAK,mBAAmB,CAAC,CAAC,CAM9E,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_useFilters, useFilters } from "./useFilters.js";
|
|
3
|
+
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/compositions/Filters/parts/FiltersProvider.tsx
|
|
7
|
+
var FiltersContext, FiltersProvider, useFiltersContext;
|
|
8
|
+
var init_FiltersProvider = __esmMin(() => {
|
|
9
|
+
init_useFilters();
|
|
10
|
+
FiltersContext = createContext(null);
|
|
11
|
+
FiltersProvider = ({ children, defaultValues: initialDefaultValues, initialValues, onChange, onSubmit, onDrawerOpen }) => {
|
|
12
|
+
const filters = useFilters({
|
|
13
|
+
initialValues,
|
|
14
|
+
defaultValues: initialDefaultValues,
|
|
15
|
+
onChange,
|
|
16
|
+
onSubmit
|
|
17
|
+
});
|
|
18
|
+
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
19
|
+
const openDrawer = useCallback(() => {
|
|
20
|
+
setIsDrawerOpen(true);
|
|
21
|
+
onDrawerOpen === null || onDrawerOpen === void 0 || onDrawerOpen(filters.values);
|
|
22
|
+
}, [
|
|
23
|
+
onDrawerOpen,
|
|
24
|
+
setIsDrawerOpen,
|
|
25
|
+
filters.values
|
|
26
|
+
]);
|
|
27
|
+
const closeDrawer = useCallback(() => {
|
|
28
|
+
setIsDrawerOpen(false);
|
|
29
|
+
}, [setIsDrawerOpen]);
|
|
30
|
+
const value = useMemo(() => ({
|
|
31
|
+
filters,
|
|
32
|
+
isDrawerOpen,
|
|
33
|
+
openDrawer,
|
|
34
|
+
closeDrawer
|
|
35
|
+
}), [
|
|
36
|
+
filters,
|
|
37
|
+
isDrawerOpen,
|
|
38
|
+
openDrawer,
|
|
39
|
+
closeDrawer
|
|
40
|
+
]);
|
|
41
|
+
return /* @__PURE__ */ jsx(FiltersContext.Provider, {
|
|
42
|
+
value,
|
|
43
|
+
children: typeof children === "function" ? children(value) : children
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
useFiltersContext = () => {
|
|
47
|
+
const context = useContext(FiltersContext);
|
|
48
|
+
if (!context) throw new Error("useFiltersContext must be used within a FiltersProvider");
|
|
49
|
+
return context;
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
init_FiltersProvider();
|
|
55
|
+
export { FiltersProvider, init_FiltersProvider, useFiltersContext };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyObject, FilterConfig, FilterConfigGroup } from '../types';
|
|
2
|
+
export declare const isFilterConfigGroup: <V extends AnyObject>(item: FilterConfig<V>) => item is FilterConfigGroup<V>;
|
|
3
|
+
export declare const getKeysWithDifferentValues: <Values extends AnyObject>(a?: Values, b?: Values) => (keyof Values)[];
|
|
4
|
+
export declare const isSameValues: <Values extends AnyObject>(a?: Values, b?: Values) => boolean;
|
|
5
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/compositions/Filters/parts/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE1E,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,KAAG,IAAI,IAAI,iBAAiB,CAAC,CAAC,CACrF,CAAA;AAEvB,eAAO,MAAM,0BAA0B,GAAI,MAAM,SAAS,SAAS,MAAM,MAAM,MAAM,MAAM,KAAG,CAAC,MAAM,MAAM,CAAC,EAgD3G,CAAA;AAID,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,SAAS,MAAM,MAAM,MAAM,MAAM,YAa5E,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __esmMin, __name } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/compositions/Filters/parts/helpers.ts
|
|
4
|
+
var isFilterConfigGroup, getKeysWithDifferentValues, isSameValues;
|
|
5
|
+
var init_helpers = __esmMin(() => {
|
|
6
|
+
isFilterConfigGroup = (item) => item.type === "group";
|
|
7
|
+
getKeysWithDifferentValues = (a, b) => {
|
|
8
|
+
if (a === b) return [];
|
|
9
|
+
if (!a || !b) return [];
|
|
10
|
+
const keysA = Object.keys(a);
|
|
11
|
+
const keysB = Object.keys(b);
|
|
12
|
+
return keysA.filter((_, i) => {
|
|
13
|
+
const keyA = keysA[i];
|
|
14
|
+
const keyB = keysB[i];
|
|
15
|
+
if (!Object.hasOwn(b, keyA)) return true;
|
|
16
|
+
if (!Object.hasOwn(a, keyB)) return true;
|
|
17
|
+
const valueA = a[keyA];
|
|
18
|
+
const valueB = b[keyA];
|
|
19
|
+
if (valueA === valueB) return false;
|
|
20
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
21
|
+
if (valueA.length !== valueB.length) return true;
|
|
22
|
+
if (valueA.length === 2 && valueB.length === 2 && (valueA[0] !== valueB[0] || valueA[1] !== valueB[1])) return true;
|
|
23
|
+
return !valueA.every((aValueInValueA) => valueB.includes(aValueInValueA));
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
isSameValues = (a, b) => {
|
|
29
|
+
if (a === b) return true;
|
|
30
|
+
if (!a || !b) return false;
|
|
31
|
+
if (Object.keys(a).length !== Object.keys(b).length) return false;
|
|
32
|
+
return getKeysWithDifferentValues(a, b).length === 0;
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
init_helpers();
|
|
38
|
+
export { getKeysWithDifferentValues, init_helpers, isFilterConfigGroup, isSameValues };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AnyObject } from '../types';
|
|
2
|
+
export type FiltersState<V extends AnyObject> = {
|
|
3
|
+
values: V;
|
|
4
|
+
lastSubmittedValues: V;
|
|
5
|
+
defaultValues: V;
|
|
6
|
+
};
|
|
7
|
+
export type FiltersAction<V extends AnyObject> = {
|
|
8
|
+
type: 'SET_VALUE';
|
|
9
|
+
payload: {
|
|
10
|
+
name: keyof V;
|
|
11
|
+
value: unknown;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
type: 'SET_VALUES';
|
|
15
|
+
payload: {
|
|
16
|
+
values: Partial<V>;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
type: 'RESET_FIELD';
|
|
20
|
+
payload: {
|
|
21
|
+
name: keyof V;
|
|
22
|
+
defaultValue?: V[keyof V];
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
type: 'RESET_FIELDS';
|
|
26
|
+
payload: {
|
|
27
|
+
names: (keyof V)[];
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
type: 'RESET';
|
|
31
|
+
payload: {
|
|
32
|
+
values?: Partial<V>;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
type: 'SUBMIT';
|
|
36
|
+
} | {
|
|
37
|
+
type: 'DISCARD';
|
|
38
|
+
};
|
|
39
|
+
export declare const filtersReducer: <V extends AnyObject>(state: FiltersState<V>, action: FiltersAction<V>) => FiltersState<V>;
|
|
40
|
+
//# sourceMappingURL=reducer.d.ts.map
|