@tamagui/checkbox-headless 1.89.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/BubbleInput.js +65 -0
  3. package/dist/cjs/BubbleInput.js.map +6 -0
  4. package/dist/cjs/BubbleInput.native.js +70 -0
  5. package/dist/cjs/BubbleInput.native.js.map +6 -0
  6. package/dist/cjs/index.js +16 -0
  7. package/dist/cjs/index.js.map +6 -0
  8. package/dist/cjs/index.native.js +22 -0
  9. package/dist/cjs/index.native.js.map +6 -0
  10. package/dist/cjs/useCheckbox.js +83 -0
  11. package/dist/cjs/useCheckbox.js.map +6 -0
  12. package/dist/cjs/useCheckbox.native.js +88 -0
  13. package/dist/cjs/useCheckbox.native.js.map +6 -0
  14. package/dist/cjs/utils.js +27 -0
  15. package/dist/cjs/utils.js.map +6 -0
  16. package/dist/cjs/utils.native.js +33 -0
  17. package/dist/cjs/utils.native.js.map +6 -0
  18. package/dist/esm/BubbleInput.js +44 -0
  19. package/dist/esm/BubbleInput.js.map +6 -0
  20. package/dist/esm/BubbleInput.mjs +47 -0
  21. package/dist/esm/BubbleInput.native.js +44 -0
  22. package/dist/esm/BubbleInput.native.js.map +6 -0
  23. package/dist/esm/index.js +3 -0
  24. package/dist/esm/index.js.map +6 -0
  25. package/dist/esm/index.mjs +2 -0
  26. package/dist/esm/index.native.js +3 -0
  27. package/dist/esm/index.native.js.map +6 -0
  28. package/dist/esm/useCheckbox.js +66 -0
  29. package/dist/esm/useCheckbox.js.map +6 -0
  30. package/dist/esm/useCheckbox.mjs +58 -0
  31. package/dist/esm/useCheckbox.native.js +66 -0
  32. package/dist/esm/useCheckbox.native.js.map +6 -0
  33. package/dist/esm/utils.js +11 -0
  34. package/dist/esm/utils.js.map +6 -0
  35. package/dist/esm/utils.mjs +7 -0
  36. package/dist/esm/utils.native.js +11 -0
  37. package/dist/esm/utils.native.js.map +6 -0
  38. package/dist/jsx/BubbleInput.js +44 -0
  39. package/dist/jsx/BubbleInput.js.map +6 -0
  40. package/dist/jsx/BubbleInput.mjs +47 -0
  41. package/dist/jsx/BubbleInput.native.js +44 -0
  42. package/dist/jsx/BubbleInput.native.js.map +6 -0
  43. package/dist/jsx/index.js +3 -0
  44. package/dist/jsx/index.js.map +6 -0
  45. package/dist/jsx/index.mjs +2 -0
  46. package/dist/jsx/index.native.js +3 -0
  47. package/dist/jsx/index.native.js.map +6 -0
  48. package/dist/jsx/useCheckbox.js +66 -0
  49. package/dist/jsx/useCheckbox.js.map +6 -0
  50. package/dist/jsx/useCheckbox.mjs +58 -0
  51. package/dist/jsx/useCheckbox.native.js +66 -0
  52. package/dist/jsx/useCheckbox.native.js.map +6 -0
  53. package/dist/jsx/utils.js +11 -0
  54. package/dist/jsx/utils.js.map +6 -0
  55. package/dist/jsx/utils.mjs +7 -0
  56. package/dist/jsx/utils.native.js +11 -0
  57. package/dist/jsx/utils.native.js.map +6 -0
  58. package/package.json +55 -0
  59. package/src/BubbleInput.tsx +64 -0
  60. package/src/index.ts +2 -0
  61. package/src/useCheckbox.tsx +112 -0
  62. package/src/utils.tsx +9 -0
  63. package/types/BubbleInput.d.ts +10 -0
  64. package/types/BubbleInput.d.ts.map +1 -0
  65. package/types/index.d.ts +3 -0
  66. package/types/index.d.ts.map +1 -0
  67. package/types/useCheckbox.d.ts +43 -0
  68. package/types/useCheckbox.d.ts.map +1 -0
  69. package/types/utils.d.ts +4 -0
  70. package/types/utils.d.ts.map +1 -0
