tamagui 1.0.11 → 1.0.13
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/package.json +44 -44
- package/dist/cjs/helpers/focusableInputHOC.js +0 -92
- package/dist/cjs/helpers/focusableInputHOC.js.map +0 -7
- package/dist/cjs/helpers/getSpace.js +0 -34
- package/dist/cjs/helpers/getSpace.js.map +0 -7
- package/dist/cjs/helpers/prevent.js +0 -28
- package/dist/cjs/helpers/prevent.js.map +0 -7
- package/dist/cjs/hooks/useKeyboardDismissable.js +0 -95
- package/dist/cjs/hooks/useKeyboardDismissable.js.map +0 -7
- package/dist/cjs/lib/focusable.js +0 -16
- package/dist/cjs/lib/focusable.js.map +0 -7
- package/dist/cjs/lib/linear-gradient.js +0 -29
- package/dist/cjs/lib/linear-gradient.js.map +0 -7
- package/dist/cjs/lib/registerFocusable.js +0 -37
- package/dist/cjs/lib/registerFocusable.js.map +0 -7
- package/dist/cjs/lib/registerFocusable.native.js +0 -60
- package/dist/cjs/lib/registerFocusable.native.js.map +0 -7
- package/dist/cjs/polyfills.js +0 -11
- package/dist/cjs/polyfills.js.map +0 -7
- package/dist/cjs/views/BlurView.js +0 -90
- package/dist/cjs/views/BlurView.js.map +0 -7
- package/dist/cjs/views/BlurView.native.js +0 -38
- package/dist/cjs/views/BlurView.native.js.map +0 -7
- package/dist/cjs/views/ExitAnimationContext.js +0 -34
- package/dist/cjs/views/ExitAnimationContext.js.map +0 -7
- package/dist/cjs/views/Hoverable.js +0 -92
- package/dist/cjs/views/Hoverable.js.map +0 -7
- package/dist/cjs/views/Label.js +0 -177
- package/dist/cjs/views/Label.js.map +0 -7
- package/dist/cjs/views/LinearGradient.js +0 -81
- package/dist/cjs/views/LinearGradient.js.map +0 -7
- package/dist/cjs/views/Switch.js +0 -265
- package/dist/cjs/views/Switch.js.map +0 -7
- package/dist/cjs/views/Table.js +0 -84
- package/dist/cjs/views/Table.js.map +0 -7
- package/dist/cjs/views/Toast.js +0 -129
- package/dist/cjs/views/Toast.js.map +0 -7
- package/dist/esm/helpers/focusableInputHOC.js +0 -68
- package/dist/esm/helpers/focusableInputHOC.js.map +0 -7
- package/dist/esm/helpers/getSpace.js +0 -11
- package/dist/esm/helpers/getSpace.js.map +0 -7
- package/dist/esm/helpers/prevent.js +0 -5
- package/dist/esm/helpers/prevent.js.map +0 -7
- package/dist/esm/hooks/useKeyboardDismissable.js +0 -69
- package/dist/esm/hooks/useKeyboardDismissable.js.map +0 -7
- package/dist/esm/lib/focusable.js +0 -1
- package/dist/esm/lib/focusable.js.map +0 -7
- package/dist/esm/lib/linear-gradient.js +0 -5
- package/dist/esm/lib/linear-gradient.js.map +0 -7
- package/dist/esm/lib/registerFocusable.js +0 -12
- package/dist/esm/lib/registerFocusable.js.map +0 -7
- package/dist/esm/lib/registerFocusable.native.js +0 -35
- package/dist/esm/lib/registerFocusable.native.js.map +0 -7
- package/dist/esm/polyfills.js +0 -10
- package/dist/esm/polyfills.js.map +0 -7
- package/dist/esm/views/BlurView.js +0 -66
- package/dist/esm/views/BlurView.js.map +0 -7
- package/dist/esm/views/BlurView.native.js +0 -15
- package/dist/esm/views/BlurView.native.js.map +0 -7
- package/dist/esm/views/ExitAnimationContext.js +0 -10
- package/dist/esm/views/ExitAnimationContext.js.map +0 -7
- package/dist/esm/views/Hoverable.js +0 -66
- package/dist/esm/views/Hoverable.js.map +0 -7
- package/dist/esm/views/Label.js +0 -158
- package/dist/esm/views/Label.js.map +0 -7
- package/dist/esm/views/LinearGradient.js +0 -58
- package/dist/esm/views/LinearGradient.js.map +0 -7
- package/dist/esm/views/Switch.js +0 -244
- package/dist/esm/views/Switch.js.map +0 -7
- package/dist/esm/views/Table.js +0 -56
- package/dist/esm/views/Table.js.map +0 -7
- package/dist/esm/views/Toast.js +0 -107
- package/dist/esm/views/Toast.js.map +0 -7
- package/dist/jsx/helpers/focusableInputHOC.js +0 -49
- package/dist/jsx/helpers/focusableInputHOC.js.map +0 -7
- package/dist/jsx/helpers/getSpace.js +0 -11
- package/dist/jsx/helpers/getSpace.js.map +0 -7
- package/dist/jsx/helpers/prevent.js +0 -5
- package/dist/jsx/helpers/prevent.js.map +0 -7
- package/dist/jsx/hooks/useKeyboardDismissable.js +0 -69
- package/dist/jsx/hooks/useKeyboardDismissable.js.map +0 -7
- package/dist/jsx/lib/focusable.js +0 -1
- package/dist/jsx/lib/focusable.js.map +0 -7
- package/dist/jsx/lib/linear-gradient.js +0 -5
- package/dist/jsx/lib/linear-gradient.js.map +0 -7
- package/dist/jsx/lib/registerFocusable.js +0 -12
- package/dist/jsx/lib/registerFocusable.js.map +0 -7
- package/dist/jsx/lib/registerFocusable.native.js +0 -35
- package/dist/jsx/lib/registerFocusable.native.js.map +0 -7
- package/dist/jsx/polyfills.js +0 -10
- package/dist/jsx/polyfills.js.map +0 -7
- package/dist/jsx/views/BlurView.js +0 -27
- package/dist/jsx/views/BlurView.js.map +0 -7
- package/dist/jsx/views/BlurView.native.js +0 -15
- package/dist/jsx/views/BlurView.native.js.map +0 -7
- package/dist/jsx/views/ExitAnimationContext.js +0 -10
- package/dist/jsx/views/ExitAnimationContext.js.map +0 -7
- package/dist/jsx/views/Hoverable.js +0 -58
- package/dist/jsx/views/Hoverable.js.map +0 -7
- package/dist/jsx/views/Label.js +0 -118
- package/dist/jsx/views/Label.js.map +0 -7
- package/dist/jsx/views/LinearGradient.js +0 -46
- package/dist/jsx/views/LinearGradient.js.map +0 -7
- package/dist/jsx/views/Switch.js +0 -164
- package/dist/jsx/views/Switch.js.map +0 -7
- package/dist/jsx/views/Table.js +0 -56
- package/dist/jsx/views/Table.js.map +0 -7
- package/dist/jsx/views/Toast.js +0 -73
- package/dist/jsx/views/Toast.js.map +0 -7
- package/types/lib/linear-gradient.d.ts +0 -3
- package/types/views/LinearGradient.d.ts +0 -10
package/dist/cjs/views/Switch.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
|
-
var __export = (target, all) => {
|
|
37
|
-
for (var name in all)
|
|
38
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
-
};
|
|
40
|
-
var __copyProps = (to, from, except, desc) => {
|
|
41
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
-
for (let key of __getOwnPropNames(from))
|
|
43
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
-
}
|
|
46
|
-
return to;
|
|
47
|
-
};
|
|
48
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
49
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
-
var Switch_exports = {};
|
|
51
|
-
__export(Switch_exports, {
|
|
52
|
-
Switch: () => Switch,
|
|
53
|
-
SwitchFrame: () => SwitchFrame,
|
|
54
|
-
SwitchThumb: () => SwitchThumb,
|
|
55
|
-
SwitchThumbFrame: () => SwitchThumbFrame,
|
|
56
|
-
createSwitchScope: () => createSwitchScope
|
|
57
|
-
});
|
|
58
|
-
module.exports = __toCommonJS(Switch_exports);
|
|
59
|
-
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
60
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
61
|
-
var import_core = require("@tamagui/core");
|
|
62
|
-
var import_create_context = require("@tamagui/create-context");
|
|
63
|
-
var import_stacks = require("@tamagui/stacks");
|
|
64
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
65
|
-
var React = __toESM(require("react"));
|
|
66
|
-
var import_registerFocusable = require("../lib/registerFocusable");
|
|
67
|
-
var import_Label = require("./Label");
|
|
68
|
-
const SWITCH_NAME = "Switch";
|
|
69
|
-
const scopeContexts = (0, import_create_context.createContextScope)(SWITCH_NAME);
|
|
70
|
-
const [createSwitchContext] = scopeContexts;
|
|
71
|
-
const createSwitchScope = scopeContexts[1];
|
|
72
|
-
const [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
|
|
73
|
-
const getSwitchHeight = (val) => Math.round((0, import_core.getVariableValue)((0, import_core.getSize)(val)) * 0.65);
|
|
74
|
-
const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
|
|
75
|
-
const SwitchFrame = (0, import_core.styled)(import_stacks.XStack, {
|
|
76
|
-
name: "Switch",
|
|
77
|
-
tag: "button",
|
|
78
|
-
borderRadius: 1e3,
|
|
79
|
-
borderWidth: 2,
|
|
80
|
-
borderColor: "transparent",
|
|
81
|
-
backgroundColor: "$background",
|
|
82
|
-
focusStyle: {
|
|
83
|
-
borderColor: "$borderColorFocus"
|
|
84
|
-
},
|
|
85
|
-
variants: {
|
|
86
|
-
size: {
|
|
87
|
-
"...size": (val) => {
|
|
88
|
-
const height = (0, import_core.calc)(getSwitchHeight(val), "+", 4);
|
|
89
|
-
const width = (0, import_core.calc)(getSwitchWidth(val), "+", 4);
|
|
90
|
-
return {
|
|
91
|
-
height,
|
|
92
|
-
minHeight: height,
|
|
93
|
-
width
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
defaultVariants: {
|
|
99
|
-
size: "$4"
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
const SwitchComponent = React.forwardRef((props, forwardedRef) => {
|
|
103
|
-
const _a = props, {
|
|
104
|
-
__scopeSwitch,
|
|
105
|
-
labeledBy: ariaLabelledby,
|
|
106
|
-
name,
|
|
107
|
-
checked: checkedProp,
|
|
108
|
-
defaultChecked,
|
|
109
|
-
required,
|
|
110
|
-
disabled,
|
|
111
|
-
value = "on",
|
|
112
|
-
onCheckedChange,
|
|
113
|
-
size = "$4"
|
|
114
|
-
} = _a, switchProps = __objRest(_a, [
|
|
115
|
-
"__scopeSwitch",
|
|
116
|
-
"labeledBy",
|
|
117
|
-
"name",
|
|
118
|
-
"checked",
|
|
119
|
-
"defaultChecked",
|
|
120
|
-
"required",
|
|
121
|
-
"disabled",
|
|
122
|
-
"value",
|
|
123
|
-
"onCheckedChange",
|
|
124
|
-
"size"
|
|
125
|
-
]);
|
|
126
|
-
const [button, setButton] = React.useState(null);
|
|
127
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node));
|
|
128
|
-
const labelId = (0, import_Label.useLabelContext)(button);
|
|
129
|
-
const labelledBy = ariaLabelledby || labelId;
|
|
130
|
-
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
131
|
-
const isFormControl = import_core.isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
132
|
-
const [checked = false, setChecked] = (0, import_use_controllable_state.useControllableState)({
|
|
133
|
-
prop: checkedProp,
|
|
134
|
-
defaultProp: defaultChecked || false,
|
|
135
|
-
onChange: onCheckedChange
|
|
136
|
-
});
|
|
137
|
-
if (!import_core.isWeb) {
|
|
138
|
-
React.useEffect(() => {
|
|
139
|
-
if (!props.id)
|
|
140
|
-
return;
|
|
141
|
-
return (0, import_registerFocusable.registerFocusable)(props.id, {
|
|
142
|
-
focus: () => {
|
|
143
|
-
setChecked((x) => !x);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}, [props.id]);
|
|
147
|
-
}
|
|
148
|
-
return /* @__PURE__ */ React.createElement(SwitchProvider, {
|
|
149
|
-
scope: __scopeSwitch,
|
|
150
|
-
checked,
|
|
151
|
-
disabled,
|
|
152
|
-
size
|
|
153
|
-
}, /* @__PURE__ */ React.createElement(SwitchFrame, __spreadProps(__spreadValues({
|
|
154
|
-
size,
|
|
155
|
-
role: "switch",
|
|
156
|
-
"aria-checked": checked,
|
|
157
|
-
"aria-labelledby": labelledBy,
|
|
158
|
-
"aria-required": required,
|
|
159
|
-
"data-state": getState(checked),
|
|
160
|
-
"data-disabled": disabled ? "" : void 0,
|
|
161
|
-
disabled,
|
|
162
|
-
tabIndex: disabled ? void 0 : 0,
|
|
163
|
-
value
|
|
164
|
-
}, switchProps), {
|
|
165
|
-
ref: composedRefs,
|
|
166
|
-
onPress: (event) => {
|
|
167
|
-
var _a2;
|
|
168
|
-
(_a2 = props.onPress) == null ? void 0 : _a2.call(props, event);
|
|
169
|
-
setChecked((prevChecked) => !prevChecked);
|
|
170
|
-
if (import_core.isWeb && isFormControl) {
|
|
171
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
172
|
-
if (!hasConsumerStoppedPropagationRef.current)
|
|
173
|
-
event.stopPropagation();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
})), import_core.isWeb && isFormControl && /* @__PURE__ */ React.createElement(BubbleInput, {
|
|
177
|
-
control: button,
|
|
178
|
-
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
179
|
-
name,
|
|
180
|
-
value,
|
|
181
|
-
checked,
|
|
182
|
-
required,
|
|
183
|
-
disabled,
|
|
184
|
-
style: { transform: "translateX(-100%)" }
|
|
185
|
-
}));
|
|
186
|
-
});
|
|
187
|
-
SwitchComponent.displayName = SWITCH_NAME;
|
|
188
|
-
const Switch = SwitchFrame.extractable((0, import_core.themeable)(SwitchComponent), {
|
|
189
|
-
neverFlatten: true
|
|
190
|
-
});
|
|
191
|
-
const THUMB_NAME = "SwitchThumb";
|
|
192
|
-
const SwitchThumbFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
193
|
-
name: "SwitchThumb",
|
|
194
|
-
backgroundColor: "$background",
|
|
195
|
-
borderRadius: 1e3,
|
|
196
|
-
variants: {
|
|
197
|
-
size: {
|
|
198
|
-
"...size": (val) => ({
|
|
199
|
-
height: getSwitchHeight(val),
|
|
200
|
-
width: getSwitchHeight(val)
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
defaultVariants: {
|
|
205
|
-
size: "$4"
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
const SwitchThumb = SwitchThumbFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
209
|
-
const _a = props, { __scopeSwitch } = _a, thumbProps = __objRest(_a, ["__scopeSwitch"]);
|
|
210
|
-
const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch);
|
|
211
|
-
return /* @__PURE__ */ React.createElement(SwitchThumbFrame, __spreadProps(__spreadValues({
|
|
212
|
-
size,
|
|
213
|
-
"data-state": getState(checked),
|
|
214
|
-
"data-disabled": disabled ? "" : void 0
|
|
215
|
-
}, thumbProps), {
|
|
216
|
-
x: checked ? (0, import_core.getVariableValue)(getSwitchWidth(size)) - (0, import_core.getVariableValue)(getSwitchHeight(size)) : 0,
|
|
217
|
-
ref: forwardedRef
|
|
218
|
-
}));
|
|
219
|
-
}), {
|
|
220
|
-
neverFlatten: true
|
|
221
|
-
});
|
|
222
|
-
SwitchThumb.displayName = THUMB_NAME;
|
|
223
|
-
Switch.Thumb = SwitchThumb;
|
|
224
|
-
const BubbleInput = (props) => {
|
|
225
|
-
const _a = props, { control, checked, bubbles = true } = _a, inputProps = __objRest(_a, ["control", "checked", "bubbles"]);
|
|
226
|
-
const ref = React.useRef(null);
|
|
227
|
-
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
|
|
228
|
-
React.useEffect(() => {
|
|
229
|
-
const input = ref.current;
|
|
230
|
-
const inputProto = window.HTMLInputElement.prototype;
|
|
231
|
-
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
232
|
-
const setChecked = descriptor.set;
|
|
233
|
-
if (prevChecked !== checked && setChecked) {
|
|
234
|
-
const event = new Event("click", { bubbles });
|
|
235
|
-
setChecked.call(input, checked);
|
|
236
|
-
input.dispatchEvent(event);
|
|
237
|
-
}
|
|
238
|
-
}, [prevChecked, checked, bubbles]);
|
|
239
|
-
return /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({
|
|
240
|
-
type: "checkbox",
|
|
241
|
-
"aria-hidden": true,
|
|
242
|
-
defaultChecked: checked
|
|
243
|
-
}, inputProps), {
|
|
244
|
-
tabIndex: -1,
|
|
245
|
-
ref,
|
|
246
|
-
style: __spreadProps(__spreadValues({}, props.style), {
|
|
247
|
-
position: "absolute",
|
|
248
|
-
pointerEvents: "none",
|
|
249
|
-
opacity: 0,
|
|
250
|
-
margin: 0
|
|
251
|
-
})
|
|
252
|
-
}));
|
|
253
|
-
};
|
|
254
|
-
function getState(checked) {
|
|
255
|
-
return checked ? "checked" : "unchecked";
|
|
256
|
-
}
|
|
257
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
-
0 && (module.exports = {
|
|
259
|
-
Switch,
|
|
260
|
-
SwitchFrame,
|
|
261
|
-
SwitchThumb,
|
|
262
|
-
SwitchThumbFrame,
|
|
263
|
-
createSwitchScope
|
|
264
|
-
});
|
|
265
|
-
//# sourceMappingURL=Switch.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/views/Switch.tsx"],
|
|
4
|
-
"sourcesContent": ["// via radix\n// https://github.com/radix-ui/primitives/blob/main/packages/react/switch/src/Switch.tsx\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n ReactComponentWithRef,\n SizeTokens,\n calc,\n getSize,\n getVariableValue,\n isWeb,\n styled,\n themeable,\n} from '@tamagui/core'\nimport { ScopedProps, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, XStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nimport { registerFocusable } from '../lib/registerFocusable'\nimport { useLabelContext } from './Label'\n\nconst SWITCH_NAME = 'Switch'\n\nconst scopeContexts = createContextScope(SWITCH_NAME)\nconst [createSwitchContext] = scopeContexts\nexport const createSwitchScope = scopeContexts[1]\n\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<{\n checked: boolean\n disabled?: boolean\n size: SizeTokens\n}>(SWITCH_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\n// TODO make customizable\nconst getSwitchHeight = (val: SizeTokens) => Math.round(getVariableValue(getSize(val)) * 0.65)\nconst getSwitchWidth = (val: SizeTokens) => getSwitchHeight(val) * 2\n\nexport const SwitchFrame = styled(XStack, {\n name: 'Switch',\n tag: 'button',\n borderRadius: 1000,\n borderWidth: 2,\n borderColor: 'transparent',\n backgroundColor: '$background',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': (val) => {\n const height = calc(getSwitchHeight(val), '+', 4)\n const width = calc(getSwitchWidth(val), '+', 4)\n return {\n height,\n minHeight: height,\n width,\n }\n },\n },\n },\n\n defaultVariants: {\n size: '$4',\n },\n})\n\ntype SwitchButtonProps = GetProps<typeof SwitchFrame>\n\nexport type SwitchProps = SwitchButtonProps & {\n labeledBy?: string\n name?: string\n value?: string\n checked?: boolean\n defaultChecked?: boolean\n required?: boolean\n onCheckedChange?(checked: boolean): void\n}\n\nconst SwitchComponent = React.forwardRef<HTMLButtonElement | View, SwitchProps>(\n (props: ScopedProps<SwitchProps, 'Switch'>, forwardedRef) => {\n const {\n __scopeSwitch,\n labeledBy: ariaLabelledby,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n size = '$4',\n ...switchProps\n } = props\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node as any))\n const labelId = useLabelContext(button)\n const labelledBy = ariaLabelledby || labelId\n const hasConsumerStoppedPropagationRef = React.useRef(false)\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = isWeb ? (button ? Boolean(button.closest('form')) : true) : false\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked || false,\n onChange: onCheckedChange,\n })\n\n if (!isWeb) {\n React.useEffect(() => {\n if (!props.id) return\n return registerFocusable(props.id, {\n focus: () => {\n setChecked((x) => !x)\n },\n })\n }, [props.id])\n }\n\n return (\n <SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled} size={size}>\n <SwitchFrame\n size={size}\n // @ts-ignore\n role=\"switch\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n // @ts-ignore\n tabIndex={disabled ? undefined : 0}\n // @ts-ignore\n value={value}\n {...switchProps}\n ref={composedRefs}\n onPress={(event) => {\n props.onPress?.(event)\n setChecked((prevChecked) => !prevChecked)\n if (isWeb && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped()\n // if switch is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect switch updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation()\n }\n }}\n />\n {isWeb && isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </SwitchProvider>\n )\n }\n)\n\nSwitchComponent.displayName = SWITCH_NAME\n\nexport const Switch: ReactComponentWithRef<SwitchProps, HTMLButtonElement | View> & {\n Thumb: typeof SwitchThumb\n} = SwitchFrame.extractable(themeable(SwitchComponent as any) as any, {\n neverFlatten: true,\n})\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb'\n\nexport const SwitchThumbFrame = styled(ThemeableStack, {\n name: 'SwitchThumb',\n backgroundColor: '$background',\n borderRadius: 1000,\n\n variants: {\n size: {\n '...size': (val) => ({\n height: getSwitchHeight(val),\n width: getSwitchHeight(val),\n }),\n },\n },\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport type SwitchThumbProps = GetProps<typeof SwitchThumbFrame>\n\nexport const SwitchThumb = SwitchThumbFrame.extractable(\n React.forwardRef<React.ElementRef<'span'>, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps, 'Switch'>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props\n const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch)\n return (\n <SwitchThumbFrame\n size={size}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n {...thumbProps}\n x={\n checked\n ? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size))\n : 0\n }\n ref={forwardedRef}\n />\n )\n }\n ),\n {\n neverFlatten: true,\n }\n)\n\nSwitchThumb.displayName = THUMB_NAME\nSwitch.Thumb = SwitchThumb\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = any //Radix.ComponentPropsWithoutRef<'input'>\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean\n control: HTMLElement | null\n bubbles: boolean\n}\n\n// TODO make this native friendly\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props\n const ref = React.useRef<HTMLInputElement>(null)\n const prevChecked = usePrevious(checked)\n // const controlSize = useSize(control)\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!\n const inputProto = window.HTMLInputElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor\n const setChecked = descriptor.set\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles })\n setChecked.call(input, checked)\n input.dispatchEvent(event)\n }\n }, [prevChecked, checked, bubbles])\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n // ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n )\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked'\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA4B;AAC5B,0BAAgC;AAChC,kBAUO;AACP,4BAAgD;AAChD,oBAAuC;AACvC,oCAAqC;AACrC,YAAuB;AAGvB,+BAAkC;AAClC,mBAAgC;AAEhC,MAAM,cAAc;AAEpB,MAAM,gBAAgB,8CAAmB,WAAW;AACpD,MAAM,CAAC,uBAAuB;AACvB,MAAM,oBAAoB,cAAc;AAE/C,MAAM,CAAC,gBAAgB,oBAAoB,oBAIxC,WAAW;AAOd,MAAM,kBAAkB,CAAC,QAAoB,KAAK,MAAM,kCAAiB,yBAAQ,GAAG,CAAC,IAAI,IAAI;AAC7F,MAAM,iBAAiB,CAAC,QAAoB,gBAAgB,GAAG,IAAI;AAE5D,MAAM,cAAc,wBAAO,sBAAQ;AAAA,EACxC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,cAAc;AAAA,EACd,aAAa;AAAA,EACb,aAAa;AAAA,EACb,iBAAiB;AAAA,EAEjB,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,QAAQ;AAClB,cAAM,SAAS,sBAAK,gBAAgB,GAAG,GAAG,KAAK,CAAC;AAChD,cAAM,QAAQ,sBAAK,eAAe,GAAG,GAAG,KAAK,CAAC;AAC9C,eAAO;AAAA,UACL;AAAA,UACA,WAAW;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAcD,MAAM,kBAAkB,MAAM,WAC5B,CAA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Descriptor;
|
|
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: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var Table_exports = {};
|
|
19
|
-
__export(Table_exports, {
|
|
20
|
-
Table: () => Table,
|
|
21
|
-
TableCell: () => TableCell,
|
|
22
|
-
TableHead: () => TableHead,
|
|
23
|
-
TableHeadCell: () => TableHeadCell,
|
|
24
|
-
TableHeadText: () => TableHeadText,
|
|
25
|
-
TableRow: () => TableRow
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(Table_exports);
|
|
28
|
-
var import_core = require("@tamagui/core");
|
|
29
|
-
const Table = (0, import_core.styled)(import_core.Stack, {
|
|
30
|
-
name: "Table",
|
|
31
|
-
tag: "table"
|
|
32
|
-
});
|
|
33
|
-
const TableRow = (0, import_core.styled)(import_core.Stack, {
|
|
34
|
-
name: "TableRow",
|
|
35
|
-
tag: "tr",
|
|
36
|
-
alignSelf: "stretch",
|
|
37
|
-
flex: 1
|
|
38
|
-
});
|
|
39
|
-
const TableHead = (0, import_core.styled)(import_core.Stack, {
|
|
40
|
-
name: "TableHead",
|
|
41
|
-
tag: "thead",
|
|
42
|
-
flexDirection: "row",
|
|
43
|
-
alignSelf: "stretch",
|
|
44
|
-
flex: 1,
|
|
45
|
-
borderBottomColor: "#eee",
|
|
46
|
-
borderBottomWidth: 1
|
|
47
|
-
});
|
|
48
|
-
const TableHeadCell = (0, import_core.styled)(import_core.Stack, {
|
|
49
|
-
name: "TableHeadCell",
|
|
50
|
-
tag: "th",
|
|
51
|
-
display: import_core.isWeb ? "table-head" : "flex",
|
|
52
|
-
flexDirection: "row"
|
|
53
|
-
});
|
|
54
|
-
const TableHeadText = (0, import_core.styled)(import_core.Text, {
|
|
55
|
-
name: "TableHeadText",
|
|
56
|
-
backgroundColor: "rgba(0,0,0,0.05)",
|
|
57
|
-
padding: 2,
|
|
58
|
-
paddingHorizontal: 8,
|
|
59
|
-
marginLeft: -8,
|
|
60
|
-
borderRadius: 10,
|
|
61
|
-
maxWidth: "100%",
|
|
62
|
-
ellipse: true,
|
|
63
|
-
fontSize: 12
|
|
64
|
-
});
|
|
65
|
-
const TableCell = (0, import_core.styled)(import_core.Stack, {
|
|
66
|
-
name: "TableCell",
|
|
67
|
-
flex: 1,
|
|
68
|
-
alignSelf: "stretch",
|
|
69
|
-
alignItems: "center",
|
|
70
|
-
tag: "td",
|
|
71
|
-
display: import_core.isWeb ? "table-cell" : "flex",
|
|
72
|
-
paddingVertical: "$3",
|
|
73
|
-
paddingHorizontal: "$2"
|
|
74
|
-
});
|
|
75
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
-
0 && (module.exports = {
|
|
77
|
-
Table,
|
|
78
|
-
TableCell,
|
|
79
|
-
TableHead,
|
|
80
|
-
TableHeadCell,
|
|
81
|
-
TableHeadText,
|
|
82
|
-
TableRow
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=Table.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/views/Table.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Stack, StackProps, Text, TextProps, isWeb, styled } from '@tamagui/core'\n\nexport const Table = styled(Stack, {\n name: 'Table',\n tag: 'table',\n})\n\nexport const TableRow = styled(Stack, {\n name: 'TableRow',\n tag: 'tr',\n alignSelf: 'stretch', // minWidth: 100%\n flex: 1,\n})\n\nexport const TableHead = styled(Stack, {\n name: 'TableHead',\n tag: 'thead',\n flexDirection: 'row',\n alignSelf: 'stretch',\n flex: 1,\n borderBottomColor: '#eee',\n borderBottomWidth: 1,\n})\n\nexport const TableHeadCell = styled(Stack, {\n name: 'TableHeadCell',\n tag: 'th',\n // @ts-ignore\n display: isWeb ? 'table-head' : 'flex',\n flexDirection: 'row',\n})\n\nexport const TableHeadText = styled(Text, {\n name: 'TableHeadText',\n backgroundColor: 'rgba(0,0,0,0.05)',\n padding: 2,\n paddingHorizontal: 8,\n marginLeft: -8,\n borderRadius: 10,\n maxWidth: '100%',\n ellipse: true,\n fontSize: 12,\n})\n\nexport type TableCellProps = StackProps & TextProps\n\nexport const TableCell = styled(Stack, {\n name: 'TableCell',\n flex: 1,\n alignSelf: 'stretch',\n alignItems: 'center',\n tag: 'td',\n // @ts-ignore\n display: isWeb ? 'table-cell' : 'flex',\n // borderBottomWidth: 1,\n // borderBottomColor: '$borderColor',\n paddingVertical: '$3',\n paddingHorizontal: '$2',\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkE;AAE3D,MAAM,QAAQ,wBAAO,mBAAO;AAAA,EACjC,MAAM;AAAA,EACN,KAAK;AACP,CAAC;AAEM,MAAM,WAAW,wBAAO,mBAAO;AAAA,EACpC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA,EACX,MAAM;AACR,CAAC;AAEM,MAAM,YAAY,wBAAO,mBAAO;AAAA,EACrC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,eAAe;AAAA,EACf,WAAW;AAAA,EACX,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,mBAAmB;AACrB,CAAC;AAEM,MAAM,gBAAgB,wBAAO,mBAAO;AAAA,EACzC,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,SAAS,oBAAQ,eAAe;AAAA,EAChC,eAAe;AACjB,CAAC;AAEM,MAAM,gBAAgB,wBAAO,kBAAM;AAAA,EACxC,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AACZ,CAAC;AAIM,MAAM,YAAY,wBAAO,mBAAO;AAAA,EACrC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,KAAK;AAAA,EAEL,SAAS,oBAAQ,eAAe;AAAA,EAGhC,iBAAiB;AAAA,EACjB,mBAAmB;AACrB,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/cjs/views/Toast.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
var Toast_exports = {};
|
|
36
|
-
__export(Toast_exports, {
|
|
37
|
-
Toast: () => Toast,
|
|
38
|
-
ToastRoot: () => ToastRoot
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(Toast_exports);
|
|
41
|
-
var import_animate_presence = require("@tamagui/animate-presence");
|
|
42
|
-
var import_core = require("@tamagui/core");
|
|
43
|
-
var import_stacks = require("@tamagui/stacks");
|
|
44
|
-
var import_text = require("@tamagui/text");
|
|
45
|
-
var import_use_force_update = require("@tamagui/use-force-update");
|
|
46
|
-
var import_react = require("react");
|
|
47
|
-
var import_react_dom = require("react-dom");
|
|
48
|
-
let clear = () => {
|
|
49
|
-
};
|
|
50
|
-
let show = (content) => {
|
|
51
|
-
console.warn("Note:", content);
|
|
52
|
-
};
|
|
53
|
-
const Toast = {
|
|
54
|
-
clear,
|
|
55
|
-
show: (content, options) => show(content, options),
|
|
56
|
-
error: (content, options) => show(content, __spreadProps(__spreadValues({}, options), { type: "error" })),
|
|
57
|
-
success: (content, options) => show(content, __spreadProps(__spreadValues({}, options), { type: "success" }))
|
|
58
|
-
};
|
|
59
|
-
if (typeof window !== "undefined") {
|
|
60
|
-
window["Toast"] = Toast;
|
|
61
|
-
}
|
|
62
|
-
const ToastRoot = (0, import_react.memo)(function ToastRoot2(props) {
|
|
63
|
-
const forceUpdate = (0, import_use_force_update.useForceUpdate)();
|
|
64
|
-
const stateRef = (0, import_react.useRef)({
|
|
65
|
-
show: false,
|
|
66
|
-
content: "",
|
|
67
|
-
type: "info",
|
|
68
|
-
timeout: null
|
|
69
|
-
});
|
|
70
|
-
const setState = (x) => {
|
|
71
|
-
stateRef.current = x;
|
|
72
|
-
forceUpdate();
|
|
73
|
-
};
|
|
74
|
-
(0, import_react.useEffect)(() => {
|
|
75
|
-
return () => {
|
|
76
|
-
clearTimeout(stateRef.current.timeout ?? 0);
|
|
77
|
-
};
|
|
78
|
-
}, []);
|
|
79
|
-
clear = () => {
|
|
80
|
-
setState({ show: false, content: "" });
|
|
81
|
-
};
|
|
82
|
-
show = (0, import_react.useCallback)((content, { duration = 3e3, type = "info" } = {}) => {
|
|
83
|
-
clearTimeout(stateRef.current.timeout ?? 0);
|
|
84
|
-
const timeout = setTimeout(() => {
|
|
85
|
-
setState({
|
|
86
|
-
show: false,
|
|
87
|
-
content: "",
|
|
88
|
-
type,
|
|
89
|
-
timeout: null
|
|
90
|
-
});
|
|
91
|
-
}, duration);
|
|
92
|
-
setState({
|
|
93
|
-
show: true,
|
|
94
|
-
content,
|
|
95
|
-
type,
|
|
96
|
-
timeout
|
|
97
|
-
});
|
|
98
|
-
}, [stateRef]);
|
|
99
|
-
const state = stateRef.current;
|
|
100
|
-
const contents = /* @__PURE__ */ React.createElement(import_stacks.YStack, {
|
|
101
|
-
position: "absolute",
|
|
102
|
-
pointerEvents: "none",
|
|
103
|
-
fullscreen: true,
|
|
104
|
-
alignItems: "center",
|
|
105
|
-
justifyContent: "flex-end",
|
|
106
|
-
zIndex: 1e10,
|
|
107
|
-
padding: "5%"
|
|
108
|
-
}, /* @__PURE__ */ React.createElement(import_core.Theme, {
|
|
109
|
-
name: state.type === "info" ? null : state.type === "success" ? "green" : "red"
|
|
110
|
-
}, /* @__PURE__ */ React.createElement(import_animate_presence.AnimatePresence, null, state.show && !!state.content && /* @__PURE__ */ React.createElement(import_stacks.YStack, {
|
|
111
|
-
animation: props.animation || "toast",
|
|
112
|
-
backgroundColor: "$background",
|
|
113
|
-
elevation: "$2",
|
|
114
|
-
borderRadius: "$4",
|
|
115
|
-
paddingHorizontal: "$4",
|
|
116
|
-
paddingVertical: "$3"
|
|
117
|
-
}, /* @__PURE__ */ React.createElement(import_text.Paragraph, null, state.content)))));
|
|
118
|
-
const portalEl = document.getElementById("toasts");
|
|
119
|
-
if (import_core.isWeb && portalEl) {
|
|
120
|
-
return (0, import_react_dom.createPortal)(contents, portalEl);
|
|
121
|
-
}
|
|
122
|
-
return contents;
|
|
123
|
-
});
|
|
124
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
-
0 && (module.exports = {
|
|
126
|
-
Toast,
|
|
127
|
-
ToastRoot
|
|
128
|
-
});
|
|
129
|
-
//# sourceMappingURL=Toast.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/views/Toast.tsx"],
|
|
4
|
-
"sourcesContent": ["import { AnimatePresence } from '@tamagui/animate-presence'\nimport { AnimationKeys, Theme, isWeb } from '@tamagui/core'\nimport { YStack } from '@tamagui/stacks'\nimport { Paragraph } from '@tamagui/text'\nimport { useForceUpdate } from '@tamagui/use-force-update'\nimport { memo, useCallback, useEffect, useRef } from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type ToastOptions = {\n duration?: number\n type?: 'info' | 'success' | 'error'\n}\n\nlet clear = () => {}\n\nlet show: (content: any, options?: ToastOptions) => void = (content) => {\n console.warn('Note:', content)\n}\n\nexport const Toast = {\n clear,\n show: (content: any, options?: ToastOptions) => show(content, options),\n error: (content: any, options?: Omit<ToastOptions, 'type'>) =>\n show(content, { ...options, type: 'error' }),\n success: (content: any, options?: Omit<ToastOptions, 'type'>) =>\n show(content, { ...options, type: 'success' }),\n}\n\nif (typeof window !== 'undefined') {\n window['Toast'] = Toast\n}\n\nexport const ToastRoot = memo(function ToastRoot(props: { animation?: AnimationKeys }) {\n const forceUpdate = useForceUpdate()\n const stateRef = useRef({\n show: false,\n content: '',\n type: 'info',\n timeout: null,\n })\n const setState = (x: any) => {\n stateRef.current = x\n forceUpdate()\n }\n\n useEffect(() => {\n return () => {\n clearTimeout(stateRef.current.timeout ?? 0)\n }\n }, [])\n\n clear = () => {\n setState({ show: false, content: '' })\n }\n\n show = useCallback(\n (content: any, { duration = 3000, type = 'info' }: ToastOptions = {}) => {\n clearTimeout(stateRef.current.timeout ?? 0)\n const timeout = setTimeout(() => {\n setState({\n show: false,\n content: '',\n type,\n timeout: null,\n })\n }, duration)\n setState({\n show: true,\n content,\n type,\n timeout,\n })\n },\n [stateRef]\n )\n\n const state = stateRef.current\n\n const contents = (\n <YStack\n position=\"absolute\"\n pointerEvents=\"none\"\n fullscreen\n alignItems=\"center\"\n justifyContent=\"flex-end\"\n zIndex={10000000000}\n padding=\"5%\"\n >\n <Theme name={state.type === 'info' ? null : state.type === 'success' ? 'green' : 'red'}>\n <AnimatePresence>\n {state.show && !!state.content && (\n <YStack\n animation={props.animation || ('toast' as any)}\n backgroundColor=\"$background\"\n elevation=\"$2\"\n borderRadius=\"$4\"\n paddingHorizontal=\"$4\"\n paddingVertical=\"$3\"\n >\n <Paragraph>{state.content}</Paragraph>\n </YStack>\n )}\n </AnimatePresence>\n </Theme>\n </YStack>\n )\n\n const portalEl = document.getElementById('toasts')\n\n if (isWeb && portalEl) {\n return createPortal(contents, portalEl)\n }\n\n return contents\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;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AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAAA,IACH,GAAG,QAAQ;AACX,aAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,GACA,CAAC,QAAQ,CACX;AAEA,QAAM,QAAQ,SAAS;AAEvB,QAAM,WACJ,oCAAC;AAAA,IACC,UAAS;AAAA,IACT,eAAc;AAAA,IACd,YAAU;AAAA,IACV,YAAW;AAAA,IACX,gBAAe;AAAA,IACf,QAAQ;AAAA,IACR,SAAQ;AAAA,KAER,oCAAC;AAAA,IAAM,MAAM,MAAM,SAAS,SAAS,OAAO,MAAM,SAAS,YAAY,UAAU;AAAA,KAC/E,oCAAC,+CACE,MAAM,QAAQ,CAAC,CAAC,MAAM,WACrB,oCAAC;AAAA,IACC,WAAW,MAAM,aAAc;AAAA,IAC/B,iBAAgB;AAAA,IAChB,WAAU;AAAA,IACV,cAAa;AAAA,IACb,mBAAkB;AAAA,IAClB,iBAAgB;AAAA,KAEhB,oCAAC,6BAAW,MAAM,OAAQ,CAC5B,CAEJ,CACF,CACF;AAGF,QAAM,WAAW,SAAS,eAAe,QAAQ;AAEjD,MAAI,qBAAS,UAAU;AACrB,WAAO,mCAAa,UAAU,QAAQ;AAAA,EACxC;AAEA,SAAO;AACT,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { composeRefs } from "@tamagui/compose-refs";
|
|
21
|
-
import { isTamaguiComponent } from "@tamagui/core";
|
|
22
|
-
import React, { useRef } from "react";
|
|
23
|
-
import { forwardRef, useCallback, useEffect } from "react";
|
|
24
|
-
import { registerFocusable, unregisterFocusable } from "../lib/registerFocusable";
|
|
25
|
-
function focusableInputHOC(Component) {
|
|
26
|
-
return forwardRef((props, ref) => {
|
|
27
|
-
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
28
|
-
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
29
|
-
const inputRef = useCallback((input) => {
|
|
30
|
-
if (!props.id)
|
|
31
|
-
return;
|
|
32
|
-
if (!input)
|
|
33
|
-
return;
|
|
34
|
-
registerFocusable(props.id, __spreadValues({
|
|
35
|
-
focus: input.focus
|
|
36
|
-
}, isInput && {
|
|
37
|
-
focusAndSelect() {
|
|
38
|
-
input.focus();
|
|
39
|
-
if (input.setSelection && typeof inputValue.current === "string") {
|
|
40
|
-
input.setSelection(0, inputValue.current.length);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
}, [props.id]);
|
|
45
|
-
const combinedRefs = composeRefs(ref, inputRef);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
return () => {
|
|
48
|
-
if (!props.id)
|
|
49
|
-
return;
|
|
50
|
-
unregisterFocusable(props.id);
|
|
51
|
-
};
|
|
52
|
-
}, [props.id]);
|
|
53
|
-
const finalProps = isInput ? __spreadProps(__spreadValues({}, props), {
|
|
54
|
-
onChangeText(value) {
|
|
55
|
-
var _a;
|
|
56
|
-
inputValue.current = value;
|
|
57
|
-
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
58
|
-
}
|
|
59
|
-
}) : props;
|
|
60
|
-
return /* @__PURE__ */ React.createElement(Component, __spreadValues({
|
|
61
|
-
ref: combinedRefs
|
|
62
|
-
}, finalProps));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
focusableInputHOC
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=focusableInputHOC.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { isTamaguiComponent } from '@tamagui/core'\nimport React, { useRef } from 'react'\nimport { forwardRef, useCallback, useEffect } from 'react'\n\nimport { registerFocusable, unregisterFocusable } from '../lib/registerFocusable'\n\nexport function focusableInputHOC<A extends Function>(Component: A): A {\n return forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n if (!props.id) return\n unregisterFocusable(props.id)\n }\n }, [props.id])\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText(value) {\n inputValue.current = value\n props.onChangeText?.(value)\n },\n }\n : props\n\n return <Component ref={combinedRefs} {...finalProps} />\n }\n ) as any\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEO,2BAA+C,WAAiB;AACrE,SAAO,WACL,CACE,OAMA,QACG;AACH,UAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,UAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AAEjE,UAAM,WAAW,YACf,CAAC,UAAU;AACT,UAAI,CAAC,MAAM;AAAI;AACf,UAAI,CAAC;AAAO;AACZ,wBAAkB,MAAM,IAAI;AAAA,QAC1B,OAAO,MAAM;AAAA,SAET,WAAW;AAAA,QAEb,iBAAiB;AACf,gBAAM,MAAM;AACZ,cAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,kBAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,UACjD;AAAA,QACF;AAAA,MACF,EACD;AAAA,IACH,GACA,CAAC,MAAM,EAAE,CACX;AAEA,UAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,cAAU,MAAM;AACd,aAAO,MAAM;AACX,YAAI,CAAC,MAAM;AAAI;AACf,4BAAoB,MAAM,EAAE;AAAA,MAC9B;AAAA,IACF,GAAG,CAAC,MAAM,EAAE,CAAC;AAEb,UAAM,aAAa,UACf,iCACK,QADL;AAAA,MAEE,aAAa,OAAO;AAtDhC;AAuDc,mBAAW,UAAU;AACrB,oBAAM,iBAAN,+BAAqB;AAAA,MACvB;AAAA,IACF,KACA;AAEJ,WAAO,oCAAC;AAAA,MAAU,KAAK;AAAA,OAAkB,WAAY;AAAA,EACvD,CACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getTokens } from "@tamagui/core";
|
|
2
|
-
const getSpace = (size, sizeUpOrDownBy = 0) => {
|
|
3
|
-
const spaces = getTokens().space;
|
|
4
|
-
const spaceNames = Object.keys(spaces);
|
|
5
|
-
const key = spaceNames[Math.max(0, spaceNames.indexOf(String(size || "$4")) + sizeUpOrDownBy)];
|
|
6
|
-
return spaces[key] || spaces["$4"];
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
getSpace
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=getSpace.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/getSpace.tsx"],
|
|
4
|
-
"sourcesContent": ["import { SpaceTokens, getTokens } from '@tamagui/core'\n\nexport const getSpace = (size?: SpaceTokens | undefined, sizeUpOrDownBy = 0) => {\n const spaces = getTokens().space as any as SpaceTokens\n const spaceNames = Object.keys(spaces)\n const key = spaceNames[Math.max(0, spaceNames.indexOf(String(size || '$4')) + sizeUpOrDownBy)]\n return (spaces[key] || spaces['$4']) as SpaceTokens\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAEO,MAAM,WAAW,CAAC,MAAgC,iBAAiB,MAAM;AAC9E,QAAM,SAAS,UAAU,EAAE;AAC3B,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,QAAM,MAAM,WAAW,KAAK,IAAI,GAAG,WAAW,QAAQ,OAAO,QAAQ,IAAI,CAAC,IAAI,cAAc;AAC5F,SAAQ,OAAO,QAAQ,OAAO;AAChC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|