@codezee/sixtify-brahma 0.2.119 → 0.2.121

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codezee/sixtify-brahma",
3
- "version": "0.2.119",
3
+ "version": "0.2.121",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
@@ -1 +1 @@
1
- {"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,IAAI,oBAAoB,EACzC,UAAU,EACX,MAAM,eAAe,CAAC;AAkBvB,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAUzB,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAC1E,IAAI,CACF,IAAI,CACF,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EACvD,aAAa,CACd,EACD,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAC/B,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,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EACd,QAAQ,EACR,SAAa,EACb,GAAG,SAAS,EACb,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CA2atB"}
@@ -18,7 +18,7 @@ const CheckBox_styled_1 = require("../CheckBox/CheckBox.styled");
18
18
  const ChipV2_styled_1 = require("./ChipV2.styled");
19
19
  const Skeleton_1 = require("./Skeleton");
20
20
  const Tags_1 = require("./Tags");
21
- function Autocomplete({ control, defaultValue, name, required = false, label, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, withLabel = false, placeholder = "", freeSolo, isShowOptionsOnType = false, isShowSelectAll = true, isShowAvatar = false, isShowEmployeeData = false, shouldCloseOnSelect = false, onAction, renderOption, getOptionLabel, maxLimit, autoFocus = false, defaultOption, disableClearable = required ? true : false, containerProps, setValue, limitTags, ...restProps }) {
21
+ function Autocomplete({ control, defaultValue, name, required = false, label, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, withLabel = false, placeholder = "", freeSolo, isShowOptionsOnType = false, isShowSelectAll = true, isShowAvatar = false, isShowEmployeeData = false, shouldCloseOnSelect = false, onAction, renderOption, getOptionLabel, maxLimit, autoFocus = false, defaultOption, disableClearable = required ? true : false, containerProps, setValue, limitTags = 0, ...restProps }) {
22
22
  const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
23
23
  name,
24
24
  control,
@@ -28,12 +28,14 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
28
28
  const { t } = (0, react_i18next_1.useTranslation)();
29
29
  const [inputValue, setInputValue] = (0, react_1.useState)("");
30
30
  const handleSelectAll = (isSelected) => {
31
+ const disabledOptions = options.filter((option) => option.disabled);
32
+ const disabledValues = disabledOptions.map((option) => option.value);
31
33
  if (isSelected) {
32
34
  const allValues = options.map((option) => option.value);
33
35
  onChange(allValues);
34
36
  }
35
37
  else {
36
- onChange([]);
38
+ onChange(disabledValues);
37
39
  }
38
40
  };
39
41
  const highlightedOptionRef = (0, react_1.useRef)("");
@@ -41,7 +43,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
41
43
  return (multiple &&
42
44
  isShowSelectAll &&
43
45
  options.length > 0 &&
44
- value?.length === options.filter((option) => !option.disabled).length);
46
+ value?.length === options.length);
45
47
  }, [multiple, isShowSelectAll, options, value]);
