@fixefy/fixefy-ui-components 0.1.69 → 0.1.71

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.
@@ -18,7 +18,7 @@ export type AsyncDropdownPropsType = {
18
18
  multiple?: boolean;
19
19
  name: any;
20
20
  variables: any;
21
- onChange?: (value: any, name: string) => void;
21
+ onChange?: (value: any, actionType: 'check' | 'uncheck' | null) => void;
22
22
  type?: 'checkbox' | 'text';
23
23
  renderOptions?: (option: Option, index: number) => void;
24
24
  [x: string]: any;
@@ -148,12 +148,12 @@ const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox,
148
148
  });
149
149
  const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRef)=>{
150
150
  var _props_styles;
151
+ const { debug, onChange, renderOptions, fetcher, disabled, type = 'text', title_path, variables, search_path, modal_type, multiple, name, query } = props;
151
152
  const ref = (0, _react.useRef)(null);
152
153
  const theme = (0, _material.useTheme)();
153
- const [value, setValue] = (0, _react.useState)(null);
154
- const [displayedValue, setDisplayedValue] = (0, _react.useState)('');
154
+ const [displayedValue, setDisplayedValue] = (0, _react.useState)(multiple ? [] : '');
155
155
  const [options, setOptions] = (0, _react.useState)([]);
156
- // const [loadingData, setLoadingData] = useState(false)
156
+ const [loadingData, setLoadingData] = (0, _react.useState)(false);
157
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);
@@ -161,9 +161,21 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
161
161
  const [page, setPage] = (0, _react.useState)(1);
162
162
  const [prevPage, setPrevPage] = (0, _react.useState)(0);
163
163
  const pageSize = 20;
164
- const { debug, onChange, renderOptions, fetcher, disabled, type = 'text', title_path, variables, search_path, modal_type, name } = props;
165
164
  const { method_name } = variables;
166
165
  const ws = (0, _nookies.parseCookies)().ws;
166
+ (0, _react.useEffect)(()=>{
167
+ let storedFilters = sessionStorage.getItem(query) || undefined;
168
+ if (storedFilters) {
169
+ storedFilters = JSON.parse(storedFilters);
170
+ if (storedFilters === null || storedFilters === void 0 ? void 0 : storedFilters[name]) {
171
+ const storedOperator = Object.keys(storedFilters[name])[0];
172
+ setDisplayedValue(storedFilters[name][storedOperator]);
173
+ }
174
+ }
175
+ }, [
176
+ name,
177
+ query
178
+ ]);
167
179
  const getWhere = ()=>{
168
180
  if (variables.method_name == 'workspace') {
169
181
  return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
@@ -183,7 +195,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
183
195
  }
184
196
  };
185
197
  const isLocal = fetcher.query.loc;
186
- const [fetch, { data, loading }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
198
+ const [fetch, { data }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
187
199
  variables: _object_spread_props(_object_spread({}, fetcher.queryOptions.variables), {
188
200
  where: getWhere(),
189
201
  skip: page * pageSize - pageSize,
@@ -198,12 +210,6 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
198
210
  setPrevPage(0);
199
211
  setIsLastPage(false);
200
212
  };
201
- (0, _react.useEffect)(()=>{
202
- //@ts-ignore
203
- onChange && value && onChange(value, name);
204
- }, [
205
- value
206
- ]);
207
213
  const handleChildrens = (_param)=>{
208
214
  var { structure } = _param, rest = _object_without_properties(_param, [
209
215
  "structure"
@@ -253,13 +259,22 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
253
259
  var _option_title;
254
260
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
255
261
  onClick: ()=>{
256
- setValue(option);
257
- setDisplayedValue(displayedVal);
262
+ if (displayedValue.includes(option[title_path])) {
263
+ setDisplayedValue((prev)=>prev.filter((val)=>val !== displayedVal));
264
+ onChange && onChange(option, 'uncheck');
265
+ } else {
266
+ // debugger
267
+ onChange && onChange(option, 'check');
268
+ setDisplayedValue((prev)=>[
269
+ ...prev,
270
+ displayedVal
271
+ ]);
272
+ }
258
273
  },
259
274
  children: [
260
275
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
261
276
  icon: icon,
262
- checked: value === option,
277
+ checked: displayedValue.includes(option[title_path]),
263
278
  checkedIcon: checkedIcon,
264
279
  sx: {
265
280
  mr: 1,
@@ -288,8 +303,8 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
288
303
  const displayedVal = (_option_title_path = option[title_path]) !== null && _option_title_path !== void 0 ? _option_title_path : option.title;
289
304
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
290
305
  onClick: ()=>{
291
- setValue(option);
292
- setDisplayedValue((0, _helpers.titleCase)(displayedVal));
306
+ setDisplayedValue(displayedVal);
307
+ onChange && onChange(option, null);
293
308
  },
294
309
  children: modal_type === 'chip' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
295
310
  status: option.value,
@@ -321,7 +336,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
321
336
  }
322
337
  default:
323
338
  {
324
- return options.map((option)=>{
339
+ return options.map((option, index)=>{
325
340
  debug === true && console.log('renderOptions: ', title_path, option[title_path], options);
326
341
  var _option_title_path;
327
342
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
@@ -330,7 +345,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
330
345
  color: theme.palette.typography.title,
331
346
  children: (0, _helpers.titleCase)((_option_title_path = option[title_path]) !== null && _option_title_path !== void 0 ? _option_title_path : option.title)
332
347
  })
333
- });
348
+ }, index);
334
349
  });
335
350
  }
336
351
  }
@@ -343,7 +358,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
343
358
  }
344
359
  }));
345
360
  const loadMore = ()=>{
346
- // setLoadingData(true)
361
+ setLoadingData(true);
347
362
  setPage((prevPage)=>prevPage + 1);
348
363
  setPrevPage((prevPage)=>prevPage + 1);
349
364
  };
@@ -367,7 +382,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
367
382
  ...newOptions
368
383
  ]);
369
384
  }
370
- // setLoadingData(false)
385
+ setLoadingData(false);
371
386
  }
372
387
  }, [
373
388
  data,
@@ -395,7 +410,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
395
410
  handleSearch(e);
396
411
  }
397
412
  }),
398
- loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
413
+ loadingData && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
399
414
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
400
415
  })
401
416
  ]
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@apollo/client": "^3.8.4",
8
- "@fixefy/fixefy-ui-utils": "0.0.33",
8
+ "@fixefy/fixefy-ui-utils": "0.0.18",
9
9
  "@mui/icons-material": "^5.14.11",
10
10
  "@mui/material": "^5.14.11",
11
11
  "@mui/styled-engine": "^5.14.11",
@@ -56,7 +56,7 @@
56
56
  "prettier": "prettier --write \"{src,tests,example/src}/**/*.{js,ts,jsx,tsx}\""
57
57
  },
58
58
  "engines": {
59
- "node": "18"
59
+ "node": "18.17.1"
60
60
  },
61
61
  "files": [
62
62
  "dist/**/*"
@@ -70,5 +70,5 @@
70
70
  "require": "./dist/index.js"
71
71
  }
72
72
  },
73
- "version": "0.1.69"
73
+ "version": "0.1.71"
74
74
  }