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

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 (171) hide show
  1. package/dist/cjs/components/a/a.native.js +6 -4
  2. package/dist/cjs/components/a/a.web.js +6 -4
  3. package/dist/cjs/components/d/d.native.js +7 -7
  4. package/dist/cjs/components/d/d.web.js +8 -8
  5. package/dist/cjs/components/e/e.native.js +7 -5
  6. package/dist/cjs/components/e/e.web.js +7 -5
  7. package/dist/cjs/components/i/i.native.js +9 -5
  8. package/dist/cjs/components/i/i.web.js +9 -5
  9. package/dist/cjs/components/l/l.web.js +7 -5
  10. package/dist/cjs/components/o/o.native.js +4 -4
  11. package/dist/cjs/components/o/o.web.js +7 -4
  12. package/dist/cjs/components/p/p.native.js +4 -4
  13. package/dist/cjs/components/p/p.web.js +7 -4
  14. package/dist/cjs/components/s/s.native.js +4 -4
  15. package/dist/cjs/components/t/t.native.js +7 -5
  16. package/dist/cjs/components/t/t.web.js +7 -5
  17. package/dist/cjs/hooks/index.js +0 -1
  18. package/dist/cjs/hooks/index.native.js +2 -0
  19. package/dist/cjs/hooks/index.web.js +2 -0
  20. package/dist/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +43 -0
  21. package/dist/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +45 -0
  22. package/dist/cjs/hooks/useInteractiveState/useInteractiveState.native.js +16 -38
  23. package/dist/cjs/hooks/useInteractiveState/useInteractiveState.web.js +19 -48
  24. package/dist/cjs/hooks/useStyles/useStyles.helpers.js +35 -0
  25. package/dist/cjs/hooks/useStyles/useStyles.native.js +42 -0
  26. package/dist/cjs/hooks/useStyles/useStyles.web.js +71 -0
  27. package/dist/esm/components/a/a.native.js +6 -4
  28. package/dist/esm/components/a/a.web.js +6 -4
  29. package/dist/esm/components/d/d.native.js +5 -5
  30. package/dist/esm/components/d/d.web.js +5 -5
  31. package/dist/esm/components/e/e.native.js +6 -4
  32. package/dist/esm/components/e/e.web.js +6 -4
  33. package/dist/esm/components/i/i.native.js +7 -3
  34. package/dist/esm/components/i/i.web.js +7 -3
  35. package/dist/esm/components/l/l.web.js +6 -4
  36. package/dist/esm/components/o/o.native.js +3 -3
  37. package/dist/esm/components/o/o.web.js +6 -3
  38. package/dist/esm/components/p/p.native.js +3 -3
  39. package/dist/esm/components/p/p.web.js +6 -3
  40. package/dist/esm/components/s/s.native.js +3 -3
  41. package/dist/esm/components/t/t.native.js +6 -4
  42. package/dist/esm/components/t/t.web.js +6 -4
  43. package/dist/esm/hooks/index.js +0 -1
  44. package/dist/esm/hooks/index.native.js +2 -0
  45. package/dist/esm/hooks/index.web.js +2 -0
  46. package/dist/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +40 -0
  47. package/dist/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +42 -0
  48. package/dist/esm/hooks/useInteractiveState/useInteractiveState.native.js +16 -38
  49. package/dist/esm/hooks/useInteractiveState/useInteractiveState.web.js +19 -48
  50. package/dist/esm/hooks/useStyles/useStyles.helpers.js +29 -0
  51. package/dist/esm/hooks/useStyles/useStyles.native.js +38 -0
  52. package/dist/esm/hooks/useStyles/useStyles.web.js +66 -0
  53. package/dist/native/cjs/components/a/a.native.js +6 -4
  54. package/dist/native/cjs/components/a/a.web.js +6 -4
  55. package/dist/native/cjs/components/d/d.native.js +7 -7
  56. package/dist/native/cjs/components/d/d.web.js +8 -8
  57. package/dist/native/cjs/components/e/e.native.js +7 -5
  58. package/dist/native/cjs/components/e/e.web.js +7 -5
  59. package/dist/native/cjs/components/i/i.native.js +9 -5
  60. package/dist/native/cjs/components/i/i.web.js +9 -5
  61. package/dist/native/cjs/components/l/l.web.js +7 -5
  62. package/dist/native/cjs/components/o/o.native.js +4 -4
  63. package/dist/native/cjs/components/o/o.web.js +7 -4
  64. package/dist/native/cjs/components/p/p.native.js +4 -4
  65. package/dist/native/cjs/components/p/p.web.js +7 -4
  66. package/dist/native/cjs/components/s/s.native.js +4 -4
  67. package/dist/native/cjs/components/t/t.native.js +7 -5
  68. package/dist/native/cjs/components/t/t.web.js +7 -5
  69. package/dist/native/cjs/hooks/index.js +0 -1
  70. package/dist/native/cjs/hooks/index.native.js +2 -0
  71. package/dist/native/cjs/hooks/index.web.js +2 -0
  72. package/dist/native/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +43 -0
  73. package/dist/native/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +45 -0
  74. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.native.js +16 -38
  75. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.web.js +19 -48
  76. package/dist/native/cjs/hooks/useStyles/useStyles.helpers.js +35 -0
  77. package/dist/native/cjs/hooks/useStyles/useStyles.native.js +42 -0
  78. package/dist/native/cjs/hooks/useStyles/useStyles.web.js +71 -0
  79. package/dist/native/esm/components/a/a.native.js +6 -4
  80. package/dist/native/esm/components/a/a.web.js +6 -4
  81. package/dist/native/esm/components/d/d.native.js +5 -5
  82. package/dist/native/esm/components/d/d.web.js +5 -5
  83. package/dist/native/esm/components/e/e.native.js +6 -4
  84. package/dist/native/esm/components/e/e.web.js +6 -4
  85. package/dist/native/esm/components/i/i.native.js +7 -3
  86. package/dist/native/esm/components/i/i.web.js +7 -3
  87. package/dist/native/esm/components/l/l.web.js +6 -4
  88. package/dist/native/esm/components/o/o.native.js +3 -3
  89. package/dist/native/esm/components/o/o.web.js +6 -3
  90. package/dist/native/esm/components/p/p.native.js +3 -3
  91. package/dist/native/esm/components/p/p.web.js +6 -3
  92. package/dist/native/esm/components/s/s.native.js +3 -3
  93. package/dist/native/esm/components/t/t.native.js +6 -4
  94. package/dist/native/esm/components/t/t.web.js +6 -4
  95. package/dist/native/esm/hooks/index.js +0 -1
  96. package/dist/native/esm/hooks/index.native.js +2 -0
  97. package/dist/native/esm/hooks/index.web.js +2 -0
  98. package/dist/native/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +40 -0
  99. package/dist/native/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +42 -0
  100. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.native.js +16 -38
  101. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.web.js +19 -48
  102. package/dist/native/esm/hooks/useStyles/useStyles.helpers.js +29 -0
  103. package/dist/native/esm/hooks/useStyles/useStyles.native.js +38 -0
  104. package/dist/native/esm/hooks/useStyles/useStyles.web.js +66 -0
  105. package/dist/native/tsconfig.native.cjs.tsbuildinfo +1 -1
  106. package/dist/native/tsconfig.native.esm.tsbuildinfo +1 -1
  107. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  108. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  109. package/dist/types/components/a/a.native.d.ts +1 -1
  110. package/dist/types/components/a/a.native.d.ts.map +1 -1
  111. package/dist/types/components/a/a.web.d.ts +1 -1
  112. package/dist/types/components/a/a.web.d.ts.map +1 -1
  113. package/dist/types/components/d/d.native.d.ts +1 -1
  114. package/dist/types/components/d/d.native.d.ts.map +1 -1
  115. package/dist/types/components/d/d.web.d.ts +1 -1
  116. package/dist/types/components/d/d.web.d.ts.map +1 -1
  117. package/dist/types/components/e/e.native.d.ts +1 -1
  118. package/dist/types/components/e/e.native.d.ts.map +1 -1
  119. package/dist/types/components/e/e.web.d.ts +1 -1
  120. package/dist/types/components/e/e.web.d.ts.map +1 -1
  121. package/dist/types/components/i/i.native.d.ts +1 -1
  122. package/dist/types/components/i/i.native.d.ts.map +1 -1
  123. package/dist/types/components/i/i.web.d.ts +1 -1
  124. package/dist/types/components/i/i.web.d.ts.map +1 -1
  125. package/dist/types/components/l/l.web.d.ts +1 -1
  126. package/dist/types/components/l/l.web.d.ts.map +1 -1
  127. package/dist/types/components/o/o.native.d.ts +1 -1
  128. package/dist/types/components/o/o.native.d.ts.map +1 -1
  129. package/dist/types/components/o/o.web.d.ts +1 -1
  130. package/dist/types/components/o/o.web.d.ts.map +1 -1
  131. package/dist/types/components/p/p.native.d.ts +1 -1
  132. package/dist/types/components/p/p.native.d.ts.map +1 -1
  133. package/dist/types/components/p/p.web.d.ts +1 -1
  134. package/dist/types/components/p/p.web.d.ts.map +1 -1
  135. package/dist/types/components/s/s.native.d.ts +1 -1
  136. package/dist/types/components/s/s.native.d.ts.map +1 -1
  137. package/dist/types/components/t/t.native.d.ts +1 -1
  138. package/dist/types/components/t/t.native.d.ts.map +1 -1
  139. package/dist/types/components/t/t.web.d.ts +1 -1
  140. package/dist/types/components/t/t.web.d.ts.map +1 -1
  141. package/dist/types/hooks/index.d.ts +0 -1
  142. package/dist/types/hooks/index.d.ts.map +1 -1
  143. package/dist/types/hooks/index.native.d.ts +2 -0
  144. package/dist/types/hooks/index.native.d.ts.map +1 -1
  145. package/dist/types/hooks/index.web.d.ts +2 -0
  146. package/dist/types/hooks/index.web.d.ts.map +1 -1
  147. package/dist/types/hooks/useInteractiveHandlers/useInteractiveHandlers.native.d.ts +11 -0
  148. package/dist/types/hooks/useInteractiveHandlers/useInteractiveHandlers.native.d.ts.map +1 -0
  149. package/dist/types/hooks/useInteractiveHandlers/useInteractiveHandlers.web.d.ts +12 -0
  150. package/dist/types/hooks/useInteractiveHandlers/useInteractiveHandlers.web.d.ts.map +1 -0
  151. package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts +5 -7
  152. package/dist/types/hooks/useInteractiveState/useInteractiveState.native.d.ts.map +1 -1
  153. package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts +5 -7
  154. package/dist/types/hooks/useInteractiveState/useInteractiveState.web.d.ts.map +1 -1
  155. package/dist/types/hooks/useStyles/useStyles.helpers.d.ts +171 -0
  156. package/dist/types/hooks/useStyles/useStyles.helpers.d.ts.map +1 -0
  157. package/dist/types/hooks/useStyles/useStyles.native.d.ts +15 -0
  158. package/dist/types/hooks/useStyles/useStyles.native.d.ts.map +1 -0
  159. package/dist/types/hooks/useStyles/useStyles.types.d.ts +6 -0
  160. package/dist/types/hooks/useStyles/useStyles.types.d.ts.map +1 -0
  161. package/dist/types/hooks/useStyles/useStyles.web.d.ts +11 -0
  162. package/dist/types/hooks/useStyles/useStyles.web.d.ts.map +1 -0
  163. package/dist/types/types/base.d.ts +28 -6
  164. package/dist/types/types/base.d.ts.map +1 -1
  165. package/package.json +1 -1
  166. package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts +0 -18
  167. package/dist/types/hooks/useInteractiveState/useInteractiveState.types.d.ts.map +0 -1
  168. /package/dist/cjs/hooks/{useInteractiveState/useInteractiveState.types.js → useStyles/useStyles.types.js} +0 -0
  169. /package/dist/esm/hooks/{useInteractiveState/useInteractiveState.types.js → useStyles/useStyles.types.js} +0 -0
  170. /package/dist/native/cjs/hooks/{useInteractiveState/useInteractiveState.types.js → useStyles/useStyles.types.js} +0 -0
  171. /package/dist/native/esm/hooks/{useInteractiveState/useInteractiveState.types.js → useStyles/useStyles.types.js} +0 -0
