@idealyst/components 1.1.6 → 1.1.8

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 (144) hide show
  1. package/package.json +8 -3
  2. package/src/Accordion/Accordion.native.tsx +22 -14
  3. package/src/Accordion/Accordion.styles.old.tsx +298 -0
  4. package/src/Accordion/Accordion.styles.tsx +139 -248
  5. package/src/Accordion/Accordion.web.tsx +12 -7
  6. package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -2
  7. package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
  8. package/src/ActivityIndicator/ActivityIndicator.styles.tsx +43 -62
  9. package/src/ActivityIndicator/ActivityIndicator.web.tsx +2 -2
  10. package/src/Alert/Alert.native.tsx +26 -15
  11. package/src/Alert/Alert.styles.old.tsx +209 -0
  12. package/src/Alert/Alert.styles.tsx +108 -281
  13. package/src/Alert/Alert.web.tsx +6 -10
  14. package/src/Avatar/Avatar.native.tsx +5 -2
  15. package/src/Avatar/Avatar.styles.old.tsx +99 -0
  16. package/src/Avatar/Avatar.styles.tsx +47 -62
  17. package/src/Avatar/Avatar.web.tsx +2 -2
  18. package/src/Badge/Badge.native.tsx +2 -2
  19. package/src/Badge/Badge.styles.old.tsx +157 -0
  20. package/src/Badge/Badge.styles.tsx +69 -108
  21. package/src/Badge/Badge.web.tsx +6 -6
  22. package/src/Breadcrumb/Breadcrumb.native.tsx +12 -5
  23. package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
  24. package/src/Breadcrumb/Breadcrumb.styles.tsx +93 -209
  25. package/src/Breadcrumb/Breadcrumb.web.tsx +39 -27
  26. package/src/Button/Button.native.tsx +39 -14
  27. package/src/Button/Button.styles.tsx +99 -253
  28. package/src/Button/Button.web.tsx +10 -8
  29. package/src/Card/Card.native.tsx +8 -4
  30. package/src/Card/Card.styles.old.tsx +160 -0
  31. package/src/Card/Card.styles.tsx +107 -142
  32. package/src/Card/Card.web.tsx +6 -4
  33. package/src/Checkbox/Checkbox.native.tsx +14 -6
  34. package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
  35. package/src/Checkbox/Checkbox.styles.tsx +109 -197
  36. package/src/Checkbox/Checkbox.web.tsx +7 -7
  37. package/src/Chip/Chip.native.tsx +5 -5
  38. package/src/Chip/Chip.styles.old.tsx +184 -0
  39. package/src/Chip/Chip.styles.tsx +34 -22
  40. package/src/Chip/Chip.web.tsx +5 -5
  41. package/src/Dialog/Dialog.native.tsx +16 -7
  42. package/src/Dialog/Dialog.styles.old.tsx +202 -0
  43. package/src/Dialog/Dialog.styles.tsx +108 -132
  44. package/src/Dialog/Dialog.web.tsx +4 -4
  45. package/src/Divider/Divider.native.tsx +29 -42
  46. package/src/Divider/Divider.styles.old.tsx +172 -0
  47. package/src/Divider/Divider.styles.tsx +116 -242
  48. package/src/Divider/Divider.web.tsx +17 -14
  49. package/src/Icon/Icon.native.tsx +12 -4
  50. package/src/Icon/Icon.styles.old.tsx +81 -0
  51. package/src/Icon/Icon.styles.tsx +52 -60
  52. package/src/Icon/Icon.web.tsx +43 -7
  53. package/src/Icon/IconSvg/IconSvg.web.tsx +2 -0
  54. package/src/Image/Image.styles.old.tsx +69 -0
  55. package/src/Image/Image.styles.tsx +45 -43
  56. package/src/Input/Input.native.tsx +140 -56
  57. package/src/Input/Input.styles.old.tsx +289 -0
  58. package/src/Input/Input.styles.tsx +177 -228
  59. package/src/Input/Input.web.tsx +5 -8
  60. package/src/Link/Link.native.tsx +4 -1
  61. package/src/List/List.native.tsx +5 -2
  62. package/src/List/List.styles.old.tsx +242 -0
  63. package/src/List/List.styles.tsx +178 -240
  64. package/src/List/ListItem.native.tsx +16 -8
  65. package/src/List/ListItem.web.tsx +26 -15
  66. package/src/Menu/Menu.native.tsx +1 -1
  67. package/src/Menu/Menu.styles.old.tsx +197 -0
  68. package/src/Menu/Menu.styles.tsx +90 -156
  69. package/src/Menu/Menu.web.tsx +2 -2
  70. package/src/Menu/MenuItem.native.tsx +9 -5
  71. package/src/Menu/MenuItem.styles.old.tsx +114 -0
  72. package/src/Menu/MenuItem.styles.tsx +71 -104
  73. package/src/Menu/MenuItem.web.tsx +23 -5
  74. package/src/Popover/Popover.native.tsx +10 -4
  75. package/src/Popover/Popover.styles.old.tsx +135 -0
  76. package/src/Popover/Popover.styles.tsx +46 -96
  77. package/src/Popover/Popover.web.tsx +1 -1
  78. package/src/Pressable/Pressable.native.tsx +3 -1
  79. package/src/Pressable/Pressable.styles.old.tsx +27 -0
  80. package/src/Pressable/Pressable.styles.tsx +35 -20
  81. package/src/Pressable/Pressable.web.tsx +1 -1
  82. package/src/Progress/Progress.native.tsx +15 -6
  83. package/src/Progress/Progress.styles.old.tsx +200 -0
  84. package/src/Progress/Progress.styles.tsx +69 -118
  85. package/src/Progress/Progress.web.tsx +10 -9
  86. package/src/RadioButton/RadioButton.native.tsx +10 -4
  87. package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
  88. package/src/RadioButton/RadioButton.styles.tsx +81 -145
  89. package/src/RadioButton/RadioButton.web.tsx +4 -4
  90. package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
  91. package/src/SVGImage/SVGImage.styles.tsx +35 -66
  92. package/src/Screen/Screen.native.tsx +30 -27
  93. package/src/Screen/Screen.styles.old.tsx +87 -0
  94. package/src/Screen/Screen.styles.tsx +120 -71
  95. package/src/Screen/Screen.web.tsx +2 -2
  96. package/src/Select/Select.native.tsx +44 -29
  97. package/src/Select/Select.styles.old.tsx +353 -0
  98. package/src/Select/Select.styles.tsx +244 -293
  99. package/src/Select/Select.web.tsx +5 -5
  100. package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
  101. package/src/Skeleton/Skeleton.styles.tsx +31 -43
  102. package/src/Slider/Slider.native.tsx +9 -5
  103. package/src/Slider/Slider.styles.old.tsx +259 -0
  104. package/src/Slider/Slider.styles.tsx +157 -227
  105. package/src/Slider/Slider.web.tsx +5 -5
  106. package/src/Switch/Switch.native.tsx +11 -5
  107. package/src/Switch/Switch.styles.old.tsx +203 -0
  108. package/src/Switch/Switch.styles.tsx +103 -149
  109. package/src/Switch/Switch.web.tsx +8 -8
  110. package/src/TabBar/TabBar.native.tsx +24 -31
  111. package/src/TabBar/TabBar.styles.old.tsx +343 -0
  112. package/src/TabBar/TabBar.styles.tsx +204 -494
  113. package/src/TabBar/TabBar.web.tsx +21 -33
  114. package/src/Table/Table.native.tsx +18 -9
  115. package/src/Table/Table.styles.old.tsx +311 -0
  116. package/src/Table/Table.styles.tsx +151 -278
  117. package/src/Table/Table.web.tsx +1 -1
  118. package/src/Text/Text.native.tsx +1 -4
  119. package/src/Text/Text.style.demo.tsx +16 -0
  120. package/src/Text/Text.styles.old.tsx +219 -0
  121. package/src/Text/Text.styles.tsx +94 -78
  122. package/src/Text/Text.web.tsx +2 -2
  123. package/src/Text/index.ts +1 -0
  124. package/src/TextArea/TextArea.styles.old.tsx +213 -0
  125. package/src/TextArea/TextArea.styles.tsx +101 -157
  126. package/src/Tooltip/Tooltip.native.tsx +2 -2
  127. package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
  128. package/src/Tooltip/Tooltip.styles.tsx +38 -53
  129. package/src/Tooltip/Tooltip.web.tsx +2 -2
  130. package/src/Video/Video.styles.old.tsx +51 -0
  131. package/src/Video/Video.styles.tsx +32 -28
  132. package/src/View/View.native.tsx +12 -12
  133. package/src/View/View.styles.old.tsx +125 -0
  134. package/src/View/View.styles.tsx +84 -103
  135. package/src/View/View.web.tsx +14 -2
  136. package/src/examples/CardExamples.tsx +0 -6
  137. package/src/extensions/applyExtension.ts +210 -0
  138. package/src/extensions/extendComponent.ts +438 -0
  139. package/src/extensions/index.ts +102 -0
  140. package/src/extensions/types.ts +497 -0
  141. package/src/globals.ts +16 -0
  142. package/src/index.native.ts +4 -0
  143. package/src/index.ts +28 -0
  144. package/src/utils/deepMerge.ts +54 -2
