@fixefy/fixefy-ui-components 0.2.10 → 0.2.12

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.
@@ -133,28 +133,29 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
133
133
  const [prevPage, setPrevPage] = (0, _react.useState)(0);
134
134
  const pageSize = 20;
135
135
  const { method_name } = variables;
136
+ const { where } = fetcher.queryOptions.variables;
136
137
  const ws = (0, _nookies.parseCookies)().ws;
137
138
  const isLocal = fetcher.query.loc;
138
139
  const getWhere = ()=>{
139
- if (variables.method_name == 'workspace') {
140
- return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
140
+ if (method_name == 'workspace') {
141
+ return searchValue ? _object_spread_props(_object_spread({}, where), {
141
142
  _id: ws,
142
143
  [search_path]: {
143
144
  $regex: searchValue
144
145
  }
145
- }) : _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
146
+ }) : _object_spread_props(_object_spread({}, where), {
146
147
  _id: ws
147
148
  });
148
149
  } else {
149
- return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
150
+ return searchValue ? _object_spread_props(_object_spread({}, where), {
150
151
  [search_path]: {
151
152
  $regex: searchValue
152
153
  }
153
- }) : _object_spread({}, fetcher.queryOptions.variables.where);
154
+ }) : _object_spread({}, where);
154
155
  }
155
156
  };
156
157
  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), {
157
- variables: _object_spread_props(_object_spread({}, fetcher.queryOptions.variables), {
158
+ variables: _object_spread_props(_object_spread({}, where), {
158
159
  where: getWhere(),
159
160
  skip: page * pageSize - pageSize,
160
161
  limit: pageSize
@@ -183,7 +184,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
183
184
  (0, _react.useEffect)(()=>{
184
185
  if (data && !isLastPage && prevPage < page) {
185
186
  //raaya todo: this is too messy clean it
186
- const newOptions = variables.method_name == 'workspace' ? data.workspace[search_path === null || search_path === void 0 ? void 0 : search_path.split('.')[1]] : data[method_name];
187
+ const newOptions = method_name == 'workspace' ? data.workspace[search_path === null || search_path === void 0 ? void 0 : search_path.split('.')[1]] : data[method_name];
187
188
  if (newOptions == null || newOptions.length < pageSize) {
188
189
  setIsLastPage(true);
189
190
  }
@@ -1,14 +1,10 @@
1
1
  import React from 'react';
2
2
  import { EntityStatusType, ChargeStateType, InvoiceStateType, RecoStateType } from '@fixefy/fixefy-ui-utils';
3
- type ChipType = {
4
- score: string;
5
- status: EntityStatusType | ChargeStateType | InvoiceStateType | RecoStateType;
6
- };
7
3
  export interface ChipPropsType {
8
4
  status?: EntityStatusType | ChargeStateType | InvoiceStateType | RecoStateType;
9
5
  label: string | number;
10
6
  variant?: 'outlined' | 'filled';
11
- type?: ChipType;
7
+ type?: 'status' | 'priority' | 'score';
12
8
  scoreValue?: number;
13
9
  minimized?: boolean;
14
10
  [x: string]: any;
@@ -16,4 +12,3 @@ export interface ChipPropsType {
16
12
  onDelete?: (e: any) => void;
17
13
  }
18
14
  export declare const FxChip: (props: ChipPropsType) => React.JSX.Element;
19
- export {};
@@ -22,24 +22,34 @@ const FxChip = (props)=>{
22
22
  const { status, label, type = 'status', scoreValue = 0, minimized = false, variant = 'outlined', onClick, onDelete } = props;
23
23
  const newStatus = status ? status.split(' ').join('_') : status;
24
24
  const value = typeof label === 'number' ? label.toFixed(2) : label;
25
- return type === 'status' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_chipstyles.StatusChipStyled, {
26
- status: newStatus,
27
- label: (0, _fixefyuiutils.titleCase)(value),
28
- variant: variant,
29
- onClick: onClick,
30
- onDelete: onDelete,
31
- deleteIcon: onDelete ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CloseRounded, {
32
- sx: {
33
- width: 11,
34
- height: 11
35
- }
36
- }) : null
37
- }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_chipstyles.ScoreChipStyled, {
38
- score: scoreValue,
39
- scoreLabel: (0, _fixefyuiutils.getScoreColor)(scoreValue),
40
- label: (0, _fixefyuiutils.titleCase)(value),
41
- minimized: minimized,
42
- variant: variant,
43
- onClick: onClick
44
- });
25
+ if (type === 'status') {
26
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_chipstyles.StatusChipStyled, {
27
+ status: newStatus,
28
+ label: (0, _fixefyuiutils.titleCase)(value),
29
+ variant: variant,
30
+ onClick: onClick,
31
+ onDelete: onDelete,
32
+ deleteIcon: onDelete ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CloseRounded, {
33
+ sx: {
34
+ width: 11,
35
+ height: 11
36
+ }
37
+ }) : null
38
+ });
39
+ } else if (type === 'priority') {
40
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_chipstyles.PriorityChipStyled, {
41
+ status: newStatus,
42
+ label: (0, _fixefyuiutils.titleCase)(value),
43
+ variant: variant
44
+ });
45
+ } else {
46
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_chipstyles.ScoreChipStyled, {
47
+ score: scoreValue,
48
+ scoreLabel: (0, _fixefyuiutils.getScoreColor)(scoreValue),
49
+ label: (0, _fixefyuiutils.titleCase)(value),
50
+ minimized: minimized,
51
+ variant: variant,
52
+ onClick: onClick
53
+ });
54
+ }
45
55
  };
@@ -1,2 +1,3 @@
1
1
  export declare const ScoreChipStyled: StyledComponent<ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps>;
2
2
  export declare const StatusChipStyled: StyledComponent<ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps>;
3
+ export declare const PriorityChipStyled: StyledComponent<ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps>;
@@ -9,6 +9,9 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ PriorityChipStyled: function() {
13
+ return PriorityChipStyled;
14
+ },
12
15
  ScoreChipStyled: function() {
13
16
  return ScoreChipStyled;
14
17
  },
@@ -59,3 +62,21 @@ const StatusChipStyled = (0, _styles.styled)(_material.Chip)(({ theme, status, v
59
62
  border: `1px solid ${border}`
60
63
  };
61
64
  });
65
+ const PriorityChipStyled = (0, _styles.styled)(_material.Chip)(({ theme, status })=>{
66
+ const backgroundColor = theme.palette.chipPriority[status].background;
67
+ const labelColor = theme.palette.chipPriority[status].label;
68
+ const border = theme.palette.chipPriority[status].border;
69
+ return {
70
+ height: 20,
71
+ minWidth: 80,
72
+ maxWidth: 120,
73
+ ['& .MuiChip-label']: {
74
+ fontSize: 9,
75
+ fontWeight: 600,
76
+ lineHeight: '12px',
77
+ color: labelColor ? labelColor : theme.palette.statistics.label
78
+ },
79
+ backgroundColor,
80
+ border: `1px solid ${border}`
81
+ };
82
+ });
package/package.json CHANGED
@@ -70,5 +70,5 @@
70
70
  "require": "./dist/index.js"
71
71
  }
72
72
  },
73
- "version": "0.2.10"
73
+ "version": "0.2.12"
74
74
  }