ab-ui-library 1.60.0 → 1.62.0

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.
@@ -56,6 +56,8 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
56
56
  availableOptions = _ref$availableOptions === void 0 ? [] : _ref$availableOptions,
57
57
  _ref$allowCustomValue = _ref.allowCustomValues,
58
58
  allowCustomValues = _ref$allowCustomValue === void 0 ? true : _ref$allowCustomValue,
59
+ _ref$allowDuplicates = _ref.allowDuplicates,
60
+ allowDuplicates = _ref$allowDuplicates === void 0 ? false : _ref$allowDuplicates,
59
61
  searchPlaceholder = _ref.searchPlaceholder,
60
62
  chipValidationSchema = _ref.chipValidationSchema,
61
63
  chipValidationErrorMessage = _ref.chipValidationErrorMessage,
@@ -108,7 +110,7 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
108
110
  containerRef: containerRef
109
111
  });
110
112
  var handleSelectOption = function handleSelectOption(option) {
111
- if (chipManagement.getChipTexts().includes(option)) return;
113
+ if (!allowDuplicates && chipManagement.getChipTexts().includes(option)) return;
112
114
  try {
113
115
  var valueToValidate = transformToUppercase ? option.toUpperCase() : option;
114
116
  var validatedChip = chipValidation.createValidatedChip(valueToValidate);
@@ -123,7 +125,7 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
123
125
  }
124
126
  };
125
127
  var handleAddCustomValue = useCallback(function (value) {
126
- if (chipManagement.getChipTexts().includes(value)) return;
128
+ if (!allowDuplicates && chipManagement.getChipTexts().includes(value)) return;
127
129
  try {
128
130
  var valueToValidate = transformToUppercase ? value.toUpperCase() : value;
129
131
  var validatedChip = chipValidation.createValidatedChip(valueToValidate);
@@ -135,7 +137,7 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
135
137
  setChipError(error instanceof Error ? error.message : 'Invalid value');
136
138
  }
137
139
  }
138
- }, [chipManagement, chipValidation, allowInvalidChips, transformToUppercase]);
140
+ }, [chipManagement, chipValidation, allowInvalidChips, transformToUppercase, allowDuplicates]);
139
141
  var onBlurLogic = useOnBlurLogic({
140
142
  inputValue: inputValue,
141
143
  disabled: disabled,
@@ -149,10 +151,9 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
149
151
  allowInvalidChips: allowInvalidChips
150
152
  });