@@ -1,79 +1,71 @@
1
+ /**
2
+ * Icon styles using defineStyle with dynamic functions.
3
+ */
1
4
  import { StyleSheet } from 'react-native-unistyles';
2
- import { Theme, StylesheetStyles, Intent, Color, getColorFromString } from '@idealyst/theme';
3
- import { buildSizeVariants } from '../utils/buildSizeVariants';
5
+ import { defineStyle, ThemeStyleWrapper, getColorFromString } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme, Intent, Color } from '@idealyst/theme';
4
7
  import { IconSizeVariant } from './types';
5
8
 
6
- type IconVariants = {
9
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
10
+ void StyleSheet;
11
+
12
+ // Wrap theme for $iterator support
13
+ type Theme = ThemeStyleWrapper<BaseTheme>;
14
+
15
+ export type IconVariants = {
7
16
  size: IconSizeVariant;
8
17
  intent?: Intent;
9
18
  color?: Color;
10
- }
11
-
12
- export type ExpandedIconStyles = StylesheetStyles<keyof IconVariants>;
19
+ };
13
20
 
14
- export type IconStylesheet = {
15
- icon: ExpandedIconStyles;
16
- }
21
+ export type IconDynamicProps = Partial<IconVariants>;
17
22
 
18
23
  /**
19
- * Create color variants for icon
24
+ * Icon styles with dynamic color/size handling.
20
25
  */
