@tamagui/checkbox 1.116.0 → 1.116.2

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,90 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,150 @@
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
@@ -0,0 +1,28 @@
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/checkbox",
3
- "version": "1.116.0",
3
+ "version": "1.116.2",
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.116.0",
28
- "@tamagui/compose-refs": "1.116.0",
29
- "@tamagui/constants": "1.116.0",
30
- "@tamagui/core": "1.116.0",
31
- "@tamagui/create-context": "1.116.0",
32
- "@tamagui/focusable": "1.116.0",
33
- "@tamagui/font-size": "1.116.0",
34
- "@tamagui/get-token": "1.116.0",
35
- "@tamagui/helpers": "1.116.0",
36
- "@tamagui/helpers-tamagui": "1.116.0",
37
- "@tamagui/label": "1.116.0",
38
- "@tamagui/stacks": "1.116.0",
39
- "@tamagui/use-controllable-state": "1.116.0",
40
- "@tamagui/use-previous": "1.116.0"
27
+ "@tamagui/checkbox-headless": "1.116.2",
28
+ "@tamagui/compose-refs": "1.116.2",
29
+ "@tamagui/constants": "1.116.2",
30
+ "@tamagui/core": "1.116.2",
31
+ "@tamagui/create-context": "1.116.2",
32
+ "@tamagui/focusable": "1.116.2",
33
+ "@tamagui/font-size": "1.116.2",
34
+ "@tamagui/get-token": "1.116.2",
35
+ "@tamagui/helpers": "1.116.2",
36
+ "@tamagui/helpers-tamagui": "1.116.2",
37
+ "@tamagui/label": "1.116.2",
38
+ "@tamagui/stacks": "1.116.2",
39
+ "@tamagui/use-controllable-state": "1.116.2",
40
+ "@tamagui/use-previous": "1.116.2"
41
41
  },
42
42
  "exports": {
43
43
  "./package.json": "./package.json",
@@ -51,7 +51,7 @@
51
51
  }
52
52
  },
53
53
  "devDependencies": {
54
- "@tamagui/build": "1.116.0",
54
+ "@tamagui/build": "1.116.2",
55
55
  "react": "^18.2.0 || ^19.0.0"
56
56
  },
57
57
  "publishConfig": {
File without changes
File without changes