@tamagui/checkbox 1.114.4 → 1.115.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.
@@ -0,0 +1,101 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var Checkbox_exports = {};
22
+ __export(Checkbox_exports, {
23
+ CheckboxFrame: () => CheckboxFrame,
24
+ CheckboxIndicatorFrame: () => CheckboxIndicatorFrame
25
+ });
26
+ module.exports = __toCommonJS(Checkbox_exports);
27
+ var import_core = require("@tamagui/core"),
28
+ import_get_token = require("@tamagui/get-token"),
29
+ import_stacks = require("@tamagui/stacks"),
30
+ import_CheckboxStyledContext = require("./CheckboxStyledContext.cjs");
31
+ const INDICATOR_NAME = "CheckboxIndicator",
32
+ CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
33
+ // use Checkbox for easier themes
34
+ name: INDICATOR_NAME,
35
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
36
+ variants: {
37
+ unstyled: {
38
+ false: {}
39
+ }
40
+ },
41
+ defaultVariants: {
42
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
43
+ }
44
+ }),
45
+ CHECKBOX_NAME = "Checkbox",
46
+ CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
47
+ name: CHECKBOX_NAME,
48
+ tag: "button",
49
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
50
+ variants: {
51
+ unstyled: {
52
+ false: {
53
+ size: "$true",
54
+ backgroundColor: "$background",
55
+ alignItems: "center",
56
+ justifyContent: "center",
57
+ pressTheme: !0,
58
+ focusable: !0,
59
+ borderWidth: 1,
60
+ borderColor: "$borderColor",
61
+ hoverStyle: {
62
+ borderColor: "$borderColorHover"
63
+ },
64
+ focusStyle: {
65
+ borderColor: "$borderColorFocus"
66
+ },
67
+ focusVisibleStyle: {
68
+ outlineStyle: "solid",
69
+ outlineWidth: 2,
70
+ outlineColor: "$outlineColor"
71
+ }
72
+ }
73
+ },
74
+ disabled: {
75
+ true: {
76
+ pointerEvents: "none",
77
+ userSelect: "none",
78
+ cursor: "not-allowed",
79
+ hoverStyle: {
80
+ borderColor: "$borderColor",
81
+ backgroundColor: "$background"
82
+ },
83
+ pressStyle: {
84
+ borderColor: "$borderColor",
85
+ backgroundColor: "$backgroundColor"
86
+ },
87
+ focusStyle: {
88
+ outlineWidth: 0
89
+ }
90
+ }
91
+ },
92
+ size: {
93
+ "...size": val => ({
94
+ borderRadius: (0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) / 8
95
+ })
96
+ }
97
+ },
98
+ defaultVariants: {
99
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
100
+ }
101
+ });
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var CheckboxStyledContext_exports = {};
22
+ __export(CheckboxStyledContext_exports, {
23
+ CheckboxStyledContext: () => CheckboxStyledContext
24
+ });
25
+ module.exports = __toCommonJS(CheckboxStyledContext_exports);
26
+ var import_core = require("@tamagui/core");
27
+ const CheckboxStyledContext = (0, import_core.createStyledContext)({
28
+ size: "$true",
29
+ scaleIcon: 1
30
+ });
@@ -0,0 +1,165 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var createCheckbox_exports = {};
33
+ __export(createCheckbox_exports, {
34
+ CheckboxContext: () => CheckboxContext,
35
+ createCheckbox: () => createCheckbox
36
+ });
37
+ module.exports = __toCommonJS(createCheckbox_exports);
38
+ var import_react = __toESM(require("react")),
39
+ import_focusable = require("@tamagui/focusable"),
40
+ import_checkbox_headless = require("@tamagui/checkbox-headless"),
41
+ import_core = require("@tamagui/core"),
42
+ import_font_size = require("@tamagui/font-size"),
43
+ import_get_token = require("@tamagui/get-token"),
44
+ import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
45
+ import_use_controllable_state = require("@tamagui/use-controllable-state"),
46
+ import_Checkbox = require("./Checkbox.cjs"),
47
+ import_CheckboxStyledContext = require("./CheckboxStyledContext.cjs"),
48
+ import_jsx_runtime = require("react/jsx-runtime");
49
+ const CheckboxContext = import_react.default.createContext({
50
+ checked: !1,
51
+ disabled: !1
52
+ }),
53
+ ensureContext = x => {
54
+ x.context || (x.context = CheckboxContext);
55
+ };
56
+ function createCheckbox(createProps) {
57
+ const {
58
+ disableActiveTheme,
59
+ Frame = import_Checkbox.CheckboxFrame,
60
+ Indicator = import_Checkbox.CheckboxIndicatorFrame
61
+ } = createProps;
62
+ ensureContext(Frame), ensureContext(Indicator);
63
+ const FrameComponent = Frame.styleable(function (_props, forwardedRef) {
64
+ const {
65
+ scaleSize = 0.45,
66
+ sizeAdjust = 0,
67
+ scaleIcon,
68
+ checked: checkedProp,
69
+ defaultChecked,
70
+ onCheckedChange,
71
+ native,
72
+ unstyled = !1,
73
+ ...props
74
+ } = _props,
75
+ propsActive = (0, import_core.useProps)(props),
76
+ styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext);
77
+ let adjustedSize = 0,
78
+ size = 0;
79
+ unstyled || (adjustedSize = (0, import_core.getVariableValue)((0, import_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
80
+ shift: sizeAdjust
81
+ })), size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize);
82
+ const [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
83
+ prop: checkedProp,
84
+ defaultProp: defaultChecked,
85
+ onChange: onCheckedChange
86
+ }),
87
+ {
88
+ checkboxProps,
89
+ checkboxRef,
90
+ bubbleInput
91
+ } = (0, import_checkbox_headless.useCheckbox)(
92
+ // @ts-ignore
93
+ propsActive, [checked, setChecked], forwardedRef);
94
+ return (0, import_core.shouldRenderNativePlatform)(native) === "web" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
95
+ type: "checkbox",
96
+ defaultChecked: (0, import_checkbox_headless.isIndeterminate)(checked) ? !1 : checked,
97
+ tabIndex: -1,
98
+ ref: checkboxRef,
99
+ disabled: checkboxProps.disabled,
100
+ style: {
101
+ appearance: "auto",
102
+ accentColor: "var(--color6)",
103
+ ...checkboxProps.style
104
+ // TODO: any
105
+ }
106
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(CheckboxContext.Provider, {
107
+ value: {
108
+ checked,
109
+ disabled: checkboxProps.disabled
110
+ },
111
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_CheckboxStyledContext.CheckboxStyledContext.Provider, {
112
+ size: propsActive.size ?? styledContext?.size ?? "$true",
113
+ scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
114
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Frame, {
115
+ ...(!unstyled && {
116
+ width: size,
117
+ height: size
118
+ }),
119
+ tag: "button",
120
+ ref: checkboxRef,
121
+ unstyled,
122
+ ...(unstyled === !1 && {
123
+ size,
124
+ theme: checked ? "active" : null
125
+ }),
126
+ checked,
127
+ disabled: checkboxProps.disabled,
128
+ ...checkboxProps,
129
+ children: propsActive.children
130
+ }), bubbleInput]
131
+ })
132
+ });
133
+ }),
134
+ IndicatorComponent = Indicator.styleable((props, forwardedRef) => {
135
+ const {
136
+ // __scopeCheckbox,
137
+ children: childrenProp,
138
+ forceMount,
139
+ disablePassStyles,
140
+ unstyled = !1,
141
+ ...indicatorProps
142
+ } = props,
143
+ styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext);
144
+ let children = childrenProp;
145
+ if (!unstyled) {
146
+ const iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon,
147
+ theme = (0, import_core.useTheme)(),
148
+ getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
149
+ size: iconSize,
150
+ color: theme.color
151
+ });
152
+ children = import_react.default.Children.toArray(childrenProp).map(child => disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child));
153
+ }
154
+ const context = import_react.default.useContext(CheckboxContext);
155
+ return forceMount || (0, import_checkbox_headless.isIndeterminate)(context.checked) || context.checked === !0 ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(Indicator, {
156
+ pointerEvents: "none",
157
+ ...indicatorProps,
158
+ ref: forwardedRef,
159
+ children
160
+ }) : null;
161
+ });
162
+ return (0, import_core.withStaticProperties)(FrameComponent, {
163
+ Indicator: IndicatorComponent
164
+ });
165
+ }
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ },
18
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
20
+ value: !0
21
+ }), mod);
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ Checkbox: () => Checkbox
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var import_Checkbox = require("./Checkbox.cjs"),
28
+ import_createCheckbox = require("./createCheckbox.cjs");
29
+ __reExport(src_exports, require("./createCheckbox.cjs"), module.exports);
30
+ __reExport(src_exports, require("./Checkbox.cjs"), module.exports);
31
+ __reExport(src_exports, require("./CheckboxStyledContext.cjs"), module.exports);
32
+ const Checkbox = (0, import_createCheckbox.createCheckbox)({
33
+ Frame: import_Checkbox.CheckboxFrame,
34
+ Indicator: import_Checkbox.CheckboxIndicatorFrame
35
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/checkbox",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -24,20 +24,20 @@
24
24
  "clean:build": "tamagui-build clean:build"
25
25
  },
26
26
  "dependencies": {
27
- "@tamagui/checkbox-headless": "1.114.4",
28
- "@tamagui/compose-refs": "1.114.4",
29
- "@tamagui/constants": "1.114.4",
30
- "@tamagui/core": "1.114.4",
31
- "@tamagui/create-context": "1.114.4",
32
- "@tamagui/focusable": "1.114.4",
33
- "@tamagui/font-size": "1.114.4",
34
- "@tamagui/get-token": "1.114.4",
35
- "@tamagui/helpers": "1.114.4",
36
- "@tamagui/helpers-tamagui": "1.114.4",
37
- "@tamagui/label": "1.114.4",
38
- "@tamagui/stacks": "1.114.4",
39
- "@tamagui/use-controllable-state": "1.114.4",
40
- "@tamagui/use-previous": "1.114.4"
27
+ "@tamagui/checkbox-headless": "1.115.0",
28
+ "@tamagui/compose-refs": "1.115.0",
29
+ "@tamagui/constants": "1.115.0",
30
+ "@tamagui/core": "1.115.0",
31
+ "@tamagui/create-context": "1.115.0",
32
+ "@tamagui/focusable": "1.115.0",
33
+ "@tamagui/font-size": "1.115.0",
34
+ "@tamagui/get-token": "1.115.0",
35
+ "@tamagui/helpers": "1.115.0",
36
+ "@tamagui/helpers-tamagui": "1.115.0",
37
+ "@tamagui/label": "1.115.0",
38
+ "@tamagui/stacks": "1.115.0",
39
+ "@tamagui/use-controllable-state": "1.115.0",
40
+ "@tamagui/use-previous": "1.115.0"
41
41
  },
42
42
  "exports": {
43
43
  "./package.json": "./package.json",
@@ -46,11 +46,12 @@
46
46
  "react-native": "./dist/cjs/index.native.js",
47
47
  "types": "./types/index.d.ts",
48
48
  "import": "./dist/esm/index.mjs",
49
- "require": "./dist/cjs/index.js"
49
+ "require": "./dist/cjs/index.cjs",
50
+ "default": "./dist/cjs/index.native.js"
50
51
  }
51
52
  },