46
48
  const memoizedOptions = (0, react_1.useMemo)(() => {
47
49
  return [
@@ -146,7 +148,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
146
148
  const hiddenTags = limitTags ? value.slice(limitTags) : value;
147
149
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { flexWrap: "wrap", flexDirection: "row", gap: 0.2, maxHeight: 150, alignItems: "center", sx: {
148
150
  overflowY: "auto",
149
- }, children: [(0, jsx_runtime_1.jsx)(Tags_1.Tags, { disabled: disabled, getTagProps: getTagProps, isShowAvatar: isShowAvatar, tags: visibleTags }), hiddenCount > 0 && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: (0, jsx_runtime_1.jsx)(material_1.Stack, { maxHeight: "200px", alignItems: "start", overflow: "auto", children: (0, jsx_runtime_1.jsx)(Tags_1.Tags, { disabled: disabled, getTagProps: getTagProps, isShowAvatar: isShowAvatar, tags: hiddenTags }) }), children: (0, jsx_runtime_1.jsx)(ChipV2_styled_1.StyledChipV2, { label: `+${hiddenCount}` }) }))] }));
151
+ }, children: [(0, jsx_runtime_1.jsx)(Tags_1.Tags, { disabled: disabled, getTagProps: getTagProps, isShowAvatar: isShowAvatar, tags: visibleTags, startIndex: 0 }), hiddenCount > 0 && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: (0, jsx_runtime_1.jsx)(material_1.Stack, { maxHeight: "200px", alignItems: "start", overflow: "auto", children: (0, jsx_runtime_1.jsx)(Tags_1.Tags, { disabled: disabled, getTagProps: getTagProps, isShowAvatar: isShowAvatar, tags: hiddenTags, startIndex: limitTags }) }), children: (0, jsx_runtime_1.jsx)(ChipV2_styled_1.StyledChipV2, { label: `+${hiddenCount}` }) }))] }));
150
152
  }, renderOption: (props, option, { selected }) => {
151
153
  if (renderOption) {
152
154
  return renderOption(props, option, { selected });
@@ -192,46 +194,32 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
192
194
  if (withLabel) {
193
195
  return onChange(newValue);
194
196
  }
195
- if (multiple &&
196
- Array.isArray(newValue) &&
197
- maxLimit &&
198
- newValue.length > maxLimit) {
199
- Toast_1.toasts.error({
200
- title: t("common.autocomplete.limitExceed", { maxLimit }),
201
- });
202
- return;
203
- }
204
- if (multiple && isShowSelectAll && Array.isArray(newValue)) {
197
+ if (multiple && Array.isArray(newValue)) {
198
+ const disabledSelectedOptions = options.filter(({ disabled, value: disabledValue }) => disabled && value?.includes(disabledValue));
205
199
  const isSelectAllIncluded = newValue.some((option) => typeof option !== "string" && option?.value === "select-all");
206
200
  if (isSelectAllIncluded) {
207
201
  handleSelectAll(!isAllSelected);
208
202
  return;
209
203
  }
210
- }
211
- if (multiple && freeSolo) {
212
- if (Array.isArray(newValue)) {
213
- // eslint-disable-next-line sonarjs/function-return-type
214
- const values = newValue.map((option) => {
215
- return typeof option === "string" ? option : option.value;
204
+ const enabledNewValues = newValue
205
+ .map((option) => typeof option === "string" ? option : option.value)
206
+ .filter((val) => !disabledSelectedOptions.some((d) => d.value === val));
207
+ const mergedValues = [
208
+ ...disabledSelectedOptions.map(({ value }) => value),
209
+ ...enabledNewValues,
210
+ ];
211
+ if (maxLimit && mergedValues.length > maxLimit) {
212
+ Toast_1.toasts.error({
213
+ title: t("common.autocomplete.limitExceed", { maxLimit }),
216
214
  });
217
- return onChange(values);
215
+ return;
218
216
  }
219
- return onChange(value || []);
217
+ return onChange(mergedValues);
220
218
  }
221
219
  if (typeof newValue === "string") {
222
220
  return onChange(newValue ?? null);
223
221
  }
224
- if (Array.isArray(newValue)) {
225
- // eslint-disable-next-line sonarjs/function-return-type
226
- const values = newValue.map((option) => {
227
- if (typeof option === "string") {
228
- return newValue;
229
- }
230
- return option.value;
231
- });
232
- return onChange(values);
233
- }
234
- onChange(newValue ? newValue.value : null);
222
+ onChange(newValue && !Array.isArray(newValue) ? newValue.value : null);
235
223
  }, groupBy: (option) => option.heading ?? "", renderGroup: (params) => {
236
224
  if (!params.group) {
237
225
  return (0, jsx_runtime_1.jsx)(material_1.Box, { children: params.children });
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.styled.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Chip.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,eAAO,MAAM,UAAU,EAAE,eAAe,CAAC,SAAS,CAyBhD,CAAC"}
1
+ {"version":3,"file":"Chip.styled.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Chip.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,eAAO,MAAM,UAAU,EAAE,eAAe,CAAC,SAAS,CA0BhD,CAAC"}
@@ -4,11 +4,11 @@ exports.StyledChip = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  exports.StyledChip = (0, material_1.styled)(material_1.Chip, {
6
6
  shouldForwardProp: (prop) => prop !== "disabled",
7
- })(({ theme }) => {
7
+ })(({ theme, disabled }) => {
8
8
  const { lightBlue, iron } = theme.palette.app.color;
9
9
  return {
10
10
  backgroundColor: "transparent",
11
- color: lightBlue[100],
11
+ color: disabled ? iron[700] : lightBlue[100],
12
12
  borderRadius: "50px",
13
13
  padding: 0,
14
14
  [`& .${material_1.chipClasses.deleteIcon}`]: {
@@ -18,10 +18,12 @@ exports.StyledChip = (0, material_1.styled)(material_1.Chip, {
18
18
  "&:hover": {
19
19
  color: iron[800],
20
20
  },
21
+ cursor: disabled ? "auto" : "pointer",
21
22
  },
23
+ opacity: disabled ? 0.6 : 1,
22
24
  "&.Mui-disabled": {
23
- opacity: 0.6,
24
25
  pointerEvents: "none",
26
+ cursor: "auto",
25
27
  },
26
28
  };
27
29
  });
@@ -1,11 +1,12 @@
1
1
  import { type AutocompleteRenderGetTagProps } from "@mui/material";
2
2
  import type { Option } from "./Autocomplete";
3
- type TagsProps = {
3
+ type TagsProps = Readonly<{
4
4
  tags: Option[];
5
5
  getTagProps: AutocompleteRenderGetTagProps;
6
6
  isShowAvatar: boolean;
7
7
  disabled: boolean;
8
- };
9
- export declare const Tags: ({ tags, getTagProps, isShowAvatar, disabled, }: TagsProps) => import("react/jsx-runtime").JSX.Element[];
8
+ startIndex: number;
9
+ }>;
10
+ export declare const Tags: ({ tags, getTagProps, isShowAvatar, disabled, startIndex, }: TagsProps) => import("react/jsx-runtime").JSX.Element[];
10
11
  export {};
11
12
  //# sourceMappingURL=Tags.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Tags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,6BAA6B,CAAC;IAC3C,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,gDAKlB,SAAS,8CAsBX,CAAC"}
1
+ {"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Tags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C,KAAK,SAAS,GAAG,QAAQ,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,6BAA6B,CAAC;IAC3C,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,eAAO,MAAM,IAAI,GAAI,4DAMlB,SAAS,8CA0BX,CAAC"}
@@ -4,9 +4,12 @@ exports.Tags = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const AvatarCell_1 = require("./AvatarCell");
6
6
  const Chip_styled_1 = require("./Chip.styled");
7
- const Tags = ({ tags, getTagProps, isShowAvatar, disabled, }) => {
7
+ const Tags = ({ tags, getTagProps, isShowAvatar, disabled, startIndex, }) => {
8
8
  return tags.map((option, index) => {
9
- const { key, ...tagProps } = getTagProps({ index });
9
+ const realIndex = startIndex + index;
10
+ const { key, ...tagProps } = getTagProps({
11
+ index: realIndex,
12
+ });
10
13
  const label = typeof option === "string" ? option : option.label;
11
14
  return ((0, jsx_runtime_1.jsx)(Chip_styled_1.StyledChip, { avatar: (0, jsx_runtime_1.jsx)(AvatarCell_1.AvatarCell, { isShowAvatar: isShowAvatar, option: option, label: label }), label: label, ...tagProps, disabled: option.disabled || disabled }, key));
12
15
  });