@react-xp/aeiou 0.1.0-beta.3 → 0.1.0-beta.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/dist/cjs/hooks/useInteractiveState/useInteractiveState.native.js +18 -58
- package/dist/cjs/hooks/useInteractiveState/useInteractiveState.web.js +33 -42
- package/dist/esm/hooks/useInteractiveState/useInteractiveState.native.js +19 -59
- package/dist/esm/hooks/useInteractiveState/useInteractiveState.web.js +34 -43
- package/dist/native/cjs/components/a/a.native.js +17 -0
- package/dist/native/cjs/components/a/a.web.js +15 -0
- package/dist/native/cjs/components/a/index.native.js +17 -0
- package/dist/native/cjs/components/a/index.web.js +17 -0
- package/dist/native/cjs/components/d/d.native.js +28 -0
- package/dist/native/cjs/components/d/d.web.js +35 -0
- package/dist/native/cjs/components/d/index.native.js +17 -0
- package/dist/native/cjs/components/d/index.web.js +17 -0
- package/dist/native/cjs/components/e/e.native.js +21 -0
- package/dist/native/cjs/components/e/e.web.js +15 -0
- package/dist/native/cjs/components/e/index.native.js +17 -0
- package/dist/native/cjs/components/e/index.web.js +17 -0
- package/dist/native/cjs/components/i/i.native.js +30 -0
- package/dist/native/cjs/components/i/i.web.js +23 -0
- package/dist/native/cjs/components/i/index.native.js +17 -0
- package/dist/native/cjs/components/i/index.web.js +17 -0
- package/dist/native/cjs/components/i/useIUtils.js +71 -0
- package/dist/native/cjs/components/index.js +26 -0
- package/dist/native/cjs/components/index.native.js +26 -0
- package/dist/native/cjs/components/index.web.js +26 -0
- package/dist/native/cjs/components/l/index.native.js +17 -0
- package/dist/native/cjs/components/l/index.web.js +17 -0
- package/dist/native/cjs/components/l/l.native.js +10 -0
- package/dist/native/cjs/components/l/l.web.js +17 -0
- package/dist/native/cjs/components/o/index.native.js +17 -0
- package/dist/native/cjs/components/o/index.web.js +17 -0
- package/dist/native/cjs/components/o/o.native.js +12 -0
- package/dist/native/cjs/components/o/o.web.js +12 -0
- package/dist/native/cjs/components/p/index.native.js +17 -0
- package/dist/native/cjs/components/p/index.web.js +17 -0
- package/dist/native/cjs/components/p/p.native.js +13 -0
- package/dist/native/cjs/components/p/p.web.js +13 -0
- package/dist/native/cjs/components/s/index.native.js +17 -0
- package/dist/native/cjs/components/s/index.web.js +17 -0
- package/dist/native/cjs/components/s/s.native.js +10 -0
- package/dist/native/cjs/components/s/s.web.js +10 -0
- package/dist/native/cjs/components/t/index.native.js +17 -0
- package/dist/native/cjs/components/t/index.web.js +17 -0
- package/dist/native/cjs/components/t/t.native.js +16 -0
- package/dist/native/cjs/components/t/t.web.js +16 -0
- package/dist/native/cjs/components/u/context.js +14 -0
- package/dist/native/cjs/components/u/index.native.js +19 -0
- package/dist/native/cjs/components/u/index.web.js +19 -0
- package/dist/native/cjs/components/u/provider.native.js +23 -0
- package/dist/native/cjs/components/u/provider.web.js +20 -0
- package/dist/native/cjs/components/u/types.js +2 -0
- package/dist/native/cjs/components/u/useUniverse.js +8 -0
- package/dist/native/cjs/hooks/index.js +21 -0
- package/dist/native/cjs/hooks/index.native.js +21 -0
- package/dist/native/cjs/hooks/index.web.js +21 -0
- package/dist/native/cjs/hooks/useAction/types.js +2 -0
- package/dist/native/cjs/hooks/useAction/useAction.native.js +18 -0
- package/dist/native/cjs/hooks/useAction/useAction.web.js +21 -0
- package/dist/native/cjs/hooks/useCn.js +15 -0
- package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.native.js +31 -0
- package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.types.js +2 -0
- package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.web.js +62 -0
- package/dist/native/cjs/hooks/useOnChange.js +18 -0
- package/dist/native/cjs/hooks/useProps.js +66 -0
- package/dist/native/cjs/index.js +19 -0
- package/dist/native/cjs/index.native.js +19 -0
- package/dist/native/cjs/index.web.js +19 -0
- package/dist/native/cjs/types/base.js +2 -0
- package/dist/native/cjs/types/index.js +17 -0
- package/dist/native/esm/components/a/a.native.js +13 -0
- package/dist/native/esm/components/a/a.web.js +11 -0
- package/dist/native/esm/components/a/index.native.js +1 -0
- package/dist/native/esm/components/a/index.web.js +1 -0
- package/dist/native/esm/components/d/d.native.js +24 -0
- package/dist/native/esm/components/d/d.web.js +31 -0
- package/dist/native/esm/components/d/index.native.js +1 -0
- package/dist/native/esm/components/d/index.web.js +1 -0
- package/dist/native/esm/components/e/e.native.js +17 -0
- package/dist/native/esm/components/e/e.web.js +11 -0
- package/dist/native/esm/components/e/index.native.js +1 -0
- package/dist/native/esm/components/e/index.web.js +1 -0
- package/dist/native/esm/components/i/i.native.js +26 -0
- package/dist/native/esm/components/i/i.web.js +19 -0
- package/dist/native/esm/components/i/index.native.js +1 -0
- package/dist/native/esm/components/i/index.web.js +1 -0
- package/dist/native/esm/components/i/useIUtils.js +67 -0
- package/dist/native/esm/components/index.js +10 -0
- package/dist/native/esm/components/index.native.js +10 -0
- package/dist/native/esm/components/index.web.js +10 -0
- package/dist/native/esm/components/l/index.native.js +1 -0
- package/dist/native/esm/components/l/index.web.js +1 -0
- package/dist/native/esm/components/l/l.native.js +6 -0
- package/dist/native/esm/components/l/l.web.js +13 -0
- package/dist/native/esm/components/o/index.native.js +1 -0
- package/dist/native/esm/components/o/index.web.js +1 -0
- package/dist/native/esm/components/o/o.native.js +8 -0
- package/dist/native/esm/components/o/o.web.js +8 -0
- package/dist/native/esm/components/p/index.native.js +1 -0
- package/dist/native/esm/components/p/index.web.js +1 -0
- package/dist/native/esm/components/p/p.native.js +9 -0
- package/dist/native/esm/components/p/p.web.js +9 -0
- package/dist/native/esm/components/s/index.native.js +1 -0
- package/dist/native/esm/components/s/index.web.js +1 -0
- package/dist/native/esm/components/s/s.native.js +7 -0
- package/dist/native/esm/components/s/s.web.js +6 -0
- package/dist/native/esm/components/t/index.native.js +1 -0
- package/dist/native/esm/components/t/index.web.js +1 -0
- package/dist/native/esm/components/t/t.native.js +12 -0
- package/dist/native/esm/components/t/t.web.js +12 -0
- package/dist/native/esm/components/u/context.js +11 -0
- package/dist/native/esm/components/u/index.native.js +3 -0
- package/dist/native/esm/components/u/index.web.js +3 -0
- package/dist/native/esm/components/u/provider.native.js +19 -0
- package/dist/native/esm/components/u/provider.web.js +16 -0
- package/dist/native/esm/components/u/types.js +1 -0
- package/dist/native/esm/components/u/useUniverse.js +5 -0
- package/dist/native/esm/hooks/index.js +5 -0
- package/dist/native/esm/hooks/index.native.js +5 -0
- package/dist/native/esm/hooks/index.web.js +5 -0
- package/dist/native/esm/hooks/useAction/types.js +1 -0
- package/dist/native/esm/hooks/useAction/useAction.native.js +14 -0
- package/dist/native/esm/hooks/useAction/useAction.web.js +17 -0
- package/dist/native/esm/hooks/useCn.js +8 -0
- package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.native.js +28 -0
- package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.types.js +1 -0
- package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.web.js +59 -0
- package/dist/native/esm/hooks/useOnChange.js +14 -0
- package/dist/native/esm/hooks/useProps.js +59 -0
- package/dist/native/esm/index.js +3 -0
- package/dist/native/esm/index.native.js +3 -0
- package/dist/native/esm/index.web.js +3 -0
- package/dist/native/esm/types/base.js +1 -0
- package/dist/native/esm/types/index.js +1 -0
- package/dist/native/tsconfig.native.cjs.tsbuildinfo +1 -0
- package/dist/native/tsconfig.native.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts +14 -2
- package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts.map +1 -1
- package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts +3 -9
- package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts.map +1 -1
- package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts +20 -2
- package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const setWhenUndefined = (value, defaultValue) => {
|
|
2
|
+
return value === undefined ? defaultValue : value;
|
|
3
|
+
};
|
|
4
|
+
const treatTypeModeAndKeyboardType = ({ inputMode, keyboardType, type, }) => {
|
|
5
|
+
let masterInputKeyboardType = keyboardType;
|
|
6
|
+
let masterInputMode = inputMode;
|
|
7
|
+
let masterInputType = type;
|
|
8
|
+
// set values according to inputMode first
|
|
9
|
+
if (masterInputMode === 'numeric' || masterInputMode === 'decimal') {
|
|
10
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'numeric');
|
|
11
|
+
masterInputType = setWhenUndefined(masterInputType, 'number');
|
|
12
|
+
}
|
|
13
|
+
else if (masterInputMode === 'email') {
|
|
14
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'email-address');
|
|
15
|
+
masterInputType = setWhenUndefined(masterInputType, 'email');
|
|
16
|
+
}
|
|
17
|
+
else if (masterInputMode === 'search') {
|
|
18
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'default');
|
|
19
|
+
masterInputType = setWhenUndefined(masterInputType, 'search');
|
|
20
|
+
}
|
|
21
|
+
else if (masterInputMode === 'tel') {
|
|
22
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'phone-pad');
|
|
23
|
+
masterInputType = setWhenUndefined(masterInputType, 'tel');
|
|
24
|
+
}
|
|
25
|
+
else if (masterInputMode === 'url') {
|
|
26
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'url');
|
|
27
|
+
masterInputType = setWhenUndefined(masterInputType, 'url');
|
|
28
|
+
}
|
|
29
|
+
else if (masterInputType === 'text') {
|
|
30
|
+
masterInputKeyboardType = setWhenUndefined(masterInputKeyboardType, 'default');
|
|
31
|
+
masterInputType = setWhenUndefined(masterInputType, 'text');
|
|
32
|
+
}
|
|
33
|
+
// set values according to keyboardType second
|
|
34
|
+
if (masterInputKeyboardType === 'email-address') {
|
|
35
|
+
masterInputMode = setWhenUndefined(masterInputMode, 'email');
|
|
36
|
+
masterInputType = setWhenUndefined(masterInputType, 'email');
|
|
37
|
+
}
|
|
38
|
+
else if (masterInputKeyboardType === 'numeric' ||
|
|
39
|
+
masterInputKeyboardType === 'decimal-pad') {
|
|
40
|
+
masterInputMode = setWhenUndefined(masterInputMode, 'numeric');
|
|
41
|
+
masterInputType = setWhenUndefined(masterInputType, 'number');
|
|
42
|
+
}
|
|
43
|
+
else if (masterInputKeyboardType === 'phone-pad') {
|
|
44
|
+
masterInputMode = setWhenUndefined(masterInputMode, 'tel');
|
|
45
|
+
masterInputType = setWhenUndefined(masterInputType, 'tel');
|
|
46
|
+
}
|
|
47
|
+
else if (masterInputKeyboardType === 'url') {
|
|
48
|
+
masterInputMode = setWhenUndefined(masterInputMode, 'url');
|
|
49
|
+
masterInputType = setWhenUndefined(masterInputType, 'url');
|
|
50
|
+
}
|
|
51
|
+
else if (masterInputKeyboardType === 'default') {
|
|
52
|
+
masterInputMode = setWhenUndefined(masterInputMode, 'text');
|
|
53
|
+
masterInputType = setWhenUndefined(masterInputType, 'text');
|
|
54
|
+
}
|
|
55
|
+
// finally, set default type if still undefined
|
|
56
|
+
masterInputType = setWhenUndefined(masterInputType, 'text');
|
|
57
|
+
return {
|
|
58
|
+
masterInputKeyboardType,
|
|
59
|
+
masterInputMode,
|
|
60
|
+
masterInputType,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export const useIUtils = () => {
|
|
64
|
+
return {
|
|
65
|
+
treatTypeModeAndKeyboardType,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './a/index.web';
|
|
2
|
+
export * from './d/index.web';
|
|
3
|
+
export * from './e/index.web';
|
|
4
|
+
export * from './i/index.web';
|
|
5
|
+
export * from './l/index.web';
|
|
6
|
+
export * from './o/index.web';
|
|
7
|
+
export * from './p/index.web';
|
|
8
|
+
export * from './s/index.web';
|
|
9
|
+
export * from './t/index.web';
|
|
10
|
+
export * from './u/index.web';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './a/index.native';
|
|
2
|
+
export * from './d/index.native';
|
|
3
|
+
export * from './e/index.native';
|
|
4
|
+
export * from './i/index.native';
|
|
5
|
+
export * from './l/index.native';
|
|
6
|
+
export * from './o/index.native';
|
|
7
|
+
export * from './p/index.native';
|
|
8
|
+
export * from './s/index.native';
|
|
9
|
+
export * from './t/index.native';
|
|
10
|
+
export * from './u/index.native';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './a/index.web';
|
|
2
|
+
export * from './d/index.web';
|
|
3
|
+
export * from './e/index.web';
|
|
4
|
+
export * from './i/index.web';
|
|
5
|
+
export * from './l/index.web';
|
|
6
|
+
export * from './o/index.web';
|
|
7
|
+
export * from './p/index.web';
|
|
8
|
+
export * from './s/index.web';
|
|
9
|
+
export * from './t/index.web';
|
|
10
|
+
export * from './u/index.web';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './l.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './l.web';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useAction } from '../../hooks/index.native';
|
|
3
|
+
import { useCn } from '../../hooks/index.web';
|
|
4
|
+
export function L({ className, children, to, href, onClick, onPress, preventDefault, ref, ...rest }) {
|
|
5
|
+
const cn = useCn();
|
|
6
|
+
const { onAction } = useAction({
|
|
7
|
+
onClick,
|
|
8
|
+
onPress,
|
|
9
|
+
});
|
|
10
|
+
const resolvedHref = href ?? to ?? '#';
|
|
11
|
+
return (_jsx("a", { ref: ref, href: resolvedHref, className: cn('cursor-pointer', className), onClick: onAction, ...rest, children: children }));
|
|
12
|
+
}
|
|
13
|
+
export const Link = L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './o.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './o.web';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import { useCn } from '../../hooks/index.native';
|
|
4
|
+
export function O({ className, children, horizontal, ref, ...rest }) {
|
|
5
|
+
const cn = useCn();
|
|
6
|
+
return (_jsx(ScrollView, { ref: ref, className: cn(className), horizontal: horizontal, ...rest, children: children }));
|
|
7
|
+
}
|
|
8
|
+
export const Overflow = O;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useCn } from '../../hooks/index.web';
|
|
3
|
+
export function O({ className, children, horizontal, ref, ...rest }) {
|
|
4
|
+
const cn = useCn();
|
|
5
|
+
const overflowClass = horizontal ? 'overflow-x-auto' : 'overflow-y-auto';
|
|
6
|
+
return (_jsx("div", { ref: ref, className: cn(overflowClass, className), ...rest, children: children }));
|
|
7
|
+
}
|
|
8
|
+
export const Overflow = O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './p.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './p.web';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
import { useCn } from '../../hooks/index.native';
|
|
4
|
+
export function P({ className, src, source, ref, ...rest }) {
|
|
5
|
+
const cn = useCn();
|
|
6
|
+
const finalSource = src != null ? { uri: src } : source;
|
|
7
|
+
return (_jsx(Image, { ref: ref, className: cn(className), source: finalSource, ...rest }));
|
|
8
|
+
}
|
|
9
|
+
export const Picture = P;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useCn } from '../../hooks/index.web';
|
|
3
|
+
export function P({ alt, className, ref, ...rest }) {
|
|
4
|
+
const cn = useCn();
|
|
5
|
+
return (
|
|
6
|
+
// biome-ignore lint/a11y/useAltText: <explanation>
|
|
7
|
+
_jsx("img", { alt: alt, "aria-label": alt, ref: ref, className: cn('object-cover', className), ...rest }));
|
|
8
|
+
}
|
|
9
|
+
export const Picture = P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './s.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './s.web';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { SafeAreaView, } from 'react-native-safe-area-context';
|
|
3
|
+
import { useCn } from '../../hooks/index.native';
|
|
4
|
+
export function S({ className, children, ref, ...rest }) {
|
|
5
|
+
const cn = useCn();
|
|
6
|
+
return (_jsx(SafeAreaView, { ref: ref, className: cn(className), ...rest, children: children }));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './t.native';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './t.web';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { Text as RNText } from 'react-native';
|
|
3
|
+
import { useAction, useCn } from '../../hooks/index.native';
|
|
4
|
+
export function T({ className, children, onClick, onPress, ref, ...rest }) {
|
|
5
|
+
const cn = useCn();
|
|
6
|
+
const { onAction } = useAction({
|
|
7
|
+
onClick,
|
|
8
|
+
onPress,
|
|
9
|
+
});
|
|
10
|
+
return (_jsx(RNText, { ref: ref, className: cn('leading-relaxed', className), onPress: onAction, ...rest, children: children }));
|
|
11
|
+
}
|
|
12
|
+
export const Text = T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useAction, useCn } from '../../hooks/index.web';
|
|
3
|
+
export function T({ className, children, as = 'span', onClick, onPress, ref, ...rest }) {
|
|
4
|
+
const cn = useCn();
|
|
5
|
+
const { onAction } = useAction({
|
|
6
|
+
onClick,
|
|
7
|
+
onPress,
|
|
8
|
+
});
|
|
9
|
+
const Comp = as;
|
|
10
|
+
return (_jsx(Comp, { ref: ref, className: cn('leading-relaxed', className), onClick: onAction, ...rest, children: children }));
|
|
11
|
+
}
|
|
12
|
+
export const Text = T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
const defaultValue = {
|
|
3
|
+
colorScheme: 'system',
|
|
4
|
+
locale: 'en-US',
|
|
5
|
+
platform: 'web',
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
|
+
setColorScheme: () => { },
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
9
|
+
setLocale: () => { },
|
|
10
|
+
};
|
|
11
|
+
export const UniverseContext = createContext(defaultValue);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { Appearance } from 'react-native';
|
|
4
|
+
import { UniverseContext } from './context';
|
|
5
|
+
export function U({ children, config }) {
|
|
6
|
+
const systemColorScheme = Appearance.getColorScheme() ?? 'light';
|
|
7
|
+
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
8
|
+
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
colorScheme,
|
|
11
|
+
locale,
|
|
12
|
+
platform: 'native',
|
|
13
|
+
systemColorScheme,
|
|
14
|
+
setColorScheme,
|
|
15
|
+
setLocale,
|
|
16
|
+
}), [colorScheme, locale, systemColorScheme]);
|
|
17
|
+
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
18
|
+
}
|
|
19
|
+
export const Universe = U;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { UniverseContext } from './context';
|
|
4
|
+
export function U({ children, config }) {
|
|
5
|
+
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
6
|
+
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
7
|
+
const value = useMemo(() => ({
|
|
8
|
+
colorScheme,
|
|
9
|
+
locale,
|
|
10
|
+
platform: 'web',
|
|
11
|
+
setColorScheme,
|
|
12
|
+
setLocale,
|
|
13
|
+
}), [colorScheme, locale]);
|
|
14
|
+
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
15
|
+
}
|
|
16
|
+
export const Universe = U;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export const useAction = ({ onClick, onPress, }) => {
|
|
3
|
+
return useMemo(() => ({
|
|
4
|
+
onAction: (event) => {
|
|
5
|
+
if (onPress) {
|
|
6
|
+
onPress(event);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (onClick) {
|
|
10
|
+
onClick(event);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
}), [onClick, onPress]);
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export const useAction = ({ onClick, onPress, preventDefault, }) => {
|
|
3
|
+
return useMemo(() => ({
|
|
4
|
+
onAction: (event) => {
|
|
5
|
+
if (preventDefault && event && 'preventDefault' in event) {
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
}
|
|
8
|
+
if (onClick) {
|
|
9
|
+
onClick(event);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (onPress) {
|
|
13
|
+
onPress(event);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
}), [onClick, onPress, preventDefault]);
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export function useInteractiveState(options = {}) {
|
|
3
|
+
const { disabled } = options;
|
|
4
|
+
const [pressed, setPressed] = useState(false);
|
|
5
|
+
const state = disabled
|
|
6
|
+
? 'disabled'
|
|
7
|
+
: pressed
|
|
8
|
+
? 'pressed'
|
|
9
|
+
: 'idle';
|
|
10
|
+
const dataAttrs = {
|
|
11
|
+
'data-state': state,
|
|
12
|
+
'data-pressed': pressed ? 'true' : 'false',
|
|
13
|
+
'data-disabled': disabled ? 'true' : 'false',
|
|
14
|
+
};
|
|
15
|
+
const eventHandlers = {
|
|
16
|
+
onPressIn: (e) => {
|
|
17
|
+
if (disabled)
|
|
18
|
+
return;
|
|
19
|
+
setPressed(true);
|
|
20
|
+
},
|
|
21
|
+
onPressOut: (e) => {
|
|
22
|
+
if (disabled)
|
|
23
|
+
return;
|
|
24
|
+
setPressed(false);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return { state, dataAttrs, eventHandlers };
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export function useInteractiveState(options = {}) {
|
|
3
|
+
const { disabled } = options;
|
|
4
|
+
const [hovered, setHovered] = useState(false);
|
|
5
|
+
const [pressed, setPressed] = useState(false);
|
|
6
|
+
const [focused, setFocused] = useState(false);
|
|
7
|
+
const state = disabled
|
|
8
|
+
? 'disabled'
|
|
9
|
+
: pressed
|
|
10
|
+
? 'pressed'
|
|
11
|
+
: hovered
|
|
12
|
+
? 'hovered'
|
|
13
|
+
: focused
|
|
14
|
+
? 'focused'
|
|
15
|
+
: 'idle';
|
|
16
|
+
const dataAttrs = {
|
|
17
|
+
'data-state': state,
|
|
18
|
+
'data-hovered': hovered ? 'true' : 'false',
|
|
19
|
+
'data-pressed': pressed ? 'true' : 'false',
|
|
20
|
+
'data-focused': focused ? 'true' : 'false',
|
|
21
|
+
'data-disabled': disabled ? 'true' : 'false',
|
|
22
|
+
};
|
|
23
|
+
const eventHandlers = {
|
|
24
|
+
onMouseEnter: () => {
|
|
25
|
+
if (disabled)
|
|
26
|
+
return;
|
|
27
|
+
setHovered(true);
|
|
28
|
+
},
|
|
29
|
+
onMouseLeave: () => {
|
|
30
|
+
if (disabled)
|
|
31
|
+
return;
|
|
32
|
+
setHovered(false);
|
|
33
|
+
setPressed(false);
|
|
34
|
+
},
|
|
35
|
+
onMouseDown: (e) => {
|
|
36
|
+
if (disabled || e.button !== 0)
|
|
37
|
+
return;
|
|
38
|
+
setPressed(true);
|
|
39
|
+
},
|
|
40
|
+
onMouseUp: () => {
|
|
41
|
+
if (disabled)
|
|
42
|
+
return;
|
|
43
|
+
setPressed(false);
|
|
44
|
+
},
|
|
45
|
+
onFocus: () => {
|
|
46
|
+
if (disabled)
|
|
47
|
+
return;
|
|
48
|
+
setFocused(true);
|
|
49
|
+
},
|
|
50
|
+
onBlur: () => {
|
|
51
|
+
if (disabled)
|
|
52
|
+
return;
|
|
53
|
+
setFocused(false);
|
|
54
|
+
setPressed(false);
|
|
55
|
+
setHovered(false);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return { state, dataAttrs, eventHandlers };
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export const useOnChange = ({ onChange, onChangeValue }) => {
|
|
3
|
+
return useMemo(() => ({
|
|
4
|
+
onChange: (event) => {
|
|
5
|
+
if (onChange) {
|
|
6
|
+
onChange(event);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (onChangeValue) {
|
|
10
|
+
onChangeValue(event?.target?.value);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
}), [onChange, onChangeValue]);
|
|
14
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const useProps = () => {
|
|
3
|
+
const handleOmit = React.useCallback((obj = {}, keys = []) => {
|
|
4
|
+
if (!obj) {
|
|
5
|
+
return {
|
|
6
|
+
props: {},
|
|
7
|
+
restProps: {},
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
11
|
+
const result = {};
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
13
|
+
const nonUsedProps = {};
|
|
14
|
+
for (const key of Object.keys(obj)) {
|
|
15
|
+
if (!keys.includes(key)) {
|
|
16
|
+
result[key] = obj[key];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
nonUsedProps[key] = obj[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
props: result,
|
|
24
|
+
restProps: nonUsedProps,
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
const handlePick = React.useCallback((obj = {}, keys = []) => {
|
|
28
|
+
if (!obj) {
|
|
29
|
+
return {
|
|
30
|
+
props: {},
|
|
31
|
+
restProps: {},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
35
|
+
const result = {};
|
|
36
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
37
|
+
const nonUsedProps = {};
|
|
38
|
+
for (const key of Object.keys(obj)) {
|
|
39
|
+
if (keys.includes(key)) {
|
|
40
|
+
result[key] = obj[key];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
nonUsedProps[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
props: result /*Pick<
|
|
48
|
+
TObject,
|
|
49
|
+
Exclude<keyof TObject, Exclude<keyof TObject, TKeys>>
|
|
50
|
+
>*/,
|
|
51
|
+
restProps: nonUsedProps,
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
return {
|
|
55
|
+
getPropKey: (obj = {}) => handlePick(obj, ['key']),
|
|
56
|
+
omitProps: handleOmit,
|
|
57
|
+
pickProps: handlePick,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|