@react-xp/aeiou 1.0.0-beta.2 → 1.0.0-beta.4

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 (175) hide show
  1. package/dist/cjs/components/a/a.native.js +6 -3
  2. package/dist/cjs/components/a/a.web.js +2 -3
  3. package/dist/cjs/components/d/d.native.js +20 -5
  4. package/dist/cjs/components/d/d.web.js +21 -6
  5. package/dist/cjs/components/e/e.native.js +2 -3
  6. package/dist/cjs/components/e/e.web.js +4 -3
  7. package/dist/cjs/components/i/i.native.js +4 -3
  8. package/dist/cjs/components/i/i.web.js +8 -3
  9. package/dist/cjs/components/l/l.web.js +2 -3
  10. package/dist/cjs/components/o/o.native.js +4 -3
  11. package/dist/cjs/components/o/o.web.js +2 -3
  12. package/dist/cjs/components/p/p.native.js +4 -3
  13. package/dist/cjs/components/p/p.web.js +4 -3
  14. package/dist/cjs/components/s/s.native.js +2 -3
  15. package/dist/cjs/components/t/t.native.js +2 -3
  16. package/dist/cjs/components/t/t.web.js +2 -3
  17. package/dist/cjs/hooks/useStyles/useStyles.native.js +2 -0
  18. package/dist/esm/components/a/a.native.js +6 -2
  19. package/dist/esm/components/a/a.web.js +2 -2
  20. package/dist/esm/components/d/d.native.js +20 -4
  21. package/dist/esm/components/d/d.web.js +21 -5
  22. package/dist/esm/components/e/e.native.js +2 -2
  23. package/dist/esm/components/e/e.web.js +4 -2
  24. package/dist/esm/components/i/i.native.js +4 -2
  25. package/dist/esm/components/i/i.web.js +8 -2
  26. package/dist/esm/components/l/l.web.js +2 -2
  27. package/dist/esm/components/o/o.native.js +4 -2
  28. package/dist/esm/components/o/o.web.js +2 -2
  29. package/dist/esm/components/p/p.native.js +4 -2
  30. package/dist/esm/components/p/p.web.js +4 -2
  31. package/dist/esm/components/s/s.native.js +2 -2
  32. package/dist/esm/components/t/t.native.js +2 -2
  33. package/dist/esm/components/t/t.web.js +2 -2
  34. package/dist/esm/hooks/useStyles/useStyles.native.js +2 -0
  35. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  36. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  37. package/dist/types/components/d/d.native.d.ts.map +1 -1
  38. package/dist/types/hooks/useStyles/useStyles.native.d.ts.map +1 -1
  39. package/package.json +5 -5
  40. package/dist/native/cjs/components/a/a.native.js +0 -17
  41. package/dist/native/cjs/components/a/a.web.js +0 -15
  42. package/dist/native/cjs/components/a/index.native.js +0 -17
  43. package/dist/native/cjs/components/a/index.web.js +0 -17
  44. package/dist/native/cjs/components/d/d.native.js +0 -28
  45. package/dist/native/cjs/components/d/d.web.js +0 -38
  46. package/dist/native/cjs/components/d/index.native.js +0 -17
  47. package/dist/native/cjs/components/d/index.web.js +0 -17
  48. package/dist/native/cjs/components/e/e.native.js +0 -16
  49. package/dist/native/cjs/components/e/e.web.js +0 -15
  50. package/dist/native/cjs/components/e/index.native.js +0 -17
  51. package/dist/native/cjs/components/e/index.web.js +0 -17
  52. package/dist/native/cjs/components/i/i.native.js +0 -28
  53. package/dist/native/cjs/components/i/i.web.js +0 -27
  54. package/dist/native/cjs/components/i/index.native.js +0 -17
  55. package/dist/native/cjs/components/i/index.web.js +0 -17
  56. package/dist/native/cjs/components/i/useIUtils.js +0 -71
  57. package/dist/native/cjs/components/index.js +0 -26
  58. package/dist/native/cjs/components/index.native.js +0 -26
  59. package/dist/native/cjs/components/index.web.js +0 -26
  60. package/dist/native/cjs/components/l/index.native.js +0 -17
  61. package/dist/native/cjs/components/l/index.web.js +0 -17
  62. package/dist/native/cjs/components/l/l.native.js +0 -10
  63. package/dist/native/cjs/components/l/l.web.js +0 -15
  64. package/dist/native/cjs/components/o/index.native.js +0 -17
  65. package/dist/native/cjs/components/o/index.web.js +0 -17
  66. package/dist/native/cjs/components/o/o.native.js +0 -12
  67. package/dist/native/cjs/components/o/o.web.js +0 -15
  68. package/dist/native/cjs/components/p/index.native.js +0 -17
  69. package/dist/native/cjs/components/p/index.web.js +0 -17
  70. package/dist/native/cjs/components/p/p.native.js +0 -13
  71. package/dist/native/cjs/components/p/p.web.js +0 -16
  72. package/dist/native/cjs/components/s/index.native.js +0 -17
  73. package/dist/native/cjs/components/s/index.web.js +0 -17
  74. package/dist/native/cjs/components/s/s.native.js +0 -10
  75. package/dist/native/cjs/components/s/s.web.js +0 -10
  76. package/dist/native/cjs/components/t/index.native.js +0 -17
  77. package/dist/native/cjs/components/t/index.web.js +0 -17
  78. package/dist/native/cjs/components/t/t.native.js +0 -15
  79. package/dist/native/cjs/components/t/t.web.js +0 -15
  80. package/dist/native/cjs/components/u/context.js +0 -14
  81. package/dist/native/cjs/components/u/errorBoundary.js +0 -27
  82. package/dist/native/cjs/components/u/index.native.js +0 -19
  83. package/dist/native/cjs/components/u/index.web.js +0 -19
  84. package/dist/native/cjs/components/u/provider.native.js +0 -24
  85. package/dist/native/cjs/components/u/provider.web.js +0 -21
  86. package/dist/native/cjs/components/u/types.js +0 -2
  87. package/dist/native/cjs/components/u/useUniverse.js +0 -8
  88. package/dist/native/cjs/hooks/index.js +0 -19
  89. package/dist/native/cjs/hooks/index.native.js +0 -22
  90. package/dist/native/cjs/hooks/index.web.js +0 -22
  91. package/dist/native/cjs/hooks/useCn.js +0 -15
  92. package/dist/native/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +0 -43
  93. package/dist/native/cjs/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +0 -45
  94. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.native.js +0 -69
  95. package/dist/native/cjs/hooks/useInteractiveState/useInteractiveState.web.js +0 -74
  96. package/dist/native/cjs/hooks/useOnChange.js +0 -18
  97. package/dist/native/cjs/hooks/useProps.js +0 -66
  98. package/dist/native/cjs/hooks/useStyles/useStyles.helpers.js +0 -35
  99. package/dist/native/cjs/hooks/useStyles/useStyles.native.js +0 -44
  100. package/dist/native/cjs/hooks/useStyles/useStyles.types.js +0 -2
  101. package/dist/native/cjs/hooks/useStyles/useStyles.web.js +0 -71
  102. package/dist/native/cjs/index.js +0 -19
  103. package/dist/native/cjs/index.native.js +0 -19
  104. package/dist/native/cjs/index.web.js +0 -19
  105. package/dist/native/cjs/types/base.js +0 -2
  106. package/dist/native/cjs/types/index.js +0 -17
  107. package/dist/native/esm/components/a/a.native.js +0 -13
  108. package/dist/native/esm/components/a/a.web.js +0 -11
  109. package/dist/native/esm/components/a/index.native.js +0 -1
  110. package/dist/native/esm/components/a/index.web.js +0 -1
  111. package/dist/native/esm/components/d/d.native.js +0 -24
  112. package/dist/native/esm/components/d/d.web.js +0 -34
  113. package/dist/native/esm/components/d/index.native.js +0 -1
  114. package/dist/native/esm/components/d/index.web.js +0 -1
  115. package/dist/native/esm/components/e/e.native.js +0 -12
  116. package/dist/native/esm/components/e/e.web.js +0 -11
  117. package/dist/native/esm/components/e/index.native.js +0 -1
  118. package/dist/native/esm/components/e/index.web.js +0 -1
  119. package/dist/native/esm/components/i/i.native.js +0 -24
  120. package/dist/native/esm/components/i/i.web.js +0 -23
  121. package/dist/native/esm/components/i/index.native.js +0 -1
  122. package/dist/native/esm/components/i/index.web.js +0 -1
  123. package/dist/native/esm/components/i/useIUtils.js +0 -67
  124. package/dist/native/esm/components/index.js +0 -10
  125. package/dist/native/esm/components/index.native.js +0 -10
  126. package/dist/native/esm/components/index.web.js +0 -10
  127. package/dist/native/esm/components/l/index.native.js +0 -1
  128. package/dist/native/esm/components/l/index.web.js +0 -1
  129. package/dist/native/esm/components/l/l.native.js +0 -6
  130. package/dist/native/esm/components/l/l.web.js +0 -11
  131. package/dist/native/esm/components/o/index.native.js +0 -1
  132. package/dist/native/esm/components/o/index.web.js +0 -1
  133. package/dist/native/esm/components/o/o.native.js +0 -8
  134. package/dist/native/esm/components/o/o.web.js +0 -11
  135. package/dist/native/esm/components/p/index.native.js +0 -1
  136. package/dist/native/esm/components/p/index.web.js +0 -1
  137. package/dist/native/esm/components/p/p.native.js +0 -9
  138. package/dist/native/esm/components/p/p.web.js +0 -12
  139. package/dist/native/esm/components/s/index.native.js +0 -1
  140. package/dist/native/esm/components/s/index.web.js +0 -1
  141. package/dist/native/esm/components/s/s.native.js +0 -7
  142. package/dist/native/esm/components/s/s.web.js +0 -6
  143. package/dist/native/esm/components/t/index.native.js +0 -1
  144. package/dist/native/esm/components/t/index.web.js +0 -1
  145. package/dist/native/esm/components/t/t.native.js +0 -11
  146. package/dist/native/esm/components/t/t.web.js +0 -11
  147. package/dist/native/esm/components/u/context.js +0 -11
  148. package/dist/native/esm/components/u/errorBoundary.js +0 -23
  149. package/dist/native/esm/components/u/index.native.js +0 -3
  150. package/dist/native/esm/components/u/index.web.js +0 -3
  151. package/dist/native/esm/components/u/provider.native.js +0 -20
  152. package/dist/native/esm/components/u/provider.web.js +0 -17
  153. package/dist/native/esm/components/u/types.js +0 -1
  154. package/dist/native/esm/components/u/useUniverse.js +0 -5
  155. package/dist/native/esm/hooks/index.js +0 -3
  156. package/dist/native/esm/hooks/index.native.js +0 -6
  157. package/dist/native/esm/hooks/index.web.js +0 -6
  158. package/dist/native/esm/hooks/useCn.js +0 -8
  159. package/dist/native/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.native.js +0 -40
  160. package/dist/native/esm/hooks/useInteractiveHandlers/useInteractiveHandlers.web.js +0 -42
  161. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.native.js +0 -66
  162. package/dist/native/esm/hooks/useInteractiveState/useInteractiveState.web.js +0 -71
  163. package/dist/native/esm/hooks/useOnChange.js +0 -14
  164. package/dist/native/esm/hooks/useProps.js +0 -59
  165. package/dist/native/esm/hooks/useStyles/useStyles.helpers.js +0 -29
  166. package/dist/native/esm/hooks/useStyles/useStyles.native.js +0 -40
  167. package/dist/native/esm/hooks/useStyles/useStyles.types.js +0 -1
  168. package/dist/native/esm/hooks/useStyles/useStyles.web.js +0 -66
  169. package/dist/native/esm/index.js +0 -3
  170. package/dist/native/esm/index.native.js +0 -3
  171. package/dist/native/esm/index.web.js +0 -3
  172. package/dist/native/esm/types/base.js +0 -1
  173. package/dist/native/esm/types/index.js +0 -1
  174. package/dist/native/tsconfig.native.cjs.tsbuildinfo +0 -1
  175. package/dist/native/tsconfig.native.esm.tsbuildinfo +0 -1
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "nativewind/jsx-runtime";
2
- import { useCn } from '../../hooks/useCn';
3
- import { useInteractiveHandlers, useStyles } from '../../index.web';
4
- export function T({ as = 'span', className, children, ref, style, ...restProps }) {
5
- const cn = useCn();
6
- const { disabled, eventHandlers } = useInteractiveHandlers(restProps);
7
- const { getStyles } = useStyles();
8
- const Comp = as;
9
- return (_jsx(Comp, { ref: ref, className: cn('leading-relaxed', className), ...restProps, ...eventHandlers, ...getStyles({ disabled, style }), children: children }));
10
- }
11
- export const Text = T;
@@ -1,11 +0,0 @@
1
- import { createContext } from 'react';
2
- const defaultValue = {
3
- colorScheme: 'system',
4
- locale: 'en-US',
5
- platform: 'web',
6
- // eslint-disable-next-line @typescript-eslint/no-empty-function
7
- setColorScheme: () => { },
8
- // eslint-disable-next-line @typescript-eslint/no-empty-function
9
- setLocale: () => { },
10
- };
11
- export const UniverseContext = createContext(defaultValue);
@@ -1,23 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export * from './provider.native';
2
- export * from './types';
3
- export * from './useUniverse';
@@ -1,3 +0,0 @@
1
- export * from './provider.web';
2
- export * from './types';
3
- export * from './useUniverse';
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx } from "nativewind/jsx-runtime";
2
- import { useMemo, useState } from 'react';
3
- import { Appearance } from 'react-native';
4
- import { UniverseContext } from './context';
5
- import { ErrorBoundary } from './errorBoundary';
6
- export function U({ children, config, onError }) {
7
- const systemColorScheme = Appearance.getColorScheme() ?? 'light';
8
- const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
9
- const [locale, setLocale] = useState(config?.locale ?? 'en-US');
10
- const value = useMemo(() => ({
11
- colorScheme,
12
- locale,
13
- platform: 'native',
14
- systemColorScheme,
15
- setColorScheme,
16
- setLocale,
17
- }), [colorScheme, locale, systemColorScheme]);
18
- return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
19
- }
20
- export const Universe = U;
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "nativewind/jsx-runtime";
2
- import { useMemo, useState } from 'react';
3
- import { UniverseContext } from './context';
4
- import { ErrorBoundary } from './errorBoundary';
5
- export function U({ children, config, onError }) {
6
- const [colorScheme, setColorScheme] = useState(config?.colorScheme ?? 'system');
7
- const [locale, setLocale] = useState(config?.locale ?? 'en-US');
8
- const value = useMemo(() => ({
9
- colorScheme,
10
- locale,
11
- platform: 'web',
12
- setColorScheme,
13
- setLocale,
14
- }), [colorScheme, locale]);
15
- return (_jsx(ErrorBoundary, { onError: onError, children: _jsx(UniverseContext.Provider, { value: value, children: children }) }));
16
- }
17
- export const Universe = U;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { useContext } from 'react';
2
- import { UniverseContext } from './context';
3
- export function useUniverse() {
4
- return useContext(UniverseContext);
5
- }
@@ -1,3 +0,0 @@
1
- export * from './useCn';
2
- export * from './useOnChange';
3
- export * from './useProps';
@@ -1,6 +0,0 @@
1
- export * from './useCn';
2
- export * from './useInteractiveHandlers/useInteractiveHandlers.native';
3
- export * from './useInteractiveState/useInteractiveState.native';
4
- export * from './useOnChange';
5
- export * from './useProps';
6
- export * from './useStyles/useStyles.native';
@@ -1,6 +0,0 @@
1
- export * from './useCn';
2
- export * from './useInteractiveHandlers/useInteractiveHandlers.web';
3
- export * from './useInteractiveState/useInteractiveState.web';
4
- export * from './useOnChange';
5
- export * from './useProps';
6
- export * from './useStyles/useStyles.web';
@@ -1,8 +0,0 @@
1
- import clsx, {} from 'clsx';
2
- import { useMemo } from 'react';
3
- import { twMerge } from 'tailwind-merge';
4
- export const useCn = () => {
5
- return useMemo(() => (...inputs) => {
6
- return twMerge(clsx(inputs));
7
- }, []);
8
- };
@@ -1,40 +0,0 @@
1
- import { useRef } from 'react';
2
- export function useInteractiveHandlers({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
3
- const offOn = useRef('off');
4
- const eventHandlers = {
5
- onBlur: (e) => {
6
- if (disabled) {
7
- return;
8
- }
9
- onBlur?.(e);
10
- },
11
- onFocus: (e) => {
12
- if (disabled) {
13
- return;
14
- }
15
- onFocus?.(e);
16
- },
17
- onPress: (e) => {
18
- if (disabled) {
19
- return;
20
- }
21
- if ((onIn || onOut) && offOn.current === 'off') {
22
- offOn.current = 'on';
23
- onIn?.(e);
24
- }
25
- if ((onIn || onOut) && offOn.current === 'on') {
26
- offOn.current = 'off';
27
- onOut?.(e);
28
- }
29
- if (onPress) {
30
- onPress?.(e);
31
- return;
32
- }
33
- onClick?.(e);
34
- },
35
- };
36
- return {
37
- disabled,
38
- eventHandlers,
39
- };
40
- }
@@ -1,42 +0,0 @@
1
- export function useInteractiveHandlers({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
2
- const eventHandlers = {
3
- onBlur: (e) => {
4
- if (disabled) {
5
- return;
6
- }
7
- onBlur?.(e);
8
- },
9
- onClick: (e) => {
10
- if (disabled) {
11
- return;
12
- }
13
- if (onClick) {
14
- onClick?.(e);
15
- return;
16
- }
17
- onPress?.(e);
18
- },
19
- onFocus: (e) => {
20
- if (disabled) {
21
- return;
22
- }
23
- onFocus?.(e);
24
- },
25
- onMouseEnter: (e) => {
26
- if (disabled) {
27
- return;
28
- }
29
- onIn?.(e);
30
- },
31
- onMouseLeave: (e) => {
32
- if (disabled) {
33
- return;
34
- }
35
- onOut?.(e);
36
- },
37
- };
38
- return {
39
- disabled,
40
- eventHandlers,
41
- };
42
- }
@@ -1,66 +0,0 @@
1
- import { useRef, useState } from 'react';
2
- export function useInteractiveState({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
3
- const offOn = useRef('off');
4
- const [interactiveState, setInteractiveState] = useState('idle');
5
- const dataAttrs = {
6
- 'data-state': interactiveState,
7
- 'data-disabled': disabled ? 'true' : 'false',
8
- 'data-focused': interactiveState === 'focused' ? 'true' : 'false',
9
- 'data-hovered': interactiveState === 'hovered' ? 'true' : 'false',
10
- 'data-pressed': interactiveState === 'pressed' ? 'true' : 'false',
11
- };
12
- const eventHandlers = {
13
- onBlur: (e) => {
14
- if (disabled) {
15
- return;
16
- }
17
- onBlur?.(e);
18
- setInteractiveState('idle');
19
- },
20
- onFocus: (e) => {
21
- if (disabled) {
22
- return;
23
- }
24
- onFocus?.(e);
25
- setInteractiveState('focused');
26
- },
27
- onPress: (e) => {
28
- if (disabled) {
29
- return;
30
- }
31
- if ((onIn || onOut) && offOn.current === 'off') {
32
- offOn.current = 'on';
33
- onIn?.(e);
34
- }
35
- if ((onIn || onOut) && offOn.current === 'on') {
36
- offOn.current = 'off';
37
- onOut?.(e);
38
- }
39
- if (onPress) {
40
- onPress?.(e);
41
- return;
42
- }
43
- onClick?.(e);
44
- },
45
- onPressIn: (e) => {
46
- if (disabled) {
47
- return;
48
- }
49
- onIn?.(e);
50
- setInteractiveState('pressed');
51
- },
52
- onPressOut: (e) => {
53
- if (disabled) {
54
- return;
55
- }
56
- onOut?.(e);
57
- setInteractiveState('idle');
58
- },
59
- };
60
- return {
61
- dataAttrs,
62
- disabled,
63
- eventHandlers,
64
- interactiveState,
65
- };
66
- }
@@ -1,71 +0,0 @@
1
- import { useState } from 'react';
2
- export function useInteractiveState({ disabled, onBlur, onClick, onFocus, onPress, onIn, onOut, } = {}) {
3
- const [interactiveState, setInteractiveState] = useState('idle');
4
- const dataAttrs = {
5
- 'data-state': interactiveState,
6
- 'data-disabled': disabled ? 'true' : 'false',
7
- 'data-focused': interactiveState === 'focused' ? 'true' : 'false',
8
- 'data-hovered': interactiveState === 'hovered' ? 'true' : 'false',
9
- 'data-pressed': interactiveState === 'pressed' ? 'true' : 'false',
10
- };
11
- const eventHandlers = {
12
- onBlur: (e) => {
13
- if (disabled) {
14
- return;
15
- }
16
- onBlur?.(e);
17
- setInteractiveState('idle');
18
- },
19
- onClick: (e) => {
20
- if (disabled) {
21
- return;
22
- }
23
- if (onClick) {
24
- onClick?.(e);
25
- return;
26
- }
27
- onPress?.(e);
28
- },
29
- onFocus: (e) => {
30
- if (disabled) {
31
- return;
32
- }
33
- onFocus?.(e);
34
- setInteractiveState('focused');
35
- },
36
- onMouseDown: (e) => {
37
- if (disabled) {
38
- return;
39
- }
40
- setInteractiveState('pressed');
41
- },
42
- onMouseEnter: (e) => {
43
- if (disabled) {
44
- return;
45
- }
46
- onIn?.(e);
47
- setInteractiveState('hovered');
48
- },
49
- onMouseLeave: (e) => {
50
- if (disabled) {
51
- return;
52
- }
53
- console.log('[DEBUG] onMouseLeave', typeof onOut, e);
54
- onOut?.(e);
55
- setInteractiveState('idle');
56
- },
57
- onMouseUp: (e) => {
58
- if (disabled) {
59
- return;
60
- }
61
- console.log('[DEBUG] onMouseUp', e);
62
- setInteractiveState('idle');
63
- },
64
- };
65
- return {
66
- dataAttrs,
67
- disabled,
68
- eventHandlers,
69
- interactiveState,
70
- };
71
- }
@@ -1,14 +0,0 @@
1
- import { useMemo } from 'react';
2
- export const useOnChange = ({ onChange, onChangeValue, }) => {
3
- return useMemo(() => ({
4
- onChange: (event) => {
5
- if (onChange) {
6
- onChange(event);
7
- return;
8
- }
9
- if (onChangeValue) {
10
- onChangeValue(event?.target?.value);
11
- }
12
- },
13
- }), [onChange, onChangeValue]);
14
- };
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- export const useProps = () => {
3
- const handleOmit = React.useCallback((obj = {}, keys = []) => {
4
- if (!obj) {
5
- return {
6
- props: {},
7
- restProps: {},
8
- };
9
- }
10
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
11
- const result = {};
12
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
13
- const nonUsedProps = {};
14
- for (const key of Object.keys(obj)) {
15
- if (!keys.includes(key)) {
16
- result[key] = obj[key];
17
- }
18
- else {
19
- nonUsedProps[key] = obj[key];
20
- }
21
- }
22
- return {
23
- props: result,
24
- restProps: nonUsedProps,
25
- };
26
- }, []);
27
- const handlePick = React.useCallback((obj = {}, keys = []) => {
28
- if (!obj) {
29
- return {
30
- props: {},
31
- restProps: {},
32
- };
33
- }
34
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
35
- const result = {};
36
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
37
- const nonUsedProps = {};
38
- for (const key of Object.keys(obj)) {
39
- if (keys.includes(key)) {
40
- result[key] = obj[key];
41
- }
42
- else {
43
- nonUsedProps[key] = obj[key];
44
- }
45
- }
46
- return {
47
- props: result /*Pick<
48
- TObject,
49
- Exclude<keyof TObject, Exclude<keyof TObject, TKeys>>
50
- >*/,
51
- restProps: nonUsedProps,
52
- };
53
- }, []);
54
- return {
55
- getPropKey: (obj = {}) => handlePick(obj, ['key']),
56
- omitProps: handleOmit,
57
- pickProps: handlePick,
58
- };
59
- };
@@ -1,29 +0,0 @@
1
- export const extractStyles = (style) => {
2
- const base = { ...style };
3
- const disabled = style.$disabled || {};
4
- const focused = style.$focused || {};
5
- const hovered = style.$hovered || {};
6
- const pressed = style.$pressed || {};
7
- base.$disabled = undefined;
8
- base.$focused = undefined;
9
- base.$hovered = undefined;
10
- base.$pressed = undefined;
11
- return {
12
- styleBase: base,
13
- styleDisabled: disabled,
14
- styleFocused: focused,
15
- styleHovered: hovered,
16
- stylePressed: pressed,
17
- };
18
- };
19
- export const toKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
20
- export const toCssDecls = (style) => {
21
- if (!style) {
22
- return '';
23
- }
24
- // TODO: adiconar os px ou outra medida quando necessario e faça sentido
25
- return Object.entries(style)
26
- .filter(([, v]) => v !== undefined && v !== null)
27
- .map(([k, v]) => `${toKebab(k)}:${typeof v === 'number' ? `${v}` : v};`)
28
- .join('');
29
- };
@@ -1,40 +0,0 @@
1
- import { extractStyles } from './useStyles.helpers';
2
- const getStyles = ({ disabled, style, }) => {
3
- if (!style) {
4
- return {};
5
- }
6
- const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed } = extractStyles(style);
7
- const composedStyle = { ...styleBase };
8
- if (disabled) {
9
- Object.assign(composedStyle, styleDisabled || {});
10
- }
11
- return { style: composedStyle };
12
- };
13
- const getStylesWithInteraction = ({ disabled, style, }) => ({
14
- style: (options) => {
15
- if (!style) {
16
- return {};
17
- }
18
- const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed, } = extractStyles(style);
19
- const composedStyle = { ...styleBase };
20
- if (disabled) {
21
- Object.assign(composedStyle, styleDisabled || {});
22
- }
23
- if (options?.focused) {
24
- Object.assign(composedStyle, styleFocused || {});
25
- }
26
- if (options?.hovered) {
27
- Object.assign(composedStyle, styleHovered || {});
28
- }
29
- if (options?.pressed) {
30
- Object.assign(composedStyle, stylePressed || {});
31
- }
32
- return composedStyle;
33
- },
34
- });
35
- export const useStyles = () => {
36
- return {
37
- getStyles,
38
- getStylesWithInteraction,
39
- };
40
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +0,0 @@
1
- import { useId } from 'react';
2
- import { extractStyles, toCssDecls } from './useStyles.helpers';
3
- const injected = new Set();
4
- const injectOnce = (id, cssText) => {
5
- if (typeof document === 'undefined')
6
- return;
7
- if (injected.has(id))
8
- return;
9
- const style = document.createElement('style');
10
- style.setAttribute('data-interactive', id);
11
- style.textContent = cssText;
12
- document.head.appendChild(style);
13
- injected.add(id);
14
- };
15
- export const createInteractiveClass = ({ disabled, id, style, }) => {
16
- const className = `ix-${id}`;
17
- const { styleBase, styleDisabled, styleFocused, styleHovered, stylePressed } = extractStyles(style);
18
- const hoveredClass = styleHovered
19
- ? `.${className}:hover{${toCssDecls(styleHovered)}}`
20
- : '';
21
- const activeClass = stylePressed
22
- ? `.${className}:active{${toCssDecls(stylePressed)}}`
23
- : '';
24
- // focus-visible com fallback para browsers sem suporte
25
- const focusVisibleClass = styleFocused
26
- ? `
27
- .${className}:focus-visible{${toCssDecls(styleFocused)}}
28
- @supports not selector(:focus-visible){
29
- .${className}:focus{${toCssDecls(styleFocused)}}
30
- }
31
- `
32
- : '';
33
- const disabledClass = disabled
34
- ? `
35
- .${className}[data-disabled="true"]{${toCssDecls(styleDisabled)}}
36
- .${className}[data-disabled="true"]:hover{${toCssDecls(styleDisabled)}}
37
- .${className}[data-disabled="true"]:active{${toCssDecls(styleDisabled)}}
38
- `
39
- : '';
40
- const baseClass = `.${className}{${toCssDecls(styleBase)}}`;
41
- injectOnce(id, `${baseClass}${hoveredClass}${activeClass}${focusVisibleClass}${disabledClass}`);
42
- return className;
43
- };
44
- const getStyles = ({ id }) => ({ disabled, style }) => {
45
- if (!style) {
46
- return {};
47
- }
48
- const className = createInteractiveClass({ disabled, id, style });
49
- return {
50
- className,
51
- ...(disabled ? { 'aria-disabled': 'true', 'data-disabled': 'true' } : {}),
52
- };
53
- };
54
- export const useStyles = () => {
55
- const id = useId();
56
- // TODO: cleanup on unmount
57
- // useEffect(() => {
58
- // return () => {
59
- // document.querySelector(`style[data-interactive="${id}"]`)?.remove();
60
- // injected.delete(id);
61
- // };
62
- // }, [id]);
63
- return {
64
- getStyles: getStyles({ id }),
65
- };
66
- };
@@ -1,3 +0,0 @@
1
- export * from './components/index.web';
2
- export * from './hooks/index.web';
3
- export * from './types';
@@ -1,3 +0,0 @@
1
- export * from './components/index.native';
2
- export * from './hooks/index.native';
3
- export * from './types';
@@ -1,3 +0,0 @@
1
- export * from './components/index.web';
2
- export * from './hooks/index.web';
3
- export * from './types';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from './base';