@tamagui/checkbox 2.7.7 → 3.0.0-beta.1093.1
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/dist/cjs/Checkbox.cjs +97 -101
- package/dist/cjs/Checkbox.native.cjs +128 -0
- package/dist/cjs/Checkbox.native.js +111 -100
- package/dist/cjs/Checkbox.native.js.map +1 -1
- package/dist/cjs/CheckboxStyledContext.cjs +17 -23
- package/dist/cjs/CheckboxStyledContext.native.cjs +31 -0
- package/dist/cjs/CheckboxStyledContext.native.js +17 -22
- package/dist/cjs/CheckboxStyledContext.native.js.map +1 -1
- package/dist/cjs/index.cjs +8 -26
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +9 -26
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Checkbox.mjs +75 -86
- package/dist/esm/Checkbox.mjs.map +1 -1
- package/dist/esm/Checkbox.native.js +90 -86
- package/dist/esm/Checkbox.native.js.map +1 -1
- package/dist/esm/CheckboxStyledContext.mjs +5 -5
- package/dist/esm/CheckboxStyledContext.mjs.map +1 -1
- package/dist/esm/CheckboxStyledContext.native.js +5 -5
- package/dist/esm/CheckboxStyledContext.native.js.map +1 -1
- package/dist/esm/index.js +3 -11
- package/dist/esm/index.mjs +3 -11
- package/dist/esm/index.native.js +3 -11
- package/dist/jsx/Checkbox.mjs +75 -86
- package/dist/jsx/Checkbox.mjs.map +1 -1
- package/dist/jsx/Checkbox.native.cjs +128 -0
- package/dist/jsx/Checkbox.native.js +111 -100
- package/dist/jsx/Checkbox.native.js.map +1 -1
- package/dist/jsx/CheckboxStyledContext.mjs +5 -5
- package/dist/jsx/CheckboxStyledContext.mjs.map +1 -1
- package/dist/jsx/CheckboxStyledContext.native.cjs +31 -0
- package/dist/jsx/CheckboxStyledContext.native.js +17 -22
- package/dist/jsx/CheckboxStyledContext.native.js.map +1 -1
- package/dist/jsx/index.js +3 -11
- package/dist/jsx/index.mjs +3 -11
- package/dist/jsx/index.native.cjs +21 -0
- package/dist/jsx/index.native.js +9 -26
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +8 -17
- package/src/Checkbox.tsx +188 -106
- package/src/CheckboxStyledContext.tsx +2 -6
- package/src/index.ts +0 -9
- package/types/Checkbox.d.ts +129 -37
- package/types/Checkbox.d.ts.map +1 -1
- package/types/CheckboxStyledContext.d.ts +2 -4
- package/types/CheckboxStyledContext.d.ts.map +1 -1
- package/types/index.d.ts +0 -320
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/createCheckbox.cjs +0 -194
- package/dist/cjs/createCheckbox.native.js +0 -213
- package/dist/cjs/createCheckbox.native.js.map +0 -1
- package/dist/esm/createCheckbox.mjs +0 -150
- package/dist/esm/createCheckbox.mjs.map +0 -1
- package/dist/esm/createCheckbox.native.js +0 -167
- package/dist/esm/createCheckbox.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/createCheckbox.mjs +0 -150
- package/dist/jsx/createCheckbox.mjs.map +0 -1
- package/dist/jsx/createCheckbox.native.js +0 -213
- package/dist/jsx/createCheckbox.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/src/createCheckbox.tsx +0 -280
- package/types/createCheckbox.d.ts +0 -196
- package/types/createCheckbox.d.ts.map +0 -1
|
@@ -1,90 +1,94 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isIndeterminate, useCheckbox } from "@tamagui/checkbox-headless";
|
|
3
|
+
import { View, createStyledHOC, isWeb, shouldRenderNativePlatform, styled, withStaticProperties } from "@tamagui/core";
|
|
4
|
+
import { registerFocusable } from "@tamagui/focusable";
|
|
5
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
6
|
+
import React, { useMemo } from "react";
|
|
4
7
|
import { CheckboxStyledContext } from "./CheckboxStyledContext.native.js";
|
|
5
|
-
|
|
6
|
-
var CheckboxIndicatorFrame = styled(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
context: CheckboxStyledContext,
|
|
10
|
-
variants: {
|
|
11
|
-
unstyled: {
|
|
12
|
-
false: {}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
defaultVariants: {
|
|
16
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
17
|
-
}
|
|
18
|
-
}, {
|
|
19
|
-
accept: {
|
|
20
|
-
activeStyle: "style"
|
|
21
|
-
}
|
|
8
|
+
|
|
9
|
+
var CheckboxIndicatorFrame = styled(View, {
|
|
10
|
+
displayName: "CheckboxIndicator",
|
|
11
|
+
context: CheckboxStyledContext
|
|
22
12
|
});
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
alignItems: "center",
|
|
34
|
-
justifyContent: "center",
|
|
35
|
-
borderWidth: 1,
|
|
36
|
-
borderColor: "$borderColor",
|
|
37
|
-
hoverStyle: {
|
|
38
|
-
borderColor: "$borderColorHover"
|
|
39
|
-
},
|
|
40
|
-
pressStyle: {
|
|
41
|
-
backgroundColor: "$backgroundPress",
|
|
42
|
-
borderColor: "$borderColorPress"
|
|
43
|
-
},
|
|
44
|
-
focusStyle: {
|
|
45
|
-
borderColor: "$borderColorFocus"
|
|
46
|
-
},
|
|
47
|
-
focusVisibleStyle: {
|
|
48
|
-
outlineStyle: "solid",
|
|
49
|
-
outlineWidth: 2,
|
|
50
|
-
outlineColor: "$outlineColor"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
disabled: {
|
|
55
|
-
true: {
|
|
56
|
-
pointerEvents: "none",
|
|
57
|
-
userSelect: "none",
|
|
58
|
-
cursor: "not-allowed",
|
|
59
|
-
hoverStyle: {
|
|
60
|
-
borderColor: "$borderColor",
|
|
61
|
-
backgroundColor: "$background"
|
|
62
|
-
},
|
|
63
|
-
pressStyle: {
|
|
64
|
-
borderColor: "$borderColor",
|
|
65
|
-
backgroundColor: "$background"
|
|
66
|
-
},
|
|
67
|
-
focusStyle: {
|
|
68
|
-
outlineWidth: 0
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
size: {
|
|
73
|
-
"...size": function (val) {
|
|
74
|
-
var radiusToken = getVariableValue(getSize(val)) / 8;
|
|
75
|
-
return {
|
|
76
|
-
borderRadius: radiusToken
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
defaultVariants: {
|
|
82
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
accept: {
|
|
86
|
-
activeStyle: "style"
|
|
87
|
-
}
|
|
13
|
+
var CheckboxFrame = styled(View, {
|
|
14
|
+
displayName: "Checkbox",
|
|
15
|
+
render: "button",
|
|
16
|
+
context: CheckboxStyledContext,
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
variants: { disabled: { true: {
|
|
20
|
+
pointerEvents: "none",
|
|
21
|
+
userSelect: "none"
|
|
22
|
+
} } }
|
|
88
23
|
});
|
|
89
|
-
|
|
24
|
+
var CheckboxContext = /* @__PURE__ */ React.createContext({
|
|
25
|
+
checked: false,
|
|
26
|
+
disabled: false
|
|
27
|
+
});
|
|
28
|
+
var Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(propsIn, forwardedRef) {
|
|
29
|
+
var { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = propsIn;
|
|
30
|
+
var [checked = false, setChecked] = useControllableState({
|
|
31
|
+
prop: checkedProp,
|
|
32
|
+
defaultProp: defaultChecked,
|
|
33
|
+
onChange: onCheckedChange
|
|
34
|
+
});
|
|
35
|
+
var { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(props, [checked, setChecked], forwardedRef);
|
|
36
|
+
React.useEffect(function() {
|
|
37
|
+
if (!props.id) return;
|
|
38
|
+
if (props.disabled) return;
|
|
39
|
+
return registerFocusable(props.id, {
|
|
40
|
+
focusAndSelect: function() {
|
|
41
|
+
setChecked === null || setChecked === void 0 || setChecked(function(value) {
|
|
42
|
+
return !value;
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
focus: function() {}
|
|
46
|
+
});
|
|
47
|
+
}, [props.id, props.disabled]);
|
|
48
|
+
if (shouldRenderNativePlatform(native) === "web") return /* @__PURE__ */ jsx("input", {
|
|
49
|
+
type: "checkbox",
|
|
50
|
+
defaultChecked: isIndeterminate(checked) ? false : checked,
|
|
51
|
+
tabIndex: -1,
|
|
52
|
+
ref: checkboxRef,
|
|
53
|
+
disabled: checkboxProps.disabled,
|
|
54
|
+
style: checkboxProps.style
|
|
55
|
+
});
|
|
56
|
+
var memoizedContext = useMemo(function() {
|
|
57
|
+
return {
|
|
58
|
+
checked,
|
|
59
|
+
disabled: checkboxProps.disabled
|
|
60
|
+
};
|
|
61
|
+
}, [checked, checkboxProps.disabled]);
|
|
62
|
+
var isActive = !!checked;
|
|
63
|
+
var disabled = checkboxProps.disabled;
|
|
64
|
+
return /* @__PURE__ */ jsxs(CheckboxContext.Provider, {
|
|
65
|
+
value: memoizedContext,
|
|
66
|
+
children: [/* @__PURE__ */ jsx(CheckboxFrame, {
|
|
67
|
+
render: "button",
|
|
68
|
+
ref: checkboxRef,
|
|
69
|
+
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
70
|
+
...isWeb && { type: "button" },
|
|
71
|
+
checked,
|
|
72
|
+
...checkboxProps,
|
|
73
|
+
style: [checkboxProps.style, isActive && activeStyle],
|
|
74
|
+
active: isActive,
|
|
75
|
+
disabled,
|
|
76
|
+
children: props.children
|
|
77
|
+
}), bubbleInput]
|
|
78
|
+
});
|
|
79
|
+
}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, function(props, forwardedRef) {
|
|
80
|
+
var { children, forceMount, activeStyle, ...indicatorProps } = props;
|
|
81
|
+
var { active } = CheckboxStyledContext.useStyledContext();
|
|
82
|
+
var context = React.useContext(CheckboxContext);
|
|
83
|
+
if (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {
|
|
84
|
+
pointerEvents: "none",
|
|
85
|
+
...indicatorProps,
|
|
86
|
+
style: [indicatorProps.style, active && activeStyle],
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
children
|
|
89
|
+
});
|
|
90
|
+
return null;
|
|
91
|
+
}) });
|
|
92
|
+
|
|
93
|
+
export { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };
|
|
90
94
|
//# sourceMappingURL=Checkbox.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Checkbox.native.js","names":[],"sources":["esm/Checkbox.native.js"],"sourcesContent":["import { jsx, jsxs } from \"react/jsx-runtime\";\nimport { isIndeterminate, useCheckbox } from \"@tamagui/checkbox-headless\";\nimport { View, createStyledHOC, isWeb, shouldRenderNativePlatform, styled, withStaticProperties } from \"@tamagui/core\";\nimport { registerFocusable } from \"@tamagui/focusable\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport React, { useMemo } from \"react\";\nimport { CheckboxStyledContext } from \"./CheckboxStyledContext\";\n\nvar CheckboxIndicatorFrame = styled(View, {\n\tdisplayName: \"CheckboxIndicator\",\n\tcontext: CheckboxStyledContext\n});\nvar CheckboxFrame = styled(View, {\n\tdisplayName: \"Checkbox\",\n\trender: \"button\",\n\tcontext: CheckboxStyledContext,\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tvariants: { disabled: { true: {\n\t\tpointerEvents: \"none\",\n\t\tuserSelect: \"none\"\n\t} } }\n});\nvar CheckboxContext = /* @__PURE__ */ React.createContext({\n\tchecked: false,\n\tdisabled: false\n});\nvar Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(propsIn, forwardedRef) {\n\tvar { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = propsIn;\n\tvar [checked = false, setChecked] = useControllableState({\n\t\tprop: checkedProp,\n\t\tdefaultProp: defaultChecked,\n\t\tonChange: onCheckedChange\n\t});\n\tvar { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(props, [checked, setChecked], forwardedRef);\n\tReact.useEffect(function() {\n\t\tif (!props.id) return;\n\t\tif (props.disabled) return;\n\t\treturn registerFocusable(props.id, {\n\t\t\tfocusAndSelect: function() {\n\t\t\t\tsetChecked === null || setChecked === void 0 || setChecked(function(value) {\n\t\t\t\t\treturn !value;\n\t\t\t\t});\n\t\t\t},\n\t\t\tfocus: function() {}\n\t\t});\n\t}, [props.id, props.disabled]);\n\tif (shouldRenderNativePlatform(native) === \"web\") return /* @__PURE__ */ jsx(\"input\", {\n\t\ttype: \"checkbox\",\n\t\tdefaultChecked: isIndeterminate(checked) ? false : checked,\n\t\ttabIndex: -1,\n\t\tref: checkboxRef,\n\t\tdisabled: checkboxProps.disabled,\n\t\tstyle: checkboxProps.style\n\t});\n\tvar memoizedContext = useMemo(function() {\n\t\treturn {\n\t\t\tchecked,\n\t\t\tdisabled: checkboxProps.disabled\n\t\t};\n\t}, [checked, checkboxProps.disabled]);\n\tvar isActive = !!checked;\n\tvar disabled = checkboxProps.disabled;\n\treturn /* @__PURE__ */ jsxs(CheckboxContext.Provider, {\n\t\tvalue: memoizedContext,\n\t\tchildren: [/* @__PURE__ */ jsx(CheckboxFrame, {\n\t\t\trender: \"button\",\n\t\t\tref: checkboxRef,\n\t\t\ttheme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,\n\t\t\t...isWeb && { type: \"button\" },\n\t\t\tchecked,\n\t\t\t...checkboxProps,\n\t\t\tstyle: [checkboxProps.style, isActive && activeStyle],\n\t\t\tactive: isActive,\n\t\t\tdisabled,\n\t\t\tchildren: props.children\n\t\t}), bubbleInput]\n\t});\n}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, function(props, forwardedRef) {\n\tvar { children, forceMount, activeStyle, ...indicatorProps } = props;\n\tvar { active } = CheckboxStyledContext.useStyledContext();\n\tvar context = React.useContext(CheckboxContext);\n\tif (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {\n\t\tpointerEvents: \"none\",\n\t\t...indicatorProps,\n\t\tstyle: [indicatorProps.style, active && activeStyle],\n\t\tref: forwardedRef,\n\t\tchildren\n\t});\n\treturn null;\n}) });\n\nexport { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };"],"mappings":";;;;;;;;;AAQA,IAAI,yBAAyB,OAAO,MAAM;CACzC,aAAa;CACb,SAAS;AACV,CAAC;AACD,IAAI,gBAAgB,OAAO,MAAM;CAChC,aAAa;CACb,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU,EAAE,UAAU,EAAE,MAAM;EAC7B,eAAe;EACf,YAAY;CACb,EAAE,EAAE;AACL,CAAC;AACD,IAAI,kBAAkC,sBAAM,cAAc;CACzD,SAAS;CACT,UAAU;AACX,CAAC;AACD,IAAI,YAAY,qBAAqB,gBAAgB,eAAe,SAAS,SAAS,SAAS,cAAc;CAC5G,IAAI,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,QAAQ,aAAa,aAAa,GAAG,UAAU;CAC5G,IAAI,CAAC,UAAU,OAAO,cAAc,qBAAqB;EACxD,MAAM;EACN,aAAa;EACb,UAAU;CACX,CAAC;CACD,IAAI,EAAE,eAAe,aAAa,gBAAgB,YAAY,OAAO,CAAC,SAAS,UAAU,GAAG,YAAY;CACxG,MAAM,UAAU,WAAW;EAC1B,IAAI,CAAC,MAAM,IAAI;EACf,IAAI,MAAM,UAAU;EACpB,OAAO,kBAAkB,MAAM,IAAI;GAClC,gBAAgB,WAAW;IAC1B,eAAe,QAAQ,eAAe,KAAK,KAAK,WAAW,SAAS,OAAO;KAC1E,OAAO,CAAC;IACT,CAAC;GACF;GACA,OAAO,WAAW,CAAC;EACpB,CAAC;CACF,GAAG,CAAC,MAAM,IAAI,MAAM,QAAQ,CAAC;CAC7B,IAAI,2BAA2B,MAAM,MAAM,OAAO,OAAuB,oBAAI,SAAS;EACrF,MAAM;EACN,gBAAgB,gBAAgB,OAAO,IAAI,QAAQ;EACnD,UAAU,CAAC;EACX,KAAK;EACL,UAAU,cAAc;EACxB,OAAO,cAAc;CACtB,CAAC;CACD,IAAI,kBAAkB,QAAQ,WAAW;EACxC,OAAO;GACN;GACA,UAAU,cAAc;EACzB;CACD,GAAG,CAAC,SAAS,cAAc,QAAQ,CAAC;CACpC,IAAI,WAAW,CAAC,CAAC;CACjB,IAAI,WAAW,cAAc;CAC7B,OAAuB,qBAAK,gBAAgB,UAAU;EACrD,OAAO;EACP,UAAU,CAAiB,oBAAI,eAAe;GAC7C,QAAQ;GACR,KAAK;GACL,OAAO,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI,cAAc;GACtE,GAAG,SAAS,EAAE,MAAM,SAAS;GAC7B;GACA,GAAG;GACH,OAAO,CAAC,cAAc,OAAO,YAAY,WAAW;GACpD,QAAQ;GACR;GACA,UAAU,MAAM;EACjB,CAAC,GAAG,WAAW;CAChB,CAAC;AACF,CAAC,GAAG,EAAE,WAAW,gBAAgB,wBAAwB,SAAS,OAAO,cAAc;CACtF,IAAI,EAAE,UAAU,YAAY,aAAa,GAAG,mBAAmB;CAC/D,IAAI,EAAE,WAAW,sBAAsB,iBAAiB;CACxD,IAAI,UAAU,MAAM,WAAW,eAAe;CAC9C,IAAI,cAAc,gBAAgB,QAAQ,OAAO,KAAK,QAAQ,YAAY,MAAM,OAAuB,oBAAI,wBAAwB;EAClI,eAAe;EACf,GAAG;EACH,OAAO,CAAC,eAAe,OAAO,UAAU,WAAW;EACnD,KAAK;EACL;CACD,CAAC;CACD,OAAO;AACR,CAAC,EAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createStyledContext } from "@tamagui/core";
|
|
2
|
+
|
|
2
3
|
const CheckboxStyledContext = createStyledContext({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
active: false,
|
|
7
|
-
disabled: false
|
|
4
|
+
size: true,
|
|
5
|
+
active: false,
|
|
6
|
+
disabled: false
|
|
8
7
|
});
|
|
8
|
+
|
|
9
9
|
export { CheckboxStyledContext };
|
|
10
10
|
//# sourceMappingURL=CheckboxStyledContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"CheckboxStyledContext.js","names":[],"sources":["esm/CheckboxStyledContext.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nconst CheckboxStyledContext = createStyledContext({\n size: true,\n active: false,\n disabled: false\n});\nexport {\n CheckboxStyledContext\n};\n//# sourceMappingURL=CheckboxStyledContext.js.map\n"],"mappings":";;;AACA,MAAM,wBAAwB,oBAAoB;CAChD,MAAM;CACN,QAAQ;CACR,UAAU;AACZ,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createStyledContext } from "@tamagui/core";
|
|
2
|
+
|
|
2
3
|
var CheckboxStyledContext = createStyledContext({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
active: false,
|
|
7
|
-
disabled: false
|
|
4
|
+
size: true,
|
|
5
|
+
active: false,
|
|
6
|
+
disabled: false
|
|
8
7
|
});
|
|
8
|
+
|
|
9
9
|
export { CheckboxStyledContext };
|
|
10
10
|
//# sourceMappingURL=CheckboxStyledContext.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"CheckboxStyledContext.native.js","names":[],"sources":["esm/CheckboxStyledContext.native.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nvar CheckboxStyledContext = createStyledContext({\n size: true,\n active: false,\n disabled: false\n});\nexport {\n CheckboxStyledContext\n};\n//# sourceMappingURL=CheckboxStyledContext.js.map\n"],"mappings":";;;AACA,IAAI,wBAAwB,oBAAoB;CAC9C,MAAM;CACN,QAAQ;CACR,UAAU;AACZ,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./Checkbox.mjs";
|
|
5
|
-
export * from "./CheckboxStyledContext.mjs";
|
|
6
|
-
const Checkbox = createCheckbox({
|
|
7
|
-
Frame: CheckboxFrame,
|
|
8
|
-
Indicator: CheckboxIndicatorFrame
|
|
9
|
-
});
|
|
10
|
-
export { Checkbox };
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./Checkbox.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./CheckboxStyledContext.mjs"
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./Checkbox.mjs";
|
|
5
|
-
export * from "./CheckboxStyledContext.mjs";
|
|
6
|
-
const Checkbox = createCheckbox({
|
|
7
|
-
Frame: CheckboxFrame,
|
|
8
|
-
Indicator: CheckboxIndicatorFrame
|
|
9
|
-
});
|
|
10
|
-
export { Checkbox };
|
|
11
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from "./Checkbox.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./CheckboxStyledContext.mjs"
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./Checkbox.native.js";
|
|
5
|
-
export * from "./CheckboxStyledContext.native.js";
|
|
6
|
-
var Checkbox = createCheckbox({
|
|
7
|
-
Frame: CheckboxFrame,
|
|
8
|
-
Indicator: CheckboxIndicatorFrame
|
|
9
|
-
});
|
|
10
|
-
export { Checkbox };
|
|
11
|
-
//# sourceMappingURL=index.native.js.map
|
|
1
|
+
export * from "./Checkbox.native.js"
|
|
2
|
+
|
|
3
|
+
export * from "./CheckboxStyledContext.native.js"
|
package/dist/jsx/Checkbox.mjs
CHANGED
|
@@ -1,90 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isIndeterminate, useCheckbox } from "@tamagui/checkbox-headless";
|
|
2
|
+
import { View, createStyledHOC, isWeb, shouldRenderNativePlatform, styled, withStaticProperties } from "@tamagui/core";
|
|
3
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
4
|
+
import React, { useMemo } from "react";
|
|
4
5
|
import { CheckboxStyledContext } from "./CheckboxStyledContext.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
variants: {
|
|
11
|
-
unstyled: {
|
|
12
|
-
false: {}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
defaultVariants: {
|
|
16
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
17
|
-
}
|
|
18
|
-
}, {
|
|
19
|
-
accept: {
|
|
20
|
-
activeStyle: "style"
|
|
21
|
-
}
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
const CheckboxIndicatorFrame = styled(View, {
|
|
9
|
+
displayName: "CheckboxIndicator",
|
|
10
|
+
context: CheckboxStyledContext
|
|
22
11
|
});
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
alignItems: "center",
|
|
34
|
-
justifyContent: "center",
|
|
35
|
-
borderWidth: 1,
|
|
36
|
-
borderColor: "$borderColor",
|
|
37
|
-
hoverStyle: {
|
|
38
|
-
borderColor: "$borderColorHover"
|
|
39
|
-
},
|
|
40
|
-
pressStyle: {
|
|
41
|
-
backgroundColor: "$backgroundPress",
|
|
42
|
-
borderColor: "$borderColorPress"
|
|
43
|
-
},
|
|
44
|
-
focusStyle: {
|
|
45
|
-
borderColor: "$borderColorFocus"
|
|
46
|
-
},
|
|
47
|
-
focusVisibleStyle: {
|
|
48
|
-
outlineStyle: "solid",
|
|
49
|
-
outlineWidth: 2,
|
|
50
|
-
outlineColor: "$outlineColor"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
disabled: {
|
|
55
|
-
true: {
|
|
56
|
-
pointerEvents: "none",
|
|
57
|
-
userSelect: "none",
|
|
58
|
-
cursor: "not-allowed",
|
|
59
|
-
hoverStyle: {
|
|
60
|
-
borderColor: "$borderColor",
|
|
61
|
-
backgroundColor: "$background"
|
|
62
|
-
},
|
|
63
|
-
pressStyle: {
|
|
64
|
-
borderColor: "$borderColor",
|
|
65
|
-
backgroundColor: "$background"
|
|
66
|
-
},
|
|
67
|
-
focusStyle: {
|
|
68
|
-
outlineWidth: 0
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
size: {
|
|
73
|
-
"...size": val => {
|
|
74
|
-
const radiusToken = getVariableValue(getSize(val)) / 8;
|
|
75
|
-
return {
|
|
76
|
-
borderRadius: radiusToken
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
defaultVariants: {
|
|
82
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
accept: {
|
|
86
|
-
activeStyle: "style"
|
|
87
|
-
}
|
|
12
|
+
const CheckboxFrame = styled(View, {
|
|
13
|
+
displayName: "Checkbox",
|
|
14
|
+
render: "button",
|
|
15
|
+
context: CheckboxStyledContext,
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
variants: { disabled: { true: {
|
|
19
|
+
pointerEvents: "none",
|
|
20
|
+
userSelect: "none"
|
|
21
|
+
} } }
|
|
88
22
|
});
|
|
89
|
-
|
|
23
|
+
const CheckboxContext = React.createContext({
|
|
24
|
+
checked: false,
|
|
25
|
+
disabled: false
|
|
26
|
+
});
|
|
27
|
+
const Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(propsIn, forwardedRef) {
|
|
28
|
+
const { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = propsIn;
|
|
29
|
+
const [checked = false, setChecked] = useControllableState({
|
|
30
|
+
prop: checkedProp,
|
|
31
|
+
defaultProp: defaultChecked,
|
|
32
|
+
onChange: onCheckedChange
|
|
33
|
+
});
|
|
34
|
+
const { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(props, [checked, setChecked], forwardedRef);
|
|
35
|
+
if (shouldRenderNativePlatform(native) === "web") return /* @__PURE__ */ jsx("input", {
|
|
36
|
+
type: "checkbox",
|
|
37
|
+
defaultChecked: isIndeterminate(checked) ? false : checked,
|
|
38
|
+
tabIndex: -1,
|
|
39
|
+
ref: checkboxRef,
|
|
40
|
+
disabled: checkboxProps.disabled,
|
|
41
|
+
style: checkboxProps.style
|
|
42
|
+
});
|
|
43
|
+
const memoizedContext = useMemo(() => ({
|
|
44
|
+
checked,
|
|
45
|
+
disabled: checkboxProps.disabled
|
|
46
|
+
}), [checked, checkboxProps.disabled]);
|
|
47
|
+
const isActive = !!checked;
|
|
48
|
+
const disabled = checkboxProps.disabled;
|
|
49
|
+
return /* @__PURE__ */ jsxs(CheckboxContext.Provider, {
|
|
50
|
+
value: memoizedContext,
|
|
51
|
+
children: [/* @__PURE__ */ jsx(CheckboxFrame, {
|
|
52
|
+
render: "button",
|
|
53
|
+
ref: checkboxRef,
|
|
54
|
+
theme: activeTheme ?? null,
|
|
55
|
+
...isWeb && { type: "button" },
|
|
56
|
+
checked,
|
|
57
|
+
...checkboxProps,
|
|
58
|
+
style: [checkboxProps.style, isActive && activeStyle],
|
|
59
|
+
active: isActive,
|
|
60
|
+
disabled,
|
|
61
|
+
children: props.children
|
|
62
|
+
}), bubbleInput]
|
|
63
|
+
});
|
|
64
|
+
}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, (props, forwardedRef) => {
|
|
65
|
+
const { children, forceMount, activeStyle, ...indicatorProps } = props;
|
|
66
|
+
const { active } = CheckboxStyledContext.useStyledContext();
|
|
67
|
+
const context = React.useContext(CheckboxContext);
|
|
68
|
+
if (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {
|
|
69
|
+
pointerEvents: "none",
|
|
70
|
+
...indicatorProps,
|
|
71
|
+
style: [indicatorProps.style, active && activeStyle],
|
|
72
|
+
ref: forwardedRef,
|
|
73
|
+
children
|
|
74
|
+
});
|
|
75
|
+
return null;
|
|
76
|
+
}) });
|
|
77
|
+
|
|
78
|
+
export { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };
|
|
90
79
|
//# sourceMappingURL=Checkbox.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["jsx/Checkbox.js"],"sourcesContent":["import { isIndeterminate, useCheckbox } from \"@tamagui/checkbox-headless\";\nimport { View, createStyledHOC, isWeb, shouldRenderNativePlatform, styled, withStaticProperties } from \"@tamagui/core\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport React, { useMemo } from \"react\";\nimport { CheckboxStyledContext } from \"./CheckboxStyledContext\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\n\nconst CheckboxIndicatorFrame = styled(View, {\n\tdisplayName: \"CheckboxIndicator\",\n\tcontext: CheckboxStyledContext\n});\nconst CheckboxFrame = styled(View, {\n\tdisplayName: \"Checkbox\",\n\trender: \"button\",\n\tcontext: CheckboxStyledContext,\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tvariants: { disabled: { true: {\n\t\tpointerEvents: \"none\",\n\t\tuserSelect: \"none\"\n\t} } }\n});\nconst CheckboxContext = React.createContext({\n\tchecked: false,\n\tdisabled: false\n});\nconst Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(propsIn, forwardedRef) {\n\tconst { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = propsIn;\n\tconst [checked = false, setChecked] = useControllableState({\n\t\tprop: checkedProp,\n\t\tdefaultProp: defaultChecked,\n\t\tonChange: onCheckedChange\n\t});\n\tconst { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(props, [checked, setChecked], forwardedRef);\n\tif (shouldRenderNativePlatform(native) === \"web\") return /* @__PURE__ */ jsx(\"input\", {\n\t\ttype: \"checkbox\",\n\t\tdefaultChecked: isIndeterminate(checked) ? false : checked,\n\t\ttabIndex: -1,\n\t\tref: checkboxRef,\n\t\tdisabled: checkboxProps.disabled,\n\t\tstyle: checkboxProps.style\n\t});\n\tconst memoizedContext = useMemo(() => ({\n\t\tchecked,\n\t\tdisabled: checkboxProps.disabled\n\t}), [checked, checkboxProps.disabled]);\n\tconst isActive = !!checked;\n\tconst disabled = checkboxProps.disabled;\n\treturn /* @__PURE__ */ jsxs(CheckboxContext.Provider, {\n\t\tvalue: memoizedContext,\n\t\tchildren: [/* @__PURE__ */ jsx(CheckboxFrame, {\n\t\t\trender: \"button\",\n\t\t\tref: checkboxRef,\n\t\t\ttheme: activeTheme ?? null,\n\t\t\t...isWeb && { type: \"button\" },\n\t\t\tchecked,\n\t\t\t...checkboxProps,\n\t\t\tstyle: [checkboxProps.style, isActive && activeStyle],\n\t\t\tactive: isActive,\n\t\t\tdisabled,\n\t\t\tchildren: props.children\n\t\t}), bubbleInput]\n\t});\n}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, (props, forwardedRef) => {\n\tconst { children, forceMount, activeStyle, ...indicatorProps } = props;\n\tconst { active } = CheckboxStyledContext.useStyledContext();\n\tconst context = React.useContext(CheckboxContext);\n\tif (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {\n\t\tpointerEvents: \"none\",\n\t\t...indicatorProps,\n\t\tstyle: [indicatorProps.style, active && activeStyle],\n\t\tref: forwardedRef,\n\t\tchildren\n\t});\n\treturn null;\n}) });\n\nexport { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };"],"mappings":";;;;;;;;AAOA,MAAM,yBAAyB,OAAO,MAAM;CAC3C,aAAa;CACb,SAAS;AACV,CAAC;AACD,MAAM,gBAAgB,OAAO,MAAM;CAClC,aAAa;CACb,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU,EAAE,UAAU,EAAE,MAAM;EAC7B,eAAe;EACf,YAAY;CACb,EAAE,EAAE;AACL,CAAC;AACD,MAAM,kBAAkB,MAAM,cAAc;CAC3C,SAAS;CACT,UAAU;AACX,CAAC;AACD,MAAM,YAAY,qBAAqB,gBAAgB,eAAe,SAAS,SAAS,SAAS,cAAc;CAC9G,MAAM,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,QAAQ,aAAa,aAAa,GAAG,UAAU;CAC9G,MAAM,CAAC,UAAU,OAAO,cAAc,qBAAqB;EAC1D,MAAM;EACN,aAAa;EACb,UAAU;CACX,CAAC;CACD,MAAM,EAAE,eAAe,aAAa,gBAAgB,YAAY,OAAO,CAAC,SAAS,UAAU,GAAG,YAAY;CAC1G,IAAI,2BAA2B,MAAM,MAAM,OAAO,OAAuB,oBAAI,SAAS;EACrF,MAAM;EACN,gBAAgB,gBAAgB,OAAO,IAAI,QAAQ;EACnD,UAAU,CAAC;EACX,KAAK;EACL,UAAU,cAAc;EACxB,OAAO,cAAc;CACtB,CAAC;CACD,MAAM,kBAAkB,eAAe;EACtC;EACA,UAAU,cAAc;CACzB,IAAI,CAAC,SAAS,cAAc,QAAQ,CAAC;CACrC,MAAM,WAAW,CAAC,CAAC;CACnB,MAAM,WAAW,cAAc;CAC/B,OAAuB,qBAAK,gBAAgB,UAAU;EACrD,OAAO;EACP,UAAU,CAAiB,oBAAI,eAAe;GAC7C,QAAQ;GACR,KAAK;GACL,OAAO,eAAe;GACtB,GAAG,SAAS,EAAE,MAAM,SAAS;GAC7B;GACA,GAAG;GACH,OAAO,CAAC,cAAc,OAAO,YAAY,WAAW;GACpD,QAAQ;GACR;GACA,UAAU,MAAM;EACjB,CAAC,GAAG,WAAW;CAChB,CAAC;AACF,CAAC,GAAG,EAAE,WAAW,gBAAgB,yBAAyB,OAAO,iBAAiB;CACjF,MAAM,EAAE,UAAU,YAAY,aAAa,GAAG,mBAAmB;CACjE,MAAM,EAAE,WAAW,sBAAsB,iBAAiB;CAC1D,MAAM,UAAU,MAAM,WAAW,eAAe;CAChD,IAAI,cAAc,gBAAgB,QAAQ,OAAO,KAAK,QAAQ,YAAY,MAAM,OAAuB,oBAAI,wBAAwB;EAClI,eAAe;EACf,GAAG;EACH,OAAO,CAAC,eAAe,OAAO,UAAU,WAAW;EACnD,KAAK;EACL;CACD,CAAC;CACD,OAAO;AACR,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Checkbox_exports = {};
|
|
30
|
+
__export(Checkbox_exports, {
|
|
31
|
+
Checkbox: () => Checkbox2,
|
|
32
|
+
CheckboxContext: () => CheckboxContext,
|
|
33
|
+
CheckboxFrame: () => CheckboxFrame,
|
|
34
|
+
CheckboxIndicatorFrame: () => CheckboxIndicatorFrame
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(Checkbox_exports);
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var import_checkbox_headless = require("@tamagui/checkbox-headless");
|
|
39
|
+
var import_core = require("@tamagui/core");
|
|
40
|
+
var import_focusable = require("@tamagui/focusable");
|
|
41
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
42
|
+
var import_react = __toESM(require("react"), 1);
|
|
43
|
+
var import_CheckboxStyledContext = require("./CheckboxStyledContext.native.js");
|
|
44
|
+
var CheckboxIndicatorFrame = (0, import_core.styled)(import_core.View, {
|
|
45
|
+
displayName: "CheckboxIndicator",
|
|
46
|
+
context: import_CheckboxStyledContext.CheckboxStyledContext
|
|
47
|
+
});
|
|
48
|
+
var CheckboxFrame = (0, import_core.styled)(import_core.View, {
|
|
49
|
+
displayName: "Checkbox",
|
|
50
|
+
render: "button",
|
|
51
|
+
context: import_CheckboxStyledContext.CheckboxStyledContext,
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
variants: { disabled: { true: {
|
|
55
|
+
pointerEvents: "none",
|
|
56
|
+
userSelect: "none"
|
|
57
|
+
} } }
|
|
58
|
+
});
|
|
59
|
+
var CheckboxContext = /* @__PURE__ */ import_react.default.createContext({
|
|
60
|
+
checked: false,
|
|
61
|
+
disabled: false
|
|
62
|
+
});
|
|
63
|
+
var CheckboxComponent = (0, import_core.createStyledHOC)(CheckboxFrame, function Checkbox(propsIn, forwardedRef) {
|
|
64
|
+
var { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = propsIn;
|
|
65
|
+
var [checked = false, setChecked] = (0, import_use_controllable_state.useControllableState)({
|
|
66
|
+
prop: checkedProp,
|
|
67
|
+
defaultProp: defaultChecked,
|
|
68
|
+
onChange: onCheckedChange
|
|
69
|
+
});
|
|
70
|
+
var { checkboxProps, checkboxRef, bubbleInput } = (0, import_checkbox_headless.useCheckbox)(props, [checked, setChecked], forwardedRef);
|
|
71
|
+
import_react.default.useEffect(function() {
|
|
72
|
+
if (!props.id) return;
|
|
73
|
+
if (props.disabled) return;
|
|
74
|
+
return (0, import_focusable.registerFocusable)(props.id, {
|
|
75
|
+
focusAndSelect: function() {
|
|
76
|
+
setChecked === null || setChecked === void 0 || setChecked(function(value) {
|
|
77
|
+
return !value;
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
focus: function() {}
|
|
81
|
+
});
|
|
82
|
+
}, [props.id, props.disabled]);
|
|
83
|
+
if ((0, import_core.shouldRenderNativePlatform)(native) === "web") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
84
|
+
type: "checkbox",
|
|
85
|
+
defaultChecked: (0, import_checkbox_headless.isIndeterminate)(checked) ? false : checked,
|
|
86
|
+
tabIndex: -1,
|
|
87
|
+
ref: checkboxRef,
|
|
88
|
+
disabled: checkboxProps.disabled,
|
|
89
|
+
style: checkboxProps.style
|
|
90
|
+
});
|
|
91
|
+
var memoizedContext = (0, import_react.useMemo)(function() {
|
|
92
|
+
return {
|
|
93
|
+
checked,
|
|
94
|
+
disabled: checkboxProps.disabled
|
|
95
|
+
};
|
|
96
|
+
}, [checked, checkboxProps.disabled]);
|
|
97
|
+
var isActive = !!checked;
|
|
98
|
+
var disabled = checkboxProps.disabled;
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CheckboxContext.Provider, {
|
|
100
|
+
value: memoizedContext,
|
|
101
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxFrame, {
|
|
102
|
+
render: "button",
|
|
103
|
+
ref: checkboxRef,
|
|
104
|
+
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
105
|
+
...import_core.isWeb && { type: "button" },
|
|
106
|
+
checked,
|
|
107
|
+
...checkboxProps,
|
|
108
|
+
style: [checkboxProps.style, isActive && activeStyle],
|
|
109
|
+
active: isActive,
|
|
110
|
+
disabled,
|
|
111
|
+
children: props.children
|
|
112
|
+
}), bubbleInput]
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
var CheckboxIndicator = (0, import_core.createStyledHOC)(CheckboxIndicatorFrame, function(props, forwardedRef) {
|
|
116
|
+
var { children, forceMount, activeStyle, ...indicatorProps } = props;
|
|
117
|
+
var { active } = import_CheckboxStyledContext.CheckboxStyledContext.useStyledContext();
|
|
118
|
+
var context = import_react.default.useContext(CheckboxContext);
|
|
119
|
+
if (forceMount || (0, import_checkbox_headless.isIndeterminate)(context.checked) || context.checked === true) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxIndicatorFrame, {
|
|
120
|
+
pointerEvents: "none",
|
|
121
|
+
...indicatorProps,
|
|
122
|
+
style: [indicatorProps.style, active && activeStyle],
|
|
123
|
+
ref: forwardedRef,
|
|
124
|
+
children
|
|
125
|
+
});
|
|
126
|
+
return null;
|
|
127
|
+
});
|
|
128
|
+
var Checkbox2 = (0, import_core.withStaticProperties)(CheckboxComponent, { Indicator: CheckboxIndicator });
|