52
53
  "devDependencies": {
53
- "@tamagui/build": "1.114.4",
54
+ "@tamagui/build": "1.115.0",
54
55
  "react": "^18.2.0 || ^19.0.0"
55
56
  },
56
57
  "publishConfig": {
@@ -1,90 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var Checkbox_exports = {};
16
- __export(Checkbox_exports, {
17
- CheckboxFrame: () => CheckboxFrame,
18
- CheckboxIndicatorFrame: () => CheckboxIndicatorFrame
19
- });
20
- module.exports = __toCommonJS(Checkbox_exports);
21
- var import_core = require("@tamagui/core"), import_get_token = require("@tamagui/get-token"), import_stacks = require("@tamagui/stacks"), import_CheckboxStyledContext = require("./CheckboxStyledContext");
22
- const INDICATOR_NAME = "CheckboxIndicator", CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
23
- // use Checkbox for easier themes
24
- name: INDICATOR_NAME,
25
- context: import_CheckboxStyledContext.CheckboxStyledContext,
26
- variants: {
27
- unstyled: {
28
- false: {}
29
- }
30
- },
31
- defaultVariants: {
32
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
33
- }
34
- }), CHECKBOX_NAME = "Checkbox", CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
35
- name: CHECKBOX_NAME,
36
- tag: "button",
37
- context: import_CheckboxStyledContext.CheckboxStyledContext,
38
- variants: {
39
- unstyled: {
40
- false: {
41
- size: "$true",
42
- backgroundColor: "$background",
43
- alignItems: "center",
44
- justifyContent: "center",
45
- pressTheme: !0,
46
- focusable: !0,
47
- borderWidth: 1,
48
- borderColor: "$borderColor",
49
- hoverStyle: {
50
- borderColor: "$borderColorHover"
51
- },
52
- focusStyle: {
53
- borderColor: "$borderColorFocus"
54
- },
55
- focusVisibleStyle: {
56
- outlineStyle: "solid",
57
- outlineWidth: 2,
58
- outlineColor: "$outlineColor"
59
- }
60
- }
61
- },
62
- disabled: {
63
- true: {
64
- pointerEvents: "none",
65
- userSelect: "none",
66
- cursor: "not-allowed",
67
- hoverStyle: {
68
- borderColor: "$borderColor",
69
- backgroundColor: "$background"
70
- },
71
- pressStyle: {
72
- borderColor: "$borderColor",
73
- backgroundColor: "$backgroundColor"
74
- },
75
- focusStyle: {
76
- outlineWidth: 0
77
- }
78
- }
79
- },
80
- size: {
81
- "...size": (val) => ({
82
- borderRadius: (0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) / 8
83
- })
84
- }
85
- },
86
- defaultVariants: {
87
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
88
- }
89
- });
90
- //# sourceMappingURL=Checkbox.js.map
@@ -1,25 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var CheckboxStyledContext_exports = {};
16
- __export(CheckboxStyledContext_exports, {
17
- CheckboxStyledContext: () => CheckboxStyledContext
18
- });
19
- module.exports = __toCommonJS(CheckboxStyledContext_exports);
20
- var import_core = require("@tamagui/core");
21
- const CheckboxStyledContext = (0, import_core.createStyledContext)({
22
- size: "$true",
23
- scaleIcon: 1
24
- });
25
- //# sourceMappingURL=CheckboxStyledContext.js.map
@@ -1,150 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var createCheckbox_exports = {};
24
- __export(createCheckbox_exports, {
25
- CheckboxContext: () => CheckboxContext,
26
- createCheckbox: () => createCheckbox
27
- });
28
- module.exports = __toCommonJS(createCheckbox_exports);
29
- var import_react = __toESM(require("react")), import_focusable = require("@tamagui/focusable"), import_checkbox_headless = require("@tamagui/checkbox-headless"), import_core = require("@tamagui/core"), import_font_size = require("@tamagui/font-size"), import_get_token = require("@tamagui/get-token"), import_helpers_tamagui = require("@tamagui/helpers-tamagui"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_Checkbox = require("./Checkbox"), import_CheckboxStyledContext = require("./CheckboxStyledContext"), import_jsx_runtime = require("react/jsx-runtime");
30
- const CheckboxContext = import_react.default.createContext({
31
- checked: !1,
32
- disabled: !1
33
- }), ensureContext = (x) => {
34
- x.context || (x.context = CheckboxContext);
35
- };
36
- function createCheckbox(createProps) {
37
- const {
38
- disableActiveTheme,
39
- Frame = import_Checkbox.CheckboxFrame,
40
- Indicator = import_Checkbox.CheckboxIndicatorFrame
41
- } = createProps;
42
- ensureContext(Frame), ensureContext(Indicator);
43
- const FrameComponent = Frame.styleable(
44
- function(_props, forwardedRef) {
45
- const {
46
- scaleSize = 0.45,
47
- sizeAdjust = 0,
48
- scaleIcon,
49
- checked: checkedProp,
50
- defaultChecked,
51
- onCheckedChange,
52
- native,
53
- unstyled = !1,
54
- ...props
55
- } = _props, propsActive = (0, import_core.useProps)(props), styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext);
56
- let adjustedSize = 0, size = 0;
57
- unstyled || (adjustedSize = (0, import_core.getVariableValue)(
58
- (0, import_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
59
- shift: sizeAdjust
60
- })
61
- ), size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize);
62
- const [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
63
- prop: checkedProp,
64
- defaultProp: defaultChecked,
65
- onChange: onCheckedChange
66
- }), { checkboxProps, checkboxRef, bubbleInput } = (0, import_checkbox_headless.useCheckbox)(
67
- // @ts-ignore
68
- propsActive,
69
- [checked, setChecked],
70
- forwardedRef
71
- );
72
- return (0, import_core.shouldRenderNativePlatform)(native) === "web" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
73
- "input",
74
- {
75
- type: "checkbox",
76
- defaultChecked: (0, import_checkbox_headless.isIndeterminate)(checked) ? !1 : checked,
77
- tabIndex: -1,
78
- ref: checkboxRef,
79
- disabled: checkboxProps.disabled,
80
- style: {
81
- appearance: "auto",
82
- accentColor: "var(--color6)",
83
- ...checkboxProps.style
84
- // TODO: any
85
- }
86
- }
87
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
- CheckboxContext.Provider,
89
- {
90
- value: {
91
- checked,
92
- disabled: checkboxProps.disabled
93
- },
94
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
95
- import_CheckboxStyledContext.CheckboxStyledContext.Provider,
96
- {
97
- size: propsActive.size ?? styledContext?.size ?? "$true",
98
- scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
99
- children: [
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- Frame,
102
- {
103
- ...!unstyled && {
104
- width: size,
105
- height: size
106
- },
107
- tag: "button",
108
- ref: checkboxRef,
109
- unstyled,
110
- ...unstyled === !1 && {
111
- size,
112
- theme: checked ? "active" : null
113
- },
114
- checked,
115
- disabled: checkboxProps.disabled,
116
- ...checkboxProps,
117
- children: propsActive.children
118
- }
119
- ),
120
- bubbleInput
121
- ]
122
- }
123
- )
124
- }
125
- );
126
- }
127
- ), IndicatorComponent = Indicator.styleable(
128
- (props, forwardedRef) => {
129
- const {
130
- // __scopeCheckbox,
131
- children: childrenProp,
132
- forceMount,
133
- disablePassStyles,
134
- unstyled = !1,
135
- ...indicatorProps
136
- } = props, styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext);
137
- let children = childrenProp;
138
- if (!unstyled) {
139
- const iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon, theme = (0, import_core.useTheme)(), getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color });
140
- children = import_react.default.Children.toArray(childrenProp).map((child) => disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child));
141
- }
142
- const context = import_react.default.useContext(CheckboxContext);
143
- return forceMount || (0, import_checkbox_headless.isIndeterminate)(context.checked) || context.checked === !0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Indicator, { pointerEvents: "none", ...indicatorProps, ref: forwardedRef, children }) : null;
144
- }
145
- );
146
- return (0, import_core.withStaticProperties)(FrameComponent, {
147
- Indicator: IndicatorComponent
148
- });
149
- }
150
- //# sourceMappingURL=createCheckbox.js.map
package/dist/cjs/index.js DELETED
@@ -1,28 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var src_exports = {};
16
- __export(src_exports, {
17
- Checkbox: () => Checkbox
18
- });
19
- module.exports = __toCommonJS(src_exports);
20
- var import_Checkbox = require("./Checkbox"), import_createCheckbox = require("./createCheckbox");
21
- __reExport(src_exports, require("./createCheckbox"), module.exports);
22
- __reExport(src_exports, require("./Checkbox"), module.exports);
23
- __reExport(src_exports, require("./CheckboxStyledContext"), module.exports);
24
- const Checkbox = (0, import_createCheckbox.createCheckbox)({
25
- Frame: import_Checkbox.CheckboxFrame,
26
- Indicator: import_Checkbox.CheckboxIndicatorFrame
27
- });
28
- //# sourceMappingURL=index.js.map
File without changes
File without changes