151
153
  var handleRemoveLastChip = function handleRemoveLastChip() {
152
- var lastChip = chipManagement.chips[chipManagement.chips.length - 1];
153
- if (lastChip) {
154
- var chipText = typeof lastChip === 'string' ? lastChip : lastChip.text;
155
- chipManagement.removeChip(chipText);
154
+ var lastChipIndex = chipManagement.chips.length - 1;
155
+ if (lastChipIndex >= 0) {
156
+ chipManagement.removeChip(lastChipIndex);
156
157
  }
157
158
  };
158
159
  var handleInputChange = function handleInputChange(e) {
@@ -225,7 +226,8 @@ var MultiTextareaWithChipsComponent = function MultiTextareaWithChipsComponent(_
225
226
  text: text,
226
227
  withAction: !disabled,
227
228
  onClick: function onClick() {
228
- chipManagement.removeChip(text);
229
+ // Pass index instead of text to remove specific chip
230
+ chipManagement.removeChip(index);
229
231
  setTimeout(function () {
230
232
  var _inputRef$current;
231
233
  (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
@@ -8,12 +8,13 @@ interface UseChipManagementProps {
8
8
  };
9
9
  setValue?: (fieldName: string, value: TFormValue) => void;
10
10
  onAddChip?: (chip: string) => void;
11
- onRemoveChip?: (chip: string) => void;
11
+ onRemoveChip?: (chip: string, index: number) => void;
12
12
  }
13
13
  export declare const useChipManagement: ({ initialChips, fieldName, formProps, setValue, onAddChip, onRemoveChip }: UseChipManagementProps) => {
14
14
  chips: ChipValue[];
15
15
  addChip: (chip: ChipValue) => void;
16
- removeChip: (chipText: string) => void;
16
+ removeChip: (index: number) => void;
17
+ removeChipByText: (chipText: string) => void;
17
18
  getChipTexts: () => string[];
18
19
  hasErrorChips: boolean;
19
20
  getErrorMessage: () => string;
@@ -41,15 +41,31 @@ var useChipManagement = function useChipManagement(_ref) {
41
41
  onAddChip === null || onAddChip === void 0 || onAddChip(chip.text);
42
42
  }
43
43
  }, [chips, updateFormValue, onAddChip]);
44
- var removeChip = useCallback(function (chipText) {
44
+ var removeChip = useCallback(function (index) {
45
45
  isUserInteraction.current = true;
46
- var newChips = chips.filter(function (chip) {
47
- var text = typeof chip === 'string' ? chip : chip.text;
48
- return text !== chipText;
46
+ var chipToRemove = chips[index];
47
+ var chipText = typeof chipToRemove === 'string' ? chipToRemove : chipToRemove.text;
48
+ var newChips = chips.filter(function (_, i) {
49
+ return i !== index;
49
50
  });
50
51
  setChips(newChips);
51
52
  updateFormValue(newChips);
52
- onRemoveChip === null || onRemoveChip === void 0 || onRemoveChip(chipText);
53
+ onRemoveChip === null || onRemoveChip === void 0 || onRemoveChip(chipText, index);
54
+ }, [chips, updateFormValue, onRemoveChip]);
55
+ var removeChipByText = useCallback(function (chipText) {
56
+ isUserInteraction.current = true;
57
+ var index = chips.findIndex(function (chip) {
58
+ var text = typeof chip === 'string' ? chip : chip.text;
59
+ return text === chipText;
60
+ });
61
+ if (index !== -1) {
62
+ var newChips = chips.filter(function (_, i) {
63
+ return i !== index;
64
+ });
65
+ setChips(newChips);
66
+ updateFormValue(newChips);
67
+ onRemoveChip === null || onRemoveChip === void 0 || onRemoveChip(chipText, index);
68
+ }
53
69
  }, [chips, updateFormValue, onRemoveChip]);
54
70
  var getChipTexts = useCallback(function () {
55
71
  return chips.map(function (chip) {
@@ -72,6 +88,7 @@ var useChipManagement = function useChipManagement(_ref) {
72
88
  chips: chips,
73
89
  addChip: addChip,
74
90
  removeChip: removeChip,
91
+ removeChipByText: removeChipByText,
75
92
  getChipTexts: getChipTexts,
76
93
  hasErrorChips: hasErrorChips,
77
94
  getErrorMessage: getErrorMessage
@@ -18,11 +18,12 @@ export interface TMultiTextareaWithChipsProps extends IFormCompProps {
18
18
  helperText?: string;
19
19
  chips?: ChipValue[];
20
20
  onAddChip?: (chip: string) => void;
21
- onRemoveChip?: (chip: string) => void;
21
+ onRemoveChip?: (chipText: string, index: number) => void;
22
22
  className?: string;
23
23
  disabled?: boolean;
24
24
  availableOptions?: string[];
25
25
  allowCustomValues?: boolean;
26
+ allowDuplicates?: boolean;
26
27
  searchPlaceholder?: string;
27
28
  chipValidationSchema?: AnySchema;
28
29
  chipValidationErrorMessage?: string;
@@ -0,0 +1,4 @@
1
+ import type { ISVGIconProps } from './types';
2
+ import type { ReactElement } from 'react';
3
+ export declare const IconBag: ({ size, type, className, onClick, refHandler, id, dataId }: ISVGIconProps) => ReactElement;
4
+ export default IconBag;
@@ -0,0 +1,30 @@
1
+ import { _ as _defineProperty } from '../../defineProperty-9000dd50.js';
2
+ import React from 'react';
3
+ import classNames from 'classnames';
4
+ import '../../typeof-28108b73.js';
5
+
6
+ var IconBag = function IconBag(_ref) {
7
+ var size = _ref.size,
8
+ type = _ref.type,
9
+ _ref$className = _ref.className,
10
+ className = _ref$className === void 0 ? '' : _ref$className,
11
+ onClick = _ref.onClick,
12
+ refHandler = _ref.refHandler,
13
+ id = _ref.id,
14
+ dataId = _ref.dataId;
15
+ return /*#__PURE__*/React.createElement("svg", {
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ className: classNames('svg-icon', _defineProperty(_defineProperty(_defineProperty({}, "svg-icon__size-".concat(size), size), "svg-icon__type-".concat(type), type), className, className)),
18
+ viewBox: "0 0 24 24",
19
+ fill: "none",
20
+ onClick: onClick,
21
+ ref: refHandler,
22
+ id: id,
23
+ "data-id": dataId ? "".concat(dataId, "-svg-icon") : ''
24
+ }, /*#__PURE__*/React.createElement("path", {
25
+ d: "M7.66667 0H16.3333C16.8396 0 17.258 0.376205 17.3242 0.864306L17.3333 1V5.33333H19.6667C22.0599 5.33333 24 7.27343 24 9.66667V18.3333C24 20.7266 22.0599 22.6667 19.6667 22.6667H4.33333C1.9401 22.6667 0 20.7266 0 18.3333V9.66667C0 7.27343 1.9401 5.33333 4.33333 5.33333H6.66667V1C6.66667 0.493739 7.04287 0.0753454 7.53097 0.00912889L7.66667 0H16.3333H7.66667ZM19.6667 7.33333H4.33333C3.04467 7.33333 2 8.378 2 9.66667V18.3333C2 19.622 3.04467 20.6667 4.33333 20.6667H19.6667C20.9553 20.6667 22 19.622 22 18.3333V9.66667C22 8.378 20.9553 7.33333 19.6667 7.33333ZM15.3333 2H8.66667V5.33333H15.3333V2Z",
26
+ fill: "#555555"
27
+ }));
28
+ };
29
+
30
+ export { IconBag, IconBag as default };
@@ -9,6 +9,7 @@ export * from './IconAlertFilled';
9
9
  export * from './IconAm';
10
10
  export * from './IconAmd';
11
11
  export * from './IconAmdFilled';
12
+ export * from './IconAppStore';
12
13
  export * from './IconApple';
13
14
  export * from './IconAppsList';
14
15
  export * from './IconAppsListDetail';
@@ -60,6 +61,7 @@ export * from './IconAttach';
60
61
  export * from './IconAttachFilled';
61
62
  export * from './IconBadge';
62
63
  export * from './IconBadgeFilled';
64
+ export * from './IconBag';
63
65
  export * from './IconBeach';
64
66
  export * from './IconBeachFilled';
65
67
  export * from './IconBed';
@@ -9,12 +9,12 @@ export { IconAlertFilled } from './IconAlertFilled.js';
9
9
  export { IconAm } from './IconAm.js';
10
10
  export { IconAmd } from './IconAmd.js';
11
11
  export { IconAmdFilled } from './IconAmdFilled.js';
12
+ export { IconAppStore } from './IconAppStore.js';
12
13
  export { IconApple } from './IconApple.js';
13
14
  export { IconAppsList } from './IconAppsList.js';
14
15
  export { IconAppsListDetail } from './IconAppsListDetail.js';
15
16
  export { IconAppsListDetailFilled } from './IconAppsListDetailFilled.js';
16
17
  export { IconAppsListFilled } from './IconAppsListFilled.js';
17
- export { IconAppStore } from './IconAppStore.js';
18
18
  export { IconArrowCircleDown } from './IconArrowCircleDown.js';
19
19
  export { IconArrowCircleDownSplit } from './IconArrowCircleDownSplit.js';
20
20
  export { IconArrowDown } from './IconArrowDown.js';
@@ -60,6 +60,7 @@ export { IconAttach } from './IconAttach.js';
60
60
  export { IconAttachFilled } from './IconAttachFilled.js';
61
61
  export { IconBadge } from './IconBadge.js';
62
62
  export { IconBadgeFilled } from './IconBadgeFilled.js';
63
+ export { IconBag } from './IconBag.js';
63
64
  export { IconBeach } from './IconBeach.js';
64
65
  export { IconBeachFilled } from './IconBeachFilled.js';
65
66
  export { IconBed } from './IconBed.js';
package/index.js CHANGED
@@ -74,12 +74,12 @@ export { IconAlertFilled } from './components/SVGIcons/IconAlertFilled.js';
74
74
  export { IconAm } from './components/SVGIcons/IconAm.js';
75
75
  export { IconAmd } from './components/SVGIcons/IconAmd.js';
76
76
  export { IconAmdFilled } from './components/SVGIcons/IconAmdFilled.js';
77
+ export { IconAppStore } from './components/SVGIcons/IconAppStore.js';
77
78
  export { IconApple } from './components/SVGIcons/IconApple.js';
78
79
  export { IconAppsList } from './components/SVGIcons/IconAppsList.js';
79
80
  export { IconAppsListDetail } from './components/SVGIcons/IconAppsListDetail.js';
80
81
  export { IconAppsListDetailFilled } from './components/SVGIcons/IconAppsListDetailFilled.js';
81
82
  export { IconAppsListFilled } from './components/SVGIcons/IconAppsListFilled.js';
82
- export { IconAppStore } from './components/SVGIcons/IconAppStore.js';
83
83
  export { IconArrowCircleDown } from './components/SVGIcons/IconArrowCircleDown.js';
84
84
  export { IconArrowCircleDownSplit } from './components/SVGIcons/IconArrowCircleDownSplit.js';
85
85
  export { IconArrowDown } from './components/SVGIcons/IconArrowDown.js';
@@ -125,6 +125,7 @@ export { IconAttach } from './components/SVGIcons/IconAttach.js';
125
125
  export { IconAttachFilled } from './components/SVGIcons/IconAttachFilled.js';
126
126
  export { IconBadge } from './components/SVGIcons/IconBadge.js';
127
127
  export { IconBadgeFilled } from './components/SVGIcons/IconBadgeFilled.js';
128
+ export { IconBag } from './components/SVGIcons/IconBag.js';
128
129
  export { IconBeach } from './components/SVGIcons/IconBeach.js';
129
130
  export { IconBeachFilled } from './components/SVGIcons/IconBeachFilled.js';
130
131
  export { IconBed } from './components/SVGIcons/IconBed.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-ui-library",
3
- "version": "1.60.0",
3
+ "version": "1.62.0",
4
4
  "description": "UI library for AM",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",