@react-xp/aeiou 0.1.0-beta.11 → 0.1.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/cjs/components/a/a.native.js +4 -6
  2. package/dist/cjs/components/a/a.web.js +4 -6
  3. package/dist/cjs/components/e/e.native.js +3 -12
  4. package/dist/cjs/components/e/e.web.js +3 -7
  5. package/dist/cjs/components/l/l.web.js +3 -7
  6. package/dist/cjs/components/t/t.native.js +3 -6
  7. package/dist/cjs/components/t/t.web.js +3 -6
  8. package/dist/cjs/components/u/errorBoundary.js +27 -0
  9. package/dist/cjs/components/u/provider.native.js +3 -2
  10. package/dist/cjs/components/u/provider.web.js +3 -2
  11. package/dist/cjs/hooks/index.js +0 -2
  12. package/dist/cjs/hooks/index.native.js +0 -2
  13. package/dist/cjs/hooks/index.web.js +0 -2
  14. package/dist/cjs/hooks/useInteractiveState/useInteractiveState.native.js +65 -5
  15. package/dist/cjs/hooks/useInteractiveState/useInteractiveState.web.js +62 -21
  16. package/dist/esm/components/a/a.native.js +5 -7
  17. package/dist/esm/components/a/a.web.js +5 -7
  18. package/dist/esm/components/e/e.native.js +4 -13
  19. package/dist/esm/components/e/e.web.js +4 -8
  20. package/dist/esm/components/l/l.web.js +4 -8
  21. package/dist/esm/components/t/t.native.js +4 -7
  22. package/dist/esm/components/t/t.web.js +4 -7
  23. package/dist/esm/components/u/errorBoundary.js +23 -0
  24. package/dist/esm/components/u/provider.native.js +3 -2
  25. package/dist/esm/components/u/provider.web.js +3 -2
  26. package/dist/esm/hooks/index.js +0 -2
  27. package/dist/esm/hooks/index.native.js +0 -2
  28. package/dist/esm/hooks/index.web.js +0 -2
  29. package/dist/esm/hooks/useInteractiveState/useInteractiveState.native.js +66 -6
  30. package/dist/esm/hooks/useInteractiveState/useInteractiveState.web.js +62 -21
  31. package/dist/native/cjs/components/a/a.native.js +4 -6
  32. package/dist/native/cjs/components/a/a.web.js +4 -6
  33. package/dist/native/cjs/components/e/e.native.js +3 -12
  34. package/dist/native/cjs/components/e/e.web.js +3 -7
  35. package/dist/native/cjs/components/l/l.web.js +3 -7
  36. package/dist/native/cjs/components/t/t.native.js +3 -6
  37. package/dist/native/cjs/components/t/t.web.js +3 -6
  38. package/dist/native/cjs/components/u/errorBoundary.js +27 -0
  39. package/dist/native/cjs/components/u/provider.native.js +3 -2
  40. package/dist/native/cjs/components/u/provider.web.js +3 -2
  41. package/dist/native/cjs/hooks/index.js +0 -2
  42. package/dist/native/cjs/hooks/index.native.js +0 -2
  43. package/dist/native/cjs/hooks/index.web.js +0 -2
  44. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.native.js +65 -5
  45. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.web.js +62 -21
  46. package/dist/native/esm/components/a/a.native.js +5 -7
  47. package/dist/native/esm/components/a/a.web.js +5 -7
  48. package/dist/native/esm/components/e/e.native.js +4 -13
  49. package/dist/native/esm/components/e/e.web.js +4 -8
  50. package/dist/native/esm/components/l/l.web.js +4 -8
  51. package/dist/native/esm/components/t/t.native.js +4 -7
  52. package/dist/native/esm/components/t/t.web.js +4 -7
  53. package/dist/native/esm/components/u/errorBoundary.js +23 -0
  54. package/dist/native/esm/components/u/provider.native.js +3 -2
  55. package/dist/native/esm/components/u/provider.web.js +3 -2
  56. package/dist/native/esm/hooks/index.js +0 -2
  57. package/dist/native/esm/hooks/index.native.js +0 -2
  58. package/dist/native/esm/hooks/index.web.js +0 -2
  59. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.native.js +66 -6
  60. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.web.js +62 -21
  61. package/dist/native/tsconfig.native.cjs.tsbuildinfo +1 -1
  62. package/dist/native/tsconfig.native.esm.tsbuildinfo +1 -1
  63. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  64. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  65. package/dist/types/components/a/a.native.d.ts +1 -1
  66. package/dist/types/components/a/a.native.d.ts.map +1 -1
  67. package/dist/types/components/a/a.web.d.ts +1 -1
  68. package/dist/types/components/a/a.web.d.ts.map +1 -1
  69. package/dist/types/components/e/e.native.d.ts +1 -1
  70. package/dist/types/components/e/e.native.d.ts.map +1 -1
  71. package/dist/types/components/e/e.web.d.ts +1 -1
  72. package/dist/types/components/e/e.web.d.ts.map +1 -1
  73. package/dist/types/components/i/useIUtils.d.ts +2 -2
  74. package/dist/types/components/l/l.web.d.ts +1 -1
  75. package/dist/types/components/l/l.web.d.ts.map +1 -1
  76. package/dist/types/components/t/t.native.d.ts +1 -1
  77. package/dist/types/components/t/t.native.d.ts.map +1 -1
  78. package/dist/types/components/t/t.web.d.ts +1 -1
  79. package/dist/types/components/t/t.web.d.ts.map +1 -1
  80. package/dist/types/components/u/errorBoundary.d.ts +18 -0
  81. package/dist/types/components/u/errorBoundary.d.ts.map +1 -0
  82. package/dist/types/components/u/provider.native.d.ts +1 -1
  83. package/dist/types/components/u/provider.native.d.ts.map +1 -1
  84. package/dist/types/components/u/provider.web.d.ts +1 -1
  85. package/dist/types/components/u/provider.web.d.ts.map +1 -1
  86. package/dist/types/components/u/types.d.ts +5 -0
  87. package/dist/types/components/u/types.d.ts.map +1 -1
  88. package/dist/types/hooks/index.d.ts +0 -2
  89. package/dist/types/hooks/index.d.ts.map +1 -1
  90. package/dist/types/hooks/index.native.d.ts +0 -2
  91. package/dist/types/hooks/index.native.d.ts.map +1 -1
  92. package/dist/types/hooks/index.web.d.ts +0 -2
  93. package/dist/types/hooks/index.web.d.ts.map +1 -1
  94. package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts +13 -5
  95. package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts.map +1 -1
  96. package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts +2 -2
  97. package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts.map +1 -1
  98. package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts +10 -7
  99. package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts.map +1 -1
  100. package/dist/types/types/base.d.ts +14 -4
  101. package/dist/types/types/base.d.ts.map +1 -1
  102. package/package.json +1 -1
  103. package/dist/cjs/hooks/useAction/types.js +0 -2
  104. package/dist/cjs/hooks/useAction/useAction.native.js +0 -18
  105. package/dist/cjs/hooks/useAction/useAction.web.js +0 -21
  106. package/dist/cjs/hooks/useOnHoverOrPress.js +0 -21
  107. package/dist/esm/hooks/useAction/types.js +0 -1
  108. package/dist/esm/hooks/useAction/useAction.native.js +0 -14
  109. package/dist/esm/hooks/useAction/useAction.web.js +0 -17
  110. package/dist/esm/hooks/useOnHoverOrPress.js +0 -17
  111. package/dist/native/cjs/hooks/useAction/types.js +0 -2
  112. package/dist/native/cjs/hooks/useAction/useAction.native.js +0 -18
  113. package/dist/native/cjs/hooks/useAction/useAction.web.js +0 -21
  114. package/dist/native/cjs/hooks/useOnHoverOrPress.js +0 -21
  115. package/dist/native/esm/hooks/useAction/types.js +0 -1
  116. package/dist/native/esm/hooks/useAction/useAction.native.js +0 -14
  117. package/dist/native/esm/hooks/useAction/useAction.web.js +0 -17
  118. package/dist/native/esm/hooks/useOnHoverOrPress.js +0 -17
  119. package/dist/types/hooks/useAction/types.d.ts +0 -7
  120. package/dist/types/hooks/useAction/types.d.ts.map +0 -1
  121. package/dist/types/hooks/useAction/useAction.native.d.ts +0 -5
  122. package/dist/types/hooks/useAction/useAction.native.d.ts.map +0 -1
  123. package/dist/types/hooks/useAction/useAction.web.d.ts +0 -5
  124. package/dist/types/hooks/useAction/useAction.web.d.ts.map +0 -1
  125. package/dist/types/hooks/useOnHoverOrPress.d.ts +0 -12
  126. package/dist/types/hooks/useOnHoverOrPress.d.ts.map +0 -1