@@ -4,9 +4,9 @@ exports.Overflow = void 0;
4
4
  exports.O = O;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
- const index_native_1 = require("../../hooks/index.native");
8
- function O({ className, children, horizontal, ref, ...rest }) {
9
- const cn = (0, index_native_1.useCn)();
10
- return ((0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { ref: ref, className: cn(className), horizontal: horizontal, ...rest, children: children }));
7
+ const useCn_1 = require("../../hooks/useCn");
8
+ function O({ className, children, horizontal, ref, ...restProps }) {
9
+ const cn = (0, useCn_1.useCn)();
10
+ return ((0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { ref: ref, className: cn(className), horizontal: horizontal, ...restProps, children: children }));
11
11
  }
12
12
  exports.Overflow = O;
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Overflow = void 0;
4
4
  exports.O = O;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
- const index_web_1 = require("../../hooks/index.web");
7
- function O({ className, children, horizontal, ref, style, ...rest }) {
8
- const cn = (0, index_web_1.useCn)();
6
+ const useCn_1 = require("../../hooks/useCn");
7
+ const index_web_1 = require("../../index.web");
8
+ function O({ className, children, horizontal, ref, style, ...restProps }) {
9
+ const cn = (0, useCn_1.useCn)();
10
+ const { disabled, eventHandlers } = (0, index_web_1.useInteractiveHandlers)(restProps);
11
+ const { getStyles } = (0, index_web_1.useStyles)();
9
12
  const overflowClass = horizontal ? 'overflow-x-auto' : 'overflow-y-auto';
10
- return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: cn(overflowClass, className), style: style, ...rest, children: children }));
13
+ return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: cn(overflowClass, className), ...restProps, ...eventHandlers, ...getStyles({ disabled, style }), children: children }));
11
14
  }
