@tamagui/checkbox 2.0.0-rc.4 → 2.0.0-rc.40
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 +93 -88
- package/dist/cjs/Checkbox.native.js +93 -91
- package/dist/cjs/Checkbox.native.js.map +1 -1
- package/dist/cjs/CheckboxStyledContext.cjs +14 -12
- package/dist/cjs/CheckboxStyledContext.native.js +20 -18
- package/dist/cjs/CheckboxStyledContext.native.js.map +1 -1
- package/dist/cjs/createCheckbox.cjs +163 -153
- package/dist/cjs/createCheckbox.native.js +180 -176
- package/dist/cjs/createCheckbox.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -13
- package/dist/cjs/index.native.js +15 -13
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Checkbox.mjs +77 -74
- package/dist/esm/Checkbox.mjs.map +1 -1
- package/dist/esm/Checkbox.native.js +77 -77
- package/dist/esm/Checkbox.native.js.map +1 -1
- package/dist/esm/CheckboxStyledContext.mjs +2 -2
- package/dist/esm/CheckboxStyledContext.native.js +2 -2
- package/dist/esm/createCheckbox.mjs +119 -114
- package/dist/esm/createCheckbox.mjs.map +1 -1
- package/dist/esm/createCheckbox.native.js +134 -136
- package/dist/esm/createCheckbox.native.js.map +1 -1
- package/dist/esm/index.js +6 -8
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/Checkbox.mjs +77 -74
- package/dist/jsx/Checkbox.mjs.map +1 -1
- package/dist/jsx/Checkbox.native.js +93 -91
- package/dist/jsx/Checkbox.native.js.map +1 -1
- package/dist/jsx/CheckboxStyledContext.mjs +2 -2
- package/dist/jsx/CheckboxStyledContext.native.js +20 -18
- package/dist/jsx/CheckboxStyledContext.native.js.map +1 -1
- package/dist/jsx/createCheckbox.mjs +119 -114
- package/dist/jsx/createCheckbox.mjs.map +1 -1
- package/dist/jsx/createCheckbox.native.js +180 -176
- package/dist/jsx/createCheckbox.native.js.map +1 -1
- package/dist/jsx/index.js +6 -8
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +15 -13
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +19 -22
- package/types/createCheckbox.d.ts +3 -3
- package/types/index.d.ts +3 -3
- package/dist/cjs/Checkbox.js +0 -108
- package/dist/cjs/Checkbox.js.map +0 -6
- package/dist/cjs/CheckboxStyledContext.js +0 -28
- package/dist/cjs/CheckboxStyledContext.js.map +0 -6
- package/dist/cjs/createCheckbox.js +0 -165
- package/dist/cjs/createCheckbox.js.map +0 -6
- package/dist/cjs/index.js +0 -28
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Checkbox.js +0 -95
- package/dist/esm/Checkbox.js.map +0 -6
- package/dist/esm/CheckboxStyledContext.js +0 -12
- package/dist/esm/CheckboxStyledContext.js.map +0 -6
- package/dist/esm/createCheckbox.js +0 -158
- package/dist/esm/createCheckbox.js.map +0 -6
- package/dist/jsx/Checkbox.js +0 -95
- package/dist/jsx/Checkbox.js.map +0 -6
- package/dist/jsx/CheckboxStyledContext.js +0 -12
- package/dist/jsx/CheckboxStyledContext.js.map +0 -6
- package/dist/jsx/createCheckbox.js +0 -158
- package/dist/jsx/createCheckbox.js.map +0 -6
|
@@ -2,182 +2,192 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var createCheckbox_exports = {};
|
|
33
35
|
__export(createCheckbox_exports, {
|
|
34
36
|
CheckboxContext: () => CheckboxContext,
|
|
35
37
|
createCheckbox: () => createCheckbox
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(createCheckbox_exports);
|
|
38
|
-
var import_checkbox_headless = require("@tamagui/checkbox-headless")
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
var import_checkbox_headless = require("@tamagui/checkbox-headless");
|
|
41
|
+
var import_core = require("@tamagui/core");
|
|
42
|
+
require("@tamagui/focusable");
|
|
43
|
+
var import_font_size = require("@tamagui/font-size");
|
|
44
|
+
var import_get_token = require("@tamagui/get-token");
|
|
45
|
+
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
46
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
47
|
+
var import_react = __toESM(require("react"), 1);
|
|
48
|
+
var import_Checkbox = require("./Checkbox.cjs");
|
|
49
|
+
var import_CheckboxStyledContext = require("./CheckboxStyledContext.cjs");
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
51
|
const CheckboxContext = import_react.default.createContext({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
checked: false,
|
|
53
|
+
disabled: false
|
|
54
|
+
});
|
|
55
|
+
const ensureContext = x => {
|
|
56
|
+
if (!x.context) x.context = CheckboxContext;
|
|
57
|
+
};
|
|
56
58
|
function createCheckbox(createProps) {
|
|
57
59
|
const {
|
|
58
60
|
Frame = import_Checkbox.CheckboxFrame,
|
|
59
61
|
Indicator = import_Checkbox.CheckboxIndicatorFrame
|
|
60
62
|
} = createProps;
|
|
61
|
-
ensureContext(Frame)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
ensureContext(Frame);
|
|
64
|
+
ensureContext(Indicator);
|
|
65
|
+
const FrameComponent = Frame.styleable(function Checkbox(_props, forwardedRef) {
|
|
66
|
+
const {
|
|
67
|
+
scaleSize = .45,
|
|
68
|
+
sizeAdjust = 0,
|
|
69
|
+
scaleIcon,
|
|
70
|
+
checked: checkedProp,
|
|
71
|
+
defaultChecked,
|
|
72
|
+
onCheckedChange,
|
|
73
|
+
native,
|
|
74
|
+
unstyled = false,
|
|
75
|
+
activeStyle,
|
|
76
|
+
activeTheme,
|
|
77
|
+
...props
|
|
78
|
+
} = _props;
|
|
79
|
+
const propsActive = (0, import_core.useProps)(props);
|
|
80
|
+
const styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext.context);
|
|
81
|
+
let adjustedSize = 0;
|
|
82
|
+
let size = 0;
|
|
83
|
+
if (!unstyled) {
|
|
84
|
+
adjustedSize = (0, import_core.getVariableValue)((0, import_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
|
|
81
85
|
shift: sizeAdjust
|
|
82
|
-
}))
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
86
|
+
}));
|
|
87
|
+
size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize;
|
|
88
|
+
}
|
|
89
|
+
const [checked = false, setChecked] = (0, import_use_controllable_state.useControllableState)({
|
|
90
|
+
prop: checkedProp,
|
|
91
|
+
defaultProp: defaultChecked,
|
|
92
|
+
onChange: onCheckedChange
|
|
93
|
+
});
|
|
94
|
+
const {
|
|
95
|
+
checkboxProps,
|
|
96
|
+
checkboxRef,
|
|
97
|
+
bubbleInput
|
|
98
|
+
} = (0, import_checkbox_headless.useCheckbox)(
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
propsActive, [checked, setChecked], forwardedRef);
|
|
101
|
+
if ((0, import_core.shouldRenderNativePlatform)(native) === "web") return /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
|
|
102
|
+
type: "checkbox",
|
|
103
|
+
defaultChecked: (0, import_checkbox_headless.isIndeterminate)(checked) ? false : checked,
|
|
104
|
+
tabIndex: -1,
|
|
105
|
+
ref: checkboxRef,
|
|
106
|
+
disabled: checkboxProps.disabled,
|
|
107
|
+
style: {
|
|
108
|
+
appearance: "auto",
|
|
109
|
+
accentColor: "var(--color6)",
|
|
110
|
+
...checkboxProps.style
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const memoizedContext = (0, import_react.useMemo)(() => ({
|
|
114
|
+
checked,
|
|
115
|
+
disabled: checkboxProps.disabled
|
|
116
|
+
}), [checked, checkboxProps.disabled]);
|
|
117
|
+
const isActive = !!checked;
|
|
118
|
+
const disabled = checkboxProps.disabled;
|
|
119
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CheckboxContext.Provider, {
|
|
120
|
+
value: memoizedContext,
|
|
121
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_CheckboxStyledContext.CheckboxStyledContext.Provider, {
|
|
122
|
+
size: propsActive.size ?? styledContext?.size ?? "$true",
|
|
123
|
+
scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
|
|
124
|
+
unstyled,
|
|
125
|
+
active: isActive,
|
|
126
|
+
disabled,
|
|
127
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Frame, {
|
|
128
|
+
render: "button",
|
|
129
|
+
ref: checkboxRef,
|
|
118
130
|
unstyled,
|
|
119
|
-
|
|
131
|
+
theme: activeTheme ?? null,
|
|
132
|
+
...(import_core.isWeb && {
|
|
133
|
+
type: "button"
|
|
134
|
+
}),
|
|
135
|
+
...(!unstyled && {
|
|
136
|
+
width: size,
|
|
137
|
+
height: size,
|
|
138
|
+
size
|
|
139
|
+
}),
|
|
140
|
+
checked,
|
|
120
141
|
disabled,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
unstyled
|
|
125
|
-
|
|
126
|
-
...(import_core.isWeb && {
|
|
127
|
-
type: "button"
|
|
128
|
-
}),
|
|
129
|
-
...(!unstyled && {
|
|
130
|
-
width: size,
|
|
131
|
-
height: size,
|
|
132
|
-
size
|
|
142
|
+
...checkboxProps,
|
|
143
|
+
...props,
|
|
144
|
+
...(isActive && {
|
|
145
|
+
...(!unstyled && !activeStyle && {
|
|
146
|
+
backgroundColor: "$backgroundActive"
|
|
133
147
|
}),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
...activeStyle
|
|
149
|
+
}),
|
|
150
|
+
children: propsActive.children
|
|
151
|
+
}), bubbleInput]
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
const IndicatorComponent = Indicator.styleable((props, forwardedRef) => {
|
|
156
|
+
const {
|
|
157
|
+
children: childrenProp,
|
|
158
|
+
forceMount,
|
|
159
|
+
disablePassStyles,
|
|
160
|
+
unstyled = false,
|
|
161
|
+
activeStyle,
|
|
162
|
+
...indicatorProps
|
|
163
|
+
} = props;
|
|
164
|
+
const styledContext = import_CheckboxStyledContext.CheckboxStyledContext.useStyledContext();
|
|
165
|
+
const {
|
|
166
|
+
active
|
|
167
|
+
} = styledContext;
|
|
168
|
+
let children = childrenProp;
|
|
169
|
+
if (!unstyled) {
|
|
170
|
+
const iconSize = (typeof styledContext.size === "number" ? styledContext.size * .65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon;
|
|
171
|
+
const theme = (0, import_core.useTheme)();
|
|
172
|
+
const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
173
|
+
size: iconSize,
|
|
174
|
+
color: theme.color
|
|
147
175
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
active
|
|
161
|
-
} = styledContext;
|
|
162
|
-
let children = childrenProp;
|
|
163
|
-
if (!unstyled) {
|
|
164
|
-
const iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon,
|
|
165
|
-
theme = (0, import_core.useTheme)(),
|
|
166
|
-
getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
167
|
-
size: iconSize,
|
|
168
|
-
color: theme.color
|
|
169
|
-
});
|
|
170
|
-
children = import_react.default.Children.toArray(childrenProp).map(child => disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child));
|
|
171
|
-
}
|
|
172
|
-
const context = import_react.default.useContext(CheckboxContext);
|
|
173
|
-
return forceMount || (0, import_checkbox_headless.isIndeterminate)(context.checked) || context.checked === !0 ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(Indicator, {
|
|
174
|
-
pointerEvents: "none",
|
|
175
|
-
...indicatorProps,
|
|
176
|
-
...(active && activeStyle),
|
|
177
|
-
ref: forwardedRef,
|
|
178
|
-
children
|
|
179
|
-
}) : null;
|
|
176
|
+
children = import_react.default.Children.toArray(childrenProp).map(child => {
|
|
177
|
+
if (disablePassStyles || !import_react.default.isValidElement(child)) return child;
|
|
178
|
+
return getThemedIcon(child);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const context = import_react.default.useContext(CheckboxContext);
|
|
182
|
+
if (forceMount || (0, import_checkbox_headless.isIndeterminate)(context.checked) || context.checked === true) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Indicator, {
|
|
183
|
+
pointerEvents: "none",
|
|
184
|
+
...indicatorProps,
|
|
185
|
+
...(active && activeStyle),
|
|
186
|
+
ref: forwardedRef,
|
|
187
|
+
children
|
|
180
188
|
});
|
|
189
|
+
return null;
|
|
190
|
+
});
|
|
181
191
|
return (0, import_core.withStaticProperties)(FrameComponent, {
|
|
182
192
|
Indicator: IndicatorComponent
|
|
183
193
|
});
|