@@ -0,0 +1,66 @@
1
+ import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import { isWeb } from "@tamagui/constants";
3
+ import { composeEventHandlers } from "@tamagui/helpers";
4
+ import { useLabelContext } from "@tamagui/label";
5
+ import React from "react";
6
+ import { BubbleInput } from "./BubbleInput";
7
+ import { getState, isIndeterminate } from "./utils";
8
+ import { jsx } from "react/jsx-runtime";
9
+ function useCheckbox(props, [checked, setChecked], ref) {
10
+ const {
11
+ labelledBy: ariaLabelledby,
12
+ name,
13
+ required,
14
+ disabled,
15
+ value = "on",
16
+ onCheckedChange,
17
+ ...checkboxProps
18
+ } = props, [button, setButton] = React.useState(null), composedRefs = useComposedRefs(ref, (node) => setButton(node)), hasConsumerStoppedPropagationRef = React.useRef(!1), isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = useLabelContext(button), labelledBy = ariaLabelledby || labelId;
19
+ return {
20
+ bubbleInput: isWeb && isFormControl ? /* @__PURE__ */ jsx(
21
+ BubbleInput,
22
+ {
23
+ isHidden: !0,
24
+ control: button,
25
+ bubbles: !hasConsumerStoppedPropagationRef.current,
26
+ name,
27
+ value,
28
+ checked,
29
+ required,
30
+ disabled
31
+ }
32
+ ) : null,
33
+ checkboxRef: composedRefs,
34
+ checkboxProps: {
35
+ role: "checkbox",
36
+ "aria-labelledby": labelledBy,
37
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
38
+ ...checkboxProps,
39
+ ...isWeb && {
40
+ type: "button",
41
+ value,
42
+ "data-state": getState(checked),
43
+ "data-disabled": disabled ? "" : void 0,
44
+ disabled,
45
+ onKeyDown: composeEventHandlers(
46
+ props.onKeyDown,
47
+ (event) => {
48
+ event.key === "Enter" && event.preventDefault();
49
+ }
50
+ )
51
+ },
52
+ onPress: composeEventHandlers(
53
+ props.onPress,
54
+ (event) => {
55
+ setChecked(
56
+ (prevChecked) => isIndeterminate(prevChecked) ? !0 : !prevChecked
57
+ ), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
58
+ }
59
+ )
60
+ }
61
+ };
62
+ }
63
+ export {
64
+ useCheckbox
65
+ };
66
+ //# sourceMappingURL=useCheckbox.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useCheckbox.tsx"],
4
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,aAAa;AAEtB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,OAAO,WAAW;AAGlB,SAAS,mBAAmB;AAC5B,SAAS,UAAU,uBAAuB;AAsDlC;AA7BD,SAAS,YACd,OACA,CAAC,SAAS,UAAU,GAIpB,KACA;AACA,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OACE,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAmC,IAAI,GACnE,eAAe,gBAAgB,KAAK,CAAC,SAAS,UAAU,IAAW,CAAC,GACpE,mCAAmC,MAAM,OAAO,EAAK,GAErD,gBAAgB,QAAS,SAAS,EAAQ,OAAO,QAAQ,MAAM,IAAK,KAAQ,IAE5E,UAAU,gBAAgB,MAAM,GAChC,aAAa,kBAAkB;AAErC,SAAO;AAAA,IACL,aACE,SAAS,gBACP;AAAA,MAAC;AAAA;AAAA,QACC,UAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS,CAAC,iCAAiC;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,IACE;AAAA,IACN,aAAa;AAAA,IACb,eAAe;AAAA,MACb,MAAM;AAAA,MACN,mBAAmB;AAAA,MACnB,gBAAgB,gBAAgB,OAAO,IAAI,UAAU;AAAA,MACrD,GAAG;AAAA,MACH,GAAI,SAAS;AAAA,QACX,MAAM;AAAA,QACN;AAAA,QACA,cAAc,SAAS,OAAO;AAAA,QAC9B,iBAAiB,WAAW,KAAK;AAAA,QACjC;AAAA,QACA,WAAW;AAAA,UACR,MAA6C;AAAA,UAC9C,CAAC,UAAU;AAET,YAAI,MAAM,QAAQ,WAAS,MAAM,eAAe;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACP,MAAM;AAAA,QACN,CAAC,UAAgC;AAC/B;AAAA,YAAW,CAAC,gBACV,gBAAgB,WAAW,IAAI,KAAO,CAAC;AAAA,UACzC,GACI,iBAAiB,0BAA0B,UAC7C,iCAAiC,UAAU,MAAM,qBAAqB,GAIjE,iCAAiC,WAAS,MAAM,gBAAgB;AAAA,QAEzE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
5
+ "names": []
6
+ }
@@ -0,0 +1,11 @@
1
+ function isIndeterminate(checked) {
2
+ return checked === "indeterminate";
3
+ }
4
+ function getState(checked) {
5
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
6
+ }
7
+ export {
8
+ getState,
9
+ isIndeterminate
10
+ };
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils.tsx"],
4
+ "mappings": "AAEO,SAAS,gBAAgB,SAAoD;AAClF,SAAO,YAAY;AACrB;AAEO,SAAS,SAAS,SAAuB;AAC9C,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;",
5
+ "names": []
6
+ }
@@ -0,0 +1,7 @@
1
+ function isIndeterminate(checked) {
2
+ return checked === "indeterminate";
3
+ }
4
+ function getState(checked) {
5
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
6
+ }
7
+ export { getState, isIndeterminate };
@@ -0,0 +1,11 @@
1
+ function isIndeterminate(checked) {
2
+ return checked === "indeterminate";
3
+ }
4
+ function getState(checked) {
5
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
6
+ }
7
+ export {
8
+ getState,
9
+ isIndeterminate
10
+ };
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils.tsx"],
4
+ "mappings": "AAEO,SAAS,gBAAgB,SAAoD;AAClF,SAAO,YAAY;AACrB;AAEO,SAAS,SAAS,SAAuB;AAC9C,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;",
5
+ "names": []
6
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@tamagui/checkbox-headless",
3
+ "version": "1.89.0",
4
+ "sideEffects": [
5
+ "*.css"
6
+ ],
7
+ "source": "src/index.ts",
8
+ "types": "./types/index.d.ts",
9
+ "main": "dist/cjs",
10
+ "module": "dist/esm",
11
+ "module:jsx": "dist/jsx",
12
+ "files": [
13
+ "src",
14
+ "types",
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tamagui-build",
19
+ "watch": "tamagui-build --watch",
20
+ "lint": "../../node_modules/.bin/biome check src",
21
+ "lint:fix": "../../node_modules/.bin/biome check --apply-unsafe src",
22
+ "clean": "tamagui-build clean",
23
+ "clean:build": "tamagui-build clean:build"
24
+ },
25
+ "dependencies": {
26
+ "@tamagui/compose-refs": "1.89.0",
27
+ "@tamagui/constants": "1.89.0",
28
+ "@tamagui/create-context": "1.89.0",
29
+ "@tamagui/focusable": "1.89.0",
30
+ "@tamagui/helpers": "1.89.0",
31
+ "@tamagui/label": "1.89.0",
32
+ "@tamagui/use-controllable-state": "1.89.0",
33
+ "@tamagui/use-previous": "1.89.0"
34
+ },
35
+ "exports": {
36
+ "./package.json": "./package.json",
37
+ ".": {
38
+ "types": "./types/index.d.ts",
39
+ "import": "./dist/esm/index.js",
40
+ "require": "./dist/cjs/index.js",
41
+ "react-native": "./dist/cjs/index.native.js"
42
+ }
43
+ },
44
+ "peerDependencies": {
45
+ "react": "*"
46
+ },
47
+ "devDependencies": {
48
+ "@tamagui/build": "1.89.0",
49
+ "react": "^18.2.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
55
+ }
@@ -0,0 +1,64 @@
1
+ import { usePrevious } from '@tamagui/use-previous'
2
+ import * as React from 'react'
3
+
4
+ import type { CheckedState } from './useCheckbox'
5
+ import { isIndeterminate } from './utils'
6
+
7
+ export interface BubbleInputProps extends Omit<React.ComponentProps<'input'>, 'checked'> {
8
+ checked: CheckedState
9
+ control: HTMLElement | null
10
+ bubbles: boolean
11
+
12
+ isHidden?: boolean
13
+ }
14
+
15
+ export const BubbleInput = (props: BubbleInputProps) => {
16
+ const { checked, bubbles = true, control, isHidden, ...inputProps } = props
17
+ const ref = React.useRef<HTMLInputElement>(null)
18
+ const prevChecked = usePrevious(checked)
19
+ // const controlSize = useSize(control)
20
+ // Bubble checked change to parents (e.g form change event)
21
+ React.useEffect(() => {
22
+ const input = ref.current!
23
+ const inputProto = window.HTMLInputElement.prototype
24
+ const descriptor = Object.getOwnPropertyDescriptor(
25
+ inputProto,
26
+ 'checked'
27
+ ) as PropertyDescriptor
28
+ const setChecked = descriptor.set
29
+
30
+ if (prevChecked !== checked && setChecked) {
31
+ const event = new Event('click', { bubbles })
32
+ input.indeterminate = isIndeterminate(checked)
33
+ setChecked.call(input, isIndeterminate(checked) ? false : checked)
34
+ input.dispatchEvent(event)
35
+ }
36
+ }, [prevChecked, checked, bubbles])
37
+
38
+ return (
39
+ <input
40
+ type="checkbox"
41
+ defaultChecked={isIndeterminate(checked) ? false : checked}
42
+ {...inputProps}
43
+ tabIndex={-1}
44
+ ref={ref}
45
+ aria-hidden={isHidden}
46
+ style={{
47
+ ...(isHidden
48
+ ? {
49
+ // ...controlSize,
50
+ position: 'absolute',
51
+ pointerEvents: 'none',
52
+ opacity: 0,
53
+ margin: 0,
54
+ }
55
+ : {
56
+ appearance: 'auto',
57
+ accentColor: 'var(--color6)',
58
+ }),
59
+
60
+ ...props.style,
61
+ }}
62
+ />
63
+ )
64
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './useCheckbox'
2
+ export * from './utils'
@@ -0,0 +1,112 @@
1
+ import { useComposedRefs } from '@tamagui/compose-refs'
2
+ import { isWeb } from '@tamagui/constants'
3
+ import type { GestureReponderEvent } from '@tamagui/core'
4
+ import { composeEventHandlers } from '@tamagui/helpers'
5
+ import { useLabelContext } from '@tamagui/label'
6
+ import React from 'react'
7
+ import type { PressableProps, View, ViewProps } from 'react-native'
8
+
9
+ import { BubbleInput } from './BubbleInput'
10
+ import { getState, isIndeterminate } from './utils'
11
+
12
+ export type CheckedState = boolean | 'indeterminate'
13
+
14
+ type CheckboxBaseProps = ViewProps & Pick<PressableProps, 'onPress'>
15
+
16
+ export type CheckboxExtraProps = {
17
+ children?: React.ReactNode
18
+ id?: string
19
+ disabled?: boolean
20
+ checked?: CheckedState
21
+ defaultChecked?: CheckedState
22
+ required?: boolean
23
+ /**
24
+ *
25
+ * @param checked Either boolean or "indeterminate" which is meant to allow for a third state that means "neither", usually indicated by a minus sign.
26
+ */
27
+ onCheckedChange?(checked: CheckedState): void
28
+ labelledBy?: string
29
+ name?: string
30
+ value?: string
31
+ }
32
+
33
+ export type CheckboxProps = CheckboxBaseProps & CheckboxExtraProps
34
+
35
+ export function useCheckbox<R extends View, P extends CheckboxProps>(
36
+ props: P,
37
+ [checked, setChecked]: [
38
+ CheckedState,
39
+ React.Dispatch<React.SetStateAction<CheckedState>>,
40
+ ],
41
+ ref: React.Ref<R>
42
+ ) {
43
+ const {
44
+ labelledBy: ariaLabelledby,
45
+ name,
46
+ required,
47
+ disabled,
48
+ value = 'on',
49
+ onCheckedChange,
50
+ ...checkboxProps
51
+ } = props
52
+ const [button, setButton] = React.useState<HTMLButtonElement | null>(null)
53
+ const composedRefs = useComposedRefs(ref, (node) => setButton(node as any))
54
+ const hasConsumerStoppedPropagationRef = React.useRef(false)
55
+ // We set this to true by default so that events bubble to forms without JS (SSR)
56
+ const isFormControl = isWeb ? (button ? Boolean(button.closest('form')) : true) : false
57
+
58
+ const labelId = useLabelContext(button)
59
+ const labelledBy = ariaLabelledby || labelId
60
+
61
+ return {
62
+ bubbleInput:
63
+ isWeb && isFormControl ? (
64
+ <BubbleInput
65
+ isHidden
66
+ control={button}
67
+ bubbles={!hasConsumerStoppedPropagationRef.current}
68
+ name={name}
69
+ value={value}
70
+ checked={checked}
71
+ required={required}
72
+ disabled={disabled}
73
+ />
74
+ ) : null,
75
+ checkboxRef: composedRefs,
76
+ checkboxProps: {
77
+ role: 'checkbox',
78
+ 'aria-labelledby': labelledBy,
79
+ 'aria-checked': isIndeterminate(checked) ? 'mixed' : checked,
80
+ ...checkboxProps,
81
+ ...(isWeb && {
82
+ type: 'button',
83
+ value,
84
+ 'data-state': getState(checked),
85
+ 'data-disabled': disabled ? '' : undefined,
86
+ disabled: disabled,
87
+ onKeyDown: composeEventHandlers(
88
+ (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,
89
+ (event) => {
90
+ // According to WAI ARIA, Checkboxes don't activate on enter keypress
91
+ if (event.key === 'Enter') event.preventDefault()
92
+ }
93
+ ),
94
+ }),
95
+ onPress: composeEventHandlers(
96
+ props.onPress as any,
97
+ (event: GestureReponderEvent) => {
98
+ setChecked((prevChecked) =>
99
+ isIndeterminate(prevChecked) ? true : !prevChecked
100
+ )
101
+ if (isFormControl && 'isPropagationStopped' in event) {
102
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped()
103
+ // if checkbox is in a form, stop propagation from the button so that we only propagate
104
+ // one click event (from the input). We propagate changes from an input so that native
105
+ // form validation works and form events reflect checkbox updates.
106
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation()
107
+ }
108
+ }
109
+ ),
110
+ } satisfies CheckboxBaseProps,
111
+ }
112
+ }
package/src/utils.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import type { CheckedState } from './useCheckbox'
2
+
3
+ export function isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {
4
+ return checked === 'indeterminate'
5
+ }
6
+
7
+ export function getState(checked: CheckedState) {
8
+ return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked'
9
+ }
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { CheckedState } from './useCheckbox';
3
+ export interface BubbleInputProps extends Omit<React.ComponentProps<'input'>, 'checked'> {
4
+ checked: CheckedState;
5
+ control: HTMLElement | null;
6
+ bubbles: boolean;
7
+ isHidden?: boolean;
8
+ }
9
+ export declare const BubbleInput: (props: BubbleInputProps) => JSX.Element;
10
+ //# sourceMappingURL=BubbleInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BubbleInput.d.ts","sourceRoot":"","sources":["../src/BubbleInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IACtF,OAAO,EAAE,YAAY,CAAA;IACrB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAEhB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,UAAW,gBAAgB,gBAiDlD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './useCheckbox';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA"}
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import type { PressableProps, View, ViewProps } from 'react-native';
3
+ export type CheckedState = boolean | 'indeterminate';
4
+ type CheckboxBaseProps = ViewProps & Pick<PressableProps, 'onPress'>;
5
+ export type CheckboxExtraProps = {
6
+ children?: React.ReactNode;
7
+ id?: string;
8
+ disabled?: boolean;
9
+ checked?: CheckedState;
10
+ defaultChecked?: CheckedState;
11
+ required?: boolean;
12
+ /**
13
+ *
14
+ * @param checked Either boolean or "indeterminate" which is meant to allow for a third state that means "neither", usually indicated by a minus sign.
15
+ */
16
+ onCheckedChange?(checked: CheckedState): void;
17
+ labelledBy?: string;
18
+ name?: string;
19
+ value?: string;
20
+ };
21
+ export type CheckboxProps = CheckboxBaseProps & CheckboxExtraProps;
22
+ export declare function useCheckbox<R extends View, P extends CheckboxProps>(props: P, [checked, setChecked]: [
23
+ CheckedState,
24
+ React.Dispatch<React.SetStateAction<CheckedState>>
25
+ ], ref: React.Ref<R>): {
26
+ bubbleInput: JSX.Element | null;
27
+ checkboxRef: (node: R) => void;
28
+ checkboxProps: {
29
+ role: "checkbox";
30
+ 'aria-labelledby': string | undefined;
31
+ 'aria-checked': boolean | "mixed";
32
+ } & Omit<P, "disabled" | "labelledBy" | "name" | "required" | "value" | "onCheckedChange"> & {
33
+ onPress: import("@tamagui/core").EventHandler<import("react-native").GestureResponderEvent> | undefined;
34
+ type?: string | undefined;
35
+ value?: string | undefined;
36
+ 'data-state'?: string | undefined;
37
+ 'data-disabled'?: string | undefined;
38
+ disabled?: boolean | undefined;
39
+ onKeyDown?: import("@tamagui/core").EventHandler<React.KeyboardEvent<HTMLButtonElement>> | undefined;
40
+ };
41
+ };
42
+ export {};
43
+ //# sourceMappingURL=useCheckbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCheckbox.d.ts","sourceRoot":"","sources":["../src/useCheckbox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAKnE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,eAAe,CAAA;AAEpD,KAAK,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;AAEpE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,cAAc,CAAC,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,eAAe,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAElE,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,aAAa,EACjE,KAAK,EAAE,CAAC,EACR,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE;IACrB,YAAY;IACZ,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;CACnD,EACD,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;EAuElB"}
@@ -0,0 +1,4 @@
1
+ import type { CheckedState } from './useCheckbox';
2
+ export declare function isIndeterminate(checked?: CheckedState): checked is 'indeterminate';
3
+ export declare function getState(checked: CheckedState): "indeterminate" | "checked" | "unchecked";
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,IAAI,eAAe,CAElF;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,YAAY,6CAE7C"}