@@ -6,12 +6,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
7
  const index_native_1 = require("../../hooks/index.native");
8
8
  const index_native_2 = require("../e/index.native");
9
- function A({ className, children, onPress, onClick, disabled, ref, style, ...rest }) {
9
+ function A({ accessibilityLabel, accessibilityRole, accessibilityState, className, children, loading, disabled, ref, style, ...rest }) {
10
10
  const cn = (0, index_native_1.useCn)();
11
- const { onAction } = (0, index_native_1.useAction)({
12
- onClick,
13
- onPress,
14
- });
15
- return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { ref: ref, onPress: onAction, disabled: disabled, children: (0, jsx_runtime_1.jsx)(index_native_2.E, { className: cn(disabled && 'opacity-60', className), style: style, ...rest, children: children }) }));
11
+ const { eventHandlers } = (0, index_native_1.useInteractiveState)({ ...rest, disabled });
12
+ const isDisabled = Boolean(disabled || loading);
13
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { ref: ref, disabled: isDisabled, accessibilityLabel: accessibilityLabel, accessibilityRole: accessibilityRole, accessibilityState: accessibilityState, ...eventHandlers, children: (0, jsx_runtime_1.jsx)(index_native_2.E, { className: cn(disabled && 'opacity-60', className), style: style, ...rest, children: children }) }));
16
14
  }