12
15
  exports.Overflow = O;
@@ -4,10 +4,10 @@ exports.Picture = void 0;
4
4
  exports.P = P;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
- const index_native_1 = require("../../hooks/index.native");
8
- function P({ className, src, source, ref, ...rest }) {
9
- const cn = (0, index_native_1.useCn)();
7
+ const useCn_1 = require("../../hooks/useCn");
8
+ function P({ className, src, source, ref, ...restProps }) {
9
+ const cn = (0, useCn_1.useCn)();
10
10
  const finalSource = src != null ? { uri: src } : source;
11
- return ((0, jsx_runtime_1.jsx)(react_native_1.Image, { ref: ref, className: cn(className), source: finalSource, ...rest }));
11
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Image, { ref: ref, className: cn(className), source: finalSource, ...restProps }));
12
12
  }
13
13
  exports.Picture = P;
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Picture = void 0;
4
4
  exports.P = P;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
- const index_web_1 = require("../../hooks/index.web");
7
- function P({ alt, className, ref, style, ...rest }) {
8
- const cn = (0, index_web_1.useCn)();
6
+ const useCn_1 = require("../../hooks/useCn");
7
+ const index_web_1 = require("../../index.web");
8
+ function P({ alt, className, ref, style, source, src, ...restProps }) {
9
+ const cn = (0, useCn_1.useCn)();
10
+ const { disabled, eventHandlers } = (0, index_web_1.useInteractiveHandlers)(restProps);
11
+ const { getStyles } = (0, index_web_1.useStyles)();
9
12
  return (
10
13
  // biome-ignore lint/a11y/useAltText: <explanation>
11
- (0, jsx_runtime_1.jsx)("img", { alt: alt, "aria-label": alt, ref: ref, className: cn('object-cover', className), style: style, ...rest }));
14
+ (0, jsx_runtime_1.jsx)("img", { alt: alt, "aria-label": alt, ref: ref, className: cn('object-cover', className), src: src ?? source, ...restProps, ...eventHandlers, ...getStyles({ disabled, style }) }));
12
15
  }