21
- function getIconColor(theme: Theme, color?: Color, intent?: Intent): string {
22
- if (intent) {
23
- return theme.intents[intent]?.primary
24
- } else if (color) {
25
- return getColorFromString(theme, color);
26
- }
27
- return theme.colors.text.primary;
28
- }
26
+ export const iconStyles = defineStyle('Icon', (theme: Theme) => ({
27
+ icon: ({ color, intent, size = 'md' }: IconDynamicProps) => {
28
+ // Handle size - can be a named size or number
29
+ let iconWidth: number;
30
+ let iconHeight: number;
29
31
 
30
- function buildIconSize(theme: Theme, size?: IconSizeVariant) {
31
- // Handle direct numeric sizes
32
- if (typeof size === 'number') {
33
- return {
34
- width: size,
35
- height: size,
36
- };
37
- }
32
+ if (typeof size === 'number') {
33
+ iconWidth = size;
34
+ iconHeight = size;
35
+ } else {
36
+ const sizeKey = size || 'md';
37
+ const iconSize = theme.sizes.icon[sizeKey];
38
+ if (typeof iconSize === 'number') {
39
+ iconWidth = iconSize;
40
+ iconHeight = iconSize;
41
+ } else {
42
+ iconWidth = (iconSize?.width as number) ?? 24;
43
+ iconHeight = (iconSize?.height as number) ?? 24;
44
+ }
45
+ }
38
46
 
39
- // Default to 'md' if size is undefined
40
- const sizeKey = size || 'md';
41
- const iconSize = theme.sizes.icon[sizeKey];
47
+ // Get color - intent takes priority, then color prop, then default
48
+ const iconColor = intent
49
+ ? theme.intents[intent]?.primary
50
+ : color
51
+ ? getColorFromString(theme as unknown as BaseTheme, color)
52
+ : theme.colors.text.primary;
42
53
 
43
- if (typeof iconSize === 'number') {
44
54
  return {
45
- width: iconSize,
46
- height: iconSize,
47
- };
48
- }
49
-
50
- return buildSizeVariants(theme, 'icon', (size) => ({
51
- width: size.width,
52
- height: size.height,
53
- }))[sizeKey];
54
- }
55
-
56
- function createIconStyles(theme: Theme) {
57
- return ({ color, intent, size }: Partial<IconVariants>) => {
58
- const iconSize = buildIconSize(theme, size);
59
- return {
60
- width: iconSize.width,
61
- height: iconSize.height,
62
- color: getIconColor(theme, color, intent),
55
+ width: iconWidth,
56
+ height: iconHeight,
57
+ color: iconColor,
63
58
  _web: {
64
- display: 'inline-block',
59
+ fontSize: iconWidth,
60
+ width: '1em',
61
+ height: '1em',
62
+ display: 'inline-flex',
63
+ alignItems: 'center',
64
+ justifyContent: 'center',
65
65
  verticalAlign: 'middle',
66
66
  flexShrink: 0,
67
- lineHeight: 0,
67
+ lineHeight: 1,
68
68
  },
69
69
  } as const;
70
- }
71
- }
72
-
73
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
74
- // transform on native cannot resolve function calls to extract variant structures.
75
- export const iconStyles = StyleSheet.create((theme: Theme) => {
76
- return {
77
- icon: createIconStyles(theme),
78
- } as const;
79
- });
70
+ },
71
+ }));
@@ -3,14 +3,16 @@ import MdiIcon from '@mdi/react';
3
3
  import { IconProps } from './types';
