@grupalia/rn-ui-kit 0.0.41 → 0.2.0

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 (141) hide show
  1. package/lib/commonjs/components/BaseAlert.js +149 -0
  2. package/lib/commonjs/components/BaseAlert.js.map +1 -0
  3. package/lib/commonjs/components/BaseBadge.js +40 -19
  4. package/lib/commonjs/components/BaseBadge.js.map +1 -1
  5. package/lib/commonjs/components/BaseButton.js +71 -38
  6. package/lib/commonjs/components/BaseButton.js.map +1 -1
  7. package/lib/commonjs/components/BaseIcon.js +31 -0
  8. package/lib/commonjs/components/BaseIcon.js.map +1 -0
  9. package/lib/commonjs/components/BaseSpinner.js +21 -0
  10. package/lib/commonjs/components/BaseSpinner.js.map +1 -0
  11. package/lib/commonjs/components/BaseStackedList.js +108 -0
  12. package/lib/commonjs/components/BaseStackedList.js.map +1 -0
  13. package/lib/commonjs/components/index.js +28 -0
  14. package/lib/commonjs/components/index.js.map +1 -1
  15. package/lib/commonjs/hoc-components.js +40 -0
  16. package/lib/commonjs/hoc-components.js.map +1 -0
  17. package/lib/commonjs/hooks/useBreakpoints.js +25 -0
  18. package/lib/commonjs/hooks/useBreakpoints.js.map +1 -0
  19. package/lib/commonjs/hooks/useIsAboveBreakpoint.js +15 -0
  20. package/lib/commonjs/hooks/useIsAboveBreakpoint.js.map +1 -0
  21. package/lib/commonjs/index.js +17 -1
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/preset.js +6 -2
  24. package/lib/commonjs/preset.js.map +1 -1
  25. package/lib/commonjs/styles/background-colors.js +1 -1
  26. package/lib/commonjs/styles/background-colors.js.map +1 -1
  27. package/lib/commonjs/styles/border-colors.js +1 -1
  28. package/lib/commonjs/styles/border-colors.js.map +1 -1
  29. package/lib/commonjs/styles/foreground-colors.js +0 -12
  30. package/lib/commonjs/styles/foreground-colors.js.map +1 -1
  31. package/lib/commonjs/styles/text-colors.js +1 -1
  32. package/lib/commonjs/styles/text-colors.js.map +1 -1
  33. package/lib/commonjs/styles/utility-colors.js +124 -124
  34. package/lib/commonjs/styles/utility-colors.js.map +1 -1
  35. package/lib/module/components/BaseAlert.js +144 -0
  36. package/lib/module/components/BaseAlert.js.map +1 -0
  37. package/lib/module/components/BaseBadge.js +39 -18
  38. package/lib/module/components/BaseBadge.js.map +1 -1
  39. package/lib/module/components/BaseButton.js +68 -35
  40. package/lib/module/components/BaseButton.js.map +1 -1
  41. package/lib/module/components/BaseIcon.js +26 -0
  42. package/lib/module/components/BaseIcon.js.map +1 -0
  43. package/lib/module/components/BaseSpinner.js +16 -0
  44. package/lib/module/components/BaseSpinner.js.map +1 -0
  45. package/lib/module/components/BaseStackedList.js +102 -0
  46. package/lib/module/components/BaseStackedList.js.map +1 -0
  47. package/lib/module/components/index.js +4 -0
  48. package/lib/module/components/index.js.map +1 -1
  49. package/lib/module/hoc-components.js +37 -0
  50. package/lib/module/hoc-components.js.map +1 -0
  51. package/lib/module/hooks/useBreakpoints.js +20 -0
  52. package/lib/module/hooks/useBreakpoints.js.map +1 -0
  53. package/lib/module/hooks/useIsAboveBreakpoint.js +11 -0
  54. package/lib/module/hooks/useIsAboveBreakpoint.js.map +1 -0
  55. package/lib/module/index.js +2 -0
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/preset.js +6 -2
  58. package/lib/module/preset.js.map +1 -1
  59. package/lib/module/styles/background-colors.js +1 -1
  60. package/lib/module/styles/background-colors.js.map +1 -1
  61. package/lib/module/styles/border-colors.js +1 -1
  62. package/lib/module/styles/border-colors.js.map +1 -1
  63. package/lib/module/styles/foreground-colors.js +0 -12
  64. package/lib/module/styles/foreground-colors.js.map +1 -1
  65. package/lib/module/styles/text-colors.js +1 -1
  66. package/lib/module/styles/text-colors.js.map +1 -1
  67. package/lib/module/styles/utility-colors.js +124 -124
  68. package/lib/module/styles/utility-colors.js.map +1 -1
  69. package/lib/typescript/commonjs/components/BaseAlert.d.ts +11 -0
  70. package/lib/typescript/commonjs/components/BaseAlert.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/components/BaseBadge.d.ts +11 -5
  72. package/lib/typescript/commonjs/components/BaseBadge.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/components/BaseButton.d.ts +9 -4
  74. package/lib/typescript/commonjs/components/BaseButton.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/components/BaseIcon.d.ts +19 -0
  76. package/lib/typescript/commonjs/components/BaseIcon.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/components/BaseSpinner.d.ts +8 -0
  78. package/lib/typescript/commonjs/components/BaseSpinner.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/components/BaseStackedList.d.ts +23 -0
  80. package/lib/typescript/commonjs/components/BaseStackedList.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/components/index.d.ts +4 -0
  82. package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/hoc-components.d.ts +139 -0
  84. package/lib/typescript/commonjs/hoc-components.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/hooks/useBreakpoints.d.ts +8 -0
  86. package/lib/typescript/commonjs/hooks/useBreakpoints.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/hooks/useIsAboveBreakpoint.d.ts +3 -0
  88. package/lib/typescript/commonjs/hooks/useIsAboveBreakpoint.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/index.d.ts +2 -0
  90. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/preset.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/styles/foreground-colors.d.ts +1 -12
  93. package/lib/typescript/commonjs/styles/foreground-colors.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/styles/utility-colors.d.ts +125 -124
  95. package/lib/typescript/commonjs/styles/utility-colors.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/types/heroicons.d.ts +2 -2
  97. package/lib/typescript/commonjs/types/heroicons.d.ts.map +1 -1
  98. package/lib/typescript/module/components/BaseAlert.d.ts +11 -0
  99. package/lib/typescript/module/components/BaseAlert.d.ts.map +1 -0
  100. package/lib/typescript/module/components/BaseBadge.d.ts +11 -5
  101. package/lib/typescript/module/components/BaseBadge.d.ts.map +1 -1
  102. package/lib/typescript/module/components/BaseButton.d.ts +9 -4
  103. package/lib/typescript/module/components/BaseButton.d.ts.map +1 -1
  104. package/lib/typescript/module/components/BaseIcon.d.ts +19 -0
  105. package/lib/typescript/module/components/BaseIcon.d.ts.map +1 -0
  106. package/lib/typescript/module/components/BaseSpinner.d.ts +8 -0
  107. package/lib/typescript/module/components/BaseSpinner.d.ts.map +1 -0
  108. package/lib/typescript/module/components/BaseStackedList.d.ts +23 -0
  109. package/lib/typescript/module/components/BaseStackedList.d.ts.map +1 -0
  110. package/lib/typescript/module/components/index.d.ts +4 -0
  111. package/lib/typescript/module/components/index.d.ts.map +1 -1
  112. package/lib/typescript/module/hoc-components.d.ts +139 -0
  113. package/lib/typescript/module/hoc-components.d.ts.map +1 -0
  114. package/lib/typescript/module/hooks/useBreakpoints.d.ts +8 -0
  115. package/lib/typescript/module/hooks/useBreakpoints.d.ts.map +1 -0
  116. package/lib/typescript/module/hooks/useIsAboveBreakpoint.d.ts +3 -0
  117. package/lib/typescript/module/hooks/useIsAboveBreakpoint.d.ts.map +1 -0
  118. package/lib/typescript/module/index.d.ts +2 -0
  119. package/lib/typescript/module/index.d.ts.map +1 -1
  120. package/lib/typescript/module/preset.d.ts.map +1 -1
  121. package/lib/typescript/module/styles/foreground-colors.d.ts +1 -12
  122. package/lib/typescript/module/styles/foreground-colors.d.ts.map +1 -1
  123. package/lib/typescript/module/styles/utility-colors.d.ts +125 -124
  124. package/lib/typescript/module/styles/utility-colors.d.ts.map +1 -1
  125. package/lib/typescript/module/types/heroicons.d.ts +2 -2
  126. package/lib/typescript/module/types/heroicons.d.ts.map +1 -1
  127. package/package.json +8 -4
  128. package/src/components/BaseAlert.tsx +175 -0
  129. package/src/components/BaseBadge.tsx +191 -0
  130. package/src/components/BaseButton.tsx +288 -0
  131. package/src/components/BaseIcon.tsx +41 -0
  132. package/src/components/BaseSpinner.tsx +18 -0
  133. package/src/components/BaseStackedList.tsx +137 -0
  134. package/src/components/index.ts +6 -0
  135. package/src/preset.cjs +1 -1
  136. package/src/preset.ts +7 -1
  137. package/src/styles/background-colors.ts +1 -1
  138. package/src/styles/border-colors.ts +1 -1
  139. package/src/styles/foreground-colors.ts +19 -12
  140. package/src/styles/text-colors.ts +1 -1
  141. package/src/styles/utility-colors.ts +250 -124