13
16
  exports.Picture = P;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.S = S;
4
4
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
5
5
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
6
- const index_native_1 = require("../../hooks/index.native");
7
- function S({ className, children, ref, ...rest }) {
8
- const cn = (0, index_native_1.useCn)();
9
- return ((0, jsx_runtime_1.jsx)(react_native_safe_area_context_1.SafeAreaView, { ref: ref, className: cn(className), ...rest, children: children }));
6
+ const useCn_1 = require("../../hooks/useCn");
7
+ function S({ className, children, ref, ...restProps }) {
8
+ const cn = (0, useCn_1.useCn)();
9
+ return ((0, jsx_runtime_1.jsx)(react_native_safe_area_context_1.SafeAreaView, { ref: ref, className: cn(className), ...restProps, children: children }));
10
10
  }
@@ -4,10 +4,12 @@ exports.Text = void 0;
4
4
  exports.T = T;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
6
  const react_native_1 = require("react-native");
7
- const index_native_1 = require("../../hooks/index.native");
8
- function T({ className, children, ref, ...rest }) {
9
- const cn = (0, index_native_1.useCn)();
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 }));
7
+ const useCn_1 = require("../../hooks/useCn");
8
+ const index_native_1 = require("../../index.native");
9
+ function T({ className, children, ref, style, ...restProps }) {
10
+ const cn = (0, useCn_1.useCn)();
11
+ const { disabled, eventHandlers } = (0, index_native_1.useInteractiveHandlers)(restProps);
12
+ const { getStyles } = (0, index_native_1.useStyles)();
13
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { ref: ref, className: cn('leading-relaxed', className), ...restProps, ...eventHandlers, ...getStyles({ disabled, style }), children: children }));
12
14
  }
13
15
  exports.Text = T;
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Text = void 0;
4
4
  exports.T = T;
5
5
  const jsx_runtime_1 = require("nativewind/jsx-runtime");
