@kadoui/react 1.10.13 → 1.10.14

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.
@@ -14,6 +14,6 @@ type MergedSelectMode = WithMultiSelect | WithSingleSelect;
14
14
  type SelectBoxOptionsPropsT = ButtonHTMLAttributes<HTMLButtonElement> & MergedSelectMode & {
15
15
  options: SelectBoxOptionT[];
16
16
  };
17
- export default function SelectBoxOptions({ options, multiSelect, optionValue, setOptionValue, ...p }: SelectBoxOptionsPropsT): import("react/jsx-runtime").JSX.Element[];
17
+ export default function SelectBoxOptions({ options, multiSelect, optionValue, setOptionValue, ...p }: SelectBoxOptionsPropsT): import("react/jsx-runtime").JSX.Element;
18
18
  export {};
19
19
  //# sourceMappingURL=SelectBoxOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectBoxOptions.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/SelectBoxOptions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;CAC9D,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;CACnE,CAAC;AAEF,KAAK,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE3D,KAAK,sBAAsB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GACnE,gBAAgB,GAAG;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,WAAW,EACX,cAAc,EACd,GAAG,CAAC,EACL,EAAE,sBAAsB,6CA+CxB"}
1
+ {"version":3,"file":"SelectBoxOptions.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/SelectBoxOptions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;CAC9D,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;CACnE,CAAC;AAEF,KAAK,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE3D,KAAK,sBAAsB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GACnE,gBAAgB,GAAG;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,WAAW,EACX,cAAc,EACd,GAAG,CAAC,EACL,EAAE,sBAAsB,2CAuDxB"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { use } from "react";
4
4
  import { SelectBoxContext } from "./SelectBoxContext";
5
5
  export default function SelectBoxOptions({ options, multiSelect, optionValue, setOptionValue, ...p }) {
@@ -14,30 +14,32 @@ export default function SelectBoxOptions({ options, multiSelect, optionValue, se
14
14
  otherOptions.push(item);
15
15
  }
16
16
  });
17
- const currentOptions = [...filteredOptions, ...otherOptions];
18
- return currentOptions.map((item) => {
19
- const isSelected = multiSelect
20
- ? optionValue.some((v) => v.value === item.value)
21
- : optionValue?.value === item.value;
22
- return (_jsx("button", { type: "button", "data-state": isSelected, onClick: () => {
23
- if (multiSelect) {
24
- if (isSelected) {
25
- setOptionValue(optionValue.filter((v) => v.value !== item.value));
17
+ const renderOptions = (options, isOther) => {
18
+ return options.map((item) => {
19
+ const isSelected = multiSelect
20
+ ? optionValue.some((v) => v.value === item.value)
21
+ : optionValue?.value === item.value;
22
+ return (_jsx("button", { type: "button", disabled: isOther, "data-state": isSelected, onClick: () => {
23
+ if (multiSelect) {
24
+ if (isSelected) {
25
+ setOptionValue(optionValue.filter((v) => v.value !== item.value));
26
+ }
27
+ else {
28
+ setOptionValue([...optionValue, item]);
29
+ }
26
30
  }
27
31
  else {
28
- setOptionValue([...optionValue, item]);
32
+ if (isSelected) {
33
+ setOptionValue(null);
34
+ }
35
+ else {
36
+ setOptionValue(item);
37
+ setInputSearch(item.name);
38
+ setInputFocused(false);
39
+ }
29
40
  }
30
- }
31
- else {
32
- if (isSelected) {
33
- setOptionValue(null);
34
- }
35
- else {
36
- setOptionValue(item);
37
- setInputSearch(item.name);
38
- setInputFocused(false);
39
- }
40
- }
41
- }, ...p, children: item.name }, item.value));
42
- });
41
+ }, ...p, children: item.name }, item.value));
42
+ });
43
+ };
44
+ return (_jsxs(_Fragment, { children: [renderOptions(filteredOptions), renderOptions(otherOptions, true)] }));
43
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kadoui/react",
3
- "version": "1.10.13",
3
+ "version": "1.10.14",
4
4
  "description": "Kadoui primitive components for React",
5
5
  "author": "FarzadVav",
6
6
  "license": "MIT",