4
4
  import { iconStyles } from './Icon.styles';
5
5
  import { getWebProps } from 'react-native-unistyles/web';
6
+ import { useUnistyles } from 'react-native-unistyles';
6
7
  import useMergeRefs from '../hooks/useMergeRefs';
8
+ import { getColorFromString, Intent, Color } from '@idealyst/theme';
7
9
 
8
10
  // Internal props that include the transformed path from Babel plugin
9
11
  interface InternalIconProps extends IconProps {
10
12
  path?: string; // Added by Babel plugin transformation
11
13
  }
12
14
 
13
- const Icon = forwardRef<HTMLDivElement, IconProps>((props: InternalIconProps, ref) => {
15
+ const Icon = forwardRef<HTMLSpanElement, IconProps>((props: InternalIconProps, ref) => {
14
16
  const {
15
17
  name,
16
18
  size = 'md',
@@ -23,26 +25,60 @@ const Icon = forwardRef<HTMLDivElement, IconProps>((props: InternalIconProps, re
23
25
  ...restProps
24
26
  } = props;
25
27
 
28
+ const { theme } = useUnistyles();
29
+
26
30
  // Check if we have a path prop (from Babel plugin transformation)
27
31
  const { path } = restProps as { path?: string };
28
- const iconProps = getWebProps(iconStyles.icon({ intent, color, size }));
32
+
33
+ // Compute size from theme
34
+ let iconSize: number;
35
+ if (typeof size === 'number') {
36
+ iconSize = size;
37
+ } else {
38
+ const themeSize = theme.sizes.icon[size as keyof typeof theme.sizes.icon];
39
+ iconSize = typeof themeSize === 'number' ? themeSize : (themeSize?.width ?? 24);
40
+ }
41
+
42
+ // Compute color from intent or color prop or default
43
+ const iconColor = intent
44
+ ? theme.intents[intent as Intent]?.primary
45
+ : color
46
+ ? getColorFromString(theme, color as Color)
47
+ : theme.colors.text.primary;
48
+
49
+ // Use getWebProps for className generation but override with computed values
50
+ const iconStyle = (iconStyles.icon as any)({ intent, color, size });
51
+ const iconProps = getWebProps([iconStyle, style]);
29
52
 
30
53
  const mergedRef = useMergeRefs(ref, iconProps.ref);
31
54
 
32
55
  // Use MDI React icon when path is provided (transformed by Babel plugin)
33
56
  return (
34
- <div
57
+ <span
35
58
  {...iconProps}
36
59
  ref={mergedRef}
37
- id={id}>
60
+ id={id}
61
+ style={{
62
+ ...iconProps.style,
63
+ fontSize: iconSize,
64
+ width: '1em',
65
+ height: '1em',
66
+ display: 'inline-flex',
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
69
+ flexShrink: 0,
70
+ lineHeight: 1,
71
+ color: iconColor,
72
+ }}
73
+ >
38
74
  <MdiIcon
39
75
  path={path}
40
- size={'100%'}
41
- color={'currentColor'}
76
+ size="1em"
77
+ color="currentColor"
42
78
  data-testid={testID}
43
79
  aria-label={accessibilityLabel || name}
44
80
  />
45
- </div>
81
+ </span>
46
82
  );
47
83
  });
48
84
 
@@ -19,6 +19,7 @@ interface IconSvgProps {
19
19
 
20
20
  export const IconSvg: React.FC<IconSvgProps> = ({
21
21
  path,
22
+ size = '1em',
22
23
  color = 'currentColor',
23
24
  style,
24
25
  'aria-label': ariaLabel,
@@ -29,6 +30,7 @@ export const IconSvg: React.FC<IconSvgProps> = ({
29
30
  <MdiIcon
30
31
  style={style}
31
32
  path={path}
33
+ size={size}
32
34
  color={color}
33
35
  aria-label={ariaLabel}
34
36
  data-testid={testID}
@@ -0,0 +1,69 @@
1
+ import { StyleSheet } from 'react-native-unistyles';
2
+ import { Theme, StylesheetStyles} from '@idealyst/theme';
3
+ import { applyExtensions } from '../extensions/applyExtension';
4
+
5
+ type ImageVariants = {}
6
+
7
+ export type ExpandedImageStyles = StylesheetStyles<keyof ImageVariants>;
8
+
9
+ export type ImageStylesheet = {
10
+ container: ExpandedImageStyles;
11
+ image: ExpandedImageStyles;
12
+ placeholder: ExpandedImageStyles;
13
+ fallback: ExpandedImageStyles;
14
+ loadingIndicator: ExpandedImageStyles;
15
+ }
16
+
17
+ // Style creators for extension support
18
+ function createContainerStyles(theme: Theme) {
19
+ return () => ({
20
+ position: 'relative' as const,
21
+ overflow: 'hidden' as const,
22
+ backgroundColor: theme.colors['gray.200'],
23
+ });
24
+ }
25
+
26
+ function createImageStyles() {
27
+ return () => ({
28
+ width: '100%' as const,
29
+ height: '100%' as const,
30
+ });
31
+ }
32
+
33
+ // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
34
+ // transform on native cannot resolve function calls to extract variant structures.
35
+ // @ts-ignore - TS language server needs restart to pick up theme structure changes
36
+ export const imageStyles = StyleSheet.create((theme: Theme) => {
37
+ // Apply extensions to main visual elements
38
+
39
+ return applyExtensions('Image', theme, {container: createContainerStyles(theme),
40
+ image: createImageStyles(),
41
+ // Additional styles (merged from return)
42
+ // Minor utility styles (not extended)
43
+ placeholder: {
44
+ position: 'absolute',
45
+ top: 0,
46
+ left: 0,
47
+ right: 0,
48
+ bottom: 0,
49
+ display: 'flex',
50
+ alignItems: 'center',
51
+ justifyContent: 'center',
52
+ backgroundColor: theme.colors['gray.200'],
53
+ },
54
+ fallback: {
55
+ position: 'absolute',
56
+ top: 0,
57
+ left: 0,
58
+ right: 0,
59
+ bottom: 0,
60
+ display: 'flex',
61
+ alignItems: 'center',
62
+ justifyContent: 'center',
63
+ backgroundColor: theme.colors['gray.300'],
64
+ color: theme.colors['gray.600'],
65
+ },
66
+ loadingIndicator: {
67
+ color: theme.colors['gray.600'],
68
+ }});
69
+ });
@@ -1,57 +1,59 @@
1
+ /**
2
+ * Image styles using defineStyle.
3
+ */
1
4
  import { StyleSheet } from 'react-native-unistyles';
2
- import { Theme, StylesheetStyles} from '@idealyst/theme';
3
-
4
- type ImageVariants = {}
5
-
6
- export type ExpandedImageStyles = StylesheetStyles<keyof ImageVariants>;
7
-
8
- export type ImageStylesheet = {
9
- container: ExpandedImageStyles;
10
- image: ExpandedImageStyles;
11
- placeholder: ExpandedImageStyles;
12
- fallback: ExpandedImageStyles;
13
- loadingIndicator: ExpandedImageStyles;
14
- }
15
-
16
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
17
- // transform on native cannot resolve function calls to extract variant structures.
18
- // @ts-ignore - TS language server needs restart to pick up theme structure changes
19
- export const imageStyles = StyleSheet.create((theme: Theme) => {
20
- return {
21
- container: {
22
- position: 'relative',
23
- overflow: 'hidden',
5
+ import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme } from '@idealyst/theme';
7
+
8
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
9
+ void StyleSheet;
10
+
11
+ // Wrap theme for $iterator support
12
+ type Theme = ThemeStyleWrapper<BaseTheme>;
13
+
14
+ export type ImageDynamicProps = {};
15
+
16
+ /**
17
+ * Image styles - simple container and image styles.
18
+ */
19
+ export const imageStyles = defineStyle('Image', (theme: Theme) => ({
20
+ container: (_props: ImageDynamicProps) => ({
21
+ position: 'relative' as const,
22
+ overflow: 'hidden' as const,
24
23
  backgroundColor: theme.colors['gray.200'],
25
- },
26
- image: {
27
- width: '100%',
28
- height: '100%',
29
- },
30
- placeholder: {
31
- position: 'absolute',
24
+ }),
25
+
26
+ image: (_props: ImageDynamicProps) => ({
27
+ width: '100%' as const,
28
+ height: '100%' as const,
29
+ }),
30
+
31
+ placeholder: (_props: ImageDynamicProps) => ({
32
+ position: 'absolute' as const,
32
33
  top: 0,
33
34
  left: 0,
34
35
  right: 0,
35
36
  bottom: 0,
36
- display: 'flex',
37
- alignItems: 'center',
38
- justifyContent: 'center',
37
+ display: 'flex' as const,
38
+ alignItems: 'center' as const,
39
+ justifyContent: 'center' as const,
39
40
  backgroundColor: theme.colors['gray.200'],
40
- },
41
- fallback: {
42
- position: 'absolute',
41
+ }),
42
+
43
+ fallback: (_props: ImageDynamicProps) => ({
44
+ position: 'absolute' as const,
43
45
  top: 0,
44
46
  left: 0,
45
47
  right: 0,
46
48
  bottom: 0,
47
- display: 'flex',
48
- alignItems: 'center',
49
- justifyContent: 'center',
49
+ display: 'flex' as const,
50
+ alignItems: 'center' as const,
51
+ justifyContent: 'center' as const,
50
52
  backgroundColor: theme.colors['gray.300'],
51
53
  color: theme.colors['gray.600'],
52
- },
53
- loadingIndicator: {
54
+ }),
55
+
56
+ loadingIndicator: (_props: ImageDynamicProps) => ({
54
57
  color: theme.colors['gray.600'],
55
- },
56
- };
57
- });
58
+ }),
59
+ }));