@fixefy/fixefy-ui-components 0.1.59 → 0.1.60
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/FxAsyncDropdown/FxAsyncDropdown.d.ts +5 -16
- package/dist/FxAsyncDropdown/FxAsyncDropdown.js +209 -216
- package/dist/FxAsyncDropdown/helpers/helpers.d.ts +2 -0
- package/dist/FxAsyncDropdown/helpers/helpers.js +11 -1
- package/dist/FxIcon/FxIcon.d.ts +5 -10
- package/dist/FxIcon/FxIcon.js +45 -85
- package/dist/FxIcon/index.d.ts +1 -1
- package/dist/FxIcon/index.js +3 -11
- package/dist/FxScore/styles/score.styles.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +0 -3
- package/package.json +1 -1
|
@@ -14,27 +14,16 @@ export type AsyncDropdownPropsType = {
|
|
|
14
14
|
debug?: boolean;
|
|
15
15
|
initialValue?: Option | any;
|
|
16
16
|
styles?: StylesOptions;
|
|
17
|
-
|
|
18
|
-
name: string;
|
|
19
|
-
extended: {
|
|
20
|
-
title: string;
|
|
21
|
-
title_path: string;
|
|
22
|
-
search_path: string;
|
|
23
|
-
variables: {
|
|
24
|
-
method_name: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
children: any;
|
|
28
|
-
};
|
|
29
|
-
fetcher: {
|
|
30
|
-
query: any;
|
|
31
|
-
queryOptions: any;
|
|
32
|
-
};
|
|
17
|
+
method_name: string;
|
|
33
18
|
multiple?: boolean;
|
|
19
|
+
name: any;
|
|
20
|
+
variables: any;
|
|
34
21
|
onChange?: (value: any, name: string) => void;
|
|
35
22
|
type?: 'checkbox' | 'text';
|
|
36
23
|
renderOptions?: (option: Option, index: number) => void;
|
|
37
24
|
[x: string]: any;
|
|
38
25
|
showSelectedValue?: boolean;
|
|
26
|
+
modal_type?: string;
|
|
27
|
+
query: string;
|
|
39
28
|
};
|
|
40
29
|
export declare const FxAsyncDropdown: React.ForwardRefExoticComponent<Omit<AsyncDropdownPropsType, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -10,14 +10,16 @@ Object.defineProperty(exports, "FxAsyncDropdown", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
const _jsxruntime = require("react/jsx-runtime");
|
|
13
|
-
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
14
|
-
const _iconsmaterial = require("@mui/icons-material");
|
|
15
|
-
const _graphqltag = require("graphql-tag");
|
|
16
|
-
const _client = require("@apollo/client");
|
|
17
|
-
const _fixefyuiutils = require("@fixefy/fixefy-ui-utils");
|
|
18
13
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
14
|
+
const _iconsmaterial = require("@mui/icons-material");
|
|
19
15
|
const _material = require("@mui/material");
|
|
16
|
+
const _FxChip = require("../FxChip");
|
|
17
|
+
const _graphqltag = require("graphql-tag");
|
|
20
18
|
const _dropdownstyles = require("./styles/dropdown.styles");
|
|
19
|
+
const _helpers = require("./helpers/helpers");
|
|
20
|
+
const _client = require("@apollo/client");
|
|
21
|
+
const _FxIcon = require("../FxIcon");
|
|
22
|
+
const _nookies = require("nookies");
|
|
21
23
|
function _define_property(obj, key, value) {
|
|
22
24
|
if (key in obj) {
|
|
23
25
|
Object.defineProperty(obj, key, {
|
|
@@ -31,11 +33,6 @@ function _define_property(obj, key, value) {
|
|
|
31
33
|
}
|
|
32
34
|
return obj;
|
|
33
35
|
}
|
|
34
|
-
function _interop_require_default(obj) {
|
|
35
|
-
return obj && obj.__esModule ? obj : {
|
|
36
|
-
default: obj
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
36
|
function _getRequireWildcardCache(nodeInterop) {
|
|
40
37
|
if (typeof WeakMap !== "function") return null;
|
|
41
38
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -150,82 +147,76 @@ const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox,
|
|
|
150
147
|
fontSize: "small"
|
|
151
148
|
});
|
|
152
149
|
const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRef)=>{
|
|
153
|
-
var
|
|
150
|
+
var _props_styles;
|
|
154
151
|
const ref = (0, _react.useRef)(null);
|
|
155
152
|
const theme = (0, _material.useTheme)();
|
|
153
|
+
const [value, setValue] = (0, _react.useState)(null);
|
|
154
|
+
const [displayedValue, setDisplayedValue] = (0, _react.useState)('');
|
|
156
155
|
const [options, setOptions] = (0, _react.useState)([]);
|
|
157
|
-
const [loadingData, setLoadingData] =
|
|
156
|
+
// const [loadingData, setLoadingData] = useState(false)
|
|
157
|
+
const [reason, setReason] = (0, _react.useState)('init');
|
|
158
158
|
const [isLastPage, setIsLastPage] = (0, _react.useState)(false);
|
|
159
159
|
const [searchValue, setSearchValue] = (0, _react.useState)(null);
|
|
160
160
|
const [hasClearBtn, setHasClearBtn] = (0, _react.useState)(false);
|
|
161
161
|
const [page, setPage] = (0, _react.useState)(1);
|
|
162
162
|
const [prevPage, setPrevPage] = (0, _react.useState)(0);
|
|
163
|
-
const
|
|
164
|
-
const { debug,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"renderOptions",
|
|
170
|
-
"fetcher",
|
|
171
|
-
"initialValue",
|
|
172
|
-
"multiple",
|
|
173
|
-
"disabled",
|
|
174
|
-
"type",
|
|
175
|
-
"showSelectedValue"
|
|
176
|
-
]);
|
|
177
|
-
const { name, extended, children } = structure;
|
|
178
|
-
const { search_path, variables } = extended;
|
|
163
|
+
const pageSize = 20;
|
|
164
|
+
const { debug, onChange, // onClear,
|
|
165
|
+
renderOptions, fetcher, // initialValue = {},
|
|
166
|
+
// multiple,
|
|
167
|
+
disabled, type = 'text', // showSelectedValue = true,
|
|
168
|
+
title_path, variables, search_path, modal_type, query, name } = props;
|
|
179
169
|
const { method_name } = variables;
|
|
170
|
+
const ws = (0, _nookies.parseCookies)().ws;
|
|
171
|
+
const storedFilters = sessionStorage.getItem(query) || {};
|
|
172
|
+
(0, _react.useEffect)(()=>{
|
|
173
|
+
if (storedFilters[name]) {
|
|
174
|
+
const storedOperator = Object.keys(storedFilters[name])[0];
|
|
175
|
+
setDisplayedValue((0, _helpers.titleCase)(storedFilters[name][storedOperator].replaceAll('_', ' ')));
|
|
176
|
+
}
|
|
177
|
+
}, [
|
|
178
|
+
name,
|
|
179
|
+
query
|
|
180
|
+
]);
|
|
181
|
+
const getWhere = ()=>{
|
|
182
|
+
if (variables.method_name == 'workspace') {
|
|
183
|
+
return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
|
|
184
|
+
_id: ws,
|
|
185
|
+
[search_path]: {
|
|
186
|
+
$regex: searchValue
|
|
187
|
+
}
|
|
188
|
+
}) : _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
|
|
189
|
+
_id: ws
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
|
|
193
|
+
[search_path]: {
|
|
194
|
+
$regex: searchValue
|
|
195
|
+
}
|
|
196
|
+
}) : _object_spread({}, fetcher.queryOptions.variables.where);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
180
199
|
const [fetch, { data, loading }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
|
|
181
200
|
variables: _object_spread_props(_object_spread({}, fetcher.queryOptions.variables), {
|
|
182
|
-
where:
|
|
183
|
-
[search_path]: searchValue
|
|
184
|
-
}) : _object_spread({}, fetcher.queryOptions.variables.where),
|
|
201
|
+
where: getWhere(),
|
|
185
202
|
skip: page * pageSize - pageSize,
|
|
186
203
|
limit: pageSize
|
|
187
204
|
})
|
|
188
205
|
}));
|
|
189
|
-
|
|
190
|
-
const labelOption = (_structure_extended_title_path = structure === null || structure === void 0 ? void 0 : (_structure_extended = structure.extended) === null || _structure_extended === void 0 ? void 0 : _structure_extended.title_path) !== null && _structure_extended_title_path !== void 0 ? _structure_extended_title_path : 'title';
|
|
191
|
-
const { getRootProps, getInputProps, getClearProps, getListboxProps, getOptionProps, groupedOptions, value, popupOpen, focused, setAnchorEl } = (0, _material.useAutocomplete)(_object_spread_props(_object_spread({}, rest), {
|
|
192
|
-
defaultValue: initialValue,
|
|
193
|
-
options: options,
|
|
194
|
-
disableCloseOnSelect: !!multiple,
|
|
195
|
-
multiple,
|
|
196
|
-
disabled: disabled,
|
|
197
|
-
isOptionEqualToValue: (option, value)=>{
|
|
198
|
-
return option._id === value._id;
|
|
199
|
-
},
|
|
200
|
-
getOptionLabel: (option)=>{
|
|
201
|
-
var _option_labelOption;
|
|
202
|
-
return (0, _fixefyuiutils.titleCase)((_option_labelOption = option[labelOption]) !== null && _option_labelOption !== void 0 ? _option_labelOption : option.title);
|
|
203
|
-
}
|
|
204
|
-
}));
|
|
205
|
-
const onPopupScroll = _lodash.default.debounce(()=>{
|
|
206
|
-
if (ref && ref.current) {
|
|
207
|
-
//@ts-ignore
|
|
208
|
-
const threshHold = ref.current.scrollHeight / 2;
|
|
209
|
-
//@ts-ignore
|
|
210
|
-
if (ref.current.scrollTop > threshHold && !loadingData && !isLastPage) {
|
|
211
|
-
setLoadingData(true);
|
|
212
|
-
setPage((prevPage)=>prevPage + 1);
|
|
213
|
-
setPrevPage((prevPage)=>prevPage + 1);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}, 800);
|
|
217
|
-
const createTitle = ()=>{
|
|
218
|
-
if (Array.isArray(value)) {
|
|
219
|
-
if (value && value.length) {
|
|
220
|
-
return `${(0, _fixefyuiutils.titleCase)(name)} (${value.length})`;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return (0, _fixefyuiutils.titleCase)(name);
|
|
224
|
-
};
|
|
225
|
-
const handleSearch = _lodash.default.debounce((e)=>{
|
|
206
|
+
const handleSearch = (e)=>{
|
|
226
207
|
setSearchValue(e.target.value);
|
|
208
|
+
setDisplayedValue(e.target.value);
|
|
209
|
+
setReason('searched');
|
|
227
210
|
setPage(1);
|
|
228
|
-
|
|
211
|
+
setPrevPage(0);
|
|
212
|
+
setIsLastPage(false);
|
|
213
|
+
};
|
|
214
|
+
(0, _react.useEffect)(()=>{
|
|
215
|
+
//@ts-ignore
|
|
216
|
+
onChange && value && onChange(value, name);
|
|
217
|
+
}, [
|
|
218
|
+
value
|
|
219
|
+
]);
|
|
229
220
|
const handleChildrens = (_param)=>{
|
|
230
221
|
var { structure } = _param, rest = _object_without_properties(_param, [
|
|
231
222
|
"structure"
|
|
@@ -261,89 +252,100 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
261
252
|
};
|
|
262
253
|
const handleRenderOptions = ()=>{
|
|
263
254
|
debug === true && console.log('renderOptions: ', renderOptions);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
minWidth: 24,
|
|
294
|
-
minHeight: 24,
|
|
295
|
-
p: 0,
|
|
296
|
-
['& svg']: {
|
|
297
|
-
fill: theme.palette.primary.light
|
|
298
|
-
}
|
|
255
|
+
switch(type){
|
|
256
|
+
case 'checkbox':
|
|
257
|
+
{
|
|
258
|
+
return options.map((option)=>{
|
|
259
|
+
var _option_title_path;
|
|
260
|
+
const displayedVal = (_option_title_path = option[title_path]) !== null && _option_title_path !== void 0 ? _option_title_path : option.title;
|
|
261
|
+
let title = (0, _helpers.getJPart)(option, title_path, 0);
|
|
262
|
+
//if title is an array need to extract the first element
|
|
263
|
+
if (typeof title === 'object' && title.length > 0) {
|
|
264
|
+
title = title[0];
|
|
265
|
+
}
|
|
266
|
+
var _option_title;
|
|
267
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
|
|
268
|
+
onClick: ()=>{
|
|
269
|
+
setValue(option);
|
|
270
|
+
setDisplayedValue(displayedVal);
|
|
271
|
+
},
|
|
272
|
+
children: [
|
|
273
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
274
|
+
icon: icon,
|
|
275
|
+
checked: value === option,
|
|
276
|
+
checkedIcon: checkedIcon,
|
|
277
|
+
sx: {
|
|
278
|
+
mr: 1,
|
|
279
|
+
minWidth: 24,
|
|
280
|
+
minHeight: 24,
|
|
281
|
+
p: 0,
|
|
282
|
+
['& svg']: {
|
|
283
|
+
fill: theme.palette.primary.light
|
|
299
284
|
}
|
|
285
|
+
}
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
288
|
+
variant: "subtitle2",
|
|
289
|
+
color: theme.palette.typography.title,
|
|
290
|
+
children: (0, _helpers.titleCase)((_option_title = option === null || option === void 0 ? void 0 : option.title) !== null && _option_title !== void 0 ? _option_title : title)
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
}, option._id);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
case 'text':
|
|
297
|
+
{
|
|
298
|
+
return options.map((option)=>{
|
|
299
|
+
debug === true && console.log('renderOptions: ', title_path, option[title_path], options);
|
|
300
|
+
var _option_title_path;
|
|
301
|
+
const displayedVal = (_option_title_path = option[title_path]) !== null && _option_title_path !== void 0 ? _option_title_path : option.title;
|
|
302
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
303
|
+
onClick: ()=>{
|
|
304
|
+
setValue(option);
|
|
305
|
+
setDisplayedValue((0, _helpers.titleCase)(displayedVal));
|
|
306
|
+
},
|
|
307
|
+
children: modal_type === 'chip' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
308
|
+
status: option.value,
|
|
309
|
+
label: (0, _helpers.titleCase)(displayedVal),
|
|
310
|
+
variant: "outlined"
|
|
311
|
+
}) : modal_type === 'logo' ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
314
|
+
icon: `companies/${option.logo}`,
|
|
315
|
+
width: 70,
|
|
316
|
+
height: 16
|
|
300
317
|
}),
|
|
301
318
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
319
|
+
sx: {
|
|
320
|
+
marginLeft: '5px'
|
|
321
|
+
},
|
|
302
322
|
variant: "subtitle2",
|
|
303
323
|
color: theme.palette.typography.title,
|
|
304
|
-
children: (0,
|
|
324
|
+
children: (0, _helpers.titleCase)(displayedVal)
|
|
305
325
|
})
|
|
306
326
|
]
|
|
307
|
-
}))
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
})
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
default:
|
|
329
|
-
{
|
|
330
|
-
return groupedOptions.map((option, index)=>{
|
|
331
|
-
var _structure_extended, _structure_extended1, _structure_extended2;
|
|
332
|
-
debug === true && console.log('renderOptions: ', structure === null || structure === void 0 ? void 0 : (_structure_extended = structure.extended) === null || _structure_extended === void 0 ? void 0 : _structure_extended.title_path, option[structure === null || structure === void 0 ? void 0 : (_structure_extended1 = structure.extended) === null || _structure_extended1 === void 0 ? void 0 : _structure_extended1.title_path], options);
|
|
333
|
-
var _option_structure_extended_title_path;
|
|
334
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", _object_spread_props(_object_spread({}, getOptionProps({
|
|
335
|
-
option,
|
|
336
|
-
index
|
|
337
|
-
})), {
|
|
338
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
339
|
-
variant: "subtitle2",
|
|
340
|
-
color: theme.palette.typography.title,
|
|
341
|
-
children: (0, _fixefyuiutils.titleCase)((_option_structure_extended_title_path = option[structure === null || structure === void 0 ? void 0 : (_structure_extended2 = structure.extended) === null || _structure_extended2 === void 0 ? void 0 : _structure_extended2.title_path]) !== null && _option_structure_extended_title_path !== void 0 ? _option_structure_extended_title_path : option.title)
|
|
342
|
-
})
|
|
343
|
-
}));
|
|
327
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
328
|
+
variant: "subtitle2",
|
|
329
|
+
color: theme.palette.typography.title,
|
|
330
|
+
children: (0, _helpers.titleCase)(displayedVal)
|
|
331
|
+
})
|
|
332
|
+
}, option._id);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
default:
|
|
336
|
+
{
|
|
337
|
+
return options.map((option)=>{
|
|
338
|
+
debug === true && console.log('renderOptions: ', title_path, option[title_path], options);
|
|
339
|
+
var _option_title_path;
|
|
340
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
341
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
342
|
+
variant: "subtitle2",
|
|
343
|
+
color: theme.palette.typography.title,
|
|
344
|
+
children: (0, _helpers.titleCase)((_option_title_path = option[title_path]) !== null && _option_title_path !== void 0 ? _option_title_path : option.title)
|
|
345
|
+
})
|
|
344
346
|
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
+
});
|
|
348
|
+
}
|
|
347
349
|
}
|
|
348
350
|
};
|
|
349
351
|
(0, _react.useImperativeHandle)(parentRef, ()=>({
|
|
@@ -353,32 +355,11 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
353
355
|
(_getClearProps = getClearProps()) === null || _getClearProps === void 0 ? void 0 : _getClearProps.onClick(null);
|
|
354
356
|
}
|
|
355
357
|
}));
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return ()=>{
|
|
362
|
-
if (ref && ref.current) {
|
|
363
|
-
//@ts-ignore
|
|
364
|
-
ref.current.removeEventListener('scroll', ()=>onPopupScroll());
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
}, [
|
|
368
|
-
groupedOptions
|
|
369
|
-
]);
|
|
370
|
-
(0, _react.useEffect)(()=>{
|
|
371
|
-
onChange && onChange(value, name);
|
|
372
|
-
}, [
|
|
373
|
-
value
|
|
374
|
-
]);
|
|
375
|
-
(0, _react.useEffect)(()=>{
|
|
376
|
-
if (popupOpen && !isLastPage && prevPage < page && !disabled) {
|
|
377
|
-
fetch();
|
|
378
|
-
}
|
|
379
|
-
}, [
|
|
380
|
-
popupOpen
|
|
381
|
-
]);
|
|
358
|
+
const loadMore = ()=>{
|
|
359
|
+
// setLoadingData(true)
|
|
360
|
+
setPage((prevPage)=>prevPage + 1);
|
|
361
|
+
setPrevPage((prevPage)=>prevPage + 1);
|
|
362
|
+
};
|
|
382
363
|
(0, _react.useEffect)(()=>{
|
|
383
364
|
if (!disabled) {
|
|
384
365
|
fetch();
|
|
@@ -386,71 +367,83 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
386
367
|
}, []);
|
|
387
368
|
(0, _react.useEffect)(()=>{
|
|
388
369
|
if (data && !isLastPage && prevPage < page) {
|
|
389
|
-
|
|
370
|
+
//raaya todo: this is too messy clean it
|
|
371
|
+
const newOptions = variables.method_name == 'workspace' ? data.workspace[search_path === null || search_path === void 0 ? void 0 : search_path.split('.')[1]] : data[method_name];
|
|
390
372
|
if (newOptions.length === 0 || newOptions.length < pageSize) {
|
|
391
373
|
setIsLastPage(true);
|
|
392
374
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
375
|
+
if (reason === 'searched' || reason === 'init') {
|
|
376
|
+
setOptions(newOptions);
|
|
377
|
+
} else if (reason === 'loaded more') {
|
|
378
|
+
setOptions((prevOptions)=>[
|
|
379
|
+
...prevOptions,
|
|
380
|
+
...newOptions
|
|
381
|
+
]);
|
|
382
|
+
}
|
|
383
|
+
// setLoadingData(false)
|
|
398
384
|
}
|
|
399
385
|
}, [
|
|
400
|
-
data
|
|
386
|
+
data,
|
|
387
|
+
reason
|
|
401
388
|
]);
|
|
402
|
-
var _props_styles_width, _props_styles_maxWidth;
|
|
403
389
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.Root, {
|
|
404
390
|
children: [
|
|
405
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.InputWrapper,
|
|
406
|
-
hasValue: !!(value && Object.keys(value).length),
|
|
391
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.InputWrapper, {
|
|
407
392
|
disabled: disabled,
|
|
408
393
|
sx: {
|
|
409
|
-
width:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
ref: setAnchorEl,
|
|
414
|
-
className: focused ? 'focused' : '',
|
|
394
|
+
width: '100%',
|
|
395
|
+
border: 'none !important',
|
|
396
|
+
outline: 'none !important'
|
|
397
|
+
},
|
|
415
398
|
children: [
|
|
416
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)("input",
|
|
417
|
-
|
|
399
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
400
|
+
style: {
|
|
401
|
+
border: 'none',
|
|
402
|
+
outline: 'none'
|
|
403
|
+
},
|
|
404
|
+
autoFocus: true,
|
|
405
|
+
defaultValue: displayedValue !== null && displayedValue !== void 0 ? displayedValue : '',
|
|
406
|
+
placeholder: "Select an option...",
|
|
418
407
|
onChange: (e)=>{
|
|
419
|
-
var //@ts-ignore
|
|
420
|
-
_getInputProps;
|
|
421
|
-
(_getInputProps = getInputProps()) === null || _getInputProps === void 0 ? void 0 : _getInputProps.onChange(e);
|
|
422
408
|
handleSearch(e);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
})),
|
|
427
|
-
loading ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
|
|
409
|
+
}
|
|
410
|
+
}),
|
|
411
|
+
loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
|
|
428
412
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
|
|
429
|
-
})
|
|
413
|
+
})
|
|
430
414
|
]
|
|
431
|
-
})
|
|
432
|
-
|
|
415
|
+
}),
|
|
416
|
+
options.length > 0 && !disabled ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.StyledListBox, {
|
|
417
|
+
sx: _object_spread_props(_object_spread({}, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.menuSx), {
|
|
418
|
+
'&::-webkit-scrollbar': {
|
|
419
|
+
width: '16px',
|
|
420
|
+
backgroundColor: '#F5F5F5'
|
|
421
|
+
},
|
|
422
|
+
'&::-webkit-scrollbar-thumb': {
|
|
423
|
+
backgroundColor: '#F5F5F580',
|
|
424
|
+
borderRadius: '8px',
|
|
425
|
+
border: '4px solid #F5F5F5'
|
|
426
|
+
},
|
|
427
|
+
// To support Firefox
|
|
428
|
+
scrollbarWidth: 'thin',
|
|
429
|
+
scrollbarColor: '#F5F5F580 #F5F5F5',
|
|
430
|
+
maxHeight: '300px',
|
|
431
|
+
overflowY: 'auto'
|
|
432
|
+
}),
|
|
433
|
+
ref: ref,
|
|
433
434
|
children: [
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
children && children.length ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.StyledClose, {
|
|
441
|
-
children: handleChildrens({
|
|
442
|
-
structure: children[0],
|
|
443
|
-
onClick: (e)=>{
|
|
444
|
-
var //@ts-ignore
|
|
445
|
-
_getClearProps;
|
|
446
|
-
onClear && onClear();
|
|
447
|
-
(_getClearProps = getClearProps()) === null || _getClearProps === void 0 ? void 0 : _getClearProps.onClick(e);
|
|
435
|
+
handleRenderOptions(),
|
|
436
|
+
!isLastPage && /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
437
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
438
|
+
onClick: ()=>{
|
|
439
|
+
setReason('loaded more');
|
|
440
|
+
loadMore();
|
|
448
441
|
},
|
|
449
|
-
|
|
442
|
+
children: "load more"
|
|
450
443
|
})
|
|
451
|
-
})
|
|
444
|
+
})
|
|
452
445
|
]
|
|
453
|
-
})
|
|
446
|
+
}) : null
|
|
454
447
|
]
|
|
455
448
|
});
|
|
456
449
|
});
|
|
@@ -2,3 +2,5 @@ export declare const getJPart: (j: any, jsonPath: string, defaultValue?: any) =>
|
|
|
2
2
|
export declare const isArrayValid: (arr: any[], minLength?: number, maxLength?: number) => boolean;
|
|
3
3
|
export declare const isObjectValid: (obj: any, isCheckKeys?: boolean) => boolean;
|
|
4
4
|
export declare const isStringValid: (str: string, minLength?: number | null, maxLength?: number | null, isValidateType?: boolean) => boolean;
|
|
5
|
+
export declare const titleCase: (str?: string) => string;
|
|
6
|
+
export declare const toPascalCase: (string: string, title?: boolean) => string;
|
|
@@ -20,6 +20,12 @@ _export(exports, {
|
|
|
20
20
|
},
|
|
21
21
|
isStringValid: function() {
|
|
22
22
|
return isStringValid;
|
|
23
|
+
},
|
|
24
|
+
titleCase: function() {
|
|
25
|
+
return titleCase;
|
|
26
|
+
},
|
|
27
|
+
toPascalCase: function() {
|
|
28
|
+
return toPascalCase;
|
|
23
29
|
}
|
|
24
30
|
});
|
|
25
31
|
function _define_property(obj, key, value) {
|
|
@@ -96,7 +102,7 @@ const getJPart = (j, jsonPath, defaultValue)=>{
|
|
|
96
102
|
j = JSON.parse(j);
|
|
97
103
|
} else {
|
|
98
104
|
j = j.reduce((acc, cur)=>{
|
|
99
|
-
const innerJ = getJPart(cur, pathParts.slice(i).join(
|
|
105
|
+
const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
|
|
100
106
|
if (isArrayValid(innerJ)) {
|
|
101
107
|
acc.push(...innerJ);
|
|
102
108
|
} else {
|
|
@@ -149,3 +155,7 @@ const isStringValid = (str, minLength = null, maxLength = null, isValidateType =
|
|
|
149
155
|
}
|
|
150
156
|
return rv;
|
|
151
157
|
};
|
|
158
|
+
const titleCase = (str = '')=>str && toPascalCase(str.toString(), true);
|
|
159
|
+
const toPascalCase = (string, title = false)=>{
|
|
160
|
+
return string && string.replace(/(_[a-z])?(^[a-z])?(_|\s[a-z])?/g, ($1)=>$1.toUpperCase().replace('_', title ? ' ' : ''));
|
|
161
|
+
};
|
package/dist/FxIcon/FxIcon.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
className?: string;
|
|
3
|
-
color?: unknown;
|
|
4
|
-
fontSize?: string | number;
|
|
5
|
-
height?: `${number}` | number;
|
|
1
|
+
export declare const FxIcon: ({ icon, width, height, onClick, }: {
|
|
6
2
|
icon: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export declare const FxIcon: ({ className, color, fontSize, icon, height, sx, width }: IconPropsType) => JSX.Element;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
onClick?: (() => void) | undefined;
|
|
6
|
+
}) => JSX.Element;
|
package/dist/FxIcon/FxIcon.js
CHANGED
|
@@ -9,23 +9,10 @@ Object.defineProperty(exports, "FxIcon", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
-
const _react = /*#__PURE__*/
|
|
13
|
-
const
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _material = require("@mui/material");
|
|
14
14
|
const _fixefyuiutils = require("@fixefy/fixefy-ui-utils");
|
|
15
|
-
const
|
|
16
|
-
function _define_property(obj, key, value) {
|
|
17
|
-
if (key in obj) {
|
|
18
|
-
Object.defineProperty(obj, key, {
|
|
19
|
-
value: value,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
obj[key] = value;
|
|
26
|
-
}
|
|
27
|
-
return obj;
|
|
28
|
-
}
|
|
15
|
+
const _image = /*#__PURE__*/ _interop_require_default(require("next/image"));
|
|
29
16
|
function _interop_require_default(obj) {
|
|
30
17
|
return obj && obj.__esModule ? obj : {
|
|
31
18
|
default: obj
|
|
@@ -72,76 +59,49 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
72
59
|
}
|
|
73
60
|
return newObj;
|
|
74
61
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ownKeys.forEach(function(key) {
|
|
85
|
-
_define_property(target, key, source[key]);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
function ownKeys(object, enumerableOnly) {
|
|
91
|
-
var keys = Object.keys(object);
|
|
92
|
-
if (Object.getOwnPropertySymbols) {
|
|
93
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
94
|
-
if (enumerableOnly) {
|
|
95
|
-
symbols = symbols.filter(function(sym) {
|
|
96
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
keys.push.apply(keys, symbols);
|
|
100
|
-
}
|
|
101
|
-
return keys;
|
|
102
|
-
}
|
|
103
|
-
function _object_spread_props(target, source) {
|
|
104
|
-
source = source != null ? source : {};
|
|
105
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
106
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
107
|
-
} else {
|
|
108
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
109
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return target;
|
|
113
|
-
}
|
|
114
|
-
// importing all the local icons - in the future should be removed to CDN server
|
|
115
|
-
const iconsModule = [];
|
|
116
|
-
const FxIcon = ({ className, color, fontSize, icon, height, sx, width })=>{
|
|
117
|
-
if (!icon) throw Error('Provide a property `icon`');
|
|
118
|
-
let rv;
|
|
119
|
-
const splittedPath = icon.split('/');
|
|
120
|
-
const iconWithoutPath = (0, _fixefyuiutils.toPascalCase)(splittedPath[splittedPath.length - 1]);
|
|
121
|
-
// const name = toPascalCase(icon)
|
|
122
|
-
if (iconsModule[iconWithoutPath]) {
|
|
123
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_content.DynamicIcon, {
|
|
124
|
-
icon: iconsModule[iconWithoutPath],
|
|
125
|
-
sx: sx
|
|
126
|
-
});
|
|
127
|
-
// @ts-ignore
|
|
128
|
-
} else if (_iconsmaterial[iconWithoutPath]) {
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
const MUIIcon = _iconsmaterial[iconWithoutPath];
|
|
131
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(MUIIcon, {
|
|
132
|
-
className: className,
|
|
133
|
-
color: color,
|
|
134
|
-
sx: _object_spread_props(_object_spread({}, sx), {
|
|
135
|
-
fontSize
|
|
62
|
+
const PublicIcon = ({ icon, width, height, onClick })=>{
|
|
63
|
+
const [isError, setError] = (0, _react.useState)(false);
|
|
64
|
+
const handleError = (isError)=>setError(isError);
|
|
65
|
+
if (isError) {
|
|
66
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Avatar, {
|
|
67
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
68
|
+
fontSize: 29,
|
|
69
|
+
fontWeight: 600,
|
|
70
|
+
children: (0, _fixefyuiutils.toInitials)(icon)
|
|
136
71
|
})
|
|
137
72
|
});
|
|
138
|
-
} else {
|
|
139
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_content.LazyIcon, {
|
|
140
|
-
icon: icon,
|
|
141
|
-
sx: sx,
|
|
142
|
-
width: width,
|
|
143
|
-
height: height
|
|
144
|
-
});
|
|
145
73
|
}
|
|
146
|
-
return
|
|
74
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_image.default, {
|
|
75
|
+
alt: "",
|
|
76
|
+
width: width,
|
|
77
|
+
height: height,
|
|
78
|
+
loader: imageLoader,
|
|
79
|
+
src: icon,
|
|
80
|
+
onLoad: ()=>handleError(false),
|
|
81
|
+
onError: ()=>handleError(true),
|
|
82
|
+
onClick: onClick
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const FxIcon = ({ icon, width, height, onClick })=>{
|
|
86
|
+
if (!icon) throw Error('Provide a property `icon`');
|
|
87
|
+
return parseIconFromLibrary({
|
|
88
|
+
icon,
|
|
89
|
+
width,
|
|
90
|
+
height,
|
|
91
|
+
onClick
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const parseIconFromLibrary = ({ icon, width, height, onClick })=>{
|
|
95
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(PublicIcon, {
|
|
96
|
+
icon: icon,
|
|
97
|
+
width: width,
|
|
98
|
+
height: height,
|
|
99
|
+
onClick: onClick
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const imageLoader = ({ src })=>{
|
|
103
|
+
const transformedSrc = src.split('/');
|
|
104
|
+
transformedSrc.splice(transformedSrc.length - 1, 1, transformedSrc[transformedSrc.length - 1].split(/(?=[A-Z])/).join('_').toLowerCase());
|
|
105
|
+
const url = transformedSrc.join('/');
|
|
106
|
+
return `${process.env.NEXT_PUBLIC_ASSET_URL}/${url}`;
|
|
147
107
|
};
|
package/dist/FxIcon/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FxIcon
|
|
1
|
+
export { FxIcon } from './FxIcon';
|
package/dist/FxIcon/index.js
CHANGED
|
@@ -2,18 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
FxIcon: function() {
|
|
5
|
+
Object.defineProperty(exports, "FxIcon", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
13
8
|
return _FxIcon.FxIcon;
|
|
14
|
-
},
|
|
15
|
-
IconPropsType: function() {
|
|
16
|
-
return _FxIcon.IconPropsType;
|
|
17
9
|
}
|
|
18
10
|
});
|
|
19
11
|
const _FxIcon = require("./FxIcon");
|
|
@@ -78,7 +78,8 @@ const useStyles = (0, _styles.makeStyles)((theme)=>({
|
|
|
78
78
|
flexDirection: 'column'
|
|
79
79
|
},
|
|
80
80
|
scoreNumber: {
|
|
81
|
-
color: theme.palette.common.white
|
|
81
|
+
color: theme.palette.common.white,
|
|
82
|
+
fontWeight: 700
|
|
82
83
|
},
|
|
83
84
|
scoreText: _object_spread_props(_object_spread({}, theme.typography.table), {
|
|
84
85
|
fontWeight: 400,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { FxAsyncDropdown, Option, StylesOptions, AsyncDropdownPropsType } from '
|
|
|
4
4
|
export { FxAvatar, AvatarPropsType, BackgroundColorsType } from './FxAvatar';
|
|
5
5
|
export { FxButton, ButtonPropsType } from './FxButton';
|
|
6
6
|
export { FxChip, ChipPropsType } from './FxChip';
|
|
7
|
-
export { FxIcon
|
|
7
|
+
export { FxIcon } from './FxIcon';
|
|
8
8
|
export { FxModal, ModalPropsType } from './FxModal';
|
|
9
9
|
export { FxNotes, NoteCreateInput, NotesPropsType } from './FxNotes';
|
|
10
10
|
export { FxNumberField, NumberfieldPropsType } from './FxNumberField';
|
|
@@ -18,4 +18,4 @@ export { FxStatusBar, StatusBarPropsType, Options } from './FxStatusBar';
|
|
|
18
18
|
export { FxTag, TagPropsType } from './FxTag';
|
|
19
19
|
export { FxTextField, TextFieldPropsType } from './FxTextField';
|
|
20
20
|
export { FxTodo, TodoItemType, TodoPropsType } from './FxTodo';
|
|
21
|
-
export { Card, PageHeader, Label, BoldValue, Value, PageTitle, Link, Text, ShowMore, ShowMoreContainer, DataWrapper, Bars } from './FxStyledComponents';
|
|
21
|
+
export { Card, PageHeader, Label, BoldValue, Value, PageTitle, Link, Text, ShowMore, ShowMoreContainer, DataWrapper, Bars, } from './FxStyledComponents';
|
package/dist/index.js
CHANGED
package/package.json
CHANGED