@@ -0,0 +1,41 @@
1
+ import { styled } from 'nativewind';
2
+
3
+ import foregroundColors, { Color as ForegroundColor } from '../styles/foreground-colors';
4
+ import utilityColors, { Color as UtilityColor } from '../styles/utility-colors';
5
+ import { HeroIcon, HeroIconProps } from '../types/heroicons';
6
+
7
+ type IconColor = ForegroundColor | UtilityColor;
8
+
9
+ export interface BaseIconProps extends HeroIconProps {
10
+ icon: HeroIcon;
11
+ size?: number | string;
12
+ color?: IconColor;
13
+ strokeWidth?: number;
14
+ }
15
+
16
+ function isForegroundColor(color: IconColor): color is ForegroundColor {
17
+ return Object.keys(foregroundColors).includes(color as string);
18
+ }
19
+
20
+ function BaseIcon({
21
+ icon: Icon,
22
+ size = 20,
23
+ color = 'fg-primary',
24
+ strokeWidth = 1,
25
+ ...props
26
+ }: BaseIconProps) {
27
+ const colorValue = isForegroundColor(color)
28
+ ? foregroundColors[color].light
29
+ : utilityColors[color as UtilityColor].light;
30
+
31
+ return (
32
+ <Icon
33
+ size={size}
34
+ color={colorValue}
35
+ strokeWidth={strokeWidth}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ export default styled(BaseIcon);
@@ -0,0 +1,18 @@
1
+ import { ComponentProps } from 'react';
2
+
3
+ import { ActivityIndicator } from '../hoc-components';
4
+ import colors from '../styles/colors';
5
+
6
+ interface BaseSpinnerProps extends ComponentProps<typeof ActivityIndicator> {
7
+ size?: 'small' | 'large' | number;
8
+ }
9
+
10
+ export default function BaseSpinner({ size = 'large', ...props }: BaseSpinnerProps) {
11
+ return (
12
+ <ActivityIndicator
13
+ size={size}
14
+ color={colors.brand[600]}
15
+ {...props}
16
+ />
17
+ );
18
+ }
@@ -0,0 +1,137 @@
1
+ import { styled } from 'nativewind';
2
+ import React, { ReactNode, useMemo } from 'react';
3
+ import { ViewProps } from 'react-native';
4
+ import { InboxIcon } from 'react-native-heroicons/outline';
5
+ import { ArrowLeftIcon, ArrowRightIcon } from 'react-native-heroicons/solid';
6
+
7
+ import { View, Text } from '../hoc-components';
8
+ import BaseButton from './BaseButton';
9
+ import BaseSpinner from './BaseSpinner';
10
+ import colors from '../styles/colors';
11
+
12
+ export interface BaseStackedListProps<T> {
13
+ itemsCount: number;
14
+ items: T[];
15
+ renderItem: (item: T, index: number) => ReactNode;
16
+ onNextPage: () => void;
17
+ onPrevPage: () => void;
18
+ header?: ReactNode;
19
+ pageSize: number;
20
+ loading: boolean;
21
+ currentPage?: number;
22
+ keyExtractor?: (item: T, index: number) => string;
23
+ emptyStateDescription?: string;
24
+ minHeight?: number;
25
+ }
26
+
27
+ interface EmptyStateProps extends ViewProps {
28
+ description?: string;
29
+ }
30
+
31
+ function EmptyState({ description }: EmptyStateProps) {
32
+ return (
33
+ <View className="flex flex-col justify-center px-4 py-8">
34
+ <View className="h-12 w-12 items-center justify-center rounded-full bg-tertiary">
35
+ <InboxIcon
36
+ size={24}
37
+ color={colors.gray_light[500]}
38
+ />
39
+ </View>
40
+ <Text className="mt-4 text-base font-medium text-primary">No hay nada que mostrar</Text>
41
+ {description && (
42
+ <Text className="mt-2 text-sm text-tertiary">{description}</Text>
43
+ )}
44
+ </View>
45
+ );
46
+ }
47
+
48
+ function BaseStackedList<T>({
49
+ itemsCount,
50
+ items,
51
+ renderItem,
52
+ onNextPage,
53
+ onPrevPage,
54
+ header,
55
+ pageSize,
56
+ loading,
57
+ currentPage = 0,
58
+ keyExtractor,
59
+ emptyStateDescription,
60
+ minHeight = 0,
61
+ }: BaseStackedListProps<T>) {
62
+ const totalPages = useMemo(() => Math.ceil(itemsCount / pageSize), [itemsCount, pageSize]);
63
+ const hasNextPage = currentPage < totalPages - 1;
64
+ const hasPrevPage = currentPage > 0;
65
+
66
+ const currentPageItems = useMemo(() => {
67
+ const startIndex = currentPage * pageSize;
68
+ const endIndex = startIndex + pageSize;
69
+ return items.slice(startIndex, endIndex);
70
+ }, [items, currentPage, pageSize]);
71
+
72
+ const isEmpty = items.length === 0 && !loading;
73
+ const hasItemsForCurrentPage = currentPageItems.length > pageSize * (currentPage + 1);
74
+
75
+ return (
76
+ <View className="flex flex-col rounded-xl border border-secondary bg-primary shadow-sm">
77
+ <View className="border-b border-secondary p-4">
78
+ {header}
79
+ </View>
80
+ {loading && !hasItemsForCurrentPage && (
81
+ <View
82
+ className="flex items-center justify-center py-12"
83
+ style={{ minHeight }}
84
+ >
85
+ <BaseSpinner />
86
+ </View>
87
+ )}
88
+ {!loading && isEmpty && <EmptyState description={emptyStateDescription} />}
89
+ {!loading && !isEmpty && (
90
+ <View
91
+ className="flex flex-col"
92
+ style={{ minHeight }}
93
+ >
94
+ {currentPageItems.map((item, index) => {
95
+ const itemKey = keyExtractor ? keyExtractor(item, index) : `item-${currentPage}-${index}`;
96
+ return (
97
+ <React.Fragment key={itemKey}>
98
+ {index > 0 && <View className="h-px w-full bg-gray-200" />}
99
+ {renderItem(item, index + (currentPage * pageSize))}
100
+ </React.Fragment>
101
+ );
102
+ })}
103
+ </View>
104
+ )}
105
+
106
+ {(hasNextPage || hasPrevPage) && items.length > 0 && (
107
+ <View className="flex flex-row items-center justify-between border-t border-secondary p-4">
108
+ <BaseButton
109
+ variant="secondary"
110
+ onPress={onPrevPage}
111
+ disabled={!hasPrevPage}
112
+ leftIcon={ArrowLeftIcon}
113
+ />
114
+
115
+ <Text className="text-sm font-medium text-secondary">
116
+ Página
117
+ {' '}
118
+ {currentPage + 1}
119
+ {' '}
120
+ de
121
+ {' '}
122
+ {totalPages}
123
+ </Text>
124
+
125
+ <BaseButton
126
+ variant="secondary"
127
+ onPress={onNextPage}
128
+ disabled={!hasNextPage}
129
+ leftIcon={ArrowRightIcon}
130
+ />
131
+ </View>
132
+ )}
133
+ </View>
134
+ );
135
+ }
136
+
137
+ export default styled(BaseStackedList);
@@ -0,0 +1,6 @@
1
+ export { default as BaseButton } from './BaseButton';
2
+ export { default as BaseBadge } from './BaseBadge';
3
+ export { default as BaseSpinner } from './BaseSpinner';
4
+ export { default as BaseStackedList } from './BaseStackedList';
5
+ export { default as BaseIcon } from './BaseIcon';
6
+ export { default as BaseAlert } from './BaseAlert';
package/src/preset.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  // CommonJS wrapper for preset
2
- module.exports = require('../lib/commonjs/preset.js').default;
2
+ module.exports = require('../lib/commonjs/preset.js').default;
package/src/preset.ts CHANGED
@@ -2,6 +2,7 @@ import type { Config } from 'tailwindcss';
2
2
 
3
3
  import backgroundColors from './styles/background-colors';
4
4
  import borderColors from './styles/border-colors';
5
+ import foregroundColors from './styles/foreground-colors';
5
6
  import textColors from './styles/text-colors';
6
7
 
7
8
  type SemanticColorObject = Record<string, { light: string; dark?: string }>;
@@ -18,12 +19,17 @@ function mapLightColors(
18
19
  }
19
20
 
20
21
  const preset: Config = {
21
- content: [],
22
+ content: [
23
+ './node_modules/@grupalia/rn-ui-kit/lib/module/components/**',
24
+ ],
22
25
  theme: {
23
26
  extend: {
24
27
  backgroundColor: mapLightColors(backgroundColors, 'bg'),
25
28
  textColor: mapLightColors(textColors, 'text'),
26
29
  borderColor: mapLightColors(borderColors, 'border'),
30
+ colors: {
31
+ ...mapLightColors(foregroundColors, 'fg'),
32
+ },
27
33
  },
28
34
  },
29
35
  plugins: [],
@@ -138,7 +138,7 @@ const backgroundColors: BackgroundColorsType = {
138
138
  };
139
139
 
140
140
  Object.entries(utilityColors).forEach(([key, value]) => {
141
- backgroundColors[`bg-utility-${key}`] = {
141
+ backgroundColors[`bg-${key}`] = {
142
142
  light: value.light,
143
143
  dark: value.dark,
144
144
  };
@@ -54,7 +54,7 @@ const borderColors: BorderColorsType = {
54
54
  };
55
55
 
56
56
  Object.entries(utilityColors).forEach(([key, value]) => {
57
- borderColors[`border-utility-${key}`] = {
57
+ borderColors[`border-${key}`] = {
58
58
  light: value.light,
59
59
  dark: value.dark,
60
60
  };
@@ -1,5 +1,24 @@
1
1
  import colors from './colors';
2
2
 
3
+ export type Color =
4
+ | 'fg-primary'
5
+ | 'fg-secondary'
6
+ | 'fg-tertiary'
7
+ | 'fg-quaternary'
8
+ | 'fg-white'
9
+ | 'fg-disabled'
10
+ | 'fg-disabled_subtle'
11
+ | 'fg-brand-primary'
12
+ | 'fg-brand-primary_alt'
13
+ | 'fg-brand-secondary'
14
+ | 'fg-brand-secondary_alt'
15
+ | 'fg-error-primary'
16
+ | 'fg-error-secondary'
17
+ | 'fg-warning-primary'
18
+ | 'fg-warning-secondary'
19
+ | 'fg-success-primary'
20
+ | 'fg-success-secondary';
21
+
3
22
  export default {
4
23
  'fg-primary': {
5
24
  light: colors.gray_light['900'],
@@ -9,26 +28,14 @@ export default {
9
28
  light: colors.gray_light['700'],
10
29
  dark: colors.gray_dark['300'],
11
30
  },
12
- 'fg-secondary_hover': {
13
- light: colors.gray_light['800'],
14
- dark: colors.gray_dark['200'],
15
- },
16
31
  'fg-tertiary': {
17
32
  light: colors.gray_light['600'],
18
33
  dark: colors.gray_dark['400'],
19
34
  },
20
- 'fg-tertiary_hover': {
21
- light: colors.gray_light['700'],
22
- dark: colors.gray_dark['300'],
23
- },
24
35
  'fg-quaternary': {
25
36
  light: colors.gray_light['400'],
26
37
  dark: colors.gray_dark['600'],
27
38
  },
28
- 'fg-quaternary_hover': {
29
- light: colors.gray_light['500'],
30
- dark: colors.gray_dark['500'],
31
- },
32
39
  'fg-white': {
33
40
  light: colors.base.white,
34
41
  dark: colors.base.white,
@@ -118,7 +118,7 @@ const textColors: TextColorsType = {
118
118
  };
119
119
 
120
120
  Object.entries(utilityColors).forEach(([key, value]) => {
121
- textColors[`text-utility-${key}`] = {
121
+ textColors[`text-${key}`] = {
122
122
  light: value.light,
123
123
  dark: value.dark,
124
124
  };