@fixefy/fixefy-ui-components 0.2.60 → 0.2.61
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.
|
@@ -29,5 +29,6 @@ export type AsyncDropdownPropsType = {
|
|
|
29
29
|
placeholder?: string;
|
|
30
30
|
rootStylesOverride?: any;
|
|
31
31
|
options_path?: string;
|
|
32
|
+
defaultValue?: any;
|
|
32
33
|
};
|
|
33
34
|
export declare const FxAsyncDropdown: React.ForwardRefExoticComponent<Omit<AsyncDropdownPropsType, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -121,6 +121,7 @@ const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox,
|
|
|
121
121
|
});
|
|
122
122
|
const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
123
123
|
const { onAdd, onRemoveOne, onRemoveAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query, isInitialOpen, placeholder, title_path, rootStylesOverride, logo_placeholder, logo_folder_name, options_path } = props;
|
|
124
|
+
let { defaultValue } = props;
|
|
124
125
|
const ref = (0, _react.useRef)(null);
|
|
125
126
|
const theme = (0, _material.useTheme)();
|
|
126
127
|
const [displayed, setDisplayed] = (0, _react.useState)(multiple ? [] : '');
|
|
@@ -136,6 +137,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
136
137
|
const { where, sort } = fetcher.queryOptions.variables;
|
|
137
138
|
const ws = (0, _nookies.parseCookies)().ws;
|
|
138
139
|
const isLocal = fetcher.query.loc;
|
|
140
|
+
const [defaultValueWhere, setDefaultValueWhere] = (0, _react.useState)(where);
|
|
139
141
|
const getWhere = ()=>{
|
|
140
142
|
if (method_name == 'workspace') {
|
|
141
143
|
return searchValue ? _object_spread_props(_object_spread({}, where), {
|
|
@@ -162,11 +164,23 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
162
164
|
sort: sort || {}
|
|
163
165
|
}
|
|
164
166
|
}));
|
|
167
|
+
const [defaultValueFetch, { data: defaultValueData }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
|
|
168
|
+
variables: {
|
|
169
|
+
where: defaultValueWhere,
|
|
170
|
+
sort: sort || {}
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
165
173
|
(0, _react.useEffect)(()=>{
|
|
166
174
|
if (!disabled) {
|
|
167
175
|
fetch();
|
|
168
176
|
}
|
|
169
177
|
}, []);
|
|
178
|
+
(0, _react.useEffect)(()=>{
|
|
179
|
+
if (!disabled && defaultValue) {
|
|
180
|
+
defaultValueFetch();
|
|
181
|
+
defaultValue = null;
|
|
182
|
+
}
|
|
183
|
+
}, []);
|
|
170
184
|
(0, _react.useEffect)(()=>{
|
|
171
185
|
const storedData = sessionStorage.getItem(`dropdown-${query}-${name}`);
|
|
172
186
|
if (storedData) {
|
|
@@ -197,6 +211,23 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
197
211
|
data,
|
|
198
212
|
reason
|
|
199
213
|
]);
|
|
214
|
+
(0, _react.useEffect)(()=>{
|
|
215
|
+
if (defaultValue) {
|
|
216
|
+
setDefaultValueWhere(_object_spread_props(_object_spread({}, where), {
|
|
217
|
+
[title_path]: defaultValue
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
}, []);
|
|
221
|
+
(0, _react.useEffect)(()=>{
|
|
222
|
+
var _defaultValueData_method_name;
|
|
223
|
+
if (defaultValue && (defaultValueData === null || defaultValueData === void 0 ? void 0 : (_defaultValueData_method_name = defaultValueData[method_name]) === null || _defaultValueData_method_name === void 0 ? void 0 : _defaultValueData_method_name.length) == 1) {
|
|
224
|
+
//choose default value
|
|
225
|
+
handleOptionClick(defaultValueData === null || defaultValueData === void 0 ? void 0 : defaultValueData[method_name][0]);
|
|
226
|
+
}
|
|
227
|
+
}, [
|
|
228
|
+
defaultValue,
|
|
229
|
+
defaultValueData
|
|
230
|
+
]);
|
|
200
231
|
const handleSearch = (e)=>{
|
|
201
232
|
setSearchValue(e.target.value);
|
|
202
233
|
setReason('searched');
|
|
@@ -260,7 +291,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
260
291
|
setDisplayed(option);
|
|
261
292
|
onAdd && onAdd(option);
|
|
262
293
|
addToStoredDisplayed(option);
|
|
263
|
-
!multiple && setIsOpen(false);
|
|
294
|
+
!multiple && !defaultValue && setIsOpen(false);
|
|
264
295
|
}
|
|
265
296
|
};
|
|
266
297
|
const deleteOneItem = (item)=>{
|
package/package.json
CHANGED