@capillarytech/blaze-ui 6.4.0 → 6.5.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/CapDateRangePicker/index.d.ts.map +1 -1
- package/CapDateRangePicker/index.js +5 -1
- package/CapDateRangePicker/styles.css +28 -0
- package/CapDateRangePicker/styles.module.scss.js +2 -1
- package/CapDateRangePicker/styles.scss +37 -0
- package/CapDateRangePicker/types.d.ts +5 -0
- package/CapDateRangePicker/types.d.ts.map +1 -1
- package/CapDragAndDrop/index.d.ts +19 -3
- package/CapDragAndDrop/index.d.ts.map +1 -1
- package/CapDragAndDrop/index.js +29 -24
- package/CapDragAndDrop/styles.css +15 -17
- package/CapDragAndDrop/styles.scss +16 -18
- package/CapMobileDateRangePicker/DateRangeInputSelectors.d.ts +7 -0
- package/CapMobileDateRangePicker/DateRangeInputSelectors.d.ts.map +1 -0
- package/CapMobileDateRangePicker/DateRangeInputSelectors.js +68 -0
- package/CapMobileDateRangePicker/ReactMobileDatePickerModule.d.ts.map +1 -1
- package/CapMobileDateRangePicker/ReactMobileDatePickerModule.js +2 -1
- package/CapMobileDateRangePicker/index.d.ts +5 -21
- package/CapMobileDateRangePicker/index.d.ts.map +1 -1
- package/CapMobileDateRangePicker/index.js +256 -309
- package/CapMobileDateRangePicker/messages.d.ts +17 -0
- package/CapMobileDateRangePicker/messages.d.ts.map +1 -0
- package/CapMobileDateRangePicker/messages.js +20 -0
- package/CapMobileDateRangePicker/styles.css +107 -144
- package/CapMobileDateRangePicker/styles.module.scss.js +21 -0
- package/CapMobileDateRangePicker/styles.scss +188 -192
- package/CapMobileDateRangePicker/tests/CapMobileDateRangePicker.mockData.d.ts +18 -0
- package/CapMobileDateRangePicker/tests/CapMobileDateRangePicker.mockData.d.ts.map +1 -0
- package/CapMobileDateRangePicker/types.d.ts +95 -0
- package/CapMobileDateRangePicker/types.d.ts.map +1 -0
- package/CapMobileDateRangePicker/utils.d.ts +3 -0
- package/CapMobileDateRangePicker/utils.d.ts.map +1 -0
- package/CapMobileDateRangePicker/utils.js +5 -0
- package/CapPopoverTree/index.d.ts +3 -40
- package/CapPopoverTree/index.d.ts.map +1 -1
- package/CapPopoverTree/index.js +72 -82
- package/CapPopoverTree/style.d.ts +5 -1
- package/CapPopoverTree/style.d.ts.map +1 -1
- package/CapPopoverTree/styles.css +119 -18
- package/CapPopoverTree/styles.module.scss.js +26 -0
- package/CapPopoverTree/styles.scss +179 -31
- package/CapPopoverTree/tests/CapPopoverTree.mockData.d.ts +22 -0
- package/CapPopoverTree/tests/CapPopoverTree.mockData.d.ts.map +1 -0
- package/CapPopoverTree/types.d.ts +62 -0
- package/CapPopoverTree/types.d.ts.map +1 -0
- package/CapTimeline/CapTimelineCard.d.ts +27 -4
- package/CapTimeline/CapTimelineCard.d.ts.map +1 -1
- package/CapTimeline/CapTimelineCard.js +157 -40
- package/CapTimeline/CapTimelinePanesWrapper.d.ts +25 -4
- package/CapTimeline/CapTimelinePanesWrapper.d.ts.map +1 -1
- package/CapTimeline/CapTimelinePanesWrapper.js +20 -24
- package/CapTimeline/index.d.ts +17 -2
- package/CapTimeline/index.d.ts.map +1 -1
- package/CapTimeline/index.js +23 -62
- package/CapTimeline/styles.css +40 -40
- package/CapTimeline/styles.scss +57 -76
- package/CapVirtualSelect/actions.d.ts +16 -0
- package/CapVirtualSelect/actions.d.ts.map +1 -0
- package/CapVirtualSelect/actions.js +21 -0
- package/CapVirtualSelect/constants.d.ts +13 -0
- package/CapVirtualSelect/constants.d.ts.map +1 -0
- package/CapVirtualSelect/constants.js +26 -0
- package/CapVirtualSelect/index.d.ts +169 -0
- package/CapVirtualSelect/index.d.ts.map +1 -0
- package/CapVirtualSelect/index.js +409 -0
- package/CapVirtualSelect/messages.d.ts +9 -0
- package/CapVirtualSelect/messages.d.ts.map +1 -0
- package/CapVirtualSelect/messages.js +12 -0
- package/CapVirtualSelect/reducer.d.ts +4 -0
- package/CapVirtualSelect/reducer.d.ts.map +1 -0
- package/CapVirtualSelect/reducer.js +63 -0
- package/CapVirtualSelect/saga.d.ts +40 -0
- package/CapVirtualSelect/saga.d.ts.map +1 -0
- package/CapVirtualSelect/saga.js +91 -0
- package/CapVirtualSelect/selectors.d.ts +28 -0
- package/CapVirtualSelect/selectors.d.ts.map +1 -0
- package/CapVirtualSelect/selectors.js +30 -0
- package/CapVirtualSelect/styles.css +110 -0
- package/CapVirtualSelect/styles.scss +106 -0
- package/CapVirtualSelect/tests/mockData.d.ts +7 -0
- package/CapVirtualSelect/tests/mockData.d.ts.map +1 -0
- package/CapVirtualSelect/utils.d.ts +2 -0
- package/CapVirtualSelect/utils.d.ts.map +1 -0
- package/CapVirtualSelect/utils.js +12 -0
- package/index.d.ts +2 -4
- package/index.d.ts.map +1 -1
- package/index.js +97 -99
- package/package.json +1 -1
- package/utils/dayjs.d.ts +29 -0
- package/utils/dayjs.d.ts.map +1 -1
- package/utils/dayjs.js +30 -0
- package/utils/getCapThemeConfig.d.ts.map +1 -1
- package/utils/getCapThemeConfig.js +1 -9
- package/CapDragAndDrop/messages.d.ts +0 -25
- package/CapDragAndDrop/messages.d.ts.map +0 -1
- package/CapDragAndDrop/messages.js +0 -28
- package/CapDragAndDrop/styles.module.scss.js +0 -21
- package/CapDragAndDrop/types.d.ts +0 -17
- package/CapDragAndDrop/types.d.ts.map +0 -1
- package/CapTimeline/messages.d.ts +0 -21
- package/CapTimeline/messages.d.ts.map +0 -1
- package/CapTimeline/messages.js +0 -24
- package/CapTimeline/styles.module.scss.js +0 -30
- package/CapTimeline/tests/CapTimeline.mockData.d.ts +0 -14
- package/CapTimeline/tests/CapTimeline.mockData.d.ts.map +0 -1
- package/CapTimeline/types.d.ts +0 -60
- package/CapTimeline/types.d.ts.map +0 -1
- /package/{CapDragAndDrop → CapMobileDateRangePicker}/types.js +0 -0
- /package/{CapTimeline → CapPopoverTree}/types.js +0 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import debounce from "lodash/debounce";
|
|
4
|
+
import get from "lodash/get";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
7
|
+
import { intlShape, FormattedMessage, injectIntl } from "react-intl";
|
|
8
|
+
import { connect } from "react-redux";
|
|
9
|
+
import { Virtuoso } from "react-virtuoso";
|
|
10
|
+
import { compose, bindActionCreators } from "redux";
|
|
11
|
+
import { createStructuredSelector } from "reselect";
|
|
12
|
+
import CapIcon from "../CapIcon/index.js";
|
|
13
|
+
import CapSearch from "../CapInput/Search.js";
|
|
14
|
+
import CapRow from "../CapRow/index.js";
|
|
15
|
+
import CapSpin from "../CapSpin/index.js";
|
|
16
|
+
import clearDataOnUnmount from "../ClearDataOnUnmountHoc/index.js";
|
|
17
|
+
import * as CapVirtualSelect_actions from "./actions.js";
|
|
18
|
+
import { defaultNamespace, dataTestIdPrefix, SUCCESS, FAILURE, REQUEST } from "./constants.js";
|
|
19
|
+
import messages from "./messages.js";
|
|
20
|
+
import { makeSelectGetOptionById, makeSelectGetPaginatedOptions } from "./selectors.js";
|
|
21
|
+
import './styles.css';/* empty css */
|
|
22
|
+
import { convertApiParamsMapperToObject } from "./utils.js";
|
|
23
|
+
const classPrefix = "cap-virtual-select";
|
|
24
|
+
const NoOptionsFound = () => {
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
CapRow,
|
|
27
|
+
{
|
|
28
|
+
className: classNames(`${classPrefix}-no-options`),
|
|
29
|
+
"data-testid": `${dataTestIdPrefix}-no-options`,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx(CapIcon, { className: classNames(`${classPrefix}-no-options-image`), type: "alert" }),
|
|
32
|
+
/* @__PURE__ */ jsx(CapRow, { className: classNames(`${classPrefix}-no-options-text`), children: /* @__PURE__ */ jsx(FormattedMessage, { ...messages.noOptionsFound }) })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
function CapVirtualSelect({
|
|
38
|
+
intl: { formatMessage: _formatMessage },
|
|
39
|
+
namespace: _namespace,
|
|
40
|
+
listingApiConfig,
|
|
41
|
+
getByIdApiConfig,
|
|
42
|
+
selectedOption,
|
|
43
|
+
isSearchable,
|
|
44
|
+
searchDebounceTime,
|
|
45
|
+
disabled,
|
|
46
|
+
selectedOptionPlaceholderLabel,
|
|
47
|
+
searchPlaceholderLabel,
|
|
48
|
+
loadingOptionsPlaceholder,
|
|
49
|
+
EmptyPlaceholder,
|
|
50
|
+
EmptySearchPlaceholder,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
buttonProps,
|
|
54
|
+
searchbarProps,
|
|
55
|
+
virtuosoProps,
|
|
56
|
+
onOptionClick,
|
|
57
|
+
renderOptionRow,
|
|
58
|
+
renderSelectedOptionRow,
|
|
59
|
+
transformOptions,
|
|
60
|
+
actions: actions2,
|
|
61
|
+
paginatedOptions: {
|
|
62
|
+
getPaginatedOptionsStatus,
|
|
63
|
+
getPaginatedOptions,
|
|
64
|
+
getUnTransformedPaginatedOptions,
|
|
65
|
+
getPaginatedOptionsTotalCount
|
|
66
|
+
},
|
|
67
|
+
optionById: { getOptionByIdStatus, getOptionById }
|
|
68
|
+
}) {
|
|
69
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
70
|
+
const [isDropdownVisible, setIsDropdownListVisible] = useState(false);
|
|
71
|
+
const [listingApiQueryParams, setListingApiQueryParams] = useState(
|
|
72
|
+
() => convertApiParamsMapperToObject(listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper)
|
|
73
|
+
);
|
|
74
|
+
const [defaultSelectedOption, _setDefaultSelectedOption] = useState(() => selectedOption);
|
|
75
|
+
const [selectedOptionNode, setSelectedOptionNode] = useState({});
|
|
76
|
+
const [searchValue, setSearchValue] = useState("");
|
|
77
|
+
const [basePageIndex, setBasePageIndex] = useState(
|
|
78
|
+
() => {
|
|
79
|
+
var _a2, _b2;
|
|
80
|
+
return (_b2 = (_a2 = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _a2.page) == null ? void 0 : _b2.value;
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
const dropdownRef = useRef(null);
|
|
84
|
+
const searchKey = (_b = (_a = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _a.search) == null ? void 0 : _b.key;
|
|
85
|
+
const pageKey = (_d = (_c = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _c.page) == null ? void 0 : _d.key;
|
|
86
|
+
const pageValue = (_f = (_e = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _e.page) == null ? void 0 : _f.value;
|
|
87
|
+
const areOptionsLoading = getPaginatedOptionsStatus === REQUEST || getOptionByIdStatus === REQUEST;
|
|
88
|
+
const handleOptionChange = (selectedOptionNodeValue) => {
|
|
89
|
+
setSelectedOptionNode(selectedOptionNodeValue);
|
|
90
|
+
onOptionClick(selectedOptionNodeValue);
|
|
91
|
+
setIsDropdownListVisible(false);
|
|
92
|
+
};
|
|
93
|
+
const handleDebouncedSearch = useCallback(
|
|
94
|
+
debounce((value) => {
|
|
95
|
+
setListingApiQueryParams((prevState) => ({
|
|
96
|
+
...prevState,
|
|
97
|
+
[searchKey]: value,
|
|
98
|
+
[pageKey]: pageValue
|
|
99
|
+
}));
|
|
100
|
+
}, searchDebounceTime),
|
|
101
|
+
[]
|
|
102
|
+
);
|
|
103
|
+
const handleSearchChange = (value) => {
|
|
104
|
+
setSearchValue(value);
|
|
105
|
+
if (searchValue) {
|
|
106
|
+
handleDebouncedSearch(value);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const handleLoadMoreOptions = () => {
|
|
110
|
+
const loadedUnTransformedPaginatedOptionsLength = (getUnTransformedPaginatedOptions == null ? void 0 : getUnTransformedPaginatedOptions.length) || 0;
|
|
111
|
+
const loadedPaginatedOptionsLength = defaultSelectedOption && !searchValue ? loadedUnTransformedPaginatedOptionsLength + 1 : loadedUnTransformedPaginatedOptionsLength;
|
|
112
|
+
const areAllOptionsLoaded = loadedPaginatedOptionsLength === getPaginatedOptionsTotalCount;
|
|
113
|
+
if (areOptionsLoading || areAllOptionsLoaded || getPaginatedOptionsStatus === FAILURE) return;
|
|
114
|
+
setListingApiQueryParams((prevState) => ({
|
|
115
|
+
...prevState,
|
|
116
|
+
[pageKey]: prevState[pageKey] + 1
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
119
|
+
const renderVisibleOptionNodes = (index, visibleNode) => {
|
|
120
|
+
var _a2, _b2;
|
|
121
|
+
const selectedOptionValue = get(selectedOptionNode, (_a2 = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _a2.value, "");
|
|
122
|
+
const currentSelectedOptionValue = get(visibleNode, (_b2 = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _b2.value, "");
|
|
123
|
+
return /* @__PURE__ */ jsx(
|
|
124
|
+
CapRow,
|
|
125
|
+
{
|
|
126
|
+
onClick: (event) => {
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
handleOptionChange(visibleNode);
|
|
129
|
+
},
|
|
130
|
+
className: classNames(
|
|
131
|
+
selectedOptionValue === currentSelectedOptionValue ? `${classPrefix}-selected-option-row` : `${classPrefix}-option-row`
|
|
132
|
+
),
|
|
133
|
+
"data-testid": `${dataTestIdPrefix}-option-row`,
|
|
134
|
+
children: renderOptionRow(visibleNode)
|
|
135
|
+
},
|
|
136
|
+
index
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (selectedOption) {
|
|
141
|
+
const getByIdApiQueryParams = convertApiParamsMapperToObject(
|
|
142
|
+
getByIdApiConfig == null ? void 0 : getByIdApiConfig.apiParamsMapper
|
|
143
|
+
);
|
|
144
|
+
actions2.getOptionById(selectedOption, getByIdApiConfig, getByIdApiQueryParams);
|
|
145
|
+
}
|
|
146
|
+
setBasePageIndex(convertApiParamsMapperToObject(listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper)[pageKey]);
|
|
147
|
+
}, []);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if ([SUCCESS, FAILURE].includes(getOptionByIdStatus)) {
|
|
150
|
+
setSelectedOptionNode(getOptionById);
|
|
151
|
+
}
|
|
152
|
+
}, [getOptionByIdStatus]);
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (areOptionsLoading || listingApiQueryParams[pageKey] > (listingApiConfig == null ? void 0 : listingApiConfig.rpmLimit)) return;
|
|
155
|
+
if (!defaultSelectedOption || defaultSelectedOption && [SUCCESS, FAILURE].includes(getOptionByIdStatus)) {
|
|
156
|
+
actions2.getPaginatedOptions(listingApiConfig, listingApiQueryParams, transformOptions);
|
|
157
|
+
}
|
|
158
|
+
}, [listingApiQueryParams[pageKey], listingApiQueryParams[searchKey], getOptionByIdStatus]);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
const handleClickOutside = (event) => {
|
|
161
|
+
var _a2;
|
|
162
|
+
if (!((_a2 = dropdownRef.current) == null ? void 0 : _a2.contains(event.target))) {
|
|
163
|
+
setIsDropdownListVisible(false);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
167
|
+
return () => {
|
|
168
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
169
|
+
};
|
|
170
|
+
}, []);
|
|
171
|
+
return /* @__PURE__ */ jsxs(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
ref: dropdownRef,
|
|
175
|
+
className: classNames(`${classPrefix}-container`),
|
|
176
|
+
style: { width },
|
|
177
|
+
"data-testid": `${dataTestIdPrefix}-container`,
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsxs(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
className: classNames(`${classPrefix}-button`, {
|
|
183
|
+
[`${classPrefix}-button-disabled`]: disabled || areOptionsLoading
|
|
184
|
+
}),
|
|
185
|
+
"data-testid": `${dataTestIdPrefix}-button`,
|
|
186
|
+
onClick: () => setIsDropdownListVisible(true),
|
|
187
|
+
disabled: disabled || areOptionsLoading,
|
|
188
|
+
...buttonProps,
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx(CapRow, { className: classNames(`${classPrefix}-button-label`), children: areOptionsLoading && !(listingApiQueryParams[pageKey] > basePageIndex) ? /* @__PURE__ */ jsx(CapRow, { children: loadingOptionsPlaceholder }) : /* @__PURE__ */ jsx(
|
|
191
|
+
CapRow,
|
|
192
|
+
{
|
|
193
|
+
className: classNames({
|
|
194
|
+
[`${classPrefix}-button-defined-label`]: get(
|
|
195
|
+
selectedOptionNode,
|
|
196
|
+
(_g = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _g.label,
|
|
197
|
+
selectedOptionPlaceholderLabel
|
|
198
|
+
) !== selectedOptionPlaceholderLabel
|
|
199
|
+
}),
|
|
200
|
+
children: renderSelectedOptionRow(
|
|
201
|
+
selectedOptionNode,
|
|
202
|
+
get(
|
|
203
|
+
selectedOptionNode,
|
|
204
|
+
(_h = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _h.label,
|
|
205
|
+
selectedOptionPlaceholderLabel
|
|
206
|
+
)
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
) }),
|
|
210
|
+
/* @__PURE__ */ jsx(CapIcon, { type: "chevron-down", className: classNames(`${classPrefix}-button-arrow`) })
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
isDropdownVisible && /* @__PURE__ */ jsxs(
|
|
215
|
+
CapRow,
|
|
216
|
+
{
|
|
217
|
+
className: classNames(`${classPrefix}-dropdown`),
|
|
218
|
+
style: { width },
|
|
219
|
+
"data-testid": `${dataTestIdPrefix}-dropdown`,
|
|
220
|
+
children: [
|
|
221
|
+
isSearchable && /* @__PURE__ */ jsx(
|
|
222
|
+
CapSearch,
|
|
223
|
+
{
|
|
224
|
+
className: classNames(`${classPrefix}-search-bar`),
|
|
225
|
+
"data-testid": `${dataTestIdPrefix}-search-bar`,
|
|
226
|
+
value: searchValue,
|
|
227
|
+
onChange: (event) => handleSearchChange(event.target.value),
|
|
228
|
+
placeholder: searchPlaceholderLabel,
|
|
229
|
+
allowClear: false,
|
|
230
|
+
...searchbarProps
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsx(
|
|
234
|
+
CapSpin,
|
|
235
|
+
{
|
|
236
|
+
className: classNames(`${classPrefix}-options-list-spinner`),
|
|
237
|
+
size: "small",
|
|
238
|
+
spinning: areOptionsLoading,
|
|
239
|
+
children: /* @__PURE__ */ jsx(
|
|
240
|
+
Virtuoso,
|
|
241
|
+
{
|
|
242
|
+
style: { width, height: isSearchable ? height : height + 64 },
|
|
243
|
+
className: classNames(`${classPrefix}-options-list`),
|
|
244
|
+
"data-testid": `${dataTestIdPrefix}-options-list`,
|
|
245
|
+
totalCount: getPaginatedOptions == null ? void 0 : getPaginatedOptions.length,
|
|
246
|
+
data: getPaginatedOptions,
|
|
247
|
+
endReached: handleLoadMoreOptions,
|
|
248
|
+
itemContent: renderVisibleOptionNodes,
|
|
249
|
+
components: {
|
|
250
|
+
EmptyPlaceholder: searchValue ? EmptySearchPlaceholder : EmptyPlaceholder
|
|
251
|
+
},
|
|
252
|
+
...virtuosoProps
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
CapVirtualSelect.propTypes = {
|
|
265
|
+
intl: intlShape.isRequired,
|
|
266
|
+
namespace: PropTypes.string,
|
|
267
|
+
listingApiConfig: PropTypes.objectOf(
|
|
268
|
+
PropTypes.shape({
|
|
269
|
+
method: PropTypes.func,
|
|
270
|
+
rpmLimit: PropTypes.number,
|
|
271
|
+
payloadPath: PropTypes.objectOf(
|
|
272
|
+
PropTypes.shape({
|
|
273
|
+
successStatus: PropTypes.string,
|
|
274
|
+
success: PropTypes.string,
|
|
275
|
+
error: PropTypes.string,
|
|
276
|
+
label: PropTypes.string,
|
|
277
|
+
value: PropTypes.string,
|
|
278
|
+
totalCount: PropTypes.string
|
|
279
|
+
})
|
|
280
|
+
),
|
|
281
|
+
apiParamsMapper: PropTypes.objectOf(
|
|
282
|
+
PropTypes.shape({
|
|
283
|
+
page: { key: PropTypes.string, value: PropTypes.any },
|
|
284
|
+
limit: { key: PropTypes.string, value: PropTypes.any },
|
|
285
|
+
search: { key: PropTypes.string, value: PropTypes.any }
|
|
286
|
+
})
|
|
287
|
+
)
|
|
288
|
+
})
|
|
289
|
+
),
|
|
290
|
+
getByIdApiConfig: PropTypes.objectOf(
|
|
291
|
+
PropTypes.shape({
|
|
292
|
+
method: PropTypes.func,
|
|
293
|
+
rpmLimit: PropTypes.number,
|
|
294
|
+
payloadPath: PropTypes.objectOf(
|
|
295
|
+
PropTypes.shape({
|
|
296
|
+
successStatus: PropTypes.string,
|
|
297
|
+
success: PropTypes.string,
|
|
298
|
+
error: PropTypes.string,
|
|
299
|
+
value: PropTypes.string
|
|
300
|
+
})
|
|
301
|
+
),
|
|
302
|
+
apiParamsMapper: PropTypes.objectOf(
|
|
303
|
+
PropTypes.shape({
|
|
304
|
+
page: { key: PropTypes.string, value: PropTypes.any },
|
|
305
|
+
limit: { key: PropTypes.string, value: PropTypes.any },
|
|
306
|
+
search: { key: PropTypes.string, value: PropTypes.any }
|
|
307
|
+
})
|
|
308
|
+
)
|
|
309
|
+
})
|
|
310
|
+
),
|
|
311
|
+
selectedOption: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
312
|
+
isSearchable: PropTypes.bool,
|
|
313
|
+
searchDebounceTime: PropTypes.number,
|
|
314
|
+
disabled: PropTypes.bool,
|
|
315
|
+
selectedOptionPlaceholderLabel: PropTypes.string,
|
|
316
|
+
searchPlaceholderLabel: PropTypes.string,
|
|
317
|
+
loadingOptionsPlaceholder: PropTypes.string,
|
|
318
|
+
width: PropTypes.number,
|
|
319
|
+
height: PropTypes.number,
|
|
320
|
+
buttonProps: PropTypes.object,
|
|
321
|
+
searchbarProps: PropTypes.object,
|
|
322
|
+
virtuosoProps: PropTypes.object,
|
|
323
|
+
transformOptions: PropTypes.func,
|
|
324
|
+
renderOptionRow: PropTypes.func,
|
|
325
|
+
renderSelectedOptionRow: PropTypes.func,
|
|
326
|
+
onOptionClick: PropTypes.func,
|
|
327
|
+
EmptyPlaceholder: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
328
|
+
EmptySearchPlaceholder: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
329
|
+
};
|
|
330
|
+
CapVirtualSelect.defaultProps = {
|
|
331
|
+
intl: intlShape.isRequired,
|
|
332
|
+
namespace: defaultNamespace,
|
|
333
|
+
listingApiConfig: {
|
|
334
|
+
method: () => Promise.resolve([]),
|
|
335
|
+
rpmLimit: 20,
|
|
336
|
+
payloadPath: {
|
|
337
|
+
successStatus: "success",
|
|
338
|
+
success: "data",
|
|
339
|
+
error: "error",
|
|
340
|
+
label: "name",
|
|
341
|
+
value: "id",
|
|
342
|
+
totalCount: "totalCount"
|
|
343
|
+
},
|
|
344
|
+
apiParamsMapper: {
|
|
345
|
+
page: { key: "page", value: 0 },
|
|
346
|
+
limit: { key: "limit", value: 10 },
|
|
347
|
+
search: { key: "search", value: "" }
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
getByIdApiConfig: {
|
|
351
|
+
method: () => Promise.resolve(null),
|
|
352
|
+
rpmLimit: 20,
|
|
353
|
+
payloadPath: {
|
|
354
|
+
successStatus: "success",
|
|
355
|
+
success: "data",
|
|
356
|
+
error: "error",
|
|
357
|
+
value: "id"
|
|
358
|
+
},
|
|
359
|
+
apiParamsMapper: {}
|
|
360
|
+
},
|
|
361
|
+
selectedOption: null,
|
|
362
|
+
isSearchable: false,
|
|
363
|
+
searchDebounceTime: 1500,
|
|
364
|
+
disabled: false,
|
|
365
|
+
selectedOptionPlaceholderLabel: "Select an option",
|
|
366
|
+
searchPlaceholderLabel: "Search",
|
|
367
|
+
loadingOptionsPlaceholder: "Loading options...",
|
|
368
|
+
width: 250,
|
|
369
|
+
height: 188,
|
|
370
|
+
buttonProps: {},
|
|
371
|
+
searchbarProps: {},
|
|
372
|
+
virtuosoProps: {},
|
|
373
|
+
transformOptions: (options) => options,
|
|
374
|
+
onOptionClick: (option) => option,
|
|
375
|
+
renderOptionRow: (option) => /* @__PURE__ */ jsx("div", { children: (option == null ? void 0 : option.name) || "N/A" }),
|
|
376
|
+
renderSelectedOptionRow: (selectedOption, selectedOptionValue) => /* @__PURE__ */ jsx("div", { children: selectedOptionValue }),
|
|
377
|
+
EmptyPlaceholder: NoOptionsFound,
|
|
378
|
+
EmptySearchPlaceholder: NoOptionsFound
|
|
379
|
+
};
|
|
380
|
+
const CapVirtualSelectInjected = (namespace = defaultNamespace) => {
|
|
381
|
+
const mapStateToProps = createStructuredSelector({
|
|
382
|
+
paginatedOptions: makeSelectGetPaginatedOptions(),
|
|
383
|
+
optionById: makeSelectGetOptionById()
|
|
384
|
+
});
|
|
385
|
+
function mapDispatchToProps(dispatch) {
|
|
386
|
+
const updatedActions = {
|
|
387
|
+
...CapVirtualSelect_actions
|
|
388
|
+
};
|
|
389
|
+
const allActions = Object.keys(updatedActions);
|
|
390
|
+
allActions.forEach((actionName) => {
|
|
391
|
+
const actionCreator = updatedActions[actionName];
|
|
392
|
+
updatedActions[actionName] = (...args) => {
|
|
393
|
+
const actionReturnValue = actionCreator(...args);
|
|
394
|
+
actionReturnValue.namespace = namespace;
|
|
395
|
+
return actionReturnValue;
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
actions: bindActionCreators(updatedActions, dispatch)
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
|
403
|
+
return compose(withConnect)(injectIntl(clearDataOnUnmount(CapVirtualSelect)));
|
|
404
|
+
};
|
|
405
|
+
export {
|
|
406
|
+
CapVirtualSelect,
|
|
407
|
+
CapVirtualSelectInjected,
|
|
408
|
+
CapVirtualSelectInjected as default
|
|
409
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../components/CapVirtualSelect/messages.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,kDAAkD,CAAC;;;;;;;AAErE,wBAKG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
const scope = "app.commonUtils.capUiLibrary.CapVirtualSelect";
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
noOptionsFound: {
|
|
5
|
+
id: `${scope}.noOptionsFound`,
|
|
6
|
+
defaultMessage: "No options found!"
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
messages as default,
|
|
11
|
+
scope
|
|
12
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const initialState: import("immutable").Map<"getPaginatedOptionsStatus" | "getPaginatedOptions" | "getUnTransformedPaginatedOptions" | "getPaginatedOptionsError" | "getPaginatedOptionsTotalCount" | "getOptionByIdStatus" | "getOptionById" | "getOptionByIdError", any>;
|
|
2
|
+
declare function CapVirtualSelectRootReducer(namespace?: string): (state: import("immutable").Map<"getPaginatedOptionsStatus" | "getPaginatedOptions" | "getUnTransformedPaginatedOptions" | "getPaginatedOptionsError" | "getPaginatedOptionsTotalCount" | "getOptionByIdStatus" | "getOptionById" | "getOptionByIdError", any>, action: any) => import("immutable").Map<"getPaginatedOptionsStatus" | "getPaginatedOptions" | "getUnTransformedPaginatedOptions" | "getPaginatedOptionsError" | "getPaginatedOptionsTotalCount" | "getOptionByIdStatus" | "getOptionById" | "getOptionByIdError", any>;
|
|
3
|
+
export default CapVirtualSelectRootReducer;
|
|
4
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../components/CapVirtualSelect/reducer.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,wPASvB,CAAC;AAGH,iBAAS,2BAA2B,CAAC,SAAS,SAAyB,IAC7B,6PAAoB,EAAE,WAAM,4PAgFrE;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fromJS } from "immutable";
|
|
2
|
+
import isEmpty from "lodash/isEmpty";
|
|
3
|
+
import uniqBy from "lodash/uniqBy";
|
|
4
|
+
import * as CapVirtualSelect_constants from "./constants.js";
|
|
5
|
+
import { defaultNamespace, CLEAR_DATA_ON_UNMOUNT, GET_OPTION_BY_ID_FAILURE, GET_OPTION_BY_ID_SUCCESS, GET_OPTION_BY_ID_REQUEST, GET_PAGINATED_OPTIONS_FAILURE, GET_PAGINATED_OPTIONS_SUCCESS, GET_PAGINATED_OPTIONS_REQUEST } from "./constants.js";
|
|
6
|
+
const { REQUEST, SUCCESS, FAILURE } = CapVirtualSelect_constants;
|
|
7
|
+
const initialState = fromJS({
|
|
8
|
+
getPaginatedOptionsStatus: "",
|
|
9
|
+
getPaginatedOptions: [],
|
|
10
|
+
getUnTransformedPaginatedOptions: [],
|
|
11
|
+
getPaginatedOptionsError: null,
|
|
12
|
+
getPaginatedOptionsTotalCount: 0,
|
|
13
|
+
getOptionByIdStatus: "",
|
|
14
|
+
getOptionById: {},
|
|
15
|
+
getOptionByIdError: null
|
|
16
|
+
});
|
|
17
|
+
function CapVirtualSelectRootReducer(namespace = defaultNamespace) {
|
|
18
|
+
return function CapVirtualSelectReducer(state = initialState, action) {
|
|
19
|
+
if ((action == null ? void 0 : action.namespace) !== namespace) {
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
switch (action.type) {
|
|
23
|
+
case GET_PAGINATED_OPTIONS_REQUEST:
|
|
24
|
+
return state.set("getPaginatedOptionsStatus", REQUEST).set("getPaginatedOptionsError", null);
|
|
25
|
+
case GET_PAGINATED_OPTIONS_SUCCESS: {
|
|
26
|
+
const getSelectedOption = state.get("getOptionByIdStatus") === SUCCESS ? state.get("getOptionById").toJS() : {};
|
|
27
|
+
const existingOptions = state.get("getPaginatedOptions").toJS();
|
|
28
|
+
const existingUnTransformedOptions = state.get("getUnTransformedPaginatedOptions").toJS();
|
|
29
|
+
const selectedValueKey = action == null ? void 0 : action.selectedValueKey;
|
|
30
|
+
const isSelectedOptionDefined = !isEmpty(getSelectedOption) && !(action == null ? void 0 : action.isSearchValueDefined);
|
|
31
|
+
const optionsCount = (action == null ? void 0 : action.totalCount) || 0;
|
|
32
|
+
const totalOptionsCount = isSelectedOptionDefined ? optionsCount + 1 : optionsCount;
|
|
33
|
+
const actionResult = action && action.result ? action.result : [];
|
|
34
|
+
const paginatedOptions = action && action.appendOptions ? uniqBy([...existingOptions, ...actionResult], selectedValueKey) : uniqBy(
|
|
35
|
+
[...isSelectedOptionDefined ? [getSelectedOption] : [], ...actionResult],
|
|
36
|
+
selectedValueKey
|
|
37
|
+
);
|
|
38
|
+
const unTransformedPaginatedOptions = action && action.appendOptions ? uniqBy([...existingUnTransformedOptions, ...actionResult], selectedValueKey) : uniqBy(
|
|
39
|
+
[...isSelectedOptionDefined ? [getSelectedOption] : [], ...actionResult],
|
|
40
|
+
selectedValueKey
|
|
41
|
+
);
|
|
42
|
+
const transformedOptions = (action == null ? void 0 : action.transformOptions) ? action.transformOptions(paginatedOptions) : paginatedOptions;
|
|
43
|
+
return state.set("getPaginatedOptionsStatus", SUCCESS).set("getPaginatedOptions", fromJS(transformedOptions)).set("getUnTransformedPaginatedOptions", fromJS(unTransformedPaginatedOptions)).set("getPaginatedOptionsTotalCount", totalOptionsCount).set("getPaginatedOptionsError", null);
|
|
44
|
+
}
|
|
45
|
+
case GET_PAGINATED_OPTIONS_FAILURE:
|
|
46
|
+
return state.set("getPaginatedOptionsStatus", FAILURE).set("getPaginatedOptionsError", action.error);
|
|
47
|
+
case GET_OPTION_BY_ID_REQUEST:
|
|
48
|
+
return state.set("getOptionByIdStatus", REQUEST).set("getOptionById", fromJS({})).set("getOptionByIdError", null);
|
|
49
|
+
case GET_OPTION_BY_ID_SUCCESS:
|
|
50
|
+
return state.set("getOptionByIdStatus", SUCCESS).set("getOptionById", fromJS(action.result)).set("getOptionByIdError", null);
|
|
51
|
+
case GET_OPTION_BY_ID_FAILURE:
|
|
52
|
+
return state.set("getOptionByIdStatus", FAILURE).set("getOptionById", fromJS({})).set("getOptionByIdError", action.error);
|
|
53
|
+
case CLEAR_DATA_ON_UNMOUNT:
|
|
54
|
+
return initialState;
|
|
55
|
+
default:
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
CapVirtualSelectRootReducer as default,
|
|
62
|
+
initialState
|
|
63
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare function actionMatcher({ action, namespace, type }: {
|
|
2
|
+
action: any;
|
|
3
|
+
namespace: any;
|
|
4
|
+
type: any;
|
|
5
|
+
}): boolean;
|
|
6
|
+
export declare function getPaginatedOptions(namespace: any, { listingApiConfig, queryParams, transformOptions }: {
|
|
7
|
+
listingApiConfig: any;
|
|
8
|
+
queryParams: any;
|
|
9
|
+
transformOptions: any;
|
|
10
|
+
}): Generator<import("redux-saga/effects").CallEffect<unknown> | import("redux-saga/effects").PutEffect<{
|
|
11
|
+
type: string;
|
|
12
|
+
namespace: any;
|
|
13
|
+
result: any[];
|
|
14
|
+
appendOptions: boolean;
|
|
15
|
+
totalCount: any;
|
|
16
|
+
selectedValueKey: any;
|
|
17
|
+
isSearchValueDefined: boolean;
|
|
18
|
+
transformOptions: any;
|
|
19
|
+
}> | import("redux-saga/effects").PutEffect<{
|
|
20
|
+
type: string;
|
|
21
|
+
namespace: any;
|
|
22
|
+
error: any;
|
|
23
|
+
}>, void, unknown>;
|
|
24
|
+
export declare function getOptionById(namespace: any, { id, getByIdApiConfig, queryParams }: {
|
|
25
|
+
id: any;
|
|
26
|
+
getByIdApiConfig: any;
|
|
27
|
+
queryParams: any;
|
|
28
|
+
}): Generator<import("redux-saga/effects").CallEffect<unknown> | import("redux-saga/effects").PutEffect<{
|
|
29
|
+
type: string;
|
|
30
|
+
namespace: any;
|
|
31
|
+
result: any;
|
|
32
|
+
}> | import("redux-saga/effects").PutEffect<{
|
|
33
|
+
type: string;
|
|
34
|
+
namespace: any;
|
|
35
|
+
error: any;
|
|
36
|
+
}>, void, unknown>;
|
|
37
|
+
export declare function watchGetPaginatedOptions(namespace: any): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
38
|
+
export declare function watchGetOptionById(namespace: any): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
39
|
+
export default function CapVirtualSelectRootSaga(namespace?: string): () => Generator<import("redux-saga/effects").AllEffect<Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>>, void, unknown>;
|
|
40
|
+
//# sourceMappingURL=saga.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saga.d.ts","sourceRoot":"","sources":["../../components/CapVirtualSelect/saga.ts"],"names":[],"mappings":"AAUA,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE;;;;CAAA,WAExD;AAGD,wBAAiB,mBAAmB,CAClC,SAAS,KAAA,EACT,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE;;;;CAAA;;;;;;;;;;;;;mBA+BpD;AAGD,wBAAiB,aAAa,CAAC,SAAS,KAAA,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE;;;;CAAA;;;;;;;;mBAuB9E;AAGD,wBAAiB,wBAAwB,CAAC,SAAS,KAAA,4EAOlD;AAGD,wBAAiB,kBAAkB,CAAC,SAAS,KAAA,4EAM5C;AAGD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,SAAS,SAAyB,oJAIlF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import get from "lodash/get";
|
|
2
|
+
import isEmpty from "lodash/isEmpty";
|
|
3
|
+
import values from "lodash/values";
|
|
4
|
+
import { all, takeLatest, call, put } from "redux-saga/effects";
|
|
5
|
+
import { defaultNamespace, GET_PAGINATED_OPTIONS_REQUEST, GET_OPTION_BY_ID_REQUEST, GET_OPTION_BY_ID_SUCCESS, GET_OPTION_BY_ID_FAILURE, GET_PAGINATED_OPTIONS_SUCCESS, GET_PAGINATED_OPTIONS_FAILURE } from "./constants.js";
|
|
6
|
+
const fallbackErrorMessage = "An error ocurred with api!";
|
|
7
|
+
function actionMatcher({ action, namespace, type }) {
|
|
8
|
+
return (action == null ? void 0 : action.namespace) === namespace && (action == null ? void 0 : action.type) === type;
|
|
9
|
+
}
|
|
10
|
+
function* getPaginatedOptions(namespace, { listingApiConfig, queryParams, transformOptions }) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
12
|
+
try {
|
|
13
|
+
const response = yield call(listingApiConfig == null ? void 0 : listingApiConfig.method, queryParams);
|
|
14
|
+
if (get(response, (_a = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _a.successStatus, false)) {
|
|
15
|
+
yield put({
|
|
16
|
+
type: GET_PAGINATED_OPTIONS_SUCCESS,
|
|
17
|
+
namespace,
|
|
18
|
+
result: values(get(response, (_b = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _b.success, [])),
|
|
19
|
+
appendOptions: queryParams[(_d = (_c = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _c.page) == null ? void 0 : _d.key] !== ((_f = (_e = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _e.page) == null ? void 0 : _f.value),
|
|
20
|
+
totalCount: get(response, (_g = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _g.totalCount, 0),
|
|
21
|
+
selectedValueKey: (_h = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _h.value,
|
|
22
|
+
isSearchValueDefined: !isEmpty(queryParams[(_j = (_i = listingApiConfig == null ? void 0 : listingApiConfig.apiParamsMapper) == null ? void 0 : _i.search) == null ? void 0 : _j.key]),
|
|
23
|
+
transformOptions
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
yield put({
|
|
27
|
+
type: GET_PAGINATED_OPTIONS_FAILURE,
|
|
28
|
+
namespace,
|
|
29
|
+
error: get(response, (_k = listingApiConfig == null ? void 0 : listingApiConfig.payloadPath) == null ? void 0 : _k.error, fallbackErrorMessage)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
yield put({
|
|
34
|
+
type: GET_PAGINATED_OPTIONS_FAILURE,
|
|
35
|
+
namespace,
|
|
36
|
+
error
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function* getOptionById(namespace, { id, getByIdApiConfig, queryParams }) {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
try {
|
|
43
|
+
const response = yield call(getByIdApiConfig == null ? void 0 : getByIdApiConfig.method, id, queryParams);
|
|
44
|
+
if (get(response, (_a = getByIdApiConfig == null ? void 0 : getByIdApiConfig.payloadPath) == null ? void 0 : _a.successStatus, false)) {
|
|
45
|
+
yield put({
|
|
46
|
+
type: GET_OPTION_BY_ID_SUCCESS,
|
|
47
|
+
namespace,
|
|
48
|
+
result: get(response, (_b = getByIdApiConfig == null ? void 0 : getByIdApiConfig.payloadPath) == null ? void 0 : _b.success, {})
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
yield put({
|
|
52
|
+
type: GET_OPTION_BY_ID_FAILURE,
|
|
53
|
+
namespace,
|
|
54
|
+
error: get(response, (_c = getByIdApiConfig == null ? void 0 : getByIdApiConfig.payloadPath) == null ? void 0 : _c.error, fallbackErrorMessage)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
yield put({
|
|
59
|
+
type: GET_OPTION_BY_ID_FAILURE,
|
|
60
|
+
namespace,
|
|
61
|
+
error
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function* watchGetPaginatedOptions(namespace) {
|
|
66
|
+
yield takeLatest(
|
|
67
|
+
(action) => actionMatcher({ action, namespace, type: GET_PAGINATED_OPTIONS_REQUEST }),
|
|
68
|
+
getPaginatedOptions,
|
|
69
|
+
namespace
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function* watchGetOptionById(namespace) {
|
|
73
|
+
yield takeLatest(
|
|
74
|
+
(action) => actionMatcher({ action, namespace, type: GET_OPTION_BY_ID_REQUEST }),
|
|
75
|
+
getOptionById,
|
|
76
|
+
namespace
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function CapVirtualSelectRootSaga(namespace = defaultNamespace) {
|
|
80
|
+
return function* CapVirtualSelectSaga() {
|
|
81
|
+
yield all([watchGetPaginatedOptions(namespace), watchGetOptionById(namespace)]);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
actionMatcher,
|
|
86
|
+
CapVirtualSelectRootSaga as default,
|
|
87
|
+
getOptionById,
|
|
88
|
+
getPaginatedOptions,
|
|
89
|
+
watchGetOptionById,
|
|
90
|
+
watchGetPaginatedOptions
|
|
91
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const makeSelectGetPaginatedOptions: () => ((state: import("immutable").Map<never, never>, ownProps: any) => {
|
|
2
|
+
getPaginatedOptionsStatus: any;
|
|
3
|
+
getPaginatedOptions: any;
|
|
4
|
+
getUnTransformedPaginatedOptions: any;
|
|
5
|
+
getPaginatedOptionsTotalCount: any;
|
|
6
|
+
}) & import("reselect").OutputSelectorFields<(args_0: import("immutable").Map<"getPaginatedOptionsStatus" | "getPaginatedOptions" | "getUnTransformedPaginatedOptions" | "getPaginatedOptionsError" | "getPaginatedOptionsTotalCount" | "getOptionByIdStatus" | "getOptionById" | "getOptionByIdError", any>) => {
|
|
7
|
+
getPaginatedOptionsStatus: any;
|
|
8
|
+
getPaginatedOptions: any;
|
|
9
|
+
getUnTransformedPaginatedOptions: any;
|
|
10
|
+
getPaginatedOptionsTotalCount: any;
|
|
11
|
+
}, {
|
|
12
|
+
clearCache: () => void;
|
|
13
|
+
}> & {
|
|
14
|
+
clearCache: () => void;
|
|
15
|
+
};
|
|
16
|
+
declare const makeSelectGetOptionById: () => ((state: import("immutable").Map<never, never>, ownProps: any) => {
|
|
17
|
+
getOptionByIdStatus: any;
|
|
18
|
+
getOptionById: any;
|
|
19
|
+
}) & import("reselect").OutputSelectorFields<(args_0: import("immutable").Map<"getPaginatedOptionsStatus" | "getPaginatedOptions" | "getUnTransformedPaginatedOptions" | "getPaginatedOptionsError" | "getPaginatedOptionsTotalCount" | "getOptionByIdStatus" | "getOptionById" | "getOptionByIdError", any>) => {
|
|
20
|
+
getOptionByIdStatus: any;
|
|
21
|
+
getOptionById: any;
|
|
22
|
+
}, {
|
|
23
|
+
clearCache: () => void;
|
|
24
|
+
}> & {
|
|
25
|
+
clearCache: () => void;
|
|
26
|
+
};
|
|
27
|
+
export { makeSelectGetPaginatedOptions, makeSelectGetOptionById };
|
|
28
|
+
//# sourceMappingURL=selectors.d.ts.map
|