@fixefy/fixefy-ui-components 0.2.60 → 0.2.62
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,24 @@ 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
|
+
onAdd && onAdd(defaultValueData === null || defaultValueData === void 0 ? void 0 : defaultValueData[method_name][0]);
|
|
227
|
+
}
|
|
228
|
+
}, [
|
|
229
|
+
defaultValue,
|
|
230
|
+
defaultValueData
|
|
231
|
+
]);
|
|
200
232
|
const handleSearch = (e)=>{
|
|
201
233
|
setSearchValue(e.target.value);
|
|
202
234
|
setReason('searched');
|
|
@@ -260,7 +292,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
260
292
|
setDisplayed(option);
|
|
261
293
|
onAdd && onAdd(option);
|
|
262
294
|
addToStoredDisplayed(option);
|
|
263
|
-
!multiple && setIsOpen(false);
|
|
295
|
+
!multiple && !defaultValue && setIsOpen(false);
|
|
264
296
|
}
|
|
265
297
|
};
|
|
266
298
|
const deleteOneItem = (item)=>{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const FxModalWithButton: ({ btnValue, modalData, onClick, disabled, }: {
|
|
2
|
+
export declare const FxModalWithButton: ({ btnValue, modalData, onClick, disabled, defaultOpen, }: {
|
|
3
3
|
btnValue: string;
|
|
4
4
|
modalData: any;
|
|
5
5
|
onClick?: any;
|
|
6
6
|
disabled?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
7
8
|
}) => React.JSX.Element;
|
|
@@ -52,8 +52,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
52
52
|
}
|
|
53
53
|
return newObj;
|
|
54
54
|
}
|
|
55
|
-
const FxModalWithButton = ({ btnValue, modalData, onClick, disabled })=>{
|
|
56
|
-
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
55
|
+
const FxModalWithButton = ({ btnValue, modalData, onClick, disabled, defaultOpen })=>{
|
|
56
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(defaultOpen || false);
|
|
57
57
|
const [AnchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
58
58
|
const handleClick = (e)=>{
|
|
59
59
|
if (onClick) {
|
package/package.json
CHANGED