17
15
  exports.Action = A;
@@ -4,12 +4,10 @@ exports.Action = void 0;
4
4
  exports.A = A;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const index_web_1 = require("../../hooks/index.web");
7
- function A({ className, children, onPress, onClick, disabled, ref, style, ...rest }) {
7
+ function A({ className, children, disabled, loading, ref, style, testID, accessibilityLabel, ...rest }) {
8
8
  const cn = (0, index_web_1.useCn)();
9
- const { onAction } = (0, index_web_1.useAction)({
10
- onClick,
11
- onPress,
12
- });
13
- return ((0, jsx_runtime_1.jsx)("button", { ref: ref, type: "button", disabled: disabled, className: cn('cursor-pointer', disabled && 'opacity-60', className), onClick: onAction, style: style, ...rest, children: children }));
9
+ const { eventHandlers } = (0, index_web_1.useInteractiveState)({ ...rest, disabled });
10
+ const isDisabled = Boolean(disabled || loading);
11
+ return ((0, jsx_runtime_1.jsx)("button", { ref: ref, type: "button", disabled: disabled, className: cn('cursor-pointer', disabled && 'opacity-60', className), style: style, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, "aria-label": accessibilityLabel, "data-testid": testID, ...rest, ...eventHandlers, children: children }));
14
12
  }
15
13
  exports.Action = A;
@@ -6,18 +6,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
7
  const index_native_1 = require("../../hooks/index.native");
8
8
  const index_native_2 = require("../t/index.native");
9
- function E({ className, children, onIn, onOut, onClick, onPress, ref, style, ...rest }) {
9
+ function E({ className, children, ref, style, ...rest }) {
10
10
  const cn = (0, index_native_1.useCn)();
11
- const { onAction } = (0, index_native_1.useAction)({
12
- onClick,
13
- onPress,
14
- });
15
- const { onPress: onHoverOrPress } = (0, index_native_1.useOnHoverOrPress)({ onIn, onOut });
16
- const handleOnPress = () => {
17
- onAction();
18
- onHoverOrPress();
19
- return false;
20
- };
21
- return ((0, jsx_runtime_1.jsx)(react_native_1.View, { ref: ref, className: cn(className), onStartShouldSetResponder: handleOnPress, style: style, ...rest, children: typeof children === 'string' ? (0, jsx_runtime_1.jsx)(index_native_2.T, { children: children }) : children }));
11
+ const { eventHandlers } = (0, index_native_1.useInteractiveState)(rest);
12
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { ref: ref, className: cn(className), style: style, ...rest, ...eventHandlers, children: typeof children === 'string' ? (0, jsx_runtime_1.jsx)(index_native_2.T, { children: children }) : children }));
22
13
  }
