@tamagui/checkbox 2.7.7 → 3.0.0-beta.643.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 +105 -101
- package/dist/cjs/Checkbox.native.cjs +137 -0
- package/dist/cjs/Checkbox.native.js +120 -100
- package/dist/cjs/Checkbox.native.js.map +1 -1
- package/dist/cjs/CheckboxStyledContext.cjs +18 -23
- package/dist/cjs/CheckboxStyledContext.native.cjs +32 -0
- package/dist/cjs/CheckboxStyledContext.native.js +18 -22
- package/dist/cjs/CheckboxStyledContext.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -26
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +10 -26
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Checkbox.mjs +83 -87
- package/dist/esm/Checkbox.mjs.map +1 -1
- package/dist/esm/Checkbox.native.js +99 -87
- 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 +83 -87
- package/dist/jsx/Checkbox.mjs.map +1 -1
- package/dist/jsx/Checkbox.native.cjs +137 -0
- package/dist/jsx/Checkbox.native.js +120 -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 +32 -0
- package/dist/jsx/CheckboxStyledContext.native.js +18 -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 +22 -0
- package/dist/jsx/index.native.js +10 -26
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +6 -16
- package/src/Checkbox.tsx +189 -81
- package/src/CheckboxStyledContext.tsx +2 -6
- package/src/index.ts +0 -9
- package/types/Checkbox.d.ts +446 -24
- 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,102 @@
|
|
|
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, useProps, 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
|
|
9
|
+
var CheckboxIndicatorFrame = styled(View, {
|
|
10
|
+
displayName: "CheckboxIndicator",
|
|
11
|
+
context: CheckboxStyledContext
|
|
12
|
+
}, { accept: { activeStyle: "style" } });
|
|
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
|
+
} } }
|
|
23
|
+
}, { accept: { activeStyle: "style" } });
|
|
24
|
+
var CheckboxContext = /* @__PURE__ */ React.createContext({
|
|
25
|
+
checked: false,
|
|
26
|
+
disabled: false
|
|
22
27
|
});
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
28
|
+
var Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(_props, forwardedRef) {
|
|
29
|
+
var { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = _props;
|
|
30
|
+
var propsActive = useProps(props);
|
|
31
|
+
var styledContext = React.useContext(CheckboxStyledContext.context);
|
|
32
|
+
var [checked = false, setChecked] = useControllableState({
|
|
33
|
+
prop: checkedProp,
|
|
34
|
+
defaultProp: defaultChecked,
|
|
35
|
+
onChange: onCheckedChange
|
|
36
|
+
});
|
|
37
|
+
var { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(propsActive, [checked, setChecked], forwardedRef);
|
|
38
|
+
React.useEffect(function() {
|
|
39
|
+
if (!props.id) return;
|
|
40
|
+
if (props.disabled) return;
|
|
41
|
+
return registerFocusable(props.id, {
|
|
42
|
+
focusAndSelect: function() {
|
|
43
|
+
setChecked === null || setChecked === void 0 || setChecked(function(value) {
|
|
44
|
+
return !value;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
focus: function() {}
|
|
48
|
+
});
|
|
49
|
+
}, [props.id, props.disabled]);
|
|
50
|
+
if (shouldRenderNativePlatform(native) === "web") return /* @__PURE__ */ jsx("input", {
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
defaultChecked: isIndeterminate(checked) ? false : checked,
|
|
53
|
+
tabIndex: -1,
|
|
54
|
+
ref: checkboxRef,
|
|
55
|
+
disabled: checkboxProps.disabled,
|
|
56
|
+
style: checkboxProps.style
|
|
57
|
+
});
|
|
58
|
+
var memoizedContext = useMemo(function() {
|
|
59
|
+
return {
|
|
60
|
+
checked,
|
|
61
|
+
disabled: checkboxProps.disabled
|
|
62
|
+
};
|
|
63
|
+
}, [checked, checkboxProps.disabled]);
|
|
64
|
+
var isActive = !!checked;
|
|
65
|
+
var disabled = checkboxProps.disabled;
|
|
66
|
+
var _propsActive_size, _ref;
|
|
67
|
+
return /* @__PURE__ */ jsx(CheckboxContext.Provider, {
|
|
68
|
+
value: memoizedContext,
|
|
69
|
+
children: /* @__PURE__ */ jsxs(CheckboxStyledContext.Provider, {
|
|
70
|
+
size: (_ref = (_propsActive_size = propsActive.size) !== null && _propsActive_size !== void 0 ? _propsActive_size : styledContext === null || styledContext === void 0 ? void 0 : styledContext.size) !== null && _ref !== void 0 ? _ref : true,
|
|
71
|
+
active: isActive,
|
|
72
|
+
disabled,
|
|
73
|
+
children: [/* @__PURE__ */ jsx(CheckboxFrame, {
|
|
74
|
+
render: "button",
|
|
75
|
+
ref: checkboxRef,
|
|
76
|
+
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
77
|
+
...isWeb && { type: "button" },
|
|
78
|
+
checked,
|
|
79
|
+
disabled,
|
|
80
|
+
...checkboxProps,
|
|
81
|
+
...props,
|
|
82
|
+
...isActive && activeStyle ? activeStyle : void 0,
|
|
83
|
+
children: propsActive.children
|
|
84
|
+
}), bubbleInput]
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, function(props, forwardedRef) {
|
|
88
|
+
var { children, forceMount, activeStyle, ...indicatorProps } = props;
|
|
89
|
+
var { active } = CheckboxStyledContext.useStyledContext();
|
|
90
|
+
var context = React.useContext(CheckboxContext);
|
|
91
|
+
if (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {
|
|
92
|
+
pointerEvents: "none",
|
|
93
|
+
...indicatorProps,
|
|
94
|
+
...active && activeStyle ? activeStyle : void 0,
|
|
95
|
+
ref: forwardedRef,
|
|
96
|
+
children
|
|
97
|
+
});
|
|
98
|
+
return null;
|
|
99
|
+
}) });
|
|
100
|
+
|
|
101
|
+
export { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };
|
|
90
102
|
//# 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, useProps, 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}, { accept: { activeStyle: \"style\" } });\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}, { accept: { activeStyle: \"style\" } });\nvar CheckboxContext = /* @__PURE__ */ React.createContext({\n\tchecked: false,\n\tdisabled: false\n});\nvar Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(_props, forwardedRef) {\n\tvar { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = _props;\n\tvar propsActive = useProps(props);\n\tvar styledContext = React.useContext(CheckboxStyledContext.context);\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(propsActive, [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\tvar _propsActive_size, _ref;\n\treturn /* @__PURE__ */ jsx(CheckboxContext.Provider, {\n\t\tvalue: memoizedContext,\n\t\tchildren: /* @__PURE__ */ jsxs(CheckboxStyledContext.Provider, {\n\t\t\tsize: (_ref = (_propsActive_size = propsActive.size) !== null && _propsActive_size !== void 0 ? _propsActive_size : styledContext === null || styledContext === void 0 ? void 0 : styledContext.size) !== null && _ref !== void 0 ? _ref : true,\n\t\t\tactive: isActive,\n\t\t\tdisabled,\n\t\t\tchildren: [/* @__PURE__ */ jsx(CheckboxFrame, {\n\t\t\t\trender: \"button\",\n\t\t\t\tref: checkboxRef,\n\t\t\t\ttheme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,\n\t\t\t\t...isWeb && { type: \"button\" },\n\t\t\t\tchecked,\n\t\t\t\tdisabled,\n\t\t\t\t...checkboxProps,\n\t\t\t\t...props,\n\t\t\t\t...isActive && activeStyle ? activeStyle : void 0,\n\t\t\t\tchildren: propsActive.children\n\t\t\t}), bubbleInput]\n\t\t})\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\t...active && activeStyle ? activeStyle : void 0,\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,GAAG,EAAE,QAAQ,EAAE,aAAa,QAAQ,EAAE,CAAC;AACvC,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,GAAG,EAAE,QAAQ,EAAE,aAAa,QAAQ,EAAE,CAAC;AACvC,IAAI,kBAAkC,sBAAM,cAAc;CACzD,SAAS;CACT,UAAU;AACX,CAAC;AACD,IAAI,YAAY,qBAAqB,gBAAgB,eAAe,SAAS,SAAS,QAAQ,cAAc;CAC3G,IAAI,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,QAAQ,aAAa,aAAa,GAAG,UA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Ae;IAC7C,QAAQ;IACR,KAAK;IACL,OAAO,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI,cAAc;IACtE,GAAG,SAAS,EAAE,MAAM,SAAS;IAC7B;IACA;IACA,GAAG;IACH,GAAG;IACH,GAAG,YAAY,cAAc,cAAc,KAAK;IAChD,UAAU,YAAY;GACvB,CAAC,GAAG,WAAW;EAChB,CAAC;CACF,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,GAAG,UAAU,cAAc,cAAc,KAAK;EAC9C,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,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isIndeterminate, useCheckbox } from "@tamagui/checkbox-headless";
|
|
2
|
+
import { View, createStyledHOC, isWeb, shouldRenderNativePlatform, styled, useProps, 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
const CheckboxIndicatorFrame = styled(View, {
|
|
9
|
+
displayName: "CheckboxIndicator",
|
|
10
|
+
context: CheckboxStyledContext
|
|
11
|
+
}, { accept: { activeStyle: "style" } });
|
|
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
|
+
} } }
|
|
22
|
+
}, { accept: { activeStyle: "style" } });
|
|
23
|
+
const CheckboxContext = React.createContext({
|
|
24
|
+
checked: false,
|
|
25
|
+
disabled: false
|
|
22
26
|
});
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
accept: {
|
|
86
|
-
activeStyle: "style"
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
export { CheckboxFrame, CheckboxIndicatorFrame };
|
|
27
|
+
const Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(_props, forwardedRef) {
|
|
28
|
+
const { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = _props;
|
|
29
|
+
const propsActive = useProps(props);
|
|
30
|
+
const styledContext = React.useContext(CheckboxStyledContext.context);
|
|
31
|
+
const [checked = false, setChecked] = useControllableState({
|
|
32
|
+
prop: checkedProp,
|
|
33
|
+
defaultProp: defaultChecked,
|
|
34
|
+
onChange: onCheckedChange
|
|
35
|
+
});
|
|
36
|
+
const { checkboxProps, checkboxRef, bubbleInput } = useCheckbox(propsActive, [checked, setChecked], forwardedRef);
|
|
37
|
+
if (shouldRenderNativePlatform(native) === "web") return /* @__PURE__ */ jsx("input", {
|
|
38
|
+
type: "checkbox",
|
|
39
|
+
defaultChecked: isIndeterminate(checked) ? false : checked,
|
|
40
|
+
tabIndex: -1,
|
|
41
|
+
ref: checkboxRef,
|
|
42
|
+
disabled: checkboxProps.disabled,
|
|
43
|
+
style: checkboxProps.style
|
|
44
|
+
});
|
|
45
|
+
const memoizedContext = useMemo(() => ({
|
|
46
|
+
checked,
|
|
47
|
+
disabled: checkboxProps.disabled
|
|
48
|
+
}), [checked, checkboxProps.disabled]);
|
|
49
|
+
const isActive = !!checked;
|
|
50
|
+
const disabled = checkboxProps.disabled;
|
|
51
|
+
return /* @__PURE__ */ jsx(CheckboxContext.Provider, {
|
|
52
|
+
value: memoizedContext,
|
|
53
|
+
children: /* @__PURE__ */ jsxs(CheckboxStyledContext.Provider, {
|
|
54
|
+
size: propsActive.size ?? styledContext?.size ?? true,
|
|
55
|
+
active: isActive,
|
|
56
|
+
disabled,
|
|
57
|
+
children: [/* @__PURE__ */ jsx(CheckboxFrame, {
|
|
58
|
+
render: "button",
|
|
59
|
+
ref: checkboxRef,
|
|
60
|
+
theme: activeTheme ?? null,
|
|
61
|
+
...isWeb && { type: "button" },
|
|
62
|
+
checked,
|
|
63
|
+
disabled,
|
|
64
|
+
...checkboxProps,
|
|
65
|
+
...props,
|
|
66
|
+
...isActive && activeStyle ? activeStyle : void 0,
|
|
67
|
+
children: propsActive.children
|
|
68
|
+
}), bubbleInput]
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}), { Indicator: createStyledHOC(CheckboxIndicatorFrame, (props, forwardedRef) => {
|
|
72
|
+
const { children, forceMount, activeStyle, ...indicatorProps } = props;
|
|
73
|
+
const { active } = CheckboxStyledContext.useStyledContext();
|
|
74
|
+
const context = React.useContext(CheckboxContext);
|
|
75
|
+
if (forceMount || isIndeterminate(context.checked) || context.checked === true) return /* @__PURE__ */ jsx(CheckboxIndicatorFrame, {
|
|
76
|
+
pointerEvents: "none",
|
|
77
|
+
...indicatorProps,
|
|
78
|
+
...active && activeStyle ? activeStyle : void 0,
|
|
79
|
+
ref: forwardedRef,
|
|
80
|
+
children
|
|
81
|
+
});
|
|
82
|
+
return null;
|
|
83
|
+
}) });
|
|
84
|
+
|
|
85
|
+
export { Checkbox2 as Checkbox, CheckboxContext, CheckboxFrame, CheckboxIndicatorFrame };
|
|
90
86
|
//# 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, useProps, 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}, { accept: { activeStyle: \"style\" } });\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}, { accept: { activeStyle: \"style\" } });\nconst CheckboxContext = React.createContext({\n\tchecked: false,\n\tdisabled: false\n});\nconst Checkbox2 = withStaticProperties(createStyledHOC(CheckboxFrame, function Checkbox(_props, forwardedRef) {\n\tconst { checked: checkedProp, defaultChecked, onCheckedChange, native, activeStyle, activeTheme, ...props } = _props;\n\tconst propsActive = useProps(props);\n\tconst styledContext = React.useContext(CheckboxStyledContext.context);\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(propsActive, [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__ */ jsx(CheckboxContext.Provider, {\n\t\tvalue: memoizedContext,\n\t\tchildren: /* @__PURE__ */ jsxs(CheckboxStyledContext.Provider, {\n\t\t\tsize: propsActive.size ?? styledContext?.size ?? true,\n\t\t\tactive: isActive,\n\t\t\tdisabled,\n\t\t\tchildren: [/* @__PURE__ */ jsx(CheckboxFrame, {\n\t\t\t\trender: \"button\",\n\t\t\t\tref: checkboxRef,\n\t\t\t\ttheme: activeTheme ?? null,\n\t\t\t\t...isWeb && { type: \"button\" },\n\t\t\t\tchecked,\n\t\t\t\tdisabled,\n\t\t\t\t...checkboxProps,\n\t\t\t\t...props,\n\t\t\t\t...isActive && activeStyle ? activeStyle : void 0,\n\t\t\t\tchildren: propsActive.children\n\t\t\t}), bubbleInput]\n\t\t})\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\t...active && activeStyle ? activeStyle : void 0,\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,GAAG,EAAE,QAAQ,EAAE,aAAa,QAAQ,EAAE,CAAC;AACvC,MAAM,gBAAgB,OAAO,MAAM;CAClC,aAAa;CACb,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU,EAAE,UAAU,EAAE,MAAM;EAC7B,eAAe;EACf,YAAY;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