@sonardigital/carbon-ui 1.1.93 → 1.1.96

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": "@sonardigital/carbon-ui",
3
- "version": "1.1.93",
3
+ "version": "1.1.96",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -28,13 +28,17 @@ export function FormBox<T>({
28
28
  render={({ field }) => {
29
29
  const onChange = () => {
30
30
  if (multiple) {
31
- if (!field.value) {
31
+ if (
32
+ !field.value ||
33
+ field.value === undefined ||
34
+ field.value === null
35
+ ) {
32
36
  field.onChange([value] as T[]);
33
37
  return;
34
38
  } else {
35
- if (field.value.includes(value)) {
39
+ if (field.value?.includes(value)) {
36
40
  field.onChange(
37
- field.value.filter((v: T) => v !== value) as T[],
41
+ field.value?.filter((v: T) => v !== value) as T[],
38
42
  );
39
43
  } else {
40
44
  field.onChange([...field.value, value] as T[]);
@@ -14,7 +14,7 @@ export function FormBoxes<T>({
14
14
  sx,
15
15
  }: {
16
16
  name: string;
17
- multiple: boolean;
17
+ multiple?: boolean;
18
18
  options: LocalFormBoxProps<T>[];
19
19
  sx?: Record<string, unknown>;
20
20
  }): React.ReactElement {
@@ -25,7 +25,9 @@ export function FormBoxes<T>({
25
25
  name={name}
26
26
  render={({ field }) => {
27
27
  const isEmpty = multiple
28
- ? field.value.length === 0
28
+ ? field.value?.length === 0 ||
29
+ field.value === undefined ||
30
+ field.value === null
29
31
  : field.value === undefined || field.value === null;
30
32
  const isSelected = multiple
31
33
  ? field.value?.includes(option.value)