23
14
  exports.Element = E;
@@ -4,13 +4,9 @@ exports.Element = void 0;
4
4
  exports.E = E;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const index_web_1 = require("../../hooks/index.web");
7
- function E({ className, children, onIn, onOut, onPress, onClick, ref, style, ...rest }) {
7
+ function E({ className, children, ref, style, ...rest }) {
8
8
  const cn = (0, index_web_1.useCn)();
9
- const { onAction } = (0, index_web_1.useAction)({
10
- onClick,
11
- onPress,
12
- });
13
- const { onMouseEnter, onMouseLeave } = (0, index_web_1.useOnHoverOrPress)({ onIn, onOut });
14
- return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: cn(className), onClick: onAction, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: style, ...rest, children: children }));
9
+ const { eventHandlers } = (0, index_web_1.useInteractiveState)(rest);
10
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: cn(className), style: style, ...rest, ...eventHandlers, children: children }));
15
11
  }
16
12
  exports.Element = E;
@@ -3,15 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Link = void 0;
4
4
  exports.L = L;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
- const index_native_1 = require("../../hooks/index.native");
7
6
  const index_web_1 = require("../../hooks/index.web");
8
- function L({ className, children, to, href, onClick, onPress, preventDefault, ref, style, ...rest }) {
7
+ function L({ className, children, to, href, preventDefault, ref, style, ...rest }) {
9
8
  const cn = (0, index_web_1.useCn)();
10
- const { onAction } = (0, index_native_1.useAction)({
11
- onClick,
12
- onPress,
13
- });
9
+ const { eventHandlers } = (0, index_web_1.useInteractiveState)(rest);
14
10
  const resolvedHref = href ?? to ?? '#';
15
- return ((0, jsx_runtime_1.jsx)("a", { ref: ref, href: resolvedHref, className: cn('cursor-pointer', className), onClick: onAction, style: style, ...rest, children: children }));
11
+ return ((0, jsx_runtime_1.jsx)("a", { ref: ref, href: resolvedHref, className: cn('cursor-pointer', className), style: style, ...rest, ...eventHandlers, children: children }));
16
12
  }
17
13
  exports.Link = L;
@@ -5,12 +5,9 @@ exports.T = T;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
7
  const index_native_1 = require("../../hooks/index.native");
8
- function T({ className, children, onClick, onPress, ref, ...rest }) {
8
+ function T({ className, children, ref, ...rest }) {
9
9
  const cn = (0, index_native_1.useCn)();
10
- const { onAction } = (0, index_native_1.useAction)({
11
- onClick,
12
- onPress,
13
- });
14
- return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { ref: ref, className: cn('leading-relaxed', className), onPress: onAction, ...rest, children: children }));
10
+ const { eventHandlers } = (0, index_native_1.useInteractiveState)(rest);
11
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { ref: ref, className: cn('leading-relaxed', className), ...rest, ...eventHandlers, children: children }));
15
12
  }
16
13
  exports.Text = T;
@@ -4,13 +4,10 @@ exports.Text = void 0;
4
4
  exports.T = T;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const index_web_1 = require("../../hooks/index.web");
