@elliemae/ds-data-table 3.60.0-next.33 → 3.60.0-next.35
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/cjs/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.js +173 -0
- package/dist/cjs/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.js +138 -0
- package/dist/cjs/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.js +177 -0
- package/dist/cjs/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.js +161 -0
- package/dist/cjs/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/NumberRangeFilter/NumberRangeFilterV2.js +181 -0
- package/dist/cjs/addons/Filters/Components/NumberRangeFilter/NumberRangeFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js +202 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/MultiCreatableFilterV2.js +68 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/MultiCreatableFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/MultiSelectFilterV2.js +67 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/MultiSelectFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/SingleCreatableFilterV2.js +67 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/SingleCreatableFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/SingleSelectFilterV2.js +66 -0
- package/dist/cjs/addons/Filters/Components/SelectFilter/SingleSelectFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/SingleDateFilter/SingleDateFilterV2.js +118 -0
- package/dist/cjs/addons/Filters/Components/SingleDateFilter/SingleDateFilterV2.js.map +7 -0
- package/dist/cjs/addons/Filters/Components/index.js +26 -0
- package/dist/cjs/addons/Filters/Components/index.js.map +2 -2
- package/dist/cjs/constants/index.js +2 -1
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/exported-related/FilterPopover/FilterPopoverV2.js +158 -0
- package/dist/cjs/exported-related/FilterPopover/FilterPopoverV2.js.map +7 -0
- package/dist/cjs/exported-related/FilterPopover/styled.js +62 -0
- package/dist/cjs/exported-related/FilterPopover/styled.js.map +7 -0
- package/dist/cjs/exported-related/FilterPopover/types.js.map +1 -1
- package/dist/cjs/exported-related/FilterPopover/useGetFilterHandlers.js.map +1 -1
- package/dist/cjs/exported-related/FilterPopover/useOnClickOutside.js +60 -0
- package/dist/cjs/exported-related/FilterPopover/useOnClickOutside.js.map +7 -0
- package/dist/cjs/exported-related/FilterTypes.js +11 -1
- package/dist/cjs/exported-related/FilterTypes.js.map +2 -2
- package/dist/cjs/parts/FilterBar/FiltersBar.js +9 -1
- package/dist/cjs/parts/FilterBar/FiltersBar.js.map +2 -2
- package/dist/cjs/parts/Filters/index.js +11 -1
- package/dist/cjs/parts/Filters/index.js.map +2 -2
- package/dist/esm/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.js +143 -0
- package/dist/esm/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.js +108 -0
- package/dist/esm/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.js +147 -0
- package/dist/esm/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.js +131 -0
- package/dist/esm/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/NumberRangeFilter/NumberRangeFilterV2.js +151 -0
- package/dist/esm/addons/Filters/Components/NumberRangeFilter/NumberRangeFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js +172 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/MultiCreatableFilterV2.js +38 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/MultiCreatableFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/MultiSelectFilterV2.js +37 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/MultiSelectFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/SingleCreatableFilterV2.js +37 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/SingleCreatableFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/SingleSelectFilterV2.js +36 -0
- package/dist/esm/addons/Filters/Components/SelectFilter/SingleSelectFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/SingleDateFilter/SingleDateFilterV2.js +88 -0
- package/dist/esm/addons/Filters/Components/SingleDateFilter/SingleDateFilterV2.js.map +7 -0
- package/dist/esm/addons/Filters/Components/index.js +22 -0
- package/dist/esm/addons/Filters/Components/index.js.map +2 -2
- package/dist/esm/constants/index.js +2 -1
- package/dist/esm/constants/index.js.map +2 -2
- package/dist/esm/exported-related/FilterPopover/FilterPopoverV2.js +128 -0
- package/dist/esm/exported-related/FilterPopover/FilterPopoverV2.js.map +7 -0
- package/dist/esm/exported-related/FilterPopover/styled.js +32 -0
- package/dist/esm/exported-related/FilterPopover/styled.js.map +7 -0
- package/dist/esm/exported-related/FilterPopover/useGetFilterHandlers.js.map +1 -1
- package/dist/esm/exported-related/FilterPopover/useOnClickOutside.js +30 -0
- package/dist/esm/exported-related/FilterPopover/useOnClickOutside.js.map +7 -0
- package/dist/esm/exported-related/FilterTypes.js +11 -1
- package/dist/esm/exported-related/FilterTypes.js.map +2 -2
- package/dist/esm/parts/FilterBar/FiltersBar.js +9 -1
- package/dist/esm/parts/FilterBar/FiltersBar.js.map +2 -2
- package/dist/esm/parts/Filters/index.js +22 -2
- package/dist/esm/parts/Filters/index.js.map +2 -2
- package/dist/types/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.d.ts +8 -0
- package/dist/types/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.d.ts +8 -0
- package/dist/types/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.d.ts +9 -0
- package/dist/types/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.d.ts +3 -0
- package/dist/types/addons/Filters/Components/NumberRangeFilter/NumberRangeFilterV2.d.ts +8 -0
- package/dist/types/addons/Filters/Components/SelectFilter/BaseSelectFilterV2.d.ts +11 -0
- package/dist/types/addons/Filters/Components/SelectFilter/MultiCreatableFilterV2.d.ts +6 -0
- package/dist/types/addons/Filters/Components/SelectFilter/MultiSelectFilterV2.d.ts +6 -0
- package/dist/types/addons/Filters/Components/SelectFilter/SingleCreatableFilterV2.d.ts +6 -0
- package/dist/types/addons/Filters/Components/SelectFilter/SingleSelectFilterV2.d.ts +6 -0
- package/dist/types/addons/Filters/Components/SingleDateFilter/SingleDateFilterV2.d.ts +5 -0
- package/dist/types/addons/Filters/Components/index.d.ts +10 -0
- package/dist/types/constants/index.d.ts +4 -0
- package/dist/types/exported-related/FilterPopover/FilterPopoverV2.d.ts +3 -0
- package/dist/types/exported-related/FilterPopover/styled.d.ts +6 -0
- package/dist/types/exported-related/FilterPopover/types.d.ts +16 -0
- package/dist/types/exported-related/FilterPopover/useGetFilterHandlers.d.ts +2 -2
- package/dist/types/exported-related/FilterPopover/useOnClickOutside.d.ts +1 -0
- package/dist/types/exported-related/FilterTypes.d.ts +10 -0
- package/package.json +30 -29
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useEffect, useCallback, useState } from "react";
|
|
4
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
5
|
+
import { DSInputText } from "@elliemae/ds-form-input-text";
|
|
6
|
+
import { getNumberMaskedValue, useNumberMask } from "@elliemae/ds-form-helpers-mask-hooks";
|
|
7
|
+
import { DSFormLayoutBlockItem } from "@elliemae/ds-form-layout-blocks";
|
|
8
|
+
import { SearchXsmall } from "@elliemae/ds-icons";
|
|
9
|
+
import { uid } from "uid";
|
|
10
|
+
import { FILTER_TYPES } from "../../../../exported-related/index.js";
|
|
11
|
+
import { DATA_TESTID } from "../../../../configs/constants.js";
|
|
12
|
+
import { FilterPopoverV2 } from "../../../../exported-related/FilterPopover/FilterPopoverV2.js";
|
|
13
|
+
const opts = {
|
|
14
|
+
includeThousandsSeparator: false,
|
|
15
|
+
decimalPlaces: 2,
|
|
16
|
+
decimalRequired: true
|
|
17
|
+
};
|
|
18
|
+
const idPreffix = "datatable-currency-range";
|
|
19
|
+
const CurrencyRangeFilterV2 = (props) => {
|
|
20
|
+
const {
|
|
21
|
+
column,
|
|
22
|
+
referenceColumn,
|
|
23
|
+
filterValue = { from: null, to: null },
|
|
24
|
+
reduxHeader,
|
|
25
|
+
patchHeader,
|
|
26
|
+
onValueChange,
|
|
27
|
+
innerRef,
|
|
28
|
+
domIdAffix = uid(4)
|
|
29
|
+
} = props;
|
|
30
|
+
const [from, setFrom] = useState(getNumberMaskedValue(filterValue.from ?? "", opts));
|
|
31
|
+
const [to, setTo] = useState(getNumberMaskedValue(filterValue.to ?? "", opts));
|
|
32
|
+
const ref = useRef(null);
|
|
33
|
+
const shouldFocus = useRef(true);
|
|
34
|
+
const fromInputProps = useNumberMask({
|
|
35
|
+
valueSetter: setFrom,
|
|
36
|
+
...opts
|
|
37
|
+
});
|
|
38
|
+
const toInputProps = useNumberMask({
|
|
39
|
+
valueSetter: setTo,
|
|
40
|
+
...opts
|
|
41
|
+
});
|
|
42
|
+
const handleOnKeyDown = useCallback(
|
|
43
|
+
(e) => {
|
|
44
|
+
if (e.code === "Escape") {
|
|
45
|
+
patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });
|
|
46
|
+
innerRef.current?.focus();
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[column.id, innerRef, patchHeader]
|
|
50
|
+
);
|
|
51
|
+
const handleRef = useCallback(
|
|
52
|
+
(newRef) => {
|
|
53
|
+
ref.current = newRef;
|
|
54
|
+
if (shouldFocus.current) {
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
newRef?.focus();
|
|
57
|
+
shouldFocus.current = false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
[shouldFocus]
|
|
62
|
+
);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (reduxHeader?.hideFilterMenu) {
|
|
65
|
+
shouldFocus.current = true;
|
|
66
|
+
setFrom(getNumberMaskedValue(filterValue.from ?? "", opts));
|
|
67
|
+
setTo(getNumberMaskedValue(filterValue.to ?? "", opts));
|
|
68
|
+
}
|
|
69
|
+
}, [filterValue.from, filterValue.to, reduxHeader?.hideFilterMenu]);
|
|
70
|
+
const handleSubmit = useCallback(
|
|
71
|
+
(e) => {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
if (!from || !to) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
onValueChange(FILTER_TYPES.CURRENCY_RANGE_V2, { from: from ?? "", to: to ?? "" });
|
|
77
|
+
patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });
|
|
78
|
+
innerRef.current?.focus();
|
|
79
|
+
},
|
|
80
|
+
[column.id, from, to, innerRef, onValueChange, patchHeader]
|
|
81
|
+
);
|
|
82
|
+
const handleReset = useCallback(() => {
|
|
83
|
+
setFrom("");
|
|
84
|
+
setTo("");
|
|
85
|
+
onValueChange(FILTER_TYPES.CURRENCY_RANGE_V2, void 0);
|
|
86
|
+
patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });
|
|
87
|
+
innerRef.current?.focus();
|
|
88
|
+
}, [column.id, innerRef, onValueChange, patchHeader]);
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
FilterPopoverV2,
|
|
91
|
+
{
|
|
92
|
+
onFilterSubmit: handleSubmit,
|
|
93
|
+
onFilterReset: handleReset,
|
|
94
|
+
firstElementRef: ref,
|
|
95
|
+
reduxHeader,
|
|
96
|
+
column,
|
|
97
|
+
columnReference: referenceColumn,
|
|
98
|
+
columnId: column.id,
|
|
99
|
+
menuContent: /* @__PURE__ */ jsxs(
|
|
100
|
+
Grid,
|
|
101
|
+
{
|
|
102
|
+
"data-testid": DATA_TESTID.DATA_TABLE_CURRENCY_RANGE_CONTROLLER,
|
|
103
|
+
gutter: "xxxs",
|
|
104
|
+
padding: "xxs",
|
|
105
|
+
cols: ["auto", "auto"],
|
|
106
|
+
style: { background: "white" },
|
|
107
|
+
onKeyDown: handleOnKeyDown,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(DSFormLayoutBlockItem, { label: "Min", inputID: `${idPreffix}-min-${column.id}-${domIdAffix}`, children: /* @__PURE__ */ jsx(
|
|
110
|
+
DSInputText,
|
|
111
|
+
{
|
|
112
|
+
value: from,
|
|
113
|
+
...fromInputProps,
|
|
114
|
+
id: `${idPreffix}-min-${column.id}-${domIdAffix}`,
|
|
115
|
+
style: { textAlign: "right" },
|
|
116
|
+
placeholder: "0.00",
|
|
117
|
+
innerRef: handleRef
|
|
118
|
+
}
|
|
119
|
+
) }),
|
|
120
|
+
/* @__PURE__ */ jsx(DSFormLayoutBlockItem, { label: "Max", inputID: `${idPreffix}-max-${column.id}-${domIdAffix}`, children: /* @__PURE__ */ jsx(
|
|
121
|
+
DSInputText,
|
|
122
|
+
{
|
|
123
|
+
value: to,
|
|
124
|
+
...toInputProps,
|
|
125
|
+
id: `${idPreffix}-max-${column.id}s-${domIdAffix}`,
|
|
126
|
+
style: { textAlign: "right" },
|
|
127
|
+
placeholder: "0.00"
|
|
128
|
+
}
|
|
129
|
+
) })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
triggerIcon: /* @__PURE__ */ jsx(SearchXsmall, {}),
|
|
134
|
+
customStyles: { width: referenceColumn?.offsetWidth },
|
|
135
|
+
innerRef,
|
|
136
|
+
ariaLabel: "Open Currency Range Filter"
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
export {
|
|
141
|
+
CurrencyRangeFilterV2
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=CurrencyRangeFilterV2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/CurrencyRangeFilter/CurrencyRangeFilterV2.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef, useEffect, useCallback, useState } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSInputText } from '@elliemae/ds-form-input-text';\nimport { getNumberMaskedValue, useNumberMask } from '@elliemae/ds-form-helpers-mask-hooks';\nimport { DSFormLayoutBlockItem } from '@elliemae/ds-form-layout-blocks';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { uid } from 'uid';\nimport { FILTER_TYPES } from '../../../../exported-related/index.js';\nimport type { DSDataTableT } from '../../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../../configs/constants.js';\nimport { FilterPopoverV2 } from '../../../../exported-related/FilterPopover/FilterPopoverV2.js';\n\nconst opts = {\n includeThousandsSeparator: false,\n decimalPlaces: 2,\n decimalRequired: true,\n};\n\nconst idPreffix = 'datatable-currency-range';\n\ninterface CurrentRangeFilterValue {\n from: string | null;\n to: string | null;\n}\n\nexport const CurrencyRangeFilterV2: React.ComponentType<DSDataTableT.FilterProps<CurrentRangeFilterValue>> = (\n props,\n) => {\n const {\n column,\n referenceColumn,\n filterValue = { from: null, to: null },\n reduxHeader,\n patchHeader,\n onValueChange,\n innerRef,\n domIdAffix = uid(4),\n } = props;\n\n const [from, setFrom] = useState(getNumberMaskedValue(filterValue.from ?? '', opts));\n const [to, setTo] = useState(getNumberMaskedValue(filterValue.to ?? '', opts));\n\n const ref = useRef<HTMLInputElement | null>(null);\n const shouldFocus = useRef(true);\n\n const fromInputProps = useNumberMask({\n valueSetter: setFrom,\n ...opts,\n });\n\n const toInputProps = useNumberMask({\n valueSetter: setTo,\n ...opts,\n });\n\n const handleOnKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.code === 'Escape') {\n patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });\n innerRef.current?.focus();\n }\n },\n [column.id, innerRef, patchHeader],\n );\n\n const handleRef = useCallback(\n (newRef: HTMLInputElement | null) => {\n ref.current = newRef;\n if (shouldFocus.current) {\n setTimeout(() => {\n newRef?.focus();\n shouldFocus.current = false;\n });\n }\n },\n [shouldFocus],\n );\n\n useEffect(() => {\n if (reduxHeader?.hideFilterMenu) {\n shouldFocus.current = true;\n // menu closed without applying: discard draft and sync with applied filter\n setFrom(getNumberMaskedValue(filterValue.from ?? '', opts));\n setTo(getNumberMaskedValue(filterValue.to ?? '', opts));\n }\n }, [filterValue.from, filterValue.to, reduxHeader?.hideFilterMenu]);\n\n const handleSubmit = useCallback(\n (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (!from || !to) {\n return;\n }\n\n onValueChange(FILTER_TYPES.CURRENCY_RANGE_V2, { from: from ?? '', to: to ?? '' });\n patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });\n innerRef.current?.focus();\n },\n [column.id, from, to, innerRef, onValueChange, patchHeader],\n );\n\n const handleReset = useCallback(() => {\n setFrom('');\n setTo('');\n onValueChange(FILTER_TYPES.CURRENCY_RANGE_V2, undefined);\n patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });\n innerRef.current?.focus();\n }, [column.id, innerRef, onValueChange, patchHeader]);\n\n return (\n <FilterPopoverV2\n onFilterSubmit={handleSubmit}\n onFilterReset={handleReset}\n firstElementRef={ref}\n reduxHeader={reduxHeader}\n column={column}\n columnReference={referenceColumn}\n columnId={column.id}\n menuContent={\n <Grid\n data-testid={DATA_TESTID.DATA_TABLE_CURRENCY_RANGE_CONTROLLER}\n gutter=\"xxxs\"\n padding=\"xxs\"\n cols={['auto', 'auto']}\n style={{ background: 'white' }}\n onKeyDown={handleOnKeyDown}\n >\n <DSFormLayoutBlockItem label=\"Min\" inputID={`${idPreffix}-min-${column.id}-${domIdAffix}`}>\n <DSInputText\n value={from}\n {...fromInputProps}\n id={`${idPreffix}-min-${column.id}-${domIdAffix}`}\n style={{ textAlign: 'right' }}\n placeholder=\"0.00\"\n innerRef={handleRef}\n />\n </DSFormLayoutBlockItem>\n <DSFormLayoutBlockItem label=\"Max\" inputID={`${idPreffix}-max-${column.id}-${domIdAffix}`}>\n <DSInputText\n value={to}\n {...toInputProps}\n id={`${idPreffix}-max-${column.id}s-${domIdAffix}`}\n style={{ textAlign: 'right' }}\n placeholder=\"0.00\"\n />\n </DSFormLayoutBlockItem>\n </Grid>\n }\n triggerIcon={<SearchXsmall />}\n customStyles={{ width: referenceColumn?.offsetWidth }}\n innerRef={innerRef}\n ariaLabel=\"Open Currency Range Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACuHf,SASI,KATJ;AAvHR,SAAgB,QAAQ,WAAW,aAAa,gBAAgB;AAChE,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,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YAAY,QAAQ;AAAA,UAC7B,WAAW;AAAA,UAEX;AAAA,gCAAC,yBAAsB,OAAM,OAAM,SAAS,GAAG,SAAS,QAAQ,OAAO,EAAE,IAAI,UAAU,IACrF;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACN,GAAG;AAAA,gBACJ,IAAI,GAAG,SAAS,QAAQ,OAAO,EAAE,IAAI,UAAU;AAAA,gBAC/C,OAAO,EAAE,WAAW,QAAQ;AAAA,gBAC5B,aAAY;AAAA,gBACZ,UAAU;AAAA;AAAA,YACZ,GACF;AAAA,YACA,oBAAC,yBAAsB,OAAM,OAAM,SAAS,GAAG,SAAS,QAAQ,OAAO,EAAE,IAAI,UAAU,IACrF;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACN,GAAG;AAAA,gBACJ,IAAI,GAAG,SAAS,QAAQ,OAAO,EAAE,KAAK,UAAU;AAAA,gBAChD,OAAO,EAAE,WAAW,QAAQ;AAAA,gBAC5B,aAAY;AAAA;AAAA,YACd,GACF;AAAA;AAAA;AAAA,MACF;AAAA,MAEF,aAAa,oBAAC,gBAAa;AAAA,MAC3B,cAAc,EAAE,OAAO,iBAAiB,YAAY;AAAA,MACpD;AAAA,MACA,WAAU;AAAA;AAAA,EACZ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useCallback, useRef, useState } from "react";
|
|
4
|
+
import { DatePicker2 } from "@elliemae/ds-icons";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
import { DSControlledDateRangePicker } from "@elliemae/ds-form-date-range-picker";
|
|
7
|
+
import { FILTER_TYPES } from "../../../../exported-related/index.js";
|
|
8
|
+
import { FilterPopoverV2 } from "../../../../exported-related/FilterPopover/FilterPopoverV2.js";
|
|
9
|
+
import { DATA_TESTID } from "../../../../configs/constants.js";
|
|
10
|
+
const emptyFilterValue = { startDate: null, endDate: null };
|
|
11
|
+
const DateRangeFilterV2 = (props) => {
|
|
12
|
+
const {
|
|
13
|
+
column,
|
|
14
|
+
column: { id },
|
|
15
|
+
referenceColumn,
|
|
16
|
+
filterValue = emptyFilterValue,
|
|
17
|
+
onValueChange,
|
|
18
|
+
patchHeaderFilterButtonAndMenu,
|
|
19
|
+
reduxHeader,
|
|
20
|
+
innerRef
|
|
21
|
+
} = props;
|
|
22
|
+
const dateRange = filterValue;
|
|
23
|
+
const [startDate, setStartDate] = useState(dateRange.startDate || "");
|
|
24
|
+
const [endDate, setEndDate] = useState(dateRange.endDate || "");
|
|
25
|
+
const ref = useRef(null);
|
|
26
|
+
const lastElementRef = useRef(null);
|
|
27
|
+
const shouldFocus = useRef(true);
|
|
28
|
+
const handleRef = useCallback((newRef) => {
|
|
29
|
+
ref.current = newRef;
|
|
30
|
+
if (shouldFocus.current) {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
newRef?.focus();
|
|
33
|
+
shouldFocus.current = false;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (reduxHeader?.hideFilterMenu) {
|
|
39
|
+
shouldFocus.current = true;
|
|
40
|
+
setStartDate(dateRange.startDate || "");
|
|
41
|
+
setEndDate(dateRange.endDate || "");
|
|
42
|
+
}
|
|
43
|
+
}, [dateRange.endDate, dateRange.startDate, reduxHeader?.hideFilterMenu]);
|
|
44
|
+
const handleSubmit = useCallback(
|
|
45
|
+
(e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const hasValidRange = startDate && endDate && !startDate.includes("_") && !endDate.includes("_");
|
|
48
|
+
if (hasValidRange) {
|
|
49
|
+
onValueChange(FILTER_TYPES.DATE_RANGE_V2, { startDate, endDate });
|
|
50
|
+
} else {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
patchHeaderFilterButtonAndMenu(id, true);
|
|
54
|
+
innerRef.current?.focus();
|
|
55
|
+
},
|
|
56
|
+
[endDate, id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu, startDate]
|
|
57
|
+
);
|
|
58
|
+
const handleReset = useCallback(() => {
|
|
59
|
+
setStartDate("");
|
|
60
|
+
setEndDate("");
|
|
61
|
+
onValueChange(FILTER_TYPES.DATE_RANGE_V2, void 0);
|
|
62
|
+
patchHeaderFilterButtonAndMenu(id, true);
|
|
63
|
+
innerRef.current?.focus();
|
|
64
|
+
}, [id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu]);
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
FilterPopoverV2,
|
|
67
|
+
{
|
|
68
|
+
onFilterSubmit: handleSubmit,
|
|
69
|
+
onFilterReset: handleReset,
|
|
70
|
+
firstElementRef: ref,
|
|
71
|
+
reduxHeader,
|
|
72
|
+
column,
|
|
73
|
+
columnReference: referenceColumn,
|
|
74
|
+
columnId: id,
|
|
75
|
+
menuContent: /* @__PURE__ */ jsxs(Grid, { width: "260px", "data-testid": DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER, children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Grid, { p: "xxs", style: { background: "white" }, children: /* @__PURE__ */ jsx(
|
|
77
|
+
DSControlledDateRangePicker,
|
|
78
|
+
{
|
|
79
|
+
fromDate: startDate,
|
|
80
|
+
onFromDateChange: setStartDate,
|
|
81
|
+
toDate: endDate,
|
|
82
|
+
onToDateChange: setEndDate,
|
|
83
|
+
type: "date-range-inputs",
|
|
84
|
+
innerRef: handleRef
|
|
85
|
+
}
|
|
86
|
+
) }),
|
|
87
|
+
/* @__PURE__ */ jsx(Grid, { children: /* @__PURE__ */ jsx(
|
|
88
|
+
DSControlledDateRangePicker,
|
|
89
|
+
{
|
|
90
|
+
fromDate: startDate,
|
|
91
|
+
onFromDateChange: setStartDate,
|
|
92
|
+
toDate: endDate,
|
|
93
|
+
onToDateChange: setEndDate,
|
|
94
|
+
type: "date-range-picker-controller-only",
|
|
95
|
+
lastElementRef
|
|
96
|
+
}
|
|
97
|
+
) })
|
|
98
|
+
] }),
|
|
99
|
+
triggerIcon: /* @__PURE__ */ jsx(DatePicker2, {}),
|
|
100
|
+
innerRef,
|
|
101
|
+
ariaLabel: "Open Date Range Filter"
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
DateRangeFilterV2
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=DateRangeFilterV2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/DateRangeFilter/DateRangeFilterV2.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useCallback, useRef, useState } from 'react';\nimport { DatePicker2 } from '@elliemae/ds-icons';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSControlledDateRangePicker } from '@elliemae/ds-form-date-range-picker';\nimport { FILTER_TYPES } from '../../../../exported-related/index.js';\nimport { FilterPopoverV2 } from '../../../../exported-related/FilterPopover/FilterPopoverV2.js';\nimport type { DSDataTableT } from '../../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../../configs/constants.js';\n\nconst emptyFilterValue = { startDate: null, endDate: null };\n\ninterface DateRangeFilterValue {\n startDate: string | null;\n endDate: string | null;\n}\n\nexport const DateRangeFilterV2: React.ComponentType<DSDataTableT.FilterProps<DateRangeFilterValue>> = (props) => {\n const {\n column,\n column: { id },\n referenceColumn,\n filterValue = emptyFilterValue,\n onValueChange,\n patchHeaderFilterButtonAndMenu,\n reduxHeader,\n innerRef,\n } = props;\n\n const dateRange = filterValue;\n\n const [startDate, setStartDate] = useState(dateRange.startDate || '');\n const [endDate, setEndDate] = useState(dateRange.endDate || '');\n\n const ref = useRef<HTMLInputElement | null>(null);\n const lastElementRef = useRef<HTMLElement | null>(null);\n const shouldFocus = useRef(true);\n const handleRef = useCallback((newRef: HTMLInputElement | HTMLButtonElement | null) => {\n ref.current = newRef as HTMLInputElement | null;\n if (shouldFocus.current) {\n setTimeout(() => {\n newRef?.focus();\n shouldFocus.current = false;\n });\n }\n }, []);\n\n useEffect(() => {\n if (reduxHeader?.hideFilterMenu) {\n shouldFocus.current = true;\n setStartDate(dateRange.startDate || '');\n setEndDate(dateRange.endDate || '');\n }\n }, [dateRange.endDate, dateRange.startDate, reduxHeader?.hideFilterMenu]);\n\n const handleSubmit = useCallback(\n (e: React.SyntheticEvent) => {\n e.preventDefault();\n\n const hasValidRange = startDate && endDate && !startDate.includes('_') && !endDate.includes('_');\n\n if (hasValidRange) {\n onValueChange(FILTER_TYPES.DATE_RANGE_V2, { startDate, endDate });\n } else {\n return;\n }\n\n patchHeaderFilterButtonAndMenu(id, true);\n innerRef.current?.focus();\n },\n [endDate, id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu, startDate],\n );\n\n const handleReset = useCallback(() => {\n setStartDate('');\n setEndDate('');\n onValueChange(FILTER_TYPES.DATE_RANGE_V2, undefined);\n patchHeaderFilterButtonAndMenu(id, true);\n innerRef.current?.focus();\n }, [id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu]);\n\n return (\n <FilterPopoverV2\n onFilterSubmit={handleSubmit}\n onFilterReset={handleReset}\n firstElementRef={ref}\n reduxHeader={reduxHeader}\n column={column}\n columnReference={referenceColumn}\n columnId={id}\n menuContent={\n <Grid width=\"260px\" data-testid={DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER}>\n <Grid p=\"xxs\" style={{ background: 'white' }}>\n <DSControlledDateRangePicker\n fromDate={startDate}\n onFromDateChange={setStartDate}\n toDate={endDate}\n onToDateChange={setEndDate}\n type=\"date-range-inputs\"\n innerRef={handleRef}\n />\n </Grid>\n <Grid>\n <DSControlledDateRangePicker\n fromDate={startDate}\n onFromDateChange={setStartDate}\n toDate={endDate}\n onToDateChange={setEndDate}\n type=\"date-range-picker-controller-only\"\n lastElementRef={lastElementRef}\n />\n </Grid>\n </Grid>\n }\n triggerIcon={<DatePicker2 />}\n innerRef={innerRef}\n ariaLabel=\"Open Date Range Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0Ff,SAEI,KAFJ;AA1FR,SAAgB,WAAW,aAAa,QAAQ,gBAAgB;AAChE,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,mCAAmC;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB;AAE5B,MAAM,mBAAmB,EAAE,WAAW,MAAM,SAAS,KAAK;AAOnD,MAAM,oBAAyF,CAAC,UAAU;AAC/G,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ,EAAE,GAAG;AAAA,IACb;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,YAAY;AAElB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,UAAU,aAAa,EAAE;AACpE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,UAAU,WAAW,EAAE;AAE9D,QAAM,MAAM,OAAgC,IAAI;AAChD,QAAM,iBAAiB,OAA2B,IAAI;AACtD,QAAM,cAAc,OAAO,IAAI;AAC/B,QAAM,YAAY,YAAY,CAAC,WAAwD;AACrF,QAAI,UAAU;AACd,QAAI,YAAY,SAAS;AACvB,iBAAW,MAAM;AACf,gBAAQ,MAAM;AACd,oBAAY,UAAU;AAAA,MACxB,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,QAAI,aAAa,gBAAgB;AAC/B,kBAAY,UAAU;AACtB,mBAAa,UAAU,aAAa,EAAE;AACtC,iBAAW,UAAU,WAAW,EAAE;AAAA,IACpC;AAAA,EAC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ACF;AAAA,SACF;AAAA,MAEF,aAAa,oBAAC,eAAY;AAAA,MAC1B;AAAA,MACA,WAAU;AAAA;AAAA,EACZ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useCallback, useState, useEffect } from "react";
|
|
4
|
+
import { DatePicker2 } from "@elliemae/ds-icons";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
import { DSControlledDateRangePicker } from "@elliemae/ds-form-date-range-picker";
|
|
7
|
+
import { DSControlledDateTimePicker } from "@elliemae/ds-form-date-time-picker";
|
|
8
|
+
import { DSControlledCheckbox } from "@elliemae/ds-form-checkbox";
|
|
9
|
+
import { uid } from "uid";
|
|
10
|
+
import { FILTER_TYPES } from "../../../../exported-related/index.js";
|
|
11
|
+
import { FilterPopoverV2 } from "../../../../exported-related/FilterPopover/FilterPopoverV2.js";
|
|
12
|
+
import { DATA_TESTID } from "../../../../configs/constants.js";
|
|
13
|
+
const emptyFilterValue = { startDate: null, endDate: null, isDateRange: false };
|
|
14
|
+
const DateSwitcherFilterV2 = (props) => {
|
|
15
|
+
const {
|
|
16
|
+
column,
|
|
17
|
+
column: { id },
|
|
18
|
+
referenceColumn,
|
|
19
|
+
filterValue = emptyFilterValue,
|
|
20
|
+
onValueChange,
|
|
21
|
+
patchHeaderFilterButtonAndMenu,
|
|
22
|
+
reduxHeader,
|
|
23
|
+
innerRef,
|
|
24
|
+
domIdAffix = uid(4)
|
|
25
|
+
} = props;
|
|
26
|
+
const ref = useRef(null);
|
|
27
|
+
const dateRange = filterValue;
|
|
28
|
+
const [startDate, setStartDate] = useState(dateRange.startDate || "");
|
|
29
|
+
const [endDate, setEndDate] = useState(dateRange.endDate || "");
|
|
30
|
+
const [isDateRange, setIsDateRange] = useState(dateRange.isDateRange || false);
|
|
31
|
+
const handleRef = useCallback(
|
|
32
|
+
(newRef) => {
|
|
33
|
+
ref.current = newRef;
|
|
34
|
+
if (!reduxHeader?.hideFilterMenu) {
|
|
35
|
+
setTimeout(() => newRef?.focus());
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[reduxHeader?.hideFilterMenu]
|
|
39
|
+
);
|
|
40
|
+
const handleSubmit = useCallback(
|
|
41
|
+
(e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
const hasValidRange = startDate && endDate && !startDate.includes("_") && !endDate.includes("_");
|
|
44
|
+
if (hasValidRange) {
|
|
45
|
+
onValueChange(FILTER_TYPES.DATE_SWITCHER, { startDate, endDate, isDateRange });
|
|
46
|
+
} else {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
patchHeaderFilterButtonAndMenu(id, true);
|
|
50
|
+
innerRef.current?.focus();
|
|
51
|
+
},
|
|
52
|
+
[endDate, id, innerRef, isDateRange, onValueChange, patchHeaderFilterButtonAndMenu, startDate]
|
|
53
|
+
);
|
|
54
|
+
const handleReset = useCallback(() => {
|
|
55
|
+
setStartDate("");
|
|
56
|
+
setEndDate("");
|
|
57
|
+
setIsDateRange(false);
|
|
58
|
+
onValueChange(FILTER_TYPES.DATE_SWITCHER, void 0);
|
|
59
|
+
patchHeaderFilterButtonAndMenu(id, true);
|
|
60
|
+
innerRef.current?.focus();
|
|
61
|
+
}, [id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (reduxHeader?.hideFilterMenu) {
|
|
64
|
+
setStartDate(dateRange.startDate || "");
|
|
65
|
+
setEndDate(dateRange.endDate || "");
|
|
66
|
+
setIsDateRange(dateRange.isDateRange || false);
|
|
67
|
+
}
|
|
68
|
+
}, [dateRange.endDate, dateRange.isDateRange, dateRange.startDate, reduxHeader?.hideFilterMenu]);
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
FilterPopoverV2,
|
|
71
|
+
{
|
|
72
|
+
onFilterSubmit: handleSubmit,
|
|
73
|
+
onFilterReset: handleReset,
|
|
74
|
+
firstElementRef: ref,
|
|
75
|
+
reduxHeader,
|
|
76
|
+
column,
|
|
77
|
+
columnReference: referenceColumn,
|
|
78
|
+
columnId: id,
|
|
79
|
+
menuContent: /* @__PURE__ */ jsxs(Grid, { width: "260px", "data-testid": DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER, children: [
|
|
80
|
+
/* @__PURE__ */ jsxs(Grid, { p: "xxs", gutter: "xxs", style: { background: "white" }, children: [
|
|
81
|
+
/* @__PURE__ */ jsx("div", { "data-testid": DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER_CHECKBOX_SWITCHER, children: /* @__PURE__ */ jsx(
|
|
82
|
+
DSControlledCheckbox,
|
|
83
|
+
{
|
|
84
|
+
checked: isDateRange,
|
|
85
|
+
name: "Date range",
|
|
86
|
+
label: "Date Range",
|
|
87
|
+
id: `date-range-switcher-id-internal-${domIdAffix}`,
|
|
88
|
+
onChange: () => {
|
|
89
|
+
setIsDateRange(!isDateRange);
|
|
90
|
+
setStartDate("");
|
|
91
|
+
setEndDate("");
|
|
92
|
+
},
|
|
93
|
+
innerRef: handleRef
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
isDateRange ? /* @__PURE__ */ jsx(
|
|
97
|
+
DSControlledDateRangePicker,
|
|
98
|
+
{
|
|
99
|
+
fromDate: startDate,
|
|
100
|
+
onFromDateChange: setStartDate,
|
|
101
|
+
toDate: endDate,
|
|
102
|
+
onToDateChange: setEndDate,
|
|
103
|
+
type: "date-range-inputs"
|
|
104
|
+
}
|
|
105
|
+
) : /* @__PURE__ */ jsx(
|
|
106
|
+
DSControlledDateTimePicker,
|
|
107
|
+
{
|
|
108
|
+
date: startDate,
|
|
109
|
+
onDateChange: (_date) => {
|
|
110
|
+
setStartDate(_date);
|
|
111
|
+
setEndDate(_date);
|
|
112
|
+
},
|
|
113
|
+
type: "date-inputs"
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx(Grid, { children: isDateRange ? /* @__PURE__ */ jsx(
|
|
118
|
+
DSControlledDateRangePicker,
|
|
119
|
+
{
|
|
120
|
+
fromDate: startDate,
|
|
121
|
+
onFromDateChange: setStartDate,
|
|
122
|
+
toDate: endDate,
|
|
123
|
+
onToDateChange: setEndDate,
|
|
124
|
+
type: "date-range-picker-controller-only"
|
|
125
|
+
}
|
|
126
|
+
) : /* @__PURE__ */ jsx(
|
|
127
|
+
DSControlledDateTimePicker,
|
|
128
|
+
{
|
|
129
|
+
date: startDate,
|
|
130
|
+
onDateChange: (_date) => {
|
|
131
|
+
setStartDate(_date);
|
|
132
|
+
setEndDate(_date);
|
|
133
|
+
},
|
|
134
|
+
type: "date-picker-controller-only"
|
|
135
|
+
}
|
|
136
|
+
) })
|
|
137
|
+
] }),
|
|
138
|
+
triggerIcon: /* @__PURE__ */ jsx(DatePicker2, {}),
|
|
139
|
+
innerRef,
|
|
140
|
+
ariaLabel: "Open Date Range Filter"
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
export {
|
|
145
|
+
DateSwitcherFilterV2
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=DateSwitcherFilterV2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/DateSwitcherFilter/DateSwitcherFilterV2.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef, useCallback, useState, useEffect } from 'react';\nimport { DatePicker2 } from '@elliemae/ds-icons';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSControlledDateRangePicker } from '@elliemae/ds-form-date-range-picker';\nimport { DSControlledDateTimePicker } from '@elliemae/ds-form-date-time-picker';\nimport { DSControlledCheckbox } from '@elliemae/ds-form-checkbox';\nimport { uid } from 'uid';\nimport { FILTER_TYPES } from '../../../../exported-related/index.js';\nimport { FilterPopoverV2 } from '../../../../exported-related/FilterPopover/FilterPopoverV2.js';\nimport type { DSDataTableT } from '../../../../react-desc-prop-types.js';\nimport { DATA_TESTID } from '../../../../configs/constants.js';\n\nconst emptyFilterValue = { startDate: null, endDate: null, isDateRange: false };\n\ninterface DateSwitcherFilterValue {\n startDate: string | null;\n endDate: string | null;\n isDateRange: boolean;\n}\n\nexport const DateSwitcherFilterV2: React.ComponentType<DSDataTableT.FilterProps<DateSwitcherFilterValue>> = (props) => {\n const {\n column,\n column: { id },\n referenceColumn,\n filterValue = emptyFilterValue,\n onValueChange,\n patchHeaderFilterButtonAndMenu,\n reduxHeader,\n innerRef,\n domIdAffix = uid(4),\n } = props;\n\n const ref = useRef<HTMLInputElement | null>(null);\n const dateRange = filterValue;\n\n const [startDate, setStartDate] = useState(dateRange.startDate || '');\n const [endDate, setEndDate] = useState(dateRange.endDate || '');\n const [isDateRange, setIsDateRange] = useState<boolean>(dateRange.isDateRange || false);\n\n const handleRef = useCallback(\n (newRef: HTMLInputElement | HTMLButtonElement | null) => {\n ref.current = newRef as HTMLInputElement | null;\n if (!reduxHeader?.hideFilterMenu) {\n setTimeout(() => newRef?.focus());\n }\n },\n [reduxHeader?.hideFilterMenu],\n );\n const handleSubmit = useCallback(\n (e: React.SyntheticEvent) => {\n e.preventDefault();\n\n const hasValidRange = startDate && endDate && !startDate.includes('_') && !endDate.includes('_');\n\n if (hasValidRange) {\n onValueChange(FILTER_TYPES.DATE_SWITCHER, { startDate, endDate, isDateRange });\n } else {\n return;\n }\n\n patchHeaderFilterButtonAndMenu(id, true);\n innerRef.current?.focus();\n },\n [endDate, id, innerRef, isDateRange, onValueChange, patchHeaderFilterButtonAndMenu, startDate],\n );\n const handleReset = useCallback(() => {\n setStartDate('');\n setEndDate('');\n setIsDateRange(false);\n onValueChange(FILTER_TYPES.DATE_SWITCHER, undefined);\n patchHeaderFilterButtonAndMenu(id, true);\n innerRef.current?.focus();\n }, [id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu]);\n\n useEffect(() => {\n if (reduxHeader?.hideFilterMenu) {\n // When the menu closes without applying, discard draft state\n setStartDate(dateRange.startDate || '');\n setEndDate(dateRange.endDate || '');\n setIsDateRange(dateRange.isDateRange || false);\n }\n }, [dateRange.endDate, dateRange.isDateRange, dateRange.startDate, reduxHeader?.hideFilterMenu]);\n\n return (\n <FilterPopoverV2\n onFilterSubmit={handleSubmit}\n onFilterReset={handleReset}\n firstElementRef={ref}\n reduxHeader={reduxHeader}\n column={column}\n columnReference={referenceColumn}\n columnId={id}\n menuContent={\n <Grid width=\"260px\" data-testid={DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER}>\n <Grid p=\"xxs\" gutter=\"xxs\" style={{ background: 'white' }}>\n <div data-testid={DATA_TESTID.DATA_TABLE_DATE_RANGE_CONTROLLER_CHECKBOX_SWITCHER}>\n <DSControlledCheckbox\n checked={isDateRange}\n name=\"Date range\"\n label=\"Date Range\"\n id={`date-range-switcher-id-internal-${domIdAffix}`}\n onChange={() => {\n setIsDateRange(!isDateRange);\n setStartDate('');\n setEndDate('');\n }}\n innerRef={handleRef}\n />\n </div>\n {isDateRange ? (\n <DSControlledDateRangePicker\n fromDate={startDate}\n onFromDateChange={setStartDate}\n toDate={endDate}\n onToDateChange={setEndDate}\n type=\"date-range-inputs\"\n />\n ) : (\n <DSControlledDateTimePicker\n date={startDate}\n onDateChange={(_date) => {\n setStartDate(_date);\n setEndDate(_date);\n }}\n type=\"date-inputs\"\n />\n )}\n </Grid>\n <Grid>\n {isDateRange ? (\n <DSControlledDateRangePicker\n fromDate={startDate}\n onFromDateChange={setStartDate}\n toDate={endDate}\n onToDateChange={setEndDate}\n type=\"date-range-picker-controller-only\"\n />\n ) : (\n <DSControlledDateTimePicker\n date={startDate}\n onDateChange={(_date) => {\n setStartDate(_date);\n setEndDate(_date);\n }}\n type=\"date-picker-controller-only\"\n />\n )}\n </Grid>\n </Grid>\n }\n triggerIcon={<DatePicker2 />}\n innerRef={innerRef}\n ariaLabel=\"Open Date Range Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC+Fb,SAEI,KAFJ;AA/FV,SAAgB,QAAQ,aAAa,UAAU,iBAAiB;AAChE,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,mCAAmC;AAC5C,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;AACrC,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB;AAE5B,MAAM,mBAAmB,EAAE,WAAW,MAAM,SAAS,MAAM,aAAa,MAAM;AAQvE,MAAM,uBAA+F,CAAC,UAAU;AACrH,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ,EAAE,GAAG;AAAA,IACb;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,IAAI,CAAC;AAAA,EACpB,IAAI;AAEJ,QAAM,MAAM,OAAgC,IAAI;AAChD,QAAM,YAAY;AAElB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,UAAU,aAAa,EAAE;AACpE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,UAAU,WAAW,EAAE;AAC9D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAkB,UAAU,eAAe,KAAK;AAEtF,QAAM,YAAY;AAAA,IAChB,CAAC,WAAwD;AACvD,UAAI,UAAU;AACd,UAAI,CAAC,aAAa,gBAAgB;AAChC,mBAAW,MAAM,QAAQ,MAAM,CAAC;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC,aAAa,cAAc;AAAA,EAC9B;AACA,QAAM,eAAe;AAAA,IACnB,CAAC,MAA4B;AAC3B,QAAE,eAAe;AAEjB,YAAM,gBAAgB,aAAa,WAAW,CAAC,UAAU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AAE;AACf,2BAAW,EAAE;AAAA,cACf;AAAA,cACA,UAAU;AAAA;AAAA,UACZ,GACF;AAAA,UACC,cACC;AAAA,YAAC;AAAA;AAAA,cACC,UAAU;AAAA,cACV,kBAAkB;AAAA,cAClB,QAAQ;AAAA,cACR,gBAAgB;AAAA,cAChB,MAAK;AAAA;AAAA,UACP,IAEA;AAAA,YAAC;AAAA;AAAA,cACC,MAAM;AAAA,cACN,cAAc,CAAC,UAAU;AACvB,6BAAa,KAAK;AAClB,2BAAW,KAAK;AAAA,cAClB;AAAA,cACA,MAAK;AAAA;AAAA,UACP;AAAA,WAEJ;AAAA,QACA,oBAAC,QACE,wBACC;AAAA,UAAC;AAAA;AAAA,YACC,UAAU;AAAA,YACV,kBAAkB;AAAA,YAClB,QAAQ;AAAA,YACR,gBAAgB;AAAA,YAChB,MAAK;AAAA;AAAA,QACP,IAEA;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,cAAc,CAAC,UAAU;AACvB,2BAAa,KAAK;AAClB,yBAAW,KAAK;AAAA,YAClB;AAAA,YACA,MAAK;AAAA;AAAA,QACP,GAEJ;AAAA,SACF;AAAA,MAEF,aAAa,oBAAC,eAAY;AAAA,MAC1B;AAAA,MACA,WAAU;AAAA;AAAA,EACZ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { DSInputText } from "@elliemae/ds-form-input-text";
|
|
4
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
5
|
+
import { SearchXsmall } from "@elliemae/ds-icons";
|
|
6
|
+
import { styled } from "@elliemae/ds-system";
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
8
|
+
import { uid } from "uid";
|
|
9
|
+
import { DATA_TESTID } from "../../../../configs/constants.js";
|
|
10
|
+
import { usePropsStore } from "../../../../configs/useStore/createInternalAndPropsContext.js";
|
|
11
|
+
import { DSDataTableName, DSDataTableSlots } from "../../../../constants/index.js";
|
|
12
|
+
import { FilterPopoverV2 } from "../../../../exported-related/FilterPopover/FilterPopoverV2.js";
|
|
13
|
+
import { FILTER_TYPES } from "../../../../exported-related/index.js";
|
|
14
|
+
import { ScreenReaderOnly } from "../../../../styled.js";
|
|
15
|
+
const StyledInputFreeTextSearch = styled(DSInputText, {
|
|
16
|
+
name: DSDataTableName,
|
|
17
|
+
slot: DSDataTableSlots.FREE_TEXT_SEARCH_FILTER
|
|
18
|
+
})``;
|
|
19
|
+
const StyledInputFreeTextSearchWrapper = styled(Grid, {
|
|
20
|
+
name: DSDataTableName,
|
|
21
|
+
slot: DSDataTableSlots.FREE_TEXT_SEARCH_WRAPPER
|
|
22
|
+
})``;
|
|
23
|
+
const FreeTextSearchFilterV2 = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
column,
|
|
26
|
+
referenceColumn,
|
|
27
|
+
column: { id, persistFilterInputAfterSubmit = false },
|
|
28
|
+
onValueChange,
|
|
29
|
+
patchHeaderFilterButtonAndMenu,
|
|
30
|
+
reduxHeader,
|
|
31
|
+
innerRef,
|
|
32
|
+
domIdAffix = uid(4)
|
|
33
|
+
} = props;
|
|
34
|
+
const ref = useRef(null);
|
|
35
|
+
const shouldFocus = useRef(true);
|
|
36
|
+
const getOwnerProps = usePropsStore((store) => store.get);
|
|
37
|
+
const getOwnerPropsArguments = useCallback(
|
|
38
|
+
() => ({
|
|
39
|
+
columnId: id
|
|
40
|
+
}),
|
|
41
|
+
[id]
|
|
42
|
+
);
|
|
43
|
+
const handleRef = useCallback((newRef) => {
|
|
44
|
+
ref.current = newRef;
|
|
45
|
+
if (shouldFocus.current) {
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
ref.current?.focus();
|
|
48
|
+
shouldFocus.current = false;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (reduxHeader?.hideFilterMenu) {
|
|
54
|
+
shouldFocus.current = true;
|
|
55
|
+
}
|
|
56
|
+
}, [reduxHeader?.hideFilterMenu]);
|
|
57
|
+
const [value, setValue] = useState("");
|
|
58
|
+
const handleSubmit = useCallback(
|
|
59
|
+
(e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
const trimmed = value.trim();
|
|
62
|
+
if (trimmed === "") return;
|
|
63
|
+
onValueChange(FILTER_TYPES.FREE_TEXT_SEARCH_V2, trimmed || void 0);
|
|
64
|
+
if (!persistFilterInputAfterSubmit) {
|
|
65
|
+
setValue("");
|
|
66
|
+
}
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
patchHeaderFilterButtonAndMenu(id, true);
|
|
69
|
+
innerRef?.current?.focus();
|
|
70
|
+
}, 0);
|
|
71
|
+
},
|
|
72
|
+
[id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu, persistFilterInputAfterSubmit, value]
|
|
73
|
+
);
|
|
74
|
+
const handleReset = useCallback(() => {
|
|
75
|
+
setValue("");
|
|
76
|
+
onValueChange(FILTER_TYPES.FREE_TEXT_SEARCH_V2, void 0);
|
|
77
|
+
}, [onValueChange]);
|
|
78
|
+
return /* @__PURE__ */ jsx(
|
|
79
|
+
FilterPopoverV2,
|
|
80
|
+
{
|
|
81
|
+
onFilterSubmit: handleSubmit,
|
|
82
|
+
onFilterReset: handleReset,
|
|
83
|
+
firstElementRef: ref,
|
|
84
|
+
reduxHeader,
|
|
85
|
+
column,
|
|
86
|
+
columnReference: referenceColumn,
|
|
87
|
+
columnId: id,
|
|
88
|
+
customStyles: {
|
|
89
|
+
backgroundColor: "#fff",
|
|
90
|
+
width: referenceColumn?.offsetWidth,
|
|
91
|
+
minWidth: "80px"
|
|
92
|
+
},
|
|
93
|
+
menuContent: /* @__PURE__ */ jsxs(
|
|
94
|
+
StyledInputFreeTextSearchWrapper,
|
|
95
|
+
{
|
|
96
|
+
p: "xxs",
|
|
97
|
+
gutter: "xxs",
|
|
98
|
+
getOwnerProps,
|
|
99
|
+
getOwnerPropsArguments,
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx(ScreenReaderOnly, { id: "filter-input-instructions", children: "Press Enter to apply the filter and close the dialog. Focus will return to the button that opened this dialog." }),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
StyledInputFreeTextSearch,
|
|
104
|
+
{
|
|
105
|
+
id: `ds-data-table-free-text-search-${id}-${domIdAffix}`,
|
|
106
|
+
placeholder: "",
|
|
107
|
+
value,
|
|
108
|
+
onValueChange: (newValue) => {
|
|
109
|
+
setValue(newValue);
|
|
110
|
+
},
|
|
111
|
+
innerRef: handleRef,
|
|
112
|
+
"data-testid": DATA_TESTID.DATA_TABLE_FILTER_FREE_TEXT_SEARCH,
|
|
113
|
+
"aria-label": "Free Text Search Filter",
|
|
114
|
+
"aria-describedby": "filter-input-instructions",
|
|
115
|
+
getOwnerProps,
|
|
116
|
+
getOwnerPropsArguments
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
triggerIcon: /* @__PURE__ */ jsx(SearchXsmall, {}),
|
|
123
|
+
innerRef,
|
|
124
|
+
ariaLabel: "Open Free Text Search Filter"
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
FreeTextSearchFilterV2
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=FreeTextSearchFilterV2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/FreeTextSearchFilter/FreeTextSearchFilterV2.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { DSInputText } from '@elliemae/ds-form-input-text';\nimport { Grid } from '@elliemae/ds-grid';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { styled } from '@elliemae/ds-system';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { uid } from 'uid';\nimport { DATA_TESTID } from '../../../../configs/constants.js';\nimport { usePropsStore } from '../../../../configs/useStore/createInternalAndPropsContext.js';\nimport { DSDataTableName, DSDataTableSlots } from '../../../../constants/index.js';\nimport { FilterPopoverV2 } from '../../../../exported-related/FilterPopover/FilterPopoverV2.js';\nimport { FILTER_TYPES } from '../../../../exported-related/index.js';\nimport type { DSDataTableT } from '../../../../react-desc-prop-types.js';\nimport { ScreenReaderOnly } from '../../../../styled.js';\n\nconst StyledInputFreeTextSearch = styled(DSInputText, {\n name: DSDataTableName,\n slot: DSDataTableSlots.FREE_TEXT_SEARCH_FILTER,\n})``;\n\nconst StyledInputFreeTextSearchWrapper = styled(Grid, {\n name: DSDataTableName,\n slot: DSDataTableSlots.FREE_TEXT_SEARCH_WRAPPER,\n})``;\n\nexport const FreeTextSearchFilterV2: React.ComponentType<DSDataTableT.FilterProps<string>> = (props) => {\n const {\n column,\n referenceColumn,\n column: { id, persistFilterInputAfterSubmit = false },\n onValueChange,\n patchHeaderFilterButtonAndMenu,\n reduxHeader,\n innerRef,\n domIdAffix = uid(4),\n } = props;\n\n const ref = useRef<HTMLInputElement | null>(null);\n const shouldFocus = useRef(true);\n\n const getOwnerProps = usePropsStore((store) => store.get);\n const getOwnerPropsArguments = useCallback(\n () => ({\n columnId: id,\n }),\n [id],\n );\n\n const handleRef = useCallback((newRef: HTMLInputElement | null) => {\n ref.current = newRef;\n if (shouldFocus.current) {\n requestAnimationFrame(() => {\n ref.current?.focus();\n shouldFocus.current = false;\n });\n }\n }, []);\n useEffect(() => {\n if (reduxHeader?.hideFilterMenu) {\n shouldFocus.current = true;\n }\n }, [reduxHeader?.hideFilterMenu]);\n\n const [value, setValue] = useState<string>('');\n const handleSubmit = useCallback(\n (e: React.SyntheticEvent) => {\n e.preventDefault();\n\n const trimmed = value.trim();\n if (trimmed === '') return;\n\n onValueChange(FILTER_TYPES.FREE_TEXT_SEARCH_V2, trimmed || undefined);\n if (!persistFilterInputAfterSubmit) {\n setValue('');\n }\n setTimeout(() => {\n patchHeaderFilterButtonAndMenu(id, true);\n innerRef?.current?.focus();\n }, 0);\n },\n [id, innerRef, onValueChange, patchHeaderFilterButtonAndMenu, persistFilterInputAfterSubmit, value],\n );\n const handleReset = useCallback(() => {\n setValue('');\n onValueChange(FILTER_TYPES.FREE_TEXT_SEARCH_V2, undefined);\n }, [onValueChange]);\n return (\n <FilterPopoverV2\n onFilterSubmit={handleSubmit}\n onFilterReset={handleReset}\n firstElementRef={ref}\n reduxHeader={reduxHeader}\n column={column}\n columnReference={referenceColumn}\n columnId={id}\n customStyles={{\n backgroundColor: '#fff',\n width: referenceColumn?.offsetWidth,\n minWidth: '80px',\n }}\n menuContent={\n <StyledInputFreeTextSearchWrapper\n p=\"xxs\"\n gutter=\"xxs\"\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <ScreenReaderOnly id=\"filter-input-instructions\">\n Press Enter to apply the filter and close the dialog. Focus will return to the button that opened this\n dialog.\n </ScreenReaderOnly>\n <StyledInputFreeTextSearch\n id={`ds-data-table-free-text-search-${id}-${domIdAffix}`}\n placeholder=\"\"\n value={value}\n onValueChange={(newValue) => {\n setValue(newValue);\n }}\n innerRef={handleRef}\n data-testid={DATA_TESTID.DATA_TABLE_FILTER_FREE_TEXT_SEARCH}\n aria-label=\"Free Text Search Filter\"\n aria-describedby=\"filter-input-instructions\"\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n </StyledInputFreeTextSearchWrapper>\n }\n triggerIcon={<SearchXsmall />}\n innerRef={innerRef}\n ariaLabel=\"Open Free Text Search Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoGf,SAME,KANF;AApGR,SAAS,mBAAmB;AAC5B,SAAS,YAAY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