6
- const index_web_1 = require("../../hooks/index.web");
7
- function T({ className, children, as = 'span', ref, ...rest }) {
8
- const cn = (0, index_web_1.useCn)();
9
- const { eventHandlers } = (0, index_web_1.useInteractiveState)(rest);
6
+ const useCn_1 = require("../../hooks/useCn");
7
+ const index_web_1 = require("../../index.web");
8
+ function T({ className, children, as = 'span', ref, style, ...restProps }) {
9
+ const cn = (0, useCn_1.useCn)();
10
+ const { disabled, eventHandlers } = (0, index_web_1.useInteractiveHandlers)(restProps);
11
+ const { getStyles } = (0, index_web_1.useStyles)();
10
12
  const Comp = as;
11
- return ((0, jsx_runtime_1.jsx)(Comp, { ref: ref, className: cn('leading-relaxed', className), ...rest, ...eventHandlers, children: children }));
13
+ return ((0, jsx_runtime_1.jsx)(Comp, { ref: ref, className: cn('leading-relaxed', className), ...restProps, ...eventHandlers, ...getStyles({ disabled, style }), children: children }));
12
14
  }
13
15
  exports.Text = T;
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./useCn"), exports);
18
- __exportStar(require("./useInteractiveState/useInteractiveState.web"), exports);
19
18
  __exportStar(require("./useOnChange"), exports);
20
19
  __exportStar(require("./useProps"), exports);
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./useCn"), exports);
18
+ __exportStar(require("./useInteractiveHandlers/useInteractiveHandlers.native"), exports);
18
19
  __exportStar(require("./useInteractiveState/useInteractiveState.native"), exports);
19
20
  __exportStar(require("./useOnChange"), exports);
20
21
  __exportStar(require("./useProps"), exports);
22
+ __exportStar(require("./useStyles/useStyles.native"), exports);
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./useCn"), exports);
18
+ __exportStar(require("./useInteractiveHandlers/useInteractiveHandlers.web"), exports);
18
19
  __exportStar(require("./useInteractiveState/useInteractiveState.web"), exports);
19
20
  __exportStar(require("./useOnChange"), exports);
20
21
  __exportStar(require("./useProps"), exports);
22
+ __exportStar(require("./useStyles/useStyles.web"), exports);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useInteractiveHandlers = useInteractiveHandlers;
4
+ const react_1 = require("react");
5
+ function useInteractiveHandlers({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
6
+ const offOn = (0, react_1.useRef)('off');
7
+ const eventHandlers = {
8
+ onBlur: (e) => {
9
+ if (disabled) {
10
+ return;
11
+ }
12
+ onBlur?.(e);
13
+ },
14
+ onFocus: (e) => {
15
+ if (disabled) {
16
+ return;
17
+ }
18
+ onFocus?.(e);
19
+ },
20
+ onPress: (e) => {
21
+ if (disabled) {
22
+ return;
23
+ }
24
+ if ((onIn || onOut) && offOn.current === 'off') {
25
+ offOn.current = 'on';
26
+ onIn?.(e);
27
+ }
28
+ if ((onIn || onOut) && offOn.current === 'on') {
29
+ offOn.current = 'off';
30
+ onOut?.(e);
31
+ }
32
+ if (onPress) {
33
+ onPress?.(e);
34
+ return;
35
+ }
36
+ onClick?.(e);
37
+ },
38
+ };
39
+ return {
40
+ disabled,
41
+ eventHandlers,
42
+ };
43
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useInteractiveHandlers = useInteractiveHandlers;
4
+ function useInteractiveHandlers({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
5
+ const eventHandlers = {
6
+ onBlur: (e) => {
7
+ if (disabled) {
8
+ return;
9
+ }
10
+ onBlur?.(e);
11
+ },
12
+ onClick: (e) => {
13
+ if (disabled) {
14
+ return;
15
+ }
16
+ if (onClick) {
17
+ onClick?.(e);
18
+ return;
19
+ }
20
+ onPress?.(e);
21
+ },
22
+ onFocus: (e) => {
23
+ if (disabled) {
24
+ return;
25
+ }
26
+ onFocus?.(e);
27
+ },
28
+ onMouseEnter: (e) => {
29
+ if (disabled) {
30
+ return;
31
+ }
32
+ onIn?.(e);
33
+ },
34
+ onMouseLeave: (e) => {
35
+ if (disabled) {
36
+ return;
37
+ }
38
+ onOut?.(e);
39
+ },
40
+ };
41
+ return {
42
+ disabled,
43
+ eventHandlers,
44
+ };
45
+ }
@@ -2,27 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInteractiveState = useInteractiveState;
4
4
  const react_1 = require("react");
5
- function useInteractiveState(options = {}) {
6
- const { disabled, onBlur, onClick, onFocus, onPress, onIn, onOut } = options;
7
- const [hovered, setHovered] = (0, react_1.useState)(false);
8
- const [pressed, setPressed] = (0, react_1.useState)(false);
9
- const [focused, setFocused] = (0, react_1.useState)(false);
5
+ function useInteractiveState({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
10
6
  const offOn = (0, react_1.useRef)('off');
11
- const state = disabled
12
- ? 'disabled'
13
- : pressed
14
- ? 'pressed'
15
- : hovered
16
- ? 'hovered'
17
- : focused
18
- ? 'focused'
19
- : 'idle';
7
+ const [interactiveState, setInteractiveState] = (0, react_1.useState)('idle');
20
8
  const dataAttrs = {
21
- 'data-state': state,
9
+ 'data-state': interactiveState,
22
10
  'data-disabled': disabled ? 'true' : 'false',
23
- 'data-focused': focused ? 'true' : 'false',
24
- 'data-hovered': hovered ? 'true' : 'false',
25
- 'data-pressed': pressed ? 'true' : 'false',
11
+ 'data-focused': interactiveState === 'focused' ? 'true' : 'false',
12
+ 'data-hovered': interactiveState === 'hovered' ? 'true' : 'false',
13
+ 'data-pressed': interactiveState === 'pressed' ? 'true' : 'false',
26
14
  };
27
15
  const eventHandlers = {
28
16
  onBlur: (e) => {
@@ -30,22 +18,14 @@ function useInteractiveState(options = {}) {
30
18
  return;
31
19
  }
32
20
  onBlur?.(e);
33
- setFocused(false);
34
- setPressed(false);
21
+ setInteractiveState('idle');
35
22
  },
36
23
  onFocus: (e) => {
37
24
  if (disabled) {
38
25
  return;
39
26
  }
40
27
  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);
28
+ setInteractiveState('focused');
49
29
  },
50
30
  onPress: (e) => {
51
31
  if (disabled) {
@@ -70,22 +50,20 @@ function useInteractiveState(options = {}) {
70
50
  return;
71
51
  }
72
52
  onIn?.(e);
73
- setPressed(true);
53
+ setInteractiveState('pressed');
74
54
  },
75
55
  onPressOut: (e) => {
76
56
  if (disabled) {
77
57
  return;
78
58
  }
79
59
  onOut?.(e);
80
- setPressed(false);
81
- },
82
- onOut: (e) => {
83
- if (disabled) {
84
- return;
85
- }
86
- console.log('[DEBUG] onOut', typeof onOut, e);
87
- onOut?.(e);
60
+ setInteractiveState('idle');
88
61
  },
89
62
  };
90
- return { state, dataAttrs, eventHandlers };
63
+ return {
64
+ dataAttrs,
65
+ disabled,
66
+ eventHandlers,
67
+ interactiveState,
68
+ };
91
69
  }
@@ -2,43 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInteractiveState = useInteractiveState;
4
4
  const react_1 = require("react");
5
- function useInteractiveState(options = {}) {
6
- const { disabled, onBlur, onClick, onPress, onFocus, onIn, onOut } = options;
7
- const [hovered, setHovered] = (0, react_1.useState)(false);
8
- const [pressed, setPressed] = (0, react_1.useState)(false);
9
- const [focused, setFocused] = (0, react_1.useState)(false);
10
- const state = disabled
11
- ? 'disabled'
12
- : pressed
13
- ? 'pressed'
14
- : hovered
15
- ? 'hovered'
16
- : focused
17
- ? 'focused'
18
- : 'idle';
5
+ function useInteractiveState({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
6
+ const [interactiveState, setInteractiveState] = (0, react_1.useState)('idle');
19
7
  const dataAttrs = {
20
- 'data-state': state,
8
+ 'data-state': interactiveState,
21
9
  'data-disabled': disabled ? 'true' : 'false',
22
- 'data-focused': focused ? 'true' : 'false',
23
- 'data-hovered': hovered ? 'true' : 'false',
24
- 'data-pressed': pressed ? 'true' : 'false',
10
+ 'data-focused': interactiveState === 'focused' ? 'true' : 'false',
11
+ 'data-hovered': interactiveState === 'hovered' ? 'true' : 'false',
12
+ 'data-pressed': interactiveState === 'pressed' ? 'true' : 'false',
25
13
  };
26
14
  const eventHandlers = {
27
15
  onBlur: (e) => {
28
16
  if (disabled) {
29
17
  return;
30
18
  }
31
- console.log('[DEBUG] onBlur', typeof onBlur, e);
32
19
  onBlur?.(e);
33
- setFocused(false);
34
- setPressed(false);
35
- setHovered(false);
20
+ setInteractiveState('idle');
36
21
  },
37
22
  onClick: (e) => {
38
23
  if (disabled) {
39
24
  return;
40
25
  }
41
- console.log('[DEBUG] onClick', typeof onClick, e);
42
26
  if (onClick) {
43
27
  onClick?.(e);
44
28
  return;
@@ -49,31 +33,21 @@ function useInteractiveState(options = {}) {
49
33
  if (disabled) {
50
34
  return;
51
35
  }
52
- console.log('[DEBUG] onFocus', typeof onFocus, e);
53
36
  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
+ setInteractiveState('focused');
62
38
  },
63
39
  onMouseDown: (e) => {
64
- if (disabled || e.button !== 0) {
40
+ if (disabled) {
65
41
  return;
66
42
  }
67
- console.log('[DEBUG] onMouseDown', e);
68
- setPressed(true);
43
+ setInteractiveState('pressed');
69
44
  },
70
45
  onMouseEnter: (e) => {
71
46
  if (disabled) {
72
47
  return;
73
48
  }
74
- console.log('[DEBUG] onMouseEnter', typeof onIn, e);
75
49
  onIn?.(e);
76
- setHovered(true);
50
+ setInteractiveState('hovered');
77
51
  },
78
52
  onMouseLeave: (e) => {
79
53
  if (disabled) {
@@ -81,23 +55,20 @@ function useInteractiveState(options = {}) {
81
55
  }
82
56
  console.log('[DEBUG] onMouseLeave', typeof onOut, e);
83
57
  onOut?.(e);
84
- setHovered(false);
85
- setPressed(false);
58
+ setInteractiveState('idle');
86
59
  },
87
60
  onMouseUp: (e) => {
88
61
  if (disabled) {
89
62
  return;
90
63
  }
91
64
  console.log('[DEBUG] onMouseUp', e);
92
- setPressed(false);
93
- },
94
- onOut: (e) => {
95
- if (disabled) {
96
- return;
97
- }
98
- console.log('[DEBUG] onOut', typeof onOut, e);
99
- onOut?.(e);
65
+ setInteractiveState('idle');
100
66
  },
101
67
  };
102
- return { state, dataAttrs, eventHandlers };
68
+ return {
69
+ dataAttrs,
70
+ disabled,
71
+ eventHandlers,
72
+ interactiveState,
73
+ };
103
74
  }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCssDecls = exports.toKebab = exports.extractStyles = void 0;
4
+ const extractStyles = (style) => {
5
+ const base = { ...style };
6
+ const disabled = style.$disabled || {};
7
+ const focused = style.$focused || {};
8
+ const hovered = style.$hovered || {};
9
+ const pressed = style.$pressed || {};
10
+ base.$disabled = undefined;
11
+ base.$focused = undefined;
12
+ base.$hovered = undefined;
13
+ base.$pressed = undefined;
14
+ return {
15
+ styleBase: base,
16
+ styleDisabled: disabled,
17
+ styleFocused: focused,
18
+ styleHovered: hovered,
19
+ stylePressed: pressed,
20
+ };
21
+ };
22
+ exports.extractStyles = extractStyles;
23
+ const toKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
24
+ exports.toKebab = toKebab;
25
+ const toCssDecls = (style) => {
26
+ if (!style) {
27
+ return '';
28
+ }
29
+ // TODO: adiconar os px ou outra medida quando necessario e faça sentido
30
+ return Object.entries(style)
31
+ .filter(([, v]) => v !== undefined && v !== null)
32
+ .map(([k, v]) => `${(0, exports.toKebab)(k)}:${typeof v === 'number' ? `${v}` : v};`)
33
+ .join('');
34
+ };
35
+ exports.toCssDecls = toCssDecls;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStyles = void 0;
4
+ const useStyles_helpers_1 = require("./useStyles.helpers");
5
+ const getStyles = ({ disabled, style, }) => {
6
+ if (!style) {
7
+ return {};
8
+ }
9
+ const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed } = (0, useStyles_helpers_1.extractStyles)(style);
10
+ const composedStyle = { ...styleBase };
11
+ if (disabled) {
12
+ Object.assign(composedStyle, styleDisabled || {});
13
+ }
14
+ return { style: composedStyle };
15
+ };
16
+ const getStylesWithInteraction = ({ disabled, style }) => (options) => {
17
+ if (!style) {
18
+ return {};
19
+ }
20
+ const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed, } = (0, useStyles_helpers_1.extractStyles)(style);
21
+ const composedStyle = { ...styleBase };
22
+ if (disabled) {
23
+ Object.assign(composedStyle, styleDisabled || {});
24
+ }
25
+ if (options?.focused) {
26
+ Object.assign(composedStyle, styleFocused || {});
27
+ }
28
+ if (options?.hovered) {
29
+ Object.assign(composedStyle, styleHovered || {});
30
+ }
31
+ if (options?.pressed) {
32
+ Object.assign(composedStyle, stylePressed || {});
33
+ }
34
+ return { style: composedStyle };
35
+ };
36
+ const useStyles = () => {
37
+ return {
38
+ getStyles,
39
+ getStylesWithInteraction,
40
+ };
41
+ };
42
+ exports.useStyles = useStyles;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStyles = exports.createInteractiveClass = void 0;
4
+ const react_1 = require("react");
5
+ const useStyles_helpers_1 = require("./useStyles.helpers");
6
+ const injected = new Set();
7
+ const injectOnce = (id, cssText) => {
8
+ if (typeof document === 'undefined')
9
+ return;
10
+ if (injected.has(id))
11
+ return;
12
+ const style = document.createElement('style');
13
+ style.setAttribute('data-interactive', id);
14
+ style.textContent = cssText;
15
+ document.head.appendChild(style);
16
+ injected.add(id);
17
+ };
18
+ const createInteractiveClass = ({ disabled, id, style, }) => {
19
+ const className = `ix-${id}`;
20
+ const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed } = (0, useStyles_helpers_1.extractStyles)(style);
21
+ const hoveredClass = styleHovered
22
+ ? `.${className}:hover{${(0, useStyles_helpers_1.toCssDecls)(styleHovered)}}`
23
+ : '';
24
+ const activeClass = stylePressed
25
+ ? `.${className}:active{${(0, useStyles_helpers_1.toCssDecls)(stylePressed)}}`
26
+ : '';
27
+ // focus-visible com fallback para browsers sem suporte
28
+ const focusVisibleClass = styleFocused
29
+ ? `
30
+ .${className}:focus-visible{${(0, useStyles_helpers_1.toCssDecls)(styleFocused)}}
31
+ @supports not selector(:focus-visible){
32
+ .${className}:focus{${(0, useStyles_helpers_1.toCssDecls)(styleFocused)}}
33
+ }
34
+ `
35
+ : '';
36
+ const disabledClass = disabled
37
+ ? `
38
+ .${className}[data-disabled="true"]{${(0, useStyles_helpers_1.toCssDecls)(styleDisabled)}}
39
+ .${className}[data-disabled="true"]:hover{${(0, useStyles_helpers_1.toCssDecls)(styleDisabled)}}
40
+ .${className}[data-disabled="true"]:active{${(0, useStyles_helpers_1.toCssDecls)(styleDisabled)}}
41
+ `
42
+ : '';
43
+ const baseClass = `.${className}{${(0, useStyles_helpers_1.toCssDecls)(styleBase)}}`;
44
+ injectOnce(id, `${baseClass}${hoveredClass}${activeClass}${focusVisibleClass}${disabledClass}`);
45
+ return className;
46
+ };
47
+ exports.createInteractiveClass = createInteractiveClass;
48
+ const getStyles = ({ id }) => ({ disabled, style }) => {
49
+ if (!style) {
50
+ return {};
51
+ }
52
+ const className = (0, exports.createInteractiveClass)({ disabled, id, style });
53
+ return {
54
+ className,
55
+ ...(disabled ? { 'aria-disabled': 'true', 'data-disabled': 'true' } : {}),
56
+ };
57
+ };
58
+ const useStyles = () => {
59
+ const id = (0, react_1.useId)();
60
+ // TODO: cleanup on unmount
61
+ // useEffect(() => {
62
+ // return () => {
63
+ // document.querySelector(`style[data-interactive="${id}"]`)?.remove();
64
+ // injected.delete(id);
65
+ // };
66
+ // }, [id]);
67
+ return {
68
+ getStyles: getStyles({ id }),
69
+ };
70
+ };
71
+ exports.useStyles = useStyles;
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "nativewind/jsx-runtime";
2
2
  import { Pressable } from 'react-native';
3
- import { useCn, useInteractiveState } from '../../hooks/index.native';
3
+ import { useInteractiveHandlers, useStyles } from '../../hooks/index.native';
4
+ import { useCn } from '../../hooks/useCn';
4
5
  import { E } from '../e/index.native';
5
- export function A({ accessibilityLabel, accessibilityRole, accessibilityState, className, children, loading, disabled, ref, style, ...rest }) {
6
+ export function A({ accessibilityLabel, accessibilityRole, accessibilityState, className, children, loading, ref, style, testId, ...restProps }) {
6
7
  const cn = useCn();
7
- const { eventHandlers } = useInteractiveState({ ...rest, disabled });
8
+ const { disabled, eventHandlers } = useInteractiveHandlers(restProps);
9
+ const { getStylesWithInteraction } = useStyles();
8
10
  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 }) }));
11
+ return (_jsx(Pressable, { ref: ref, disabled: isDisabled, accessibilityLabel: accessibilityLabel, accessibilityRole: accessibilityRole, accessibilityState: accessibilityState, testID: testId, ...eventHandlers, ...getStylesWithInteraction({ disabled, style }), children: _jsx(E, { className: cn(disabled && 'opacity-60', className), style: style, ...restProps, children: children }) }));
10
12
  }
11
13
  export const Action = A;
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx } from "nativewind/jsx-runtime";
2
- import { useCn, useInteractiveState } from '../../hooks/index.web';
3
- export function A({ className, children, disabled, loading, ref, style, testID, accessibilityLabel, ...rest }) {
2
+ import { useInteractiveHandlers, useStyles } from '../../hooks/index.web';
3
+ import { useCn } from '../../hooks/useCn';
4
+ export function A({ className, children, loading, ref, testId, accessibilityLabel, accessibilityRole, accessibilityState, style, ...restProps }) {
4
5
  const cn = useCn();
5
- const { eventHandlers } = useInteractiveState({ ...rest, disabled });
6
+ const { getStyles } = useStyles();
7
+ const { disabled, eventHandlers } = useInteractiveHandlers(restProps);
6
8
  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 }));
9
+ return (_jsx("button", { ref: ref, type: "button", className: cn('cursor-pointer', disabled && 'opacity-60', className), "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, "aria-label": accessibilityLabel, "data-testid": testId, ...restProps, ...eventHandlers, ...getStyles({ disabled, style }), children: children }));
8
10
  }
9
11
  export const Action = A;