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
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/views/LinearGradient.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n ColorTokens,\n ThemeTokens,\n getVariable,\n styled,\n themeable,\n useTheme,\n} from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport {\n LinearGradient as ExpoLinearGradient,\n LinearGradientProps as ExpoLinearGradientProps,\n} from '../lib/linear-gradient'\n\n//\nexport type LinearGradientProps = Omit<ExpoLinearGradientProps, 'colors'> &\n Omit<YStackProps, 'children' | keyof ExpoLinearGradientProps> & {\n colors?: (ColorTokens | ThemeTokens | (string & {}))[]\n }\n\nexport const LinearGradient: React.ForwardRefExoticComponent<\n LinearGradientProps & React.RefAttributes<HTMLElement | View>\n> = YStack.extractable(\n themeable(\n React.forwardRef((props: LinearGradientProps, ref) => {\n const {\n start,\n end,\n colors: colorsProp,\n locations,\n children,\n ...stackProps\n } = props\n const colors = useThemeColors(colorsProp || [])\n return (\n // @ts-ignore\n <LinearGradientFrame ref={ref} {...stackProps}>\n <ExpoLinearGradient\n start={start}\n end={end}\n colors={colors}\n locations={locations}\n style={StyleSheet.absoluteFill}\n >\n {children}\n </ExpoLinearGradient>\n </LinearGradientFrame>\n )\n }),\n ),\n) as any\n\nconst LinearGradientFrame = styled(YStack, {\n name: 'LinearGradient',\n overflow: 'hidden',\n position: 'relative',\n})\n\n// resolve tamagui theme values\nconst useThemeColors = (colors: string[]) => {\n const theme = useTheme()\n return colors.map((color) => {\n if (color[0] === '$') {\n return getVariable(theme[color] || color)\n }\n return color\n })\n}\n"],
|
|
5
|
-
"mappings": "AAwCU;AAxCV;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAA2B;AACpC,YAAY,WAAW;AACvB,SAAS,kBAAwB;AAEjC;AAAA,EACE,kBAAkB;AAAA,OAEb;AAQA,MAAM,iBAET,OAAO;AAAA,EACT;AAAA,IACE,MAAM,WAAW,CAAC,OAA4B,QAAQ;AACpD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,WACG;AAAA,MACL,IAAI;AACJ,YAAM,SAAS,eAAe,cAAc,CAAC,CAAC;AAC9C,aAEE,oBAAC;AAAA,QAAoB;AAAA,QAAW,GAAG;AAAA,QACjC,8BAAC;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO,WAAW;AAAA,UAEjB;AAAA,SACH;AAAA,OACF;AAAA,IAEJ,CAAC;AAAA,EACH;AACF;AAEA,MAAM,sBAAsB,OAAO,QAAQ;AAAA,EACzC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAGD,MAAM,iBAAiB,CAAC,WAAqB;AAC3C,QAAM,QAAQ,SAAS;AACvB,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,QAAI,MAAM,OAAO,KAAK;AACpB,aAAO,YAAY,MAAM,UAAU,KAAK;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,CAAC;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/views/Switch.js
DELETED
|
@@ -1,244 +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
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
33
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
34
|
-
import {
|
|
35
|
-
calc,
|
|
36
|
-
getSize,
|
|
37
|
-
getVariableValue,
|
|
38
|
-
isWeb,
|
|
39
|
-
styled,
|
|
40
|
-
themeable
|
|
41
|
-
} from "@tamagui/core";
|
|
42
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
43
|
-
import { ThemeableStack, XStack } from "@tamagui/stacks";
|
|
44
|
-
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
45
|
-
import * as React from "react";
|
|
46
|
-
import { registerFocusable } from "../lib/registerFocusable";
|
|
47
|
-
import { useLabelContext } from "./Label";
|
|
48
|
-
const SWITCH_NAME = "Switch";
|
|
49
|
-
const scopeContexts = createContextScope(SWITCH_NAME);
|
|
50
|
-
const [createSwitchContext] = scopeContexts;
|
|
51
|
-
const createSwitchScope = scopeContexts[1];
|
|
52
|
-
const [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
|
|
53
|
-
const getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65);
|
|
54
|
-
const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
|
|
55
|
-
const SwitchFrame = styled(XStack, {
|
|
56
|
-
name: "Switch",
|
|
57
|
-
tag: "button",
|
|
58
|
-
borderRadius: 1e3,
|
|
59
|
-
borderWidth: 2,
|
|
60
|
-
borderColor: "transparent",
|
|
61
|
-
backgroundColor: "$background",
|
|
62
|
-
focusStyle: {
|
|
63
|
-
borderColor: "$borderColorFocus"
|
|
64
|
-
},
|
|
65
|
-
variants: {
|
|
66
|
-
size: {
|
|
67
|
-
"...size": (val) => {
|
|
68
|
-
const height = calc(getSwitchHeight(val), "+", 4);
|
|
69
|
-
const width = calc(getSwitchWidth(val), "+", 4);
|
|
70
|
-
return {
|
|
71
|
-
height,
|
|
72
|
-
minHeight: height,
|
|
73
|
-
width
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
defaultVariants: {
|
|
79
|
-
size: "$4"
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const SwitchComponent = React.forwardRef((props, forwardedRef) => {
|
|
83
|
-
const _a = props, {
|
|
84
|
-
__scopeSwitch,
|
|
85
|
-
labeledBy: ariaLabelledby,
|
|
86
|
-
name,
|
|
87
|
-
checked: checkedProp,
|
|
88
|
-
defaultChecked,
|
|
89
|
-
required,
|
|
90
|
-
disabled,
|
|
91
|
-
value = "on",
|
|
92
|
-
onCheckedChange,
|
|
93
|
-
size = "$4"
|
|
94
|
-
} = _a, switchProps = __objRest(_a, [
|
|
95
|
-
"__scopeSwitch",
|
|
96
|
-
"labeledBy",
|
|
97
|
-
"name",
|
|
98
|
-
"checked",
|
|
99
|
-
"defaultChecked",
|
|
100
|
-
"required",
|
|
101
|
-
"disabled",
|
|
102
|
-
"value",
|
|
103
|
-
"onCheckedChange",
|
|
104
|
-
"size"
|
|
105
|
-
]);
|
|
106
|
-
const [button, setButton] = React.useState(null);
|
|
107
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
108
|
-
const labelId = useLabelContext(button);
|
|
109
|
-
const labelledBy = ariaLabelledby || labelId;
|
|
110
|
-
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
111
|
-
const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
112
|
-
const [checked = false, setChecked] = useControllableState({
|
|
113
|
-
prop: checkedProp,
|
|
114
|
-
defaultProp: defaultChecked || false,
|
|
115
|
-
onChange: onCheckedChange
|
|
116
|
-
});
|
|
117
|
-
if (!isWeb) {
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
if (!props.id)
|
|
120
|
-
return;
|
|
121
|
-
return registerFocusable(props.id, {
|
|
122
|
-
focus: () => {
|
|
123
|
-
setChecked((x) => !x);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}, [props.id]);
|
|
127
|
-
}
|
|
128
|
-
return /* @__PURE__ */ React.createElement(SwitchProvider, {
|
|
129
|
-
scope: __scopeSwitch,
|
|
130
|
-
checked,
|
|
131
|
-
disabled,
|
|
132
|
-
size
|
|
133
|
-
}, /* @__PURE__ */ React.createElement(SwitchFrame, __spreadProps(__spreadValues({
|
|
134
|
-
size,
|
|
135
|
-
role: "switch",
|
|
136
|
-
"aria-checked": checked,
|
|
137
|
-
"aria-labelledby": labelledBy,
|
|
138
|
-
"aria-required": required,
|
|
139
|
-
"data-state": getState(checked),
|
|
140
|
-
"data-disabled": disabled ? "" : void 0,
|
|
141
|
-
disabled,
|
|
142
|
-
tabIndex: disabled ? void 0 : 0,
|
|
143
|
-
value
|
|
144
|
-
}, switchProps), {
|
|
145
|
-
ref: composedRefs,
|
|
146
|
-
onPress: (event) => {
|
|
147
|
-
var _a2;
|
|
148
|
-
(_a2 = props.onPress) == null ? void 0 : _a2.call(props, event);
|
|
149
|
-
setChecked((prevChecked) => !prevChecked);
|
|
150
|
-
if (isWeb && isFormControl) {
|
|
151
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
152
|
-
if (!hasConsumerStoppedPropagationRef.current)
|
|
153
|
-
event.stopPropagation();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
})), isWeb && isFormControl && /* @__PURE__ */ React.createElement(BubbleInput, {
|
|
157
|
-
control: button,
|
|
158
|
-
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
159
|
-
name,
|
|
160
|
-
value,
|
|
161
|
-
checked,
|
|
162
|
-
required,
|
|
163
|
-
disabled,
|
|
164
|
-
style: { transform: "translateX(-100%)" }
|
|
165
|
-
}));
|
|
166
|
-
});
|
|
167
|
-
SwitchComponent.displayName = SWITCH_NAME;
|
|
168
|
-
const Switch = SwitchFrame.extractable(themeable(SwitchComponent), {
|
|
169
|
-
neverFlatten: true
|
|
170
|
-
});
|
|
171
|
-
const THUMB_NAME = "SwitchThumb";
|
|
172
|
-
const SwitchThumbFrame = styled(ThemeableStack, {
|
|
173
|
-
name: "SwitchThumb",
|
|
174
|
-
backgroundColor: "$background",
|
|
175
|
-
borderRadius: 1e3,
|
|
176
|
-
variants: {
|
|
177
|
-
size: {
|
|
178
|
-
"...size": (val) => ({
|
|
179
|
-
height: getSwitchHeight(val),
|
|
180
|
-
width: getSwitchHeight(val)
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
defaultVariants: {
|
|
185
|
-
size: "$4"
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
const SwitchThumb = SwitchThumbFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
189
|
-
const _a = props, { __scopeSwitch } = _a, thumbProps = __objRest(_a, ["__scopeSwitch"]);
|
|
190
|
-
const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch);
|
|
191
|
-
return /* @__PURE__ */ React.createElement(SwitchThumbFrame, __spreadProps(__spreadValues({
|
|
192
|
-
size,
|
|
193
|
-
"data-state": getState(checked),
|
|
194
|
-
"data-disabled": disabled ? "" : void 0
|
|
195
|
-
}, thumbProps), {
|
|
196
|
-
x: checked ? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size)) : 0,
|
|
197
|
-
ref: forwardedRef
|
|
198
|
-
}));
|
|
199
|
-
}), {
|
|
200
|
-
neverFlatten: true
|
|
201
|
-
});
|
|
202
|
-
SwitchThumb.displayName = THUMB_NAME;
|
|
203
|
-
Switch.Thumb = SwitchThumb;
|
|
204
|
-
const BubbleInput = (props) => {
|
|
205
|
-
const _a = props, { control, checked, bubbles = true } = _a, inputProps = __objRest(_a, ["control", "checked", "bubbles"]);
|
|
206
|
-
const ref = React.useRef(null);
|
|
207
|
-
const prevChecked = usePrevious(checked);
|
|
208
|
-
React.useEffect(() => {
|
|
209
|
-
const input = ref.current;
|
|
210
|
-
const inputProto = window.HTMLInputElement.prototype;
|
|
211
|
-
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
212
|
-
const setChecked = descriptor.set;
|
|
213
|
-
if (prevChecked !== checked && setChecked) {
|
|
214
|
-
const event = new Event("click", { bubbles });
|
|
215
|
-
setChecked.call(input, checked);
|
|
216
|
-
input.dispatchEvent(event);
|
|
217
|
-
}
|
|
218
|
-
}, [prevChecked, checked, bubbles]);
|
|
219
|
-
return /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({
|
|
220
|
-
type: "checkbox",
|
|
221
|
-
"aria-hidden": true,
|
|
222
|
-
defaultChecked: checked
|
|
223
|
-
}, inputProps), {
|
|
224
|
-
tabIndex: -1,
|
|
225
|
-
ref,
|
|
226
|
-
style: __spreadProps(__spreadValues({}, props.style), {
|
|
227
|
-
position: "absolute",
|
|
228
|
-
pointerEvents: "none",
|
|
229
|
-
opacity: 0,
|
|
230
|
-
margin: 0
|
|
231
|
-
})
|
|
232
|
-
}));
|
|
233
|
-
};
|
|
234
|
-
function getState(checked) {
|
|
235
|
-
return checked ? "checked" : "unchecked";
|
|
236
|
-
}
|
|
237
|
-
export {
|
|
238
|
-
Switch,
|
|
239
|
-
SwitchFrame,
|
|
240
|
-
SwitchThumb,
|
|
241
|
-
SwitchThumbFrame,
|
|
242
|
-
createSwitchScope
|
|
243
|
-
};
|
|
244
|
-
//# 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AACA;AACA;AACA;AAGA;AACA;AAEA,MAAM,cAAc;AAEpB,MAAM,gBAAgB,mBAAmB,WAAW;AACpD,MAAM,CAAC,uBAAuB;AACvB,MA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OAAO,iBAAiB;AAC3C,UAAM,aAAa,OAAO,yBAAyB,YAAY,SAAS;AACxE,UAAM,aAAa,WAAW;AAC9B,QAAI,gBAAgB,WAAW,YAAY;AACzC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,iBAAW,KAAK,OAAO,OAAO;AAC9B,YAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAElC,SACE,oCAAC;AAAA,IACC,MAAK;AAAA,IACL,eAAW;AAAA,IACX,gBAAgB;AAAA,KACZ,aAJL;AAAA,IAKC,UAAU;AAAA,IACV;AAAA,IACA,OAAO,iCACF,MAAM,QADJ;AAAA,MAGL,UAAU;AAAA,MACV,eAAe;AAAA,MACf,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACF;AAEJ;AAEA,kBAAkB,SAAkB;AAClC,SAAO,UAAU,YAAY;AAC/B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/views/Table.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Stack, Text, isWeb, styled } from "@tamagui/core";
|
|
2
|
-
const Table = styled(Stack, {
|
|
3
|
-
name: "Table",
|
|
4
|
-
tag: "table"
|
|
5
|
-
});
|
|
6
|
-
const TableRow = styled(Stack, {
|
|
7
|
-
name: "TableRow",
|
|
8
|
-
tag: "tr",
|
|
9
|
-
alignSelf: "stretch",
|
|
10
|
-
flex: 1
|
|
11
|
-
});
|
|
12
|
-
const TableHead = styled(Stack, {
|
|
13
|
-
name: "TableHead",
|
|
14
|
-
tag: "thead",
|
|
15
|
-
flexDirection: "row",
|
|
16
|
-
alignSelf: "stretch",
|
|
17
|
-
flex: 1,
|
|
18
|
-
borderBottomColor: "#eee",
|
|
19
|
-
borderBottomWidth: 1
|
|
20
|
-
});
|
|
21
|
-
const TableHeadCell = styled(Stack, {
|
|
22
|
-
name: "TableHeadCell",
|
|
23
|
-
tag: "th",
|
|
24
|
-
display: isWeb ? "table-head" : "flex",
|
|
25
|
-
flexDirection: "row"
|
|
26
|
-
});
|
|
27
|
-
const TableHeadText = styled(Text, {
|
|
28
|
-
name: "TableHeadText",
|
|
29
|
-
backgroundColor: "rgba(0,0,0,0.05)",
|
|
30
|
-
padding: 2,
|
|
31
|
-
paddingHorizontal: 8,
|
|
32
|
-
marginLeft: -8,
|
|
33
|
-
borderRadius: 10,
|
|
34
|
-
maxWidth: "100%",
|
|
35
|
-
ellipse: true,
|
|
36
|
-
fontSize: 12
|
|
37
|
-
});
|
|
38
|
-
const TableCell = styled(Stack, {
|
|
39
|
-
name: "TableCell",
|
|
40
|
-
flex: 1,
|
|
41
|
-
alignSelf: "stretch",
|
|
42
|
-
alignItems: "center",
|
|
43
|
-
tag: "td",
|
|
44
|
-
display: isWeb ? "table-cell" : "flex",
|
|
45
|
-
paddingVertical: "$3",
|
|
46
|
-
paddingHorizontal: "$2"
|
|
47
|
-
});
|
|
48
|
-
export {
|
|
49
|
-
Table,
|
|
50
|
-
TableCell,
|
|
51
|
-
TableHead,
|
|
52
|
-
TableHeadCell,
|
|
53
|
-
TableHeadText,
|
|
54
|
-
TableRow
|
|
55
|
-
};
|
|
56
|
-
//# 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;AAEO,MAAM,QAAQ,OAAO,OAAO;AAAA,EACjC,MAAM;AAAA,EACN,KAAK;AACP,CAAC;AAEM,MAAM,WAAW,OAAO,OAAO;AAAA,EACpC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA,EACX,MAAM;AACR,CAAC;AAEM,MAAM,YAAY,OAAO,OAAO;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,OAAO,OAAO;AAAA,EACzC,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,SAAS,QAAQ,eAAe;AAAA,EAChC,eAAe;AACjB,CAAC;AAEM,MAAM,gBAAgB,OAAO,MAAM;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,OAAO,OAAO;AAAA,EACrC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,KAAK;AAAA,EAEL,SAAS,QAAQ,eAAe;AAAA,EAGhC,iBAAiB;AAAA,EACjB,mBAAmB;AACrB,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/views/Toast.js
DELETED
|
@@ -1,107 +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 { AnimatePresence } from "@tamagui/animate-presence";
|
|
21
|
-
import { Theme, isWeb } from "@tamagui/core";
|
|
22
|
-
import { YStack } from "@tamagui/stacks";
|
|
23
|
-
import { Paragraph } from "@tamagui/text";
|
|
24
|
-
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
25
|
-
import { memo, useCallback, useEffect, useRef } from "react";
|
|
26
|
-
import { createPortal } from "react-dom";
|
|
27
|
-
let clear = () => {
|
|
28
|
-
};
|
|
29
|
-
let show = (content) => {
|
|
30
|
-
console.warn("Note:", content);
|
|
31
|
-
};
|
|
32
|
-
const Toast = {
|
|
33
|
-
clear,
|
|
34
|
-
show: (content, options) => show(content, options),
|
|
35
|
-
error: (content, options) => show(content, __spreadProps(__spreadValues({}, options), { type: "error" })),
|
|
36
|
-
success: (content, options) => show(content, __spreadProps(__spreadValues({}, options), { type: "success" }))
|
|
37
|
-
};
|
|
38
|
-
if (typeof window !== "undefined") {
|
|
39
|
-
window["Toast"] = Toast;
|
|
40
|
-
}
|
|
41
|
-
const ToastRoot = memo(function ToastRoot2(props) {
|
|
42
|
-
const forceUpdate = useForceUpdate();
|
|
43
|
-
const stateRef = useRef({
|
|
44
|
-
show: false,
|
|
45
|
-
content: "",
|
|
46
|
-
type: "info",
|
|
47
|
-
timeout: null
|
|
48
|
-
});
|
|
49
|
-
const setState = (x) => {
|
|
50
|
-
stateRef.current = x;
|
|
51
|
-
forceUpdate();
|
|
52
|
-
};
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
return () => {
|
|
55
|
-
clearTimeout(stateRef.current.timeout ?? 0);
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
clear = () => {
|
|
59
|
-
setState({ show: false, content: "" });
|
|
60
|
-
};
|
|
61
|
-
show = useCallback((content, { duration = 3e3, type = "info" } = {}) => {
|
|
62
|
-
clearTimeout(stateRef.current.timeout ?? 0);
|
|
63
|
-
const timeout = setTimeout(() => {
|
|
64
|
-
setState({
|
|
65
|
-
show: false,
|
|
66
|
-
content: "",
|
|
67
|
-
type,
|
|
68
|
-
timeout: null
|
|
69
|
-
});
|
|
70
|
-
}, duration);
|
|
71
|
-
setState({
|
|
72
|
-
show: true,
|
|
73
|
-
content,
|
|
74
|
-
type,
|
|
75
|
-
timeout
|
|
76
|
-
});
|
|
77
|
-
}, [stateRef]);
|
|
78
|
-
const state = stateRef.current;
|
|
79
|
-
const contents = /* @__PURE__ */ React.createElement(YStack, {
|
|
80
|
-
position: "absolute",
|
|
81
|
-
pointerEvents: "none",
|
|
82
|
-
fullscreen: true,
|
|
83
|
-
alignItems: "center",
|
|
84
|
-
justifyContent: "flex-end",
|
|
85
|
-
zIndex: 1e10,
|
|
86
|
-
padding: "5%"
|
|
87
|
-
}, /* @__PURE__ */ React.createElement(Theme, {
|
|
88
|
-
name: state.type === "info" ? null : state.type === "success" ? "green" : "red"
|
|
89
|
-
}, /* @__PURE__ */ React.createElement(AnimatePresence, null, state.show && !!state.content && /* @__PURE__ */ React.createElement(YStack, {
|
|
90
|
-
animation: props.animation || "toast",
|
|
91
|
-
backgroundColor: "$background",
|
|
92
|
-
elevation: "$2",
|
|
93
|
-
borderRadius: "$4",
|
|
94
|
-
paddingHorizontal: "$4",
|
|
95
|
-
paddingVertical: "$3"
|
|
96
|
-
}, /* @__PURE__ */ React.createElement(Paragraph, null, state.content)))));
|
|
97
|
-
const portalEl = document.getElementById("toasts");
|
|
98
|
-
if (isWeb && portalEl) {
|
|
99
|
-
return createPortal(contents, portalEl);
|
|
100
|
-
}
|
|
101
|
-
return contents;
|
|
102
|
-
});
|
|
103
|
-
export {
|
|
104
|
-
Toast,
|
|
105
|
-
ToastRoot
|
|
106
|
-
};
|
|
107
|
-
//# 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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M;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,uBACE,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,iBAAW,MAAM,OAAQ,CAC5B,CAEJ,CACF,CACF;AAGF,QAAM,WAAW,SAAS,eAAe,QAAQ;AAEjD,MAAI,SAAS,UAAU;AACrB,WAAO,aAAa,UAAU,QAAQ;AAAA,EACxC;AAEA,SAAO;AACT,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { isTamaguiComponent } from "@tamagui/core";
|
|
3
|
-
import { useRef } from "react";
|
|
4
|
-
import { forwardRef, useCallback, useEffect } from "react";
|
|
5
|
-
import { registerFocusable, unregisterFocusable } from "../lib/registerFocusable";
|
|
6
|
-
function focusableInputHOC(Component) {
|
|
7
|
-
return forwardRef((props, ref) => {
|
|
8
|
-
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
9
|
-
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
10
|
-
const inputRef = useCallback((input) => {
|
|
11
|
-
if (!props.id)
|
|
12
|
-
return;
|
|
13
|
-
if (!input)
|
|
14
|
-
return;
|
|
15
|
-
registerFocusable(props.id, {
|
|
16
|
-
focus: input.focus,
|
|
17
|
-
...isInput && {
|
|
18
|
-
focusAndSelect() {
|
|
19
|
-
input.focus();
|
|
20
|
-
if (input.setSelection && typeof inputValue.current === "string") {
|
|
21
|
-
input.setSelection(0, inputValue.current.length);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}, [props.id]);
|
|
27
|
-
const combinedRefs = composeRefs(ref, inputRef);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
return () => {
|
|
30
|
-
if (!props.id)
|
|
31
|
-
return;
|
|
32
|
-
unregisterFocusable(props.id);
|
|
33
|
-
};
|
|
34
|
-
}, [props.id]);
|
|
35
|
-
const finalProps = isInput ? {
|
|
36
|
-
...props,
|
|
37
|
-
onChangeText(value) {
|
|
38
|
-
var _a;
|
|
39
|
-
inputValue.current = value;
|
|
40
|
-
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
41
|
-
}
|
|
42
|
-
} : props;
|
|
43
|
-
return <Component ref={combinedRefs} {...finalProps} />;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
focusableInputHOC
|
|
48
|
-
};
|
|
49
|
-
//# 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,QAEb,GAAI,WAAW;AAAA,UAEb,iBAAiB;AACf,kBAAM,MAAM;AACZ,gBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,oBAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,YACjD;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;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;AAAA,MACE,GAAG;AAAA,MACH,aAAa,OAAO;AAtDhC;AAuDc,mBAAW,UAAU;AACrB,oBAAM,iBAAN,+BAAqB;AAAA,MACvB;AAAA,IACF,IACA;AAEJ,WAAO,CAAC,UAAU,KAAK,kBAAkB,YAAY;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
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { isWeb } from "@tamagui/core";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { BackHandler } from "react-native";
|
|
4
|
-
let keyboardDismissHandlers = [];
|
|
5
|
-
const keyboardDismissHandlerManager = {
|
|
6
|
-
push: (handler) => {
|
|
7
|
-
keyboardDismissHandlers.push(handler);
|
|
8
|
-
return () => {
|
|
9
|
-
keyboardDismissHandlers = keyboardDismissHandlers.filter((h) => h !== handler);
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
length: () => keyboardDismissHandlers.length,
|
|
13
|
-
pop: () => {
|
|
14
|
-
return keyboardDismissHandlers.pop();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const useKeyboardDismissable = ({ enabled, callback }) => {
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
let cleanupFn = () => {
|
|
20
|
-
};
|
|
21
|
-
if (enabled) {
|
|
22
|
-
cleanupFn = keyboardDismissHandlerManager.push(callback);
|
|
23
|
-
} else {
|
|
24
|
-
cleanupFn();
|
|
25
|
-
}
|
|
26
|
-
return () => {
|
|
27
|
-
cleanupFn();
|
|
28
|
-
};
|
|
29
|
-
}, [enabled, callback]);
|
|
30
|
-
useBackHandler({ enabled, callback });
|
|
31
|
-
};
|
|
32
|
-
const callbackOnEscape = (callback) => (e) => {
|
|
33
|
-
if (e.key === "Escape") {
|
|
34
|
-
if (!(document.activeElement instanceof HTMLInputElement) && !(document.activeElement instanceof HTMLTextAreaElement)) {
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
e.stopPropagation();
|
|
37
|
-
callback();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function useBackHandler({ enabled, callback }) {
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
let backHandler = () => {
|
|
44
|
-
callback();
|
|
45
|
-
return true;
|
|
46
|
-
};
|
|
47
|
-
const keyHandler = callbackOnEscape(callback);
|
|
48
|
-
if (enabled) {
|
|
49
|
-
BackHandler.addEventListener("hardwareBackPress", backHandler);
|
|
50
|
-
if (isWeb) {
|
|
51
|
-
window.addEventListener("keydown", keyHandler);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
55
|
-
}
|
|
56
|
-
return () => {
|
|
57
|
-
BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
58
|
-
if (isWeb) {
|
|
59
|
-
window.removeEventListener("keydown", keyHandler);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}, [enabled, callback]);
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
keyboardDismissHandlerManager,
|
|
66
|
-
useBackHandler,
|
|
67
|
-
useKeyboardDismissable
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=useKeyboardDismissable.js.map
|