7
- function T({ className, children, as = 'span', onClick, onPress, ref, ...rest }) {
7
+ function T({ className, children, as = 'span', ref, ...rest }) {
8
8
  const cn = (0, index_web_1.useCn)();
9
- const { onAction } = (0, index_web_1.useAction)({
10
- onClick,
11
- onPress,
12
- });
9
+ const { eventHandlers } = (0, index_web_1.useInteractiveState)(rest);
13
10
  const Comp = as;
14
- return ((0, jsx_runtime_1.jsx)(Comp, { ref: ref, className: cn('leading-relaxed', className), onClick: onAction, ...rest, children: children }));
11
+ return ((0, jsx_runtime_1.jsx)(Comp, { ref: ref, className: cn('leading-relaxed', className), ...rest, ...eventHandlers, children: children }));
15
12
  }
16
13
  exports.Text = T;
@@ -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
- function U({ children, config }) {
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
- function U({ children, config }) {
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;
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useAction/useAction.web"), exports);
18
17
  __exportStar(require("./useCn"), exports);
19
18
  __exportStar(require("./useInteractiveState/useInteractiveState.web"), exports);
20
19
  __exportStar(require("./useOnChange"), exports);
21
- __exportStar(require("./useOnHoverOrPress"), exports);
22
20
  __exportStar(require("./useProps"), exports);
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useAction/useAction.native"), exports);
18
17
  __exportStar(require("./useCn"), exports);
19
18
  __exportStar(require("./useInteractiveState/useInteractiveState.native"), exports);
20
19
  __exportStar(require("./useOnChange"), exports);
21
- __exportStar(require("./useOnHoverOrPress"), exports);
22
20
  __exportStar(require("./useProps"), exports);
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useAction/useAction.web"), exports);
18
17
  __exportStar(require("./useCn"), exports);
19
18
  __exportStar(require("./useInteractiveState/useInteractiveState.web"), exports);
20
19
  __exportStar(require("./useOnChange"), exports);
21
- __exportStar(require("./useOnHoverOrPress"), exports);
22
20
  __exportStar(require("./useProps"), exports);
@@ -3,29 +3,89 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInteractiveState = useInteractiveState;
4
4
  const react_1 = require("react");
5
5
  function useInteractiveState(options = {}) {
6
- const { disabled } = options;
6
+ const { disabled, onBlur, onClick, onFocus, onPress, onIn, onOut } = options;
7
+ const [hovered, setHovered] = (0, react_1.useState)(false);
7
8
  const [pressed, setPressed] = (0, react_1.useState)(false);
9
+ const [focused, setFocused] = (0, react_1.useState)(false);
10
+ const offOn = (0, react_1.useRef)('off');
8
11
  const state = disabled
9
12
  ? 'disabled'
10
13
  : pressed
11
14
  ? 'pressed'
12
- : 'idle';
15
+ : hovered
16
+ ? 'hovered'
17
+ : focused
18
+ ? 'focused'
19
+ : 'idle';
13
20
  const dataAttrs = {
14
21
  'data-state': state,
15
- 'data-pressed': pressed ? 'true' : 'false',
16
22
  'data-disabled': disabled ? 'true' : 'false',
23
+ 'data-focused': focused ? 'true' : 'false',
24
+ 'data-hovered': hovered ? 'true' : 'false',
25
+ 'data-pressed': pressed ? 'true' : 'false',
17
26
  };
18
27
  const eventHandlers = {
28
+ onBlur: (e) => {
29
+ if (disabled) {
30
+ return;
31
+ }
32
+ onBlur?.(e);
33
+ setFocused(false);
34
+ setPressed(false);
35
+ },
36
+ onFocus: (e) => {
37
+ if (disabled) {
38
+ return;
39
+ }
40
+ onFocus?.(e);
41
+ setFocused(true);
42
+ },
43
+ onIn: (e) => {
44
+ if (disabled) {
45
+ return;
46
+ }
47
+ console.log('[DEBUG] onIn', typeof onIn, e);
48
+ onIn?.(e);
49
+ },
50
+ onPress: (e) => {
51
+ if (disabled) {
52
+ return;
53
+ }
54
+ if ((onIn || onOut) && offOn.current === 'off') {
55
+ offOn.current = 'on';
56
+ onIn?.(e);
57
+ }
58
+ if ((onIn || onOut) && offOn.current === 'on') {
59
+ offOn.current = 'off';
60
+ onOut?.(e);
61
+ }
62
+ if (onPress) {
63
+ onPress?.(e);
64
+ return;
65
+ }
66
+ onClick?.(e);
67
+ },
19
68
  onPressIn: (e) => {
20
- if (disabled)
69
+ if (disabled) {
21
70
  return;
71
+ }
72
+ onIn?.(e);
22
73
  setPressed(true);
23
74
  },
24
75
  onPressOut: (e) => {
25
- if (disabled)
76
+ if (disabled) {
26
77
  return;
78
+ }
79
+ onOut?.(e);
27
80
  setPressed(false);
28
81
  },
82
+ onOut: (e) => {
83
+ if (disabled) {
84
+ return;
85
+ }
86
+ console.log('[DEBUG] onOut', typeof onOut, e);
87
+ onOut?.(e);
88
+ },
29
89
  };
30
90
  return { state, dataAttrs, eventHandlers };
31
91
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInteractiveState = useInteractiveState;
4
4
  const react_1 = require("react");
5
5
  function useInteractiveState(options = {}) {
6
- const { disabled } = options;
6
+ const { disabled, onBlur, onClick, onPress, onFocus, onIn, onOut } = options;
7
7
  const [hovered, setHovered] = (0, react_1.useState)(false);
8
8
  const [pressed, setPressed] = (0, react_1.useState)(false);
9
9
  const [focused, setFocused] = (0, react_1.useState)(false);
@@ -18,44 +18,85 @@ function useInteractiveState(options = {}) {
18
18
  : 'idle';
19
19
  const dataAttrs = {
20
20
  'data-state': state,
21
+ 'data-disabled': disabled ? 'true' : 'false',
22
+ 'data-focused': focused ? 'true' : 'false',
21
23
  'data-hovered': hovered ? 'true' : 'false',
22
24
  'data-pressed': pressed ? 'true' : 'false',
23
- 'data-focused': focused ? 'true' : 'false',
24
- 'data-disabled': disabled ? 'true' : 'false',
25
25
  };
26
26
  const eventHandlers = {
27
- onMouseEnter: () => {
28
- if (disabled)
27
+ onBlur: (e) => {
28
+ if (disabled) {
29
29
  return;
30
- setHovered(true);
30
+ }
31
+ console.log('[DEBUG] onBlur', typeof onBlur, e);
32
+ onBlur?.(e);
33
+ setFocused(false);
34
+ setPressed(false);
35
+ setHovered(false);
31
36
  },
32
- onMouseLeave: () => {
33
- if (disabled)
37
+ onClick: (e) => {
38
+ if (disabled) {
34
39
  return;
35
- setHovered(false);
36
- setPressed(false);
40
+ }
41
+ console.log('[DEBUG] onClick', typeof onClick, e);
42
+ if (onClick) {
43
+ onClick?.(e);
44
+ return;
45
+ }
46
+ onPress?.(e);
47
+ },
48
+ onFocus: (e) => {
49
+ if (disabled) {
50
+ return;
51
+ }
52
+ console.log('[DEBUG] onFocus', typeof onFocus, e);
53
+ onFocus?.(e);
54
+ setFocused(true);
55
+ },
56
+ onIn: (e) => {
57
+ if (disabled) {
58
+ return;
59
+ }
60
+ console.log('[DEBUG] onIn', typeof onIn, e);
61
+ onIn?.(e);
37
62
  },
38
63
  onMouseDown: (e) => {
39
- if (disabled || e.button !== 0)
64
+ if (disabled || e.button !== 0) {
40
65
  return;
66
+ }
67
+ console.log('[DEBUG] onMouseDown', e);
41
68
  setPressed(true);
42
69
  },
43
- onMouseUp: () => {
44
- if (disabled)
70
+ onMouseEnter: (e) => {
71
+ if (disabled) {
45
72
  return;
46
- setPressed(false);
73
+ }
74
+ console.log('[DEBUG] onMouseEnter', typeof onIn, e);
75
+ onIn?.(e);
76
+ setHovered(true);
47
77
  },
48
- onFocus: () => {
49
- if (disabled)
78
+ onMouseLeave: (e) => {
79
+ if (disabled) {
50
80
  return;
51
- setFocused(true);
81
+ }
82
+ console.log('[DEBUG] onMouseLeave', typeof onOut, e);
83
+ onOut?.(e);
84
+ setHovered(false);
85
+ setPressed(false);
52
86
  },
53
- onBlur: () => {
54
- if (disabled)
87
+ onMouseUp: (e) => {
88
+ if (disabled) {
55
89
  return;
56
- setFocused(false);
90
+ }
91
+ console.log('[DEBUG] onMouseUp', e);
57
92
  setPressed(false);
58
- setHovered(false);
93
+ },
94
+ onOut: (e) => {
95
+ if (disabled) {
96
+ return;
97
+ }
98
+ console.log('[DEBUG] onOut', typeof onOut, e);
99
+ onOut?.(e);
59
100
  },
60
101
  };
61
102
  return { state, dataAttrs, eventHandlers };
@@ -1,13 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Pressable } from 'react-native';
3
- import { useAction, useCn } from '../../hooks/index.native';
3
+ import { useCn, useInteractiveState } from '../../hooks/index.native';
4
4
  import { E } from '../e/index.native';
5
- export function A({ className, children, onPress, onClick, disabled, ref, style, ...rest }) {
5
+ export function A({ accessibilityLabel, accessibilityRole, accessibilityState, className, children, loading, disabled, ref, style, ...rest }) {
6
6
  const cn = useCn();
7
- const { onAction } = useAction({
8
- onClick,
9
- onPress,
10
- });
11
- return (_jsx(Pressable, { ref: ref, onPress: onAction, disabled: disabled, children: _jsx(E, { className: cn(disabled && 'opacity-60', className), style: style, ...rest, children: children }) }));
7
+ const { eventHandlers } = useInteractiveState({ ...rest, disabled });
8
+ const isDisabled = Boolean(disabled || loading);
9
+ return (_jsx(Pressable, { ref: ref, disabled: isDisabled, accessibilityLabel: accessibilityLabel, accessibilityRole: accessibilityRole, accessibilityState: accessibilityState, ...eventHandlers, children: _jsx(E, { className: cn(disabled && 'opacity-60', className), style: style, ...rest, children: children }) }));
12
10
  }
13
11
  export const Action = A;
@@ -1,11 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAction, useCn } from '../../hooks/index.web';
3
- export function A({ className, children, onPress, onClick, disabled, ref, style, ...rest }) {
2
+ import { useCn, useInteractiveState } from '../../hooks/index.web';
3
+ export function A({ className, children, disabled, loading, ref, style, testID, accessibilityLabel, ...rest }) {
4
4
  const cn = useCn();
5
- const { onAction } = useAction({
6
- onClick,
7
- onPress,
8
- });
9
- return (_jsx("button", { ref: ref, type: "button", disabled: disabled, className: cn('cursor-pointer', disabled && 'opacity-60', className), onClick: onAction, style: style, ...rest, children: children }));
5
+ const { eventHandlers } = useInteractiveState({ ...rest, disabled });
6
+ const isDisabled = Boolean(disabled || loading);
7
+ return (_jsx("button", { ref: ref, type: "button", disabled: disabled, className: cn('cursor-pointer', disabled && 'opacity-60', className), style: style, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, "aria-label": accessibilityLabel, "data-testid": testID, ...rest, ...eventHandlers, children: children }));
10
8
  }
11
9
  export const Action = A;
@@ -1,19 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { View } from 'react-native';
3
- import { useAction, useCn, useOnHoverOrPress } from '../../hooks/index.native';
3
+ import { useCn, useInteractiveState } from '../../hooks/index.native';
4
4
  import { T } from '../t/index.native';
5
- export function E({ className, children, onIn, onOut, onClick, onPress, ref, style, ...rest }) {
5
+ export function E({ className, children, ref, style, ...rest }) {
6
6
  const cn = useCn();
7
- const { onAction } = useAction({
8
- onClick,
9
- onPress,
10
- });
11
- const { onPress: onHoverOrPress } = useOnHoverOrPress({ onIn, onOut });
12
- const handleOnPress = () => {
13
- onAction();
14
- onHoverOrPress();
15
- return false;
16
- };
17
- return (_jsx(View, { ref: ref, className: cn(className), onStartShouldSetResponder: handleOnPress, style: style, ...rest, children: typeof children === 'string' ? _jsx(T, { children: children }) : children }));
7
+ const { eventHandlers } = useInteractiveState(rest);
8
+ return (_jsx(View, { ref: ref, className: cn(className), style: style, ...rest, ...eventHandlers, children: typeof children === 'string' ? _jsx(T, { children: children }) : children }));
18
9
  }
19
10
  export const Element = E;
@@ -1,12 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAction, useCn, useOnHoverOrPress } from '../../hooks/index.web';
3
- export function E({ className, children, onIn, onOut, onPress, onClick, ref, style, ...rest }) {
2
+ import { useCn, useInteractiveState } from '../../hooks/index.web';
3
+ export function E({ className, children, ref, style, ...rest }) {
4
4
  const cn = useCn();
5
- const { onAction } = useAction({
6
- onClick,
7
- onPress,
8
- });
9
- const { onMouseEnter, onMouseLeave } = useOnHoverOrPress({ onIn, onOut });
10
- return (_jsx("div", { ref: ref, className: cn(className), onClick: onAction, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: style, ...rest, children: children }));
5
+ const { eventHandlers } = useInteractiveState(rest);
6
+ return (_jsx("div", { ref: ref, className: cn(className), style: style, ...rest, ...eventHandlers, children: children }));
11
7
  }
12
8
  export const Element = E;
@@ -1,13 +1,9 @@
1
1
  import { jsx as _jsx } from "react/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, style, ...rest }) {
2
+ import { useCn, useInteractiveState } from '../../hooks/index.web';
3
+ export function L({ className, children, to, href, preventDefault, ref, style, ...rest }) {
5
4
  const cn = useCn();
6
- const { onAction } = useAction({
7
- onClick,
8
- onPress,
9
- });
5
+ const { eventHandlers } = useInteractiveState(rest);
10
6
  const resolvedHref = href ?? to ?? '#';
11
- return (_jsx("a", { ref: ref, href: resolvedHref, className: cn('cursor-pointer', className), onClick: onAction, style: style, ...rest, children: children }));
7
+ return (_jsx("a", { ref: ref, href: resolvedHref, className: cn('cursor-pointer', className), style: style, ...rest, ...eventHandlers, children: children }));
12
8
  }
13
9
  export const Link = L;
@@ -1,12 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
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 }) {
3
+ import { useCn, useInteractiveState } from '../../hooks/index.native';
4
+ export function T({ className, children, ref, ...rest }) {
5
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 }));
6
+ const { eventHandlers } = useInteractiveState(rest);
7
+ return (_jsx(RNText, { ref: ref, className: cn('leading-relaxed', className), ...rest, ...eventHandlers, children: children }));
11
8
  }
12
9
  export const Text = T;
@@ -1,12 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAction, useCn } from '../../hooks/index.web';
3
- export function T({ className, children, as = 'span', onClick, onPress, ref, ...rest }) {
2
+ import { useCn, useInteractiveState } from '../../hooks/index.web';
3
+ export function T({ className, children, as = 'span', ref, ...rest }) {
4
4
  const cn = useCn();
5
- const { onAction } = useAction({
6
- onClick,
7
- onPress,
8
- });
5
+ const { eventHandlers } = useInteractiveState(rest);
9
6
  const Comp = as;
10
- return (_jsx(Comp, { ref: ref, className: cn('leading-relaxed', className), onClick: onAction, ...rest, children: children }));
7
+ return (_jsx(Comp, { ref: ref, className: cn('leading-relaxed', className), ...rest, ...eventHandlers, children: children }));
11
8
  }
12
9
  export const Text = T;
@@ -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
- export function U({ children, config }) {
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
- export function U({ children, config }) {
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;