@tamagui/core 1.0.0-alpha.0 → 1.0.0-alpha.5
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/LICENSE +21 -0
- package/dist/constants/platform.js +1 -1
- package/dist/constants/platform.js.map +2 -2
- package/dist/createComponent.js +1 -1
- package/dist/createComponent.js.map +2 -2
- package/dist/hooks/useMedia.js +1 -1
- package/dist/hooks/useMedia.js.map +2 -2
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTheme.js.map +2 -2
- package/dist/index.cjs +57 -79
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +0 -1
- package/dist/index.js.map +2 -2
- package/package.json +12 -4
- package/src/constants/platform.ts +1 -1
- package/src/createComponent.tsx +2 -1
- package/src/hooks/useMedia.tsx +1 -1
- package/src/hooks/useTheme.tsx +1 -1
- package/src/index.ts +0 -1
- package/types.d.ts +0 -1
- package/.ultra.cache.json +0 -1
- package/_/constants/constants.js +0 -14
- package/_/constants/constants.js.map +0 -7
- package/_/constants/platform.js +0 -20
- package/_/constants/platform.js.map +0 -7
- package/_/constants/pseudos.js +0 -18
- package/_/constants/pseudos.js.map +0 -7
- package/_/constants/rnw.js +0 -22
- package/_/constants/rnw.js.map +0 -7
- package/_/createComponent.js +0 -427
- package/_/createComponent.js.map +0 -7
- package/_/createShorthands.js +0 -10
- package/_/createShorthands.js.map +0 -7
- package/_/createTamagui.js +0 -122
- package/_/createTamagui.js.map +0 -7
- package/_/createTheme.js +0 -20
- package/_/createTheme.js.map +0 -7
- package/_/createTokens.js +0 -29
- package/_/createTokens.js.map +0 -7
- package/_/createVariable.js +0 -22
- package/_/createVariable.js.map +0 -7
- package/_/helpers/addStylesUsingClassname.js +0 -32
- package/_/helpers/addStylesUsingClassname.js.map +0 -7
- package/_/helpers/createMediaStyle.js +0 -34
- package/_/helpers/createMediaStyle.js.map +0 -7
- package/_/helpers/createTamaguiProvider.js +0 -42
- package/_/helpers/createTamaguiProvider.js.map +0 -7
- package/_/helpers/extendStaticConfig.js +0 -176
- package/_/helpers/extendStaticConfig.js.map +0 -7
- package/_/helpers/fixNativeShadow.js +0 -8
- package/_/helpers/fixNativeShadow.js.map +0 -7
- package/_/helpers/fixNativeShadow.native.js +0 -30
- package/_/helpers/fixNativeShadow.native.js.map +0 -7
- package/_/helpers/getSplitStyles.js +0 -160
- package/_/helpers/getSplitStyles.js.map +0 -7
- package/_/helpers/getStylesAtomic.js +0 -84
- package/_/helpers/getStylesAtomic.js.map +0 -7
- package/_/helpers/getStylesAtomic.native.js +0 -10
- package/_/helpers/getStylesAtomic.native.js.map +0 -7
- package/_/helpers/insertStyleRule.js +0 -24
- package/_/helpers/insertStyleRule.js.map +0 -7
- package/_/helpers/matchMedia.js +0 -15
- package/_/helpers/matchMedia.js.map +0 -7
- package/_/helpers/matchMedia.native.js +0 -8
- package/_/helpers/matchMedia.native.js.map +0 -7
- package/_/helpers/themeable.js +0 -26
- package/_/helpers/themeable.js.map +0 -7
- package/_/hooks/useConstant.js +0 -15
- package/_/hooks/useConstant.js.map +0 -7
- package/_/hooks/useFeatures.js +0 -75
- package/_/hooks/useFeatures.js.map +0 -7
- package/_/hooks/useForceUpdate.js +0 -28
- package/_/hooks/useForceUpdate.js.map +0 -7
- package/_/hooks/useMedia.js +0 -173
- package/_/hooks/useMedia.js.map +0 -7
- package/_/hooks/usePressable.js +0 -14
- package/_/hooks/usePressable.js.map +0 -7
- package/_/hooks/useTheme.js +0 -94
- package/_/hooks/useTheme.js.map +0 -7
- package/_/index.js +0 -30
- package/_/index.js.map +0 -7
- package/_/static/postProcessStyles.js +0 -18
- package/_/static/postProcessStyles.js.map +0 -7
- package/_/static.js +0 -12
- package/_/static.js.map +0 -7
- package/_/styled.js +0 -21
- package/_/styled.js.map +0 -7
- package/_/types.js +0 -1
- package/_/types.js.map +0 -7
- package/_/views/Animated.js +0 -79
- package/_/views/Animated.js.map +0 -7
- package/_/views/Stack.js +0 -12
- package/_/views/Stack.js.map +0 -7
- package/_/views/Text.js +0 -60
- package/_/views/Text.js.map +0 -7
- package/_/views/TextAncestorContext.js +0 -19
- package/_/views/TextAncestorContext.js.map +0 -7
- package/_/views/Theme.js +0 -57
- package/_/views/Theme.js.map +0 -7
- package/_/views/ThemeContext.js +0 -6
- package/_/views/ThemeContext.js.map +0 -7
- package/_/views/ThemeInverse.js +0 -27
- package/_/views/ThemeInverse.js.map +0 -7
- package/_/views/ThemeManagerContext.js +0 -56
- package/_/views/ThemeManagerContext.js.map +0 -7
- package/_/views/ThemeProvider.js +0 -45
- package/_/views/ThemeProvider.js.map +0 -7
- package/src/hooks/useForceUpdate.tsx +0 -26
- package/tsconfig.json +0 -8
package/_/createComponent.js
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { concatClassName, stylePropsView } from "@tamagui/helpers";
|
|
4
|
-
import React, {
|
|
5
|
-
Children,
|
|
6
|
-
Fragment,
|
|
7
|
-
createElement,
|
|
8
|
-
forwardRef,
|
|
9
|
-
useCallback,
|
|
10
|
-
useContext,
|
|
11
|
-
useEffect,
|
|
12
|
-
useRef,
|
|
13
|
-
useState
|
|
14
|
-
} from "react";
|
|
15
|
-
import { Text, View } from "react-native";
|
|
16
|
-
import { stackDefaultStyles } from "./constants/constants";
|
|
17
|
-
import { isTouchDevice, isWeb } from "./constants/platform";
|
|
18
|
-
import { rnw } from "./constants/rnw";
|
|
19
|
-
import { onConfiguredOnce } from "./createTamagui";
|
|
20
|
-
import { addStylesUsingClassname } from "./helpers/addStylesUsingClassname";
|
|
21
|
-
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
22
|
-
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
23
|
-
import { useFeatures } from "./hooks/useFeatures";
|
|
24
|
-
import { useForceUpdate } from "./hooks/useForceUpdate";
|
|
25
|
-
import { usePressable } from "./hooks/usePressable";
|
|
26
|
-
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
27
|
-
import { ThemeManagerContext } from "./views/ThemeManagerContext";
|
|
28
|
-
const mouseUps = new Set();
|
|
29
|
-
if (typeof document !== "undefined") {
|
|
30
|
-
document.addEventListener("mouseup", () => {
|
|
31
|
-
mouseUps.forEach((x) => x());
|
|
32
|
-
mouseUps.clear();
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function createComponent(configIn) {
|
|
36
|
-
let staticConfig;
|
|
37
|
-
if ("parsed" in configIn) {
|
|
38
|
-
staticConfig = configIn;
|
|
39
|
-
} else {
|
|
40
|
-
staticConfig = parseStaticConfig(configIn);
|
|
41
|
-
}
|
|
42
|
-
const { Component, validStyles, isText } = staticConfig;
|
|
43
|
-
const validStyleProps = validStyles != null ? validStyles : stylePropsView;
|
|
44
|
-
let defaultProps = null;
|
|
45
|
-
let tamaguiConfig;
|
|
46
|
-
let defaultsStyle;
|
|
47
|
-
let defaultsClassName = "";
|
|
48
|
-
let initialTheme;
|
|
49
|
-
const component = forwardRef((props, forwardedRef) => {
|
|
50
|
-
var _a;
|
|
51
|
-
const {
|
|
52
|
-
tag,
|
|
53
|
-
hitSlop,
|
|
54
|
-
children,
|
|
55
|
-
pointerEvents,
|
|
56
|
-
onPress,
|
|
57
|
-
onPressIn,
|
|
58
|
-
onPressOut,
|
|
59
|
-
onHoverIn,
|
|
60
|
-
onHoverOut,
|
|
61
|
-
space,
|
|
62
|
-
disabled,
|
|
63
|
-
onMouseEnter,
|
|
64
|
-
onMouseLeave,
|
|
65
|
-
hrefAttrs,
|
|
66
|
-
onMoveShouldSetResponder,
|
|
67
|
-
onMoveShouldSetResponderCapture,
|
|
68
|
-
onResponderEnd,
|
|
69
|
-
onResponderGrant,
|
|
70
|
-
onResponderMove,
|
|
71
|
-
onResponderReject,
|
|
72
|
-
onResponderRelease,
|
|
73
|
-
onResponderStart,
|
|
74
|
-
onResponderTerminate,
|
|
75
|
-
onResponderTerminationRequest,
|
|
76
|
-
onScrollShouldSetResponder,
|
|
77
|
-
onScrollShouldSetResponderCapture,
|
|
78
|
-
onSelectionChangeShouldSetResponder,
|
|
79
|
-
onSelectionChangeShouldSetResponderCapture,
|
|
80
|
-
onStartShouldSetResponder,
|
|
81
|
-
onStartShouldSetResponderCapture,
|
|
82
|
-
onMouseDown,
|
|
83
|
-
onClick,
|
|
84
|
-
onLayout
|
|
85
|
-
} = props;
|
|
86
|
-
const forceUpdate = useForceUpdate();
|
|
87
|
-
const features = useFeatures(props, { forceUpdate });
|
|
88
|
-
const manager = useContext(ThemeManagerContext);
|
|
89
|
-
const [state, set_] = useState(() => ({
|
|
90
|
-
hover: false,
|
|
91
|
-
press: false,
|
|
92
|
-
pressIn: false,
|
|
93
|
-
theme: manager.name
|
|
94
|
-
}));
|
|
95
|
-
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
96
|
-
for (const key in next) {
|
|
97
|
-
if (prev[key] !== next[key]) {
|
|
98
|
-
return { ...prev, ...next };
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return prev;
|
|
102
|
-
}), "set");
|
|
103
|
-
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
104
|
-
Children.toArray(props.children).forEach((item) => {
|
|
105
|
-
if (typeof item === "string") {
|
|
106
|
-
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
111
|
-
const hostRef = useRef(null);
|
|
112
|
-
if (isWeb) {
|
|
113
|
-
rnw.useResponderEvents(hostRef, {
|
|
114
|
-
onMoveShouldSetResponder,
|
|
115
|
-
onMoveShouldSetResponderCapture,
|
|
116
|
-
onResponderEnd,
|
|
117
|
-
onResponderGrant,
|
|
118
|
-
onResponderMove,
|
|
119
|
-
onResponderReject,
|
|
120
|
-
onResponderRelease,
|
|
121
|
-
onResponderStart,
|
|
122
|
-
onResponderTerminate,
|
|
123
|
-
onResponderTerminationRequest,
|
|
124
|
-
onScrollShouldSetResponder,
|
|
125
|
-
onScrollShouldSetResponderCapture,
|
|
126
|
-
onSelectionChangeShouldSetResponder,
|
|
127
|
-
onSelectionChangeShouldSetResponderCapture,
|
|
128
|
-
onStartShouldSetResponder,
|
|
129
|
-
onStartShouldSetResponderCapture
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
const isTracking = useRef(false);
|
|
133
|
-
const { viewProps, pseudos, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
|
|
134
|
-
const internal = useRef();
|
|
135
|
-
if (!internal.current) {
|
|
136
|
-
internal.current = {
|
|
137
|
-
isMounted: true
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
internal.current.isMounted = true;
|
|
142
|
-
const dispose = manager == null ? void 0 : manager.onChangeTheme((name) => {
|
|
143
|
-
if (isTracking.current) {
|
|
144
|
-
set({ theme: name });
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return () => {
|
|
148
|
-
dispose();
|
|
149
|
-
mouseUps.delete(unPress);
|
|
150
|
-
isTracking.current = false;
|
|
151
|
-
internal.current.isMounted = false;
|
|
152
|
-
};
|
|
153
|
-
}, [manager]);
|
|
154
|
-
const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
|
|
155
|
-
const ReactView = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
|
|
156
|
-
const ReactText = !isWeb ? Text : element || "span";
|
|
157
|
-
const ViewComponent = isText ? ReactText : ReactView;
|
|
158
|
-
const isHovering = !isTouchDevice && !disabled && pseudos && state.hover;
|
|
159
|
-
const isPressing = !disabled && pseudos && state.press;
|
|
160
|
-
const styles = [
|
|
161
|
-
style,
|
|
162
|
-
isHovering ? pseudos.hoverStyle || null : null,
|
|
163
|
-
isPressing ? pseudos.pressStyle || null : null
|
|
164
|
-
];
|
|
165
|
-
if (isWeb) {
|
|
166
|
-
const stylesClassNames = addStylesUsingClassname(styles);
|
|
167
|
-
const classList = staticConfig.isText ? [
|
|
168
|
-
defaultsClassName,
|
|
169
|
-
classNames,
|
|
170
|
-
stylesClassNames,
|
|
171
|
-
props.className
|
|
172
|
-
] : [defaultsClassName, props.className, classNames, stylesClassNames];
|
|
173
|
-
const classListFlat = classList.flat(1).filter(Boolean).join(" ");
|
|
174
|
-
const className = concatClassName(classListFlat);
|
|
175
|
-
if (process.env.NODE_ENV === "development") {
|
|
176
|
-
if (props["debug"]) {
|
|
177
|
-
console.log("\u{1F95A} className", { style, styles, stylesClassNames, classListFlat: classListFlat.split(" "), className });
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
viewProps.className = className;
|
|
181
|
-
} else {
|
|
182
|
-
viewProps.style = styles;
|
|
183
|
-
}
|
|
184
|
-
if (pointerEvents) {
|
|
185
|
-
viewProps.pointerEvents = pointerEvents;
|
|
186
|
-
}
|
|
187
|
-
if (isWeb) {
|
|
188
|
-
const platformMethodsRef = rnw.usePlatformMethods(viewProps);
|
|
189
|
-
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
|
|
190
|
-
viewProps.ref = setRef;
|
|
191
|
-
if (props.href != null && hrefAttrs != null) {
|
|
192
|
-
const { download, rel, target } = hrefAttrs;
|
|
193
|
-
if (download != null) {
|
|
194
|
-
viewProps.download = download;
|
|
195
|
-
}
|
|
196
|
-
if (rel != null) {
|
|
197
|
-
viewProps.rel = rel;
|
|
198
|
-
}
|
|
199
|
-
if (typeof target === "string") {
|
|
200
|
-
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
if (forwardedRef) {
|
|
205
|
-
viewProps.ref = forwardedRef;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
209
|
-
const attachHover = isWeb && !isTouchDevice && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
210
|
-
const shouldAttach = internal.current.hasEverHadEvents || attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onClick" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
|
|
211
|
-
if (shouldAttach) {
|
|
212
|
-
internal.current.hasEverHadEvents = true;
|
|
213
|
-
}
|
|
214
|
-
const unPress = useCallback(() => {
|
|
215
|
-
if (!internal.current.isMounted)
|
|
216
|
-
return;
|
|
217
|
-
set({
|
|
218
|
-
press: false,
|
|
219
|
-
pressIn: false
|
|
220
|
-
});
|
|
221
|
-
}, []);
|
|
222
|
-
const events = shouldAttach ? {
|
|
223
|
-
...!isWeb && {
|
|
224
|
-
onPressOut: (e) => {
|
|
225
|
-
unPress();
|
|
226
|
-
onPressOut == null ? void 0 : onPressOut(e);
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
...isWeb && !isTouchDevice && {
|
|
230
|
-
onMouseEnter: attachHover || attachPress ? (e) => {
|
|
231
|
-
let next = {};
|
|
232
|
-
if (attachHover) {
|
|
233
|
-
next.hover = true;
|
|
234
|
-
}
|
|
235
|
-
if (state.pressIn) {
|
|
236
|
-
next.press = true;
|
|
237
|
-
}
|
|
238
|
-
if (Object.keys(next).length) {
|
|
239
|
-
set(next);
|
|
240
|
-
}
|
|
241
|
-
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
242
|
-
onMouseEnter == null ? void 0 : onMouseEnter(e);
|
|
243
|
-
} : void 0,
|
|
244
|
-
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
245
|
-
let next = {};
|
|
246
|
-
mouseUps.add(unPress);
|
|
247
|
-
if (attachHover) {
|
|
248
|
-
next.hover = false;
|
|
249
|
-
}
|
|
250
|
-
if (state.pressIn) {
|
|
251
|
-
next.press = false;
|
|
252
|
-
next.pressIn = false;
|
|
253
|
-
}
|
|
254
|
-
if (Object.keys(next).length) {
|
|
255
|
-
set(next);
|
|
256
|
-
}
|
|
257
|
-
onHoverOut == null ? void 0 : onHoverOut(e);
|
|
258
|
-
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
259
|
-
} : void 0
|
|
260
|
-
},
|
|
261
|
-
onMouseDown: attachPress ? (e) => {
|
|
262
|
-
set({
|
|
263
|
-
press: true,
|
|
264
|
-
pressIn: true
|
|
265
|
-
});
|
|
266
|
-
onPressIn == null ? void 0 : onPressIn(e);
|
|
267
|
-
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
268
|
-
} : onPressIn,
|
|
269
|
-
onClick: attachPress ? (e) => {
|
|
270
|
-
onPress == null ? void 0 : onPress(e);
|
|
271
|
-
onClick == null ? void 0 : onClick(e);
|
|
272
|
-
unPress();
|
|
273
|
-
onPressOut == null ? void 0 : onPressOut(e);
|
|
274
|
-
} : onPressOut
|
|
275
|
-
} : null;
|
|
276
|
-
if (events) {
|
|
277
|
-
if (typeof ViewComponent !== "string") {
|
|
278
|
-
const [pressProps] = usePressable({
|
|
279
|
-
disabled,
|
|
280
|
-
hitSlop,
|
|
281
|
-
onPressIn: events.onMouseDown,
|
|
282
|
-
onPressOut: events.onPressOut,
|
|
283
|
-
onPress: events.onClick
|
|
284
|
-
});
|
|
285
|
-
Object.assign(viewProps, pressProps);
|
|
286
|
-
} else {
|
|
287
|
-
Object.assign(viewProps, events);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const spacedChildrenEl = spacedChildren({
|
|
291
|
-
children,
|
|
292
|
-
space,
|
|
293
|
-
flexDirection: props.flexDirection || (defaultProps == null ? void 0 : defaultProps.flexDirection)
|
|
294
|
-
});
|
|
295
|
-
let content;
|
|
296
|
-
if (isWeb && rnw) {
|
|
297
|
-
const domProps = rnw.createDOMProps(viewProps);
|
|
298
|
-
const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
|
|
299
|
-
Object.assign(viewProps, domProps);
|
|
300
|
-
viewProps.className = className;
|
|
301
|
-
content = createElement(ViewComponent, viewProps, spacedChildrenEl);
|
|
302
|
-
} else {
|
|
303
|
-
content = createElement(ViewComponent, viewProps, spacedChildrenEl);
|
|
304
|
-
}
|
|
305
|
-
const shouldWrapTextAncestor = isWeb && staticConfig.isText && !hasTextAncestor;
|
|
306
|
-
if (shouldWrapTextAncestor) {
|
|
307
|
-
content = createElement(TextAncestorContext.Provider, { value: true }, content);
|
|
308
|
-
}
|
|
309
|
-
if (process.env.NODE_ENV === "development") {
|
|
310
|
-
if (props["debug"]) {
|
|
311
|
-
viewProps["debug"] = true;
|
|
312
|
-
console.log("\u{1F95A} props in:", props);
|
|
313
|
-
console.log("\u{1F95A} props out:", viewProps);
|
|
314
|
-
console.log((_a = props.onClick) == null ? void 0 : _a.toString());
|
|
315
|
-
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, spacedChildrenEl });
|
|
316
|
-
if (isWeb) {
|
|
317
|
-
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, features, content);
|
|
322
|
-
});
|
|
323
|
-
onConfiguredOnce((conf) => {
|
|
324
|
-
var _a;
|
|
325
|
-
tamaguiConfig = conf;
|
|
326
|
-
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
327
|
-
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
328
|
-
if (isWeb) {
|
|
329
|
-
if (next.classNames) {
|
|
330
|
-
defaultsClassName += next.classNames + " ";
|
|
331
|
-
}
|
|
332
|
-
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
|
|
333
|
-
} else {
|
|
334
|
-
console.log("we need to account for default styles for media queries", next);
|
|
335
|
-
}
|
|
336
|
-
component.defaultProps = {
|
|
337
|
-
...next.viewProps,
|
|
338
|
-
...component.defaultProps
|
|
339
|
-
};
|
|
340
|
-
if (process.env.NODE_ENV === "development") {
|
|
341
|
-
if ((_a = staticConfig.defaultProps) == null ? void 0 : _a.debug) {
|
|
342
|
-
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
component["staticConfig"] = {
|
|
347
|
-
validStyles: validStyleProps,
|
|
348
|
-
...staticConfig
|
|
349
|
-
};
|
|
350
|
-
const res = component;
|
|
351
|
-
res["extractable"] = (Component2) => {
|
|
352
|
-
Component2["staticConfig"] = extendStaticConfig(res, {
|
|
353
|
-
neverFlatten: true,
|
|
354
|
-
defaultProps: Component2.defaultProps
|
|
355
|
-
});
|
|
356
|
-
return Component2;
|
|
357
|
-
};
|
|
358
|
-
return res;
|
|
359
|
-
}
|
|
360
|
-
__name(createComponent, "createComponent");
|
|
361
|
-
const Spacer = createComponent({
|
|
362
|
-
defaultProps: stackDefaultStyles,
|
|
363
|
-
variants: {
|
|
364
|
-
size: {
|
|
365
|
-
"...size": (size, { tokens }) => {
|
|
366
|
-
var _a, _b;
|
|
367
|
-
return {
|
|
368
|
-
width: (_a = tokens.size[size]) != null ? _a : size,
|
|
369
|
-
height: (_b = tokens.size[size]) != null ? _b : size
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
direction: {
|
|
374
|
-
horizontal: {
|
|
375
|
-
height: 0
|
|
376
|
-
},
|
|
377
|
-
vertical: {
|
|
378
|
-
width: 0
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
function spacedChildren({
|
|
384
|
-
children,
|
|
385
|
-
space,
|
|
386
|
-
flexDirection
|
|
387
|
-
}) {
|
|
388
|
-
var _a, _b;
|
|
389
|
-
if (!space) {
|
|
390
|
-
return children;
|
|
391
|
-
}
|
|
392
|
-
const childrenList = Children.toArray(children);
|
|
393
|
-
const len = childrenList.length;
|
|
394
|
-
if (len === 1) {
|
|
395
|
-
return children;
|
|
396
|
-
}
|
|
397
|
-
const next = [];
|
|
398
|
-
for (const [index, child] of childrenList.entries()) {
|
|
399
|
-
if (child === null || child === void 0) {
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
const key = `${(_a = child == null ? void 0 : child["key"]) != null ? _a : index}`;
|
|
403
|
-
next.push(/* @__PURE__ */ React.createElement(Fragment, {
|
|
404
|
-
key
|
|
405
|
-
}, child));
|
|
406
|
-
if ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isVisuallyHidden"]) {
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
if (index === len - 1) {
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
next.push(/* @__PURE__ */ React.createElement(Spacer, {
|
|
413
|
-
key: `${key}_spacer`,
|
|
414
|
-
direction: flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical",
|
|
415
|
-
size: space
|
|
416
|
-
}));
|
|
417
|
-
}
|
|
418
|
-
return next;
|
|
419
|
-
}
|
|
420
|
-
__name(spacedChildren, "spacedChildren");
|
|
421
|
-
export {
|
|
422
|
-
Spacer,
|
|
423
|
-
createComponent,
|
|
424
|
-
mouseUps,
|
|
425
|
-
spacedChildren
|
|
426
|
-
};
|
|
427
|
-
//# sourceMappingURL=createComponent.js.map
|
package/_/createComponent.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/createComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["import { concatClassName, stylePropsView } from '@tamagui/helpers'\nimport React, {\n Children,\n Fragment,\n createElement,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { Text, View, ViewStyle } from 'react-native'\n\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\nimport { onConfiguredOnce } from './createTamagui'\nimport { addStylesUsingClassname } from './helpers/addStylesUsingClassname'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getSplitStyles } from './helpers/getSplitStyles'\nimport { useFeatures } from './hooks/useFeatures'\nimport { useForceUpdate } from './hooks/useForceUpdate'\nimport { usePressable } from './hooks/usePressable'\nimport { StaticComponent, StaticConfig, StaticConfigParsed, TamaguiInternalConfig } from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\nimport { ThemeManagerContext } from './views/ThemeManagerContext'\n\nexport const mouseUps = new Set<Function>()\n\nif (typeof document !== 'undefined') {\n document.addEventListener('mouseup', () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n })\n}\n\ntype DefaultProps = {}\n\nexport function createComponent<A extends Object = DefaultProps>(\n configIn: Partial<StaticConfig> | StaticConfigParsed\n) {\n let staticConfig: StaticConfigParsed\n if ('parsed' in configIn) {\n staticConfig = configIn\n } else {\n staticConfig = parseStaticConfig(configIn)\n }\n\n const { Component, validStyles, isText } = staticConfig\n const validStyleProps = validStyles ?? stylePropsView\n\n // split out default styles vs props so we can assign it to component.defaultProps\n let defaultProps = null as any\n let tamaguiConfig: TamaguiInternalConfig\n\n // web uses className, native uses style\n let defaultsStyle: any\n let defaultsClassName = ''\n let initialTheme: any\n\n // see onConfiguredOnce below which attaches a name then to this component\n\n const component = forwardRef<View, A>((props: any, forwardedRef) => {\n const {\n tag,\n hitSlop,\n children,\n pointerEvents,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n space,\n disabled,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n onMouseDown,\n onClick,\n // TODO feature load layou hook\n onLayout,\n } = props\n\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const manager = useContext(ThemeManagerContext)\n const [state, set_] = useState(() => ({\n hover: false,\n press: false,\n pressIn: false,\n theme: manager.name,\n }))\n const set = (next: Partial<typeof state>) =>\n set_((prev) => {\n for (const key in next) {\n if (prev[key] !== next[key]) {\n return { ...prev, ...next }\n }\n }\n return prev\n })\n\n // from react-native-web\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n if (typeof item === 'string') {\n console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)\n }\n })\n }\n\n const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false\n const hostRef = useRef(null)\n\n if (isWeb) {\n // from react-native-web\n rnw.useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n })\n }\n\n const isTracking = useRef(false)\n\n const { viewProps, pseudos, style, classNames } = getSplitStyles(\n props,\n staticConfig,\n (manager.theme as any) || initialTheme\n )\n\n // hasEverHadEvents prevents repareting if you remove onPress or similar...\n const internal = useRef<{ isMounted: boolean; hasEverHadEvents?: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n }\n }\n\n useEffect(() => {\n internal.current!.isMounted = true\n const dispose = manager?.onChangeTheme((name) => {\n if (isTracking.current) {\n set({ theme: name })\n }\n })\n return () => {\n dispose()\n mouseUps.delete(unPress)\n isTracking.current = false\n internal.current!.isMounted = false\n }\n }, [manager])\n\n // element\n const element = isWeb\n ? !Component || typeof Component === 'string'\n ? // default to tag, fallback to component (when both strings)\n tag || Component\n : Component\n : Component\n const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')\n const ReactText = !isWeb ? Text : element || 'span'\n const ViewComponent = isText ? ReactText : ReactView\n\n // styles\n const isHovering = !isTouchDevice && !disabled && pseudos && state.hover\n const isPressing = !disabled && pseudos && state.press\n\n const styles = [\n // parity w react-native-web, only for text in text\n // TODO this should be able to be done w css to replicate after extraction:\n // (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)\n // isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,\n style,\n isHovering ? pseudos.hoverStyle || null : null,\n isPressing ? pseudos.pressStyle || null : null,\n ]\n\n if (isWeb) {\n const stylesClassNames = addStylesUsingClassname(styles)\n const classList = staticConfig.isText\n ? [\n defaultsClassName,\n // hasTextAncestor === true && cssText.textHasAncestor,\n // TODO MOVE TO VARIANTS [number] [any]\n // numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,\n classNames,\n stylesClassNames,\n props.className,\n ]\n : [defaultsClassName, props.className, classNames, stylesClassNames]\n const classListFlat = classList.flat(1).filter(Boolean).join(' ')\n const className = concatClassName(classListFlat)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('\uD83E\uDD5A className', { style, styles, stylesClassNames, classListFlat: classListFlat.split(' '), className })\n }\n }\n viewProps.className = className\n } else {\n viewProps.style = styles\n }\n\n if (pointerEvents) {\n viewProps.pointerEvents = pointerEvents\n }\n\n if (isWeb) {\n // from react-native-web\n const platformMethodsRef = rnw.usePlatformMethods(viewProps)\n const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef)\n viewProps.ref = setRef\n if (props.href != null && hrefAttrs != null) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? '_' + target : target\n }\n }\n } else {\n if (forwardedRef) {\n viewProps.ref = forwardedRef\n }\n }\n\n const attachPress = !!(\n (pseudos && pseudos.pressStyle) ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const attachHover =\n isWeb &&\n !isTouchDevice &&\n !!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n // check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage\n // while avoiding reparenting...\n // once proper reparenting is supported, we can remove this and use that...\n const shouldAttach =\n internal.current.hasEverHadEvents ||\n attachPress ||\n attachHover ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onClick' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n\n // never remove events as we wrap in a div (for now, may be able to remove..)\n if (shouldAttach) {\n internal.current.hasEverHadEvents = true\n }\n\n const unPress = useCallback(() => {\n if (!internal.current!.isMounted) return\n set({\n press: false,\n pressIn: false,\n })\n }, [])\n\n const events = shouldAttach\n ? {\n ...(!isWeb && {\n // non web\n onPressOut: (e) => {\n unPress()\n onPressOut?.(e)\n },\n }),\n ...(isWeb &&\n !isTouchDevice && {\n onMouseEnter:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n if (attachHover) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (attachHover) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onMouseDown: attachPress\n ? (e) => {\n set({\n press: true,\n pressIn: true,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n }\n : (onPressIn as any),\n onClick: attachPress\n ? (e) => {\n // this caused issue with next.js passing href\n // e.preventDefault()\n onPress?.(e)\n onClick?.(e)\n unPress()\n onPressOut?.(e)\n }\n : (onPressOut as any),\n }\n : null\n\n if (events) {\n if (typeof ViewComponent !== 'string') {\n // TODO once we do the above we can then rely entirely on pressStyle returned here isntead of above pressStyle logic\n const [pressProps] = usePressable({\n disabled,\n hitSlop,\n onPressIn: events.onMouseDown,\n onPressOut: events.onPressOut,\n onPress: events.onClick,\n })\n Object.assign(viewProps, pressProps)\n } else {\n Object.assign(viewProps, events)\n }\n }\n\n const spacedChildrenEl = spacedChildren({\n children,\n space,\n flexDirection: props.flexDirection || defaultProps?.flexDirection,\n })\n\n let content: any\n\n // replicate react-native-web's `createElement`\n if (isWeb && rnw) {\n const domProps = rnw.createDOMProps(viewProps)\n const className =\n domProps.className && domProps.className !== viewProps.className\n ? `${domProps.className} ${viewProps.className}`\n : viewProps.className\n Object.assign(viewProps, domProps)\n viewProps.className = className\n content = createElement(ViewComponent, viewProps, spacedChildrenEl)\n } else {\n content = createElement(ViewComponent, viewProps, spacedChildrenEl)\n }\n\n const shouldWrapTextAncestor = isWeb && staticConfig.isText && !hasTextAncestor\n if (shouldWrapTextAncestor) {\n // from react-native-web\n // @ts-ignore\n content = createElement(TextAncestorContext.Provider, { value: true }, content)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n viewProps['debug'] = true\n console.log('\uD83E\uDD5A props in:', props)\n console.log('\uD83E\uDD5A props out:', viewProps)\n console.log(props.onClick?.toString())\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, spacedChildrenEl })\n // only on browser because node expands it huge\n if (isWeb) {\n console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\n }\n }\n }\n\n return (\n <>\n {features}\n {content}\n </>\n )\n })\n\n // Once configuration is run and all components are registered\n // get default props + className and analyze styles\n onConfiguredOnce((conf) => {\n tamaguiConfig = conf\n initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]\n const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)\n if (isWeb) {\n if (next.classNames) {\n defaultsClassName += next.classNames + ' '\n }\n defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])\n } else {\n console.log('we need to account for default styles for media queries', next)\n }\n // @ts-ignore\n component.defaultProps = {\n ...next.viewProps,\n ...component.defaultProps,\n }\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.defaultProps?.debug) {\n console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)\n }\n }\n })\n\n component['staticConfig'] = {\n validStyles: validStyleProps,\n ...staticConfig,\n }\n\n const res = component as any as StaticComponent<A, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n neverFlatten: true,\n defaultProps: Component.defaultProps,\n })\n return Component\n }\n\n return res\n}\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<{ size?: number; flex?: boolean | number }>({\n defaultProps: stackDefaultStyles,\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n return {\n width: tokens.size[size] ?? size,\n height: tokens.size[size] ?? size,\n }\n },\n },\n direction: {\n horizontal: {\n height: 0,\n },\n vertical: {\n width: 0,\n },\n },\n },\n})\n\nexport function spacedChildren({\n children,\n space,\n flexDirection,\n}: {\n children: any\n space?: any\n flexDirection?: ViewStyle['flexDirection']\n}) {\n if (!space) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len === 1) {\n return children\n }\n const next: any[] = []\n for (const [index, child] of childrenList.entries()) {\n if (child === null || child === undefined) {\n continue\n }\n\n const key = `${child?.['key'] ?? index}`\n next.push(<Fragment key={key}>{child}</Fragment>)\n\n // allows for custom visually hidden components that dont insert spacing\n if (child?.['type']?.['isVisuallyHidden']) {\n continue\n }\n\n if (index === len - 1) {\n break\n }\n\n next.push(\n <Spacer\n key={`${key}_spacer`}\n // @ts-ignore TODO\n direction={\n flexDirection === 'row' || flexDirection === 'row-reverse' ? 'horizontal' : 'vertical'\n }\n size={space}\n />\n )\n }\n return next\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEO,MAAM,WAAW,IAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMN,yBACL,UACA;AACA,MAAI;AACJ,MAAI,YAAY,UAAU;AACxB,mBAAe;AAAA,SACV;AACL,mBAAe,kBAAkB;AAAA;AAGnC,QAAM,EAAE,WAAW,aAAa,WAAW;AAC3C,QAAM,kBAAkB,oCAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI;AACJ,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,WAAoB,CAAC,OAAY,iBAAiB;AA/DtE;AAgEI,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,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AAAA,EAChF,cAAc;AAAA,EACd,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,MAAM,EAAE,aAAa;AAlfvC;AAmfQ,eAAO;AAAA,UACL,OAAO,aAAO,KAAK,UAAZ,YAAqB;AAAA,UAC5B,QAAQ,aAAO,KAAK,UAAZ,YAAqB;AAAA;AAAA;AAAA;AAAA,IAInC,WAAW;AAAA,MACT,YAAY;AAAA,QACV,QAAQ;AAAA;AAAA,MAEV,UAAU;AAAA,QACR,OAAO;AAAA;AAAA;AAAA;AAAA;AAMR,wBAAwB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,GAKC;AA5gBH;AA6gBE,MAAI,CAAC,OAAO;AACV,WAAO;AAAA;AAET,QAAM,eAAe,SAAS,QAAQ;AACtC,QAAM,MAAM,aAAa;AACzB,MAAI,QAAQ,GAAG;AACb,WAAO;AAAA;AAET,QAAM,OAAc;AACpB,aAAW,CAAC,OAAO,UAAU,aAAa,WAAW;AACnD,QAAI,UAAU,QAAQ,UAAU,QAAW;AACzC;AAAA;AAGF,UAAM,MAAM,GAAG,qCAAQ,WAAR,YAAkB;AACjC,SAAK,KAAK,oCAAC,UAAD;AAAA,MAAU;AAAA,OAAW;AAG/B,QAAI,qCAAQ,YAAR,mBAAkB,qBAAqB;AACzC;AAAA;AAGF,QAAI,UAAU,MAAM,GAAG;AACrB;AAAA;AAGF,SAAK,KACH,oCAAC,QAAD;AAAA,MACE,KAAK,GAAG;AAAA,MAER,WACE,kBAAkB,SAAS,kBAAkB,gBAAgB,eAAe;AAAA,MAE9E,MAAM;AAAA;AAAA;AAIZ,SAAO;AAAA;AA9CO;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/_/createShorthands.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function createShorthands(shorthands) {
|
|
4
|
-
return Object.freeze(shorthands);
|
|
5
|
-
}
|
|
6
|
-
__name(createShorthands, "createShorthands");
|
|
7
|
-
export {
|
|
8
|
-
createShorthands
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=createShorthands.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/createShorthands.ts"],
|
|
4
|
-
"sourcesContent": ["// type helper\n\nexport function createShorthands<A extends Record<string, string>>(shorthands: A): A {\n return Object.freeze(shorthands) as any\n}\n"],
|
|
5
|
-
"mappings": ";;AAEO,0BAA4D,YAAkB;AACnF,SAAO,OAAO,OAAO;AAAA;AADP;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/_/createTamagui.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { getStyleRules } from "@tamagui/helpers";
|
|
4
|
-
import { Variable, createVariable, isVariable } from "./createVariable";
|
|
5
|
-
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
6
|
-
import { configureMedia } from "./hooks/useMedia";
|
|
7
|
-
let conf;
|
|
8
|
-
const getHasConfigured = /* @__PURE__ */ __name(() => !!conf, "getHasConfigured");
|
|
9
|
-
const getTamaguiConfig = /* @__PURE__ */ __name(() => conf, "getTamaguiConfig");
|
|
10
|
-
const configListeners = new Set();
|
|
11
|
-
const onConfiguredOnce = /* @__PURE__ */ __name((cb) => {
|
|
12
|
-
if (conf) {
|
|
13
|
-
cb(conf);
|
|
14
|
-
} else {
|
|
15
|
-
configListeners.add(cb);
|
|
16
|
-
}
|
|
17
|
-
}, "onConfiguredOnce");
|
|
18
|
-
const PREFIX = `theme--`;
|
|
19
|
-
function createTamagui(config) {
|
|
20
|
-
if (conf) {
|
|
21
|
-
throw new Error(`#000 createTamagui called twice`);
|
|
22
|
-
}
|
|
23
|
-
configureMedia({
|
|
24
|
-
queries: config.media,
|
|
25
|
-
defaultActive: config.mediaQueryDefaultActive
|
|
26
|
-
});
|
|
27
|
-
const themeConfig = (() => {
|
|
28
|
-
let cssRules = [];
|
|
29
|
-
let tokenRule = `:root {`;
|
|
30
|
-
const varsByValue = new Map();
|
|
31
|
-
for (const key in config.tokens) {
|
|
32
|
-
for (const skey in config.tokens[key]) {
|
|
33
|
-
const v = config.tokens[key][skey];
|
|
34
|
-
varsByValue[v.val] = v;
|
|
35
|
-
tokenRule += `--${v.name}:${typeof v.val === "number" ? `${v.val}px` : v.val};`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
cssRules.push(`${tokenRule}
|
|
39
|
-
}`);
|
|
40
|
-
for (const themeName in config.themes) {
|
|
41
|
-
config.themes[themeName] = { ...config.themes[themeName] };
|
|
42
|
-
const theme = config.themes[themeName];
|
|
43
|
-
let vars = "";
|
|
44
|
-
for (const themeKey in theme) {
|
|
45
|
-
const val = theme[themeKey];
|
|
46
|
-
const getVariableCSS = /* @__PURE__ */ __name((inv) => {
|
|
47
|
-
var _a;
|
|
48
|
-
const v = (_a = varsByValue[inv]) != null ? _a : inv;
|
|
49
|
-
return isVariable(v) ? `--${themeKey}:var(--${v.name});` : `--${themeKey}:${v};`;
|
|
50
|
-
}, "getVariableCSS");
|
|
51
|
-
vars += getVariableCSS(val);
|
|
52
|
-
if (!isVariable(val)) {
|
|
53
|
-
theme[themeKey] = createVariable({
|
|
54
|
-
name: themeKey,
|
|
55
|
-
val
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const [themeClassName, parentName] = themeName.includes("-") ? themeName.split("-") : [themeName, ""];
|
|
60
|
-
const oppositeName = parentName === "dark" ? "light" : "dark";
|
|
61
|
-
const cssParentSel = parentName ? `.${PREFIX}${parentName}` : "";
|
|
62
|
-
const cssChildSel = `.${PREFIX}${themeClassName}`;
|
|
63
|
-
const cssSel = `${cssParentSel} ${cssChildSel}`;
|
|
64
|
-
const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {
|
|
65
|
-
${vars}
|
|
66
|
-
}`;
|
|
67
|
-
cssRules.push(cssRule);
|
|
68
|
-
}
|
|
69
|
-
Object.freeze(cssRules);
|
|
70
|
-
return {
|
|
71
|
-
cssRules,
|
|
72
|
-
css: cssRules.join("\n")
|
|
73
|
-
};
|
|
74
|
-
})();
|
|
75
|
-
const tokensParsed = {};
|
|
76
|
-
for (const key in config.tokens) {
|
|
77
|
-
tokensParsed[key] = {};
|
|
78
|
-
for (const skey in config.tokens[key]) {
|
|
79
|
-
tokensParsed[key][`$${skey}`] = config.tokens[key][skey];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const themeParsed = {};
|
|
83
|
-
const firstKey = Object.keys(config.themes)[0];
|
|
84
|
-
for (const key in config.themes[firstKey]) {
|
|
85
|
-
const val = config.themes[firstKey][key].val;
|
|
86
|
-
themeParsed[`$${key}`] = new Variable({ val, name: key });
|
|
87
|
-
}
|
|
88
|
-
const next = {
|
|
89
|
-
shorthands: {},
|
|
90
|
-
...config,
|
|
91
|
-
Provider: createTamaguiProvider({
|
|
92
|
-
defaultTheme: "light",
|
|
93
|
-
...config
|
|
94
|
-
}),
|
|
95
|
-
themeConfig,
|
|
96
|
-
themeParsed,
|
|
97
|
-
tokensParsed,
|
|
98
|
-
getCSS() {
|
|
99
|
-
return `${themeConfig.css}
|
|
100
|
-
${[...getStyleRules()].join("\n")}`;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
conf = next;
|
|
104
|
-
if (configListeners.size) {
|
|
105
|
-
configListeners.forEach((cb) => cb(next));
|
|
106
|
-
configListeners.clear();
|
|
107
|
-
}
|
|
108
|
-
return next;
|
|
109
|
-
}
|
|
110
|
-
__name(createTamagui, "createTamagui");
|
|
111
|
-
function getThemeParentClassName(themeName) {
|
|
112
|
-
return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ""}`;
|
|
113
|
-
}
|
|
114
|
-
__name(getThemeParentClassName, "getThemeParentClassName");
|
|
115
|
-
export {
|
|
116
|
-
createTamagui,
|
|
117
|
-
getHasConfigured,
|
|
118
|
-
getTamaguiConfig,
|
|
119
|
-
getThemeParentClassName,
|
|
120
|
-
onConfiguredOnce
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=createTamagui.js.map
|
package/_/createTamagui.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/createTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { getStyleRules } from '@tamagui/helpers'\n\nimport { Variable, createVariable, isVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { configureMedia } from './hooks/useMedia'\nimport {\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n TamaguiInternalConfig,\n TamaguiProviderProps,\n} from './types'\n\nexport type CreateTamaguiProps = TamaguiProviderProps &\n // we omit and re-declare it because we need to allow instantation types to be flexible\n // user then re-defines the types after createTamagui returns the typed object they want\n Omit<GenericTamaguiConfig, 'themes'> & {\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n // for ssr/native, will default to active\n mediaQueryDefaultActive?: MediaQueryKey[]\n }\n\nlet conf: TamaguiInternalConfig | null\n\nexport const getHasConfigured = () => !!conf\nexport const getTamaguiConfig = () => conf!\n\ntype ConfigListener = (conf: TamaguiInternalConfig) => void\nconst configListeners = new Set<ConfigListener>()\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n}\n\nconst PREFIX = `theme--`\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): Conf extends CreateTamaguiConfig<infer A, infer B, infer C, infer D>\n ? TamaguiInternalConfig<A, B, C, D>\n : unknown {\n if (conf) {\n throw new Error(`#000 createTamagui called twice`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n // TODO can avoid some of this CSS creation on native\n const themeConfig = (() => {\n let cssRules: string[] = []\n\n // tokens\n let tokenRule = `:root {`\n const varsByValue = new Map<string, Variable>()\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const v = config.tokens[key][skey]\n varsByValue[v.val] = v\n tokenRule += `--${v.name}:${typeof v.val === 'number' ? `${v.val}px` : v.val};`\n }\n }\n cssRules.push(`${tokenRule}\\n}`)\n\n // themes\n for (const themeName in config.themes) {\n // to allow using the same theme with diff names, be sure we don't mutate!\n config.themes[themeName] = { ...config.themes[themeName] }\n const theme = config.themes[themeName]\n let vars = ''\n for (const themeKey in theme) {\n const val = theme[themeKey]\n const getVariableCSS = (inv: any) => {\n const v = varsByValue[inv] ?? inv\n return isVariable(v) ? `--${themeKey}:var(--${v.name});` : `--${themeKey}:${v};`\n }\n vars += getVariableCSS(val)\n // TODO sanity check is necessary\n // make everything a variable that gets put into css\n if (!isVariable(val)) {\n theme[themeKey] = createVariable({\n name: themeKey,\n val,\n })\n }\n }\n\n const [themeClassName, parentName] = themeName.includes('-')\n ? themeName.split('-')\n : [themeName, '']\n // tiny hack for now assuming light/dark are typical parentName\n const oppositeName = parentName === 'dark' ? 'light' : 'dark'\n const cssParentSel = parentName ? `.${PREFIX}${parentName}` : ''\n const cssChildSel = `.${PREFIX}${themeClassName}`\n const cssSel = `${cssParentSel} ${cssChildSel}`\n // we need to force specificity\n const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {\\n${vars}\\n}`\n cssRules.push(cssRule)\n }\n\n Object.freeze(cssRules)\n\n return {\n cssRules,\n css: cssRules.join('\\n'),\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = {}\n for (const key in config.tokens) {\n tokensParsed[key] = {}\n for (const skey in config.tokens[key]) {\n tokensParsed[key][`$${skey}`] = config.tokens[key][skey]\n }\n }\n // all themes should match key and we just need variable name\n // TODO once w react native we'd want to have a reverse lookup back to value\n const themeParsed: any = {}\n const firstKey = Object.keys(config.themes)[0]\n for (const key in config.themes[firstKey]) {\n // themeParsed[`$${key}`] = config.themes[firstKey][key]\n const val = config.themes[firstKey][key].val\n themeParsed[`$${key}`] = new Variable({ val, name: key })\n }\n\n const next: TamaguiInternalConfig = {\n // @ts-ignore\n shorthands: {},\n ...config,\n Provider: createTamaguiProvider({\n defaultTheme: 'light',\n ...config,\n }),\n themeConfig,\n themeParsed,\n tokensParsed,\n getCSS() {\n return `${themeConfig.css}\\n${[...getStyleRules()].join('\\n')}`\n },\n }\n conf = next\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n // @ts-expect-error\n return next\n}\n\nexport function getThemeParentClassName(themeName?: string | null) {\n return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ''}`\n}\n\n// insertSheet() {\n// // TODO use new react method of inserting\n// const tag = createStyleTag()\n// for (const rule of cssRules) {\n// tag?.sheet?.insertRule(rule)\n// }\n// },\n\n// function createStyleTag(): HTMLStyleElement | null {\n// if (typeof document === 'undefined') {\n// return null\n// }\n// const tag = document.createElement('style')\n// tag.className = 'tamagui-css-vars'\n// tag.setAttribute('type', 'text/css')\n// tag.appendChild(document.createTextNode(''))\n// if (!document.head) {\n// throw new Error('expected head')\n// }\n// document.head.appendChild(tag)\n// return tag\n// }\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAsBA,IAAI;AAEG,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AACzB,MAAM,mBAAmB,6BAAM,MAAN;AAGhC,MAAM,kBAAkB,IAAI;AACrB,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG;AAAA,SACE;AACL,oBAAgB,IAAI;AAAA;AAAA,GAJQ;AAQhC,MAAM,SAAS;AAER,uBACL,QAGU;AACV,MAAI,MAAM;AACR,UAAM,IAAI,MAAM;AAAA;AAGlB,iBAAe;AAA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AS,KAAK;AAAA;AAAA;AAKvB,QAAM,eAAoB;AAC1B,aAAW,OAAO,OAAO,QAAQ;AAC/B,iBAAa,OAAO;AACpB,eAAW,QAAQ,OAAO,OAAO,MAAM;AACrC,mBAAa,KAAK,IAAI,UAAU,OAAO,OAAO,KAAK;AAAA;AAAA;AAKvD,QAAM,cAAmB;AACzB,QAAM,WAAW,OAAO,KAAK,OAAO,QAAQ;AAC5C,aAAW,OAAO,OAAO,OAAO,WAAW;AAEzC,UAAM,MAAM,OAAO,OAAO,UAAU,KAAK;AACzC,gBAAY,IAAI,SAAS,IAAI,SAAS,EAAE,KAAK,MAAM;AAAA;AAGrD,QAAM,OAA8B;AAAA,IAElC,YAAY;AAAA,OACT;AAAA,IACH,UAAU,sBAAsB;AAAA,MAC9B,cAAc;AAAA,SACX;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AACP,aAAO,GAAG,YAAY;AAAA,EAAQ,CAAC,GAAG,iBAAiB,KAAK;AAAA;AAAA;AAG5D,SAAO;AAEP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG;AACnC,oBAAgB;AAAA;AAIlB,SAAO;AAAA;AAnHO;AAsHT,iCAAiC,WAA2B;AACjE,SAAO,gBAAgB,YAAY,GAAG,SAAS,cAAc;AAAA;AAD/C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/_/createTheme.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { Variable, createVariable } from "./createVariable";
|
|
4
|
-
const createTheme = /* @__PURE__ */ __name((theme) => {
|
|
5
|
-
const res = {};
|
|
6
|
-
for (const key in theme) {
|
|
7
|
-
const val = theme[key];
|
|
8
|
-
if (!(val instanceof Variable)) {
|
|
9
|
-
res[key] = createVariable({
|
|
10
|
-
name: key,
|
|
11
|
-
val
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return res;
|
|
16
|
-
}, "createTheme");
|
|
17
|
-
export {
|
|
18
|
-
createTheme
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=createTheme.js.map
|