@kadoui/react 2.1.3 → 2.1.4

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.
@@ -1,9 +1,11 @@
1
1
  import { ChoiceRoot } from "./ChoiceRoot";
2
- import { ChoiceTrigger } from "./ChoiceTrigger";
2
+ import { ChoiceThumb } from "./ChoiceThumb";
3
+ import { ChoiceToggle } from "./ChoiceToggle";
3
4
  import { ChoiceNavigation } from "./ChoiceNavigation";
4
5
  export declare const Choice: typeof ChoiceRoot & {
5
6
  Navigation: typeof ChoiceNavigation;
6
- Trigger: typeof ChoiceTrigger;
7
+ Toggle: typeof ChoiceToggle;
8
+ Thumb: typeof ChoiceThumb;
7
9
  };
8
10
  export * from "./choiceTypes";
9
11
  //# sourceMappingURL=Choice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Choice.d.ts","sourceRoot":"","sources":["../../../src/react-components/Choice/Choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,eAAO,MAAM,MAAM;;;CAGjB,CAAC;AAEH,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"Choice.d.ts","sourceRoot":"","sources":["../../../src/react-components/Choice/Choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,eAAO,MAAM,MAAM;;;;CAIjB,CAAC;AAEH,cAAc,eAAe,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { ChoiceRoot } from "./ChoiceRoot";
2
- import { ChoiceTrigger } from "./ChoiceTrigger";
2
+ import { ChoiceThumb } from "./ChoiceThumb";
3
+ import { ChoiceToggle } from "./ChoiceToggle";
3
4
  import { ChoiceNavigation } from "./ChoiceNavigation";
4
5
  export const Choice = Object.assign(ChoiceRoot, {
5
6
  Navigation: ChoiceNavigation,
6
- Trigger: ChoiceTrigger,
7
+ Toggle: ChoiceToggle,
8
+ Thumb: ChoiceThumb
7
9
  });
8
10
  export * from "./choiceTypes";
@@ -0,0 +1,3 @@
1
+ import { ChoiceThumbPropsT } from "./choiceTypes";
2
+ export declare function ChoiceThumb(p: ChoiceThumbPropsT): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ChoiceThumb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoiceThumb.d.ts","sourceRoot":"","sources":["../../../src/react-components/Choice/ChoiceThumb.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,wBAAgB,WAAW,CAAC,CAAC,EAAE,iBAAiB,2CAI/C"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function ChoiceThumb(p) {
3
+ return (_jsx("span", { ...p }));
4
+ }
@@ -0,0 +1,3 @@
1
+ import type { ChoiceTriggerPropsT } from "./choiceTypes";
2
+ export declare function ChoiceToggle({ choiceName, onClick, ...p }: ChoiceTriggerPropsT): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ChoiceToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoiceToggle.d.ts","sourceRoot":"","sources":["../../../src/react-components/Choice/ChoiceToggle.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,OAAO,EACP,GAAG,CAAC,EACL,EAAE,mBAAmB,2CAiCrB"}
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { use } from "react";
4
+ import { ChoiceContext } from "./ChoiceContext";
5
+ export function ChoiceToggle({ choiceName, onClick, ...p }) {
6
+ const { multiple, activeChoice, setActiveChoice, requiredOne } = use(ChoiceContext);
7
+ const isActive = multiple
8
+ ? activeChoice.includes(choiceName)
9
+ : activeChoice === choiceName;
10
+ return (_jsx("button", { "data-state": isActive, onClick: (ev) => {
11
+ onClick?.(ev);
12
+ if (isActive) {
13
+ if (multiple) {
14
+ if (!requiredOne || activeChoice.length > 1) {
15
+ setActiveChoice((prev) => prev.filter((item) => item !== choiceName));
16
+ }
17
+ }
18
+ else {
19
+ if (!requiredOne) {
20
+ setActiveChoice(null);
21
+ }
22
+ }
23
+ }
24
+ else {
25
+ if (multiple) {
26
+ setActiveChoice((prev) => [...prev, choiceName]);
27
+ }
28
+ else {
29
+ setActiveChoice(choiceName);
30
+ }
31
+ }
32
+ }, ...p }));
33
+ }
@@ -19,5 +19,6 @@ export type ChoiceTriggerPropsT = ComponentProps<"button"> & {
19
19
  choiceName: string;
20
20
  };
21
21
  export type ChoiceNavigationPropsT = AccessNavigationPropsT;
22
+ export type ChoiceThumbPropsT = ComponentProps<"span">;
22
23
  export {};
23
24
  //# sourceMappingURL=choiceTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"choiceTypes.d.ts","sourceRoot":"","sources":["../../../src/react-components/Choice/choiceTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CACr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5C,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG;IAC3D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC"}
@@ -2,7 +2,7 @@ import { ModalRoot } from "./ModalRoot";
2
2
  import { ModalBody } from "./ModalBody";
3
3
  import { ModalHeader } from "./ModalHeader";
4
4
  import { ModalPortal } from "./ModalPortal";
5
- import { ModalToggle } from "./ModalTrigger";
5
+ import { ModalToggle } from "./ModalToggle";
6
6
  import { ModalContent } from "./ModalContent";
7
7
  export declare const Modal: typeof ModalRoot & {
8
8
  Toggle: typeof ModalToggle;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/react-components/Modal/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,KAAK;;;;;;CAMhB,CAAC;AAEH,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/react-components/Modal/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,KAAK;;;;;;CAMhB,CAAC;AAEH,cAAc,cAAc,CAAC"}
@@ -2,7 +2,7 @@ import { ModalRoot } from "./ModalRoot";
2
2
  import { ModalBody } from "./ModalBody";
3
3
  import { ModalHeader } from "./ModalHeader";
4
4
  import { ModalPortal } from "./ModalPortal";
5
- import { ModalToggle } from "./ModalTrigger";
5
+ import { ModalToggle } from "./ModalToggle";
6
6
  import { ModalContent } from "./ModalContent";
7
7
  export const Modal = Object.assign(ModalRoot, {
8
8
  Toggle: ModalToggle,
@@ -0,0 +1,3 @@
1
+ import type { ModalTogglePropsT } from "./modalTypes";
2
+ export declare function ModalToggle({ onClick, ...props }: ModalTogglePropsT): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ModalToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalToggle.d.ts","sourceRoot":"","sources":["../../../src/react-components/Modal/ModalToggle.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,2CAYnE"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { use } from "react";
4
+ import { ModalContext } from "./ModalContext";
5
+ export function ModalToggle({ onClick, ...props }) {
6
+ const { setOpen } = use(ModalContext);
7
+ return (_jsx("button", { onClick: (ev) => {
8
+ onClick?.(ev);
9
+ setOpen((prev) => !prev);
10
+ }, ...props }));
11
+ }