@react-xp/aeiou 0.1.0-beta.10 → 0.1.0-beta.12
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/components/i/i.native.js +1 -1
- package/dist/cjs/components/i/i.web.js +1 -1
- package/dist/cjs/components/u/errorBoundary.js +27 -0
- package/dist/cjs/components/u/provider.native.js +3 -2
- package/dist/cjs/components/u/provider.web.js +3 -2
- package/dist/cjs/hooks/useOnChange.js +1 -1
- package/dist/esm/components/i/i.native.js +1 -1
- package/dist/esm/components/i/i.web.js +1 -1
- package/dist/esm/components/u/errorBoundary.js +23 -0
- package/dist/esm/components/u/provider.native.js +3 -2
- package/dist/esm/components/u/provider.web.js +3 -2
- package/dist/esm/hooks/useOnChange.js +1 -1
- package/dist/native/cjs/components/i/i.native.js +1 -1
- package/dist/native/cjs/components/i/i.web.js +1 -1
- package/dist/native/cjs/components/u/errorBoundary.js +27 -0
- package/dist/native/cjs/components/u/provider.native.js +3 -2
- package/dist/native/cjs/components/u/provider.web.js +3 -2
- package/dist/native/cjs/hooks/useOnChange.js +1 -1
- package/dist/native/esm/components/i/i.native.js +1 -1
- package/dist/native/esm/components/i/i.web.js +1 -1
- package/dist/native/esm/components/u/errorBoundary.js +23 -0
- package/dist/native/esm/components/u/provider.native.js +3 -2
- package/dist/native/esm/components/u/provider.web.js +3 -2
- package/dist/native/esm/hooks/useOnChange.js +1 -1
- package/dist/native/tsconfig.native.cjs.tsbuildinfo +1 -1
- package/dist/native/tsconfig.native.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/components/i/i.native.d.ts +1 -1
- package/dist/types/components/i/i.native.d.ts.map +1 -1
- package/dist/types/components/i/i.web.d.ts +1 -1
- package/dist/types/components/i/i.web.d.ts.map +1 -1
- package/dist/types/components/u/errorBoundary.d.ts +18 -0
- package/dist/types/components/u/errorBoundary.d.ts.map +1 -0
- package/dist/types/components/u/provider.native.d.ts +1 -1
- package/dist/types/components/u/provider.native.d.ts.map +1 -1
- package/dist/types/components/u/provider.web.d.ts +1 -1
- package/dist/types/components/u/provider.web.d.ts.map +1 -1
- package/dist/types/components/u/types.d.ts +5 -0
- package/dist/types/components/u/types.d.ts.map +1 -1
- package/dist/types/hooks/useOnChange.d.ts +3 -3
- package/dist/types/hooks/useOnChange.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,6 @@ function I({ className, value, defaultValue, placeholder, onChange, onChangeValu
|
|
|
19
19
|
keyboardType,
|
|
20
20
|
type,
|
|
21
21
|
});
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
23
23
|
}
|
|
24
24
|
exports.Input = I;
|
|
@@ -18,6 +18,6 @@ function I({ className, value, defaultValue, placeholder, onChange, onChangeValu
|
|
|
18
18
|
keyboardType,
|
|
19
19
|
type,
|
|
20
20
|
});
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
22
22
|
}
|
|
23
23
|
exports.Input = I;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorBoundary = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
class ErrorBoundary extends react_1.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = { hasError: false };
|
|
10
|
+
}
|
|
11
|
+
static getDerivedStateFromError() {
|
|
12
|
+
return { hasError: true };
|
|
13
|
+
}
|
|
14
|
+
componentDidCatch(error, errorInfo) {
|
|
15
|
+
this.props.onError?.callback?.(error, errorInfo);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
if (this.state.hasError) {
|
|
19
|
+
if (this.props.onError?.render) {
|
|
20
|
+
return this.props.onError.render;
|
|
21
|
+
}
|
|
22
|
+
return (0, jsx_runtime_1.jsx)("h1", { children: "Ocorreu um erro. Por favor, tente novamente mais tarde." });
|
|
23
|
+
}
|
|
24
|
+
return this.props.children;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -6,7 +6,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_native_1 = require("react-native");
|
|
8
8
|
const context_1 = require("./context");
|
|
9
|
-
|
|
9
|
+
const errorBoundary_1 = require("./errorBoundary");
|
|
10
|
+
function U({ children, config, onError }) {
|
|
10
11
|
const systemColorScheme = react_native_1.Appearance.getColorScheme() ?? 'light';
|
|
11
12
|
const [colorScheme, setColorScheme] = (0, react_1.useState)(config?.colorScheme ?? 'system');
|
|
12
13
|
const [locale, setLocale] = (0, react_1.useState)(config?.locale ?? 'en-US');
|
|
@@ -18,6 +19,6 @@ function U({ children, config }) {
|
|
|
18
19
|
setColorScheme,
|
|
19
20
|
setLocale,
|
|
20
21
|
}), [colorScheme, locale, systemColorScheme]);
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }));
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { onError: onError, children: (0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }) }));
|
|
22
23
|
}
|
|
23
24
|
exports.Universe = U;
|
|
@@ -5,7 +5,8 @@ exports.U = U;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const context_1 = require("./context");
|
|
8
|
-
|
|
8
|
+
const errorBoundary_1 = require("./errorBoundary");
|
|
9
|
+
function U({ children, config, onError }) {
|
|
9
10
|
const [colorScheme, setColorScheme] = (0, react_1.useState)(config?.colorScheme ?? 'system');
|
|
10
11
|
const [locale, setLocale] = (0, react_1.useState)(config?.locale ?? 'en-US');
|
|
11
12
|
const value = (0, react_1.useMemo)(() => ({
|
|
@@ -15,6 +16,6 @@ function U({ children, config }) {
|
|
|
15
16
|
setColorScheme,
|
|
16
17
|
setLocale,
|
|
17
18
|
}), [colorScheme, locale]);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }));
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { onError: onError, children: (0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }) }));
|
|
19
20
|
}
|
|
20
21
|
exports.Universe = U;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOnChange = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const useOnChange = ({ onChange, onChangeValue }) => {
|
|
5
|
+
const useOnChange = ({ onChange, onChangeValue, }) => {
|
|
6
6
|
return (0, react_1.useMemo)(() => ({
|
|
7
7
|
onChange: (event) => {
|
|
8
8
|
if (onChange) {
|
|
@@ -15,6 +15,6 @@ export function I({ className, value, defaultValue, placeholder, onChange, onCha
|
|
|
15
15
|
keyboardType,
|
|
16
16
|
type,
|
|
17
17
|
});
|
|
18
|
-
return (_jsx(TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
18
|
+
return (_jsx(TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
19
19
|
}
|
|
20
20
|
export const Input = I;
|
|
@@ -14,6 +14,6 @@ export function I({ className, value, defaultValue, placeholder, onChange, onCha
|
|
|
14
14
|
keyboardType,
|
|
15
15
|
type,
|
|
16
16
|
});
|
|
17
|
-
return (_jsx("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
17
|
+
return (_jsx("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
18
18
|
}
|
|
19
19
|
export const Input = I;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
export class ErrorBoundary extends Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = { hasError: false };
|
|
7
|
+
}
|
|
8
|
+
static getDerivedStateFromError() {
|
|
9
|
+
return { hasError: true };
|
|
10
|
+
}
|
|
11
|
+
componentDidCatch(error, errorInfo) {
|
|
12
|
+
this.props.onError?.callback?.(error, errorInfo);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
if (this.state.hasError) {
|
|
16
|
+
if (this.props.onError?.render) {
|
|
17
|
+
return this.props.onError.render;
|
|
18
|
+
}
|
|
19
|
+
return _jsx("h1", { children: "Ocorreu um erro. Por favor, tente novamente mais tarde." });
|
|
20
|
+
}
|
|
21
|
+
return this.props.children;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { Appearance } from 'react-native';
|
|
4
4
|
import { UniverseContext } from './context';
|
|
5
|
-
|
|
5
|
+
import { ErrorBoundary } from './errorBoundary';
|
|
6
|
+
export function U({ children, config, onError }) {
|
|
6
7
|
const systemColorScheme = Appearance.getColorScheme() ?? 'light';
|
|
7
8
|
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
8
9
|
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
@@ -14,6 +15,6 @@ export function U({ children, config }) {
|
|
|
14
15
|
setColorScheme,
|
|
15
16
|
setLocale,
|
|
16
17
|
}), [colorScheme, locale, systemColorScheme]);
|
|
17
|
-
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
18
|
+
return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
|
|
18
19
|
}
|
|
19
20
|
export const Universe = U;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { UniverseContext } from './context';
|
|
4
|
-
|
|
4
|
+
import { ErrorBoundary } from './errorBoundary';
|
|
5
|
+
export function U({ children, config, onError }) {
|
|
5
6
|
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
6
7
|
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
7
8
|
const value = useMemo(() => ({
|
|
@@ -11,6 +12,6 @@ export function U({ children, config }) {
|
|
|
11
12
|
setColorScheme,
|
|
12
13
|
setLocale,
|
|
13
14
|
}), [colorScheme, locale]);
|
|
14
|
-
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
15
|
+
return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
|
|
15
16
|
}
|
|
16
17
|
export const Universe = U;
|
|
@@ -19,6 +19,6 @@ function I({ className, value, defaultValue, placeholder, onChange, onChangeValu
|
|
|
19
19
|
keyboardType,
|
|
20
20
|
type,
|
|
21
21
|
});
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
23
23
|
}
|
|
24
24
|
exports.Input = I;
|
|
@@ -18,6 +18,6 @@ function I({ className, value, defaultValue, placeholder, onChange, onChangeValu
|
|
|
18
18
|
keyboardType,
|
|
19
19
|
type,
|
|
20
20
|
});
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
22
22
|
}
|
|
23
23
|
exports.Input = I;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorBoundary = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("nativewind/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
class ErrorBoundary extends react_1.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.state = { hasError: false };
|
|
10
|
+
}
|
|
11
|
+
static getDerivedStateFromError() {
|
|
12
|
+
return { hasError: true };
|
|
13
|
+
}
|
|
14
|
+
componentDidCatch(error, errorInfo) {
|
|
15
|
+
this.props.onError?.callback?.(error, errorInfo);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
if (this.state.hasError) {
|
|
19
|
+
if (this.props.onError?.render) {
|
|
20
|
+
return this.props.onError.render;
|
|
21
|
+
}
|
|
22
|
+
return (0, jsx_runtime_1.jsx)("h1", { children: "Ocorreu um erro. Por favor, tente novamente mais tarde." });
|
|
23
|
+
}
|
|
24
|
+
return this.props.children;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -6,7 +6,8 @@ const jsx_runtime_1 = require("nativewind/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_native_1 = require("react-native");
|
|
8
8
|
const context_1 = require("./context");
|
|
9
|
-
|
|
9
|
+
const errorBoundary_1 = require("./errorBoundary");
|
|
10
|
+
function U({ children, config, onError }) {
|
|
10
11
|
const systemColorScheme = react_native_1.Appearance.getColorScheme() ?? 'light';
|
|
11
12
|
const [colorScheme, setColorScheme] = (0, react_1.useState)(config?.colorScheme ?? 'system');
|
|
12
13
|
const [locale, setLocale] = (0, react_1.useState)(config?.locale ?? 'en-US');
|
|
@@ -18,6 +19,6 @@ function U({ children, config }) {
|
|
|
18
19
|
setColorScheme,
|
|
19
20
|
setLocale,
|
|
20
21
|
}), [colorScheme, locale, systemColorScheme]);
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }));
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { onError: onError, children: (0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }) }));
|
|
22
23
|
}
|
|
23
24
|
exports.Universe = U;
|
|
@@ -5,7 +5,8 @@ exports.U = U;
|
|
|
5
5
|
const jsx_runtime_1 = require("nativewind/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const context_1 = require("./context");
|
|
8
|
-
|
|
8
|
+
const errorBoundary_1 = require("./errorBoundary");
|
|
9
|
+
function U({ children, config, onError }) {
|
|
9
10
|
const [colorScheme, setColorScheme] = (0, react_1.useState)(config?.colorScheme ?? 'system');
|
|
10
11
|
const [locale, setLocale] = (0, react_1.useState)(config?.locale ?? 'en-US');
|
|
11
12
|
const value = (0, react_1.useMemo)(() => ({
|
|
@@ -15,6 +16,6 @@ function U({ children, config }) {
|
|
|
15
16
|
setColorScheme,
|
|
16
17
|
setLocale,
|
|
17
18
|
}), [colorScheme, locale]);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }));
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { onError: onError, children: (0, jsx_runtime_1.jsx)(context_1.UniverseContext.Provider, { value: value, children: children }) }));
|
|
19
20
|
}
|
|
20
21
|
exports.Universe = U;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOnChange = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const useOnChange = ({ onChange, onChangeValue }) => {
|
|
5
|
+
const useOnChange = ({ onChange, onChangeValue, }) => {
|
|
6
6
|
return (0, react_1.useMemo)(() => ({
|
|
7
7
|
onChange: (event) => {
|
|
8
8
|
if (onChange) {
|
|
@@ -15,6 +15,6 @@ export function I({ className, value, defaultValue, placeholder, onChange, onCha
|
|
|
15
15
|
keyboardType,
|
|
16
16
|
type,
|
|
17
17
|
});
|
|
18
|
-
return (_jsx(TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
18
|
+
return (_jsx(TextInput, { ref: ref, className: cn(!effectiveEditable && 'opacity-60', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, secureTextEntry: masterInputType === 'password', keyboardType: masterInputKeyboardType, editable: effectiveEditable, style: style, ...rest }));
|
|
19
19
|
}
|
|
20
20
|
export const Input = I;
|
|
@@ -14,6 +14,6 @@ export function I({ className, value, defaultValue, placeholder, onChange, onCha
|
|
|
14
14
|
keyboardType,
|
|
15
15
|
type,
|
|
16
16
|
});
|
|
17
|
-
return (_jsx("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value, defaultValue: defaultValue, placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
17
|
+
return (_jsx("input", { ref: ref, type: masterInputType, inputMode: masterInputMode, className: cn('outline-none', effectiveDisabled && 'opacity-60 cursor-not-allowed', className), value: value?.toString(), defaultValue: defaultValue?.toString(), placeholder: placeholder, onChange: handleOnChange, disabled: effectiveDisabled, style: style, ...rest }));
|
|
18
18
|
}
|
|
19
19
|
export const Input = I;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
export class ErrorBoundary extends Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.state = { hasError: false };
|
|
7
|
+
}
|
|
8
|
+
static getDerivedStateFromError() {
|
|
9
|
+
return { hasError: true };
|
|
10
|
+
}
|
|
11
|
+
componentDidCatch(error, errorInfo) {
|
|
12
|
+
this.props.onError?.callback?.(error, errorInfo);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
if (this.state.hasError) {
|
|
16
|
+
if (this.props.onError?.render) {
|
|
17
|
+
return this.props.onError.render;
|
|
18
|
+
}
|
|
19
|
+
return _jsx("h1", { children: "Ocorreu um erro. Por favor, tente novamente mais tarde." });
|
|
20
|
+
}
|
|
21
|
+
return this.props.children;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { Appearance } from 'react-native';
|
|
4
4
|
import { UniverseContext } from './context';
|
|
5
|
-
|
|
5
|
+
import { ErrorBoundary } from './errorBoundary';
|
|
6
|
+
export function U({ children, config, onError }) {
|
|
6
7
|
const systemColorScheme = Appearance.getColorScheme() ?? 'light';
|
|
7
8
|
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
8
9
|
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
@@ -14,6 +15,6 @@ export function U({ children, config }) {
|
|
|
14
15
|
setColorScheme,
|
|
15
16
|
setLocale,
|
|
16
17
|
}), [colorScheme, locale, systemColorScheme]);
|
|
17
|
-
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
18
|
+
return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
|
|
18
19
|
}
|
|
19
20
|
export const Universe = U;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { UniverseContext } from './context';
|
|
4
|
-
|
|
4
|
+
import { ErrorBoundary } from './errorBoundary';
|
|
5
|
+
export function U({ children, config, onError }) {
|
|
5
6
|
const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
|
|
6
7
|
const [locale, setLocale] = useState(config?.locale ?? 'en-US');
|
|
7
8
|
const value = useMemo(() => ({
|
|
@@ -11,6 +12,6 @@ export function U({ children, config }) {
|
|
|
11
12
|
setColorScheme,
|
|
12
13
|
setLocale,
|
|
13
14
|
}), [colorScheme, locale]);
|
|
14
|
-
return (_jsx(UniverseContext.Provider, { value: value, children: children }));
|
|
15
|
+
return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
|
|
15
16
|
}
|
|
16
17
|
export const Universe = U;
|