@flipova/foundation 2.2.1 → 2.4.0-beta.1

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 (109) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +157 -156
  3. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
  4. package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
  5. package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
  6. package/components/ui/accordion/AnimatedHeight.tsx +3 -15
  7. package/components/ui/accordion/AnimatedIcon.tsx +2 -9
  8. package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
  9. package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
  10. package/components/ui/accordion/index.tsx +71 -139
  11. package/components/ui/actionsheet/index.tsx +63 -105
  12. package/components/ui/alert/index.tsx +20 -50
  13. package/components/ui/alert-dialog/index.tsx +23 -48
  14. package/components/ui/avatar/index.tsx +32 -68
  15. package/components/ui/badge/index.tsx +18 -49
  16. package/components/ui/bottomsheet/index.tsx +20 -52
  17. package/components/ui/box/index.tsx +4 -9
  18. package/components/ui/box/index.web.tsx +3 -9
  19. package/components/ui/button/index.tsx +73 -109
  20. package/components/ui/calendar/creator.tsx +69 -30
  21. package/components/ui/calendar/index.tsx +81 -159
  22. package/components/ui/calendar/styles.tsx +10 -10
  23. package/components/ui/card/index.tsx +8 -9
  24. package/components/ui/card/index.web.tsx +4 -10
  25. package/components/ui/center/index.tsx +6 -11
  26. package/components/ui/center/index.web.tsx +3 -9
  27. package/components/ui/checkbox/index.tsx +46 -107
  28. package/components/ui/date-time-picker/creator.tsx +14 -1
  29. package/components/ui/date-time-picker/index.tsx +107 -156
  30. package/components/ui/date-time-picker/index.web.tsx +11 -33
  31. package/components/ui/date-time-picker/styles.tsx +5 -5
  32. package/components/ui/divider/index.tsx +5 -6
  33. package/components/ui/drawer/index.tsx +108 -128
  34. package/components/ui/fab/index.tsx +25 -68
  35. package/components/ui/flat-list/index.tsx +11 -8
  36. package/components/ui/form-control/index.tsx +49 -90
  37. package/components/ui/gluestack-ui-provider/config.ts +69 -2
  38. package/components/ui/gluestack-ui-provider/index.tsx +32 -12
  39. package/components/ui/gluestack-ui-provider/index.web.tsx +43 -16
  40. package/components/ui/gluestack-ui-provider/script.ts +13 -8
  41. package/components/ui/gluestack-ui-provider/theme-context.ts +36 -1
  42. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +11 -4
  43. package/components/ui/grid/index.tsx +128 -165
  44. package/components/ui/grid/index.web.tsx +17 -19
  45. package/components/ui/grid/styles.tsx +1 -3
  46. package/components/ui/heading/index.tsx +146 -169
  47. package/components/ui/heading/index.web.tsx +7 -28
  48. package/components/ui/heading/styles.tsx +5 -5
  49. package/components/ui/hstack/index.tsx +16 -15
  50. package/components/ui/hstack/index.web.tsx +17 -17
  51. package/components/ui/hstack/styles.tsx +5 -5
  52. package/components/ui/icon/index.tsx +95 -486
  53. package/components/ui/icon/index.web.tsx +79 -439
  54. package/components/ui/image/index.tsx +13 -18
  55. package/components/ui/image-viewer/index.tsx +149 -221
  56. package/components/ui/image-viewer/index.web.tsx +88 -113
  57. package/components/ui/input/index.tsx +20 -33
  58. package/components/ui/link/index.tsx +16 -22
  59. package/components/ui/liquid-glass/index.tsx +19 -25
  60. package/components/ui/menu/index.tsx +44 -66
  61. package/components/ui/modal/index.tsx +70 -91
  62. package/components/ui/popover/index.tsx +102 -121
  63. package/components/ui/portal/index.tsx +5 -6
  64. package/components/ui/pressable/index.tsx +5 -9
  65. package/components/ui/progress/index.tsx +4 -11
  66. package/components/ui/radio/index.tsx +47 -83
  67. package/components/ui/select/index.tsx +38 -59
  68. package/components/ui/select/select-actionsheet.tsx +61 -108
  69. package/components/ui/skeleton/index.tsx +22 -43
  70. package/components/ui/skeleton/index.web.tsx +63 -75
  71. package/components/ui/slider/index.tsx +36 -56
  72. package/components/ui/spinner/index.tsx +1 -10
  73. package/components/ui/switch/index.tsx +6 -13
  74. package/components/ui/table/index.tsx +39 -102
  75. package/components/ui/table/index.web.tsx +41 -79
  76. package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
  77. package/components/ui/tabs/creator.tsx +32 -24
  78. package/components/ui/tabs/index.tsx +253 -309
  79. package/components/ui/text/index.tsx +23 -37
  80. package/components/ui/text/index.web.tsx +33 -35
  81. package/components/ui/text/styles.tsx +5 -5
  82. package/components/ui/textarea/index.tsx +24 -38
  83. package/components/ui/toast/index.tsx +47 -52
  84. package/components/ui/tooltip/index.tsx +12 -28
  85. package/components/ui/vstack/index.tsx +17 -17
  86. package/components/ui/vstack/index.web.tsx +17 -17
  87. package/components/ui/vstack/styles.tsx +5 -5
  88. package/design/canonical.index.txt +15 -1
  89. package/design/manifest.xml +2 -0
  90. package/design/schema.xsd +11 -0
  91. package/design/themes.xml +175 -2
  92. package/design/tools/design.js +15 -12
  93. package/design/tools/npm.js +4 -3
  94. package/design/tools/sources/.generate/config.py +60 -2
  95. package/dist/{chunk-RPLDFHEZ.mjs → chunk-2R66P5X5.mjs} +1907 -3130
  96. package/dist/chunk-2R66P5X5.mjs.map +1 -0
  97. package/dist/{chunk-JVHJUIXV.js → chunk-LCTFQJZM.js} +1909 -3129
  98. package/dist/chunk-LCTFQJZM.js.map +1 -0
  99. package/dist/index.d.mts +1 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.js +303 -291
  102. package/dist/index.mjs +1 -1
  103. package/dist/ui/index.d.mts +44 -3
  104. package/dist/ui/index.d.ts +44 -3
  105. package/dist/ui/index.js +303 -291
  106. package/dist/ui/index.mjs +1 -1
  107. package/package.json +12 -7
  108. package/dist/chunk-JVHJUIXV.js.map +0 -1
  109. package/dist/chunk-RPLDFHEZ.mjs.map +0 -1
@@ -1,18 +1,9 @@
1
- import React, {
2
- useState,
3
- createContext,
4
- useContext,
5
- useMemo,
6
- forwardRef,
7
- } from 'react';
1
+ import React, { useState, createContext, useContext, useMemo, forwardRef } from 'react';
8
2
  import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
9
3
  import { View, Dimensions, Platform, ViewProps } from 'react-native';
10
4
  import { gridStyle, gridItemStyle } from './styles';
11
5
  import { cssInterop } from 'nativewind';
12
- import {
13
- useBreakpointValue,
14
- getBreakPointValue,
15
- } from '@gluestack-ui/utils/hooks';
6
+ import { useBreakpointValue, getBreakPointValue } from '@gluestack-ui/utils/hooks';
16
7
  const { width: DEVICE_WIDTH } = Dimensions.get('window');
17
8
  const GridContext = createContext<any>({});
18
9
  function arrangeChildrenIntoRows({
@@ -40,9 +31,7 @@ function arrangeChildrenIntoRows({
40
31
  // if current row is not full, add colSpan to current row
41
32
  currentRowTotalColSpan += colSpan;
42
33
  }
43
- rowItemsCount[currentRow] = rowItemsCount[currentRow]
44
- ? [...rowItemsCount[currentRow], i]
45
- : [i];
34
+ rowItemsCount[currentRow] = rowItemsCount[currentRow] ? [...rowItemsCount[currentRow], i] : [i];
46
35
  }
47
36
  return rowItemsCount;
48
37
  }
@@ -64,11 +53,7 @@ function generateResponsiveNumColumns({ gridClass }: { gridClass: string }) {
64
53
  });
65
54
  return result;
66
55
  }
67
- function generateResponsiveColSpans({
68
- gridItemClassName,
69
- }: {
70
- gridItemClassName: string;
71
- }) {
56
+ function generateResponsiveColSpans({ gridItemClassName }: { gridItemClassName: string }) {
72
57
  const gridClassNamePattern = /\b(?:\w+:)?col-span-?\d+\b/g;
73
58
  const colSpan: any = gridItemClassName?.match(gridClassNamePattern);
74
59
  if (!colSpan) {
@@ -104,83 +89,79 @@ type IGridProps = ViewProps &
104
89
  className: string;
105
90
  };
106
91
  };
107
- const Grid = forwardRef<React.ComponentRef<typeof View>, IGridProps>(
108
- function Grid({ className, _extra, children, ...props }, ref) {
109
- const [calculatedWidth, setCalculatedWidth] = useState<number | null>(null);
110
- const gridClass = _extra?.className;
111
- const obj = generateResponsiveNumColumns({ gridClass });
112
- const responsiveNumColumns: any = useBreakpointValue(obj);
113
- const itemsPerRow = useMemo(() => {
114
- // get the colSpan of each child
115
- const colSpanArr = React.Children.map(children, (child: any) => {
116
- const gridItemClassName = child?.props?._extra?.className;
117
- const colSpan2 = getBreakPointValue(
118
- generateResponsiveColSpans({ gridItemClassName }),
119
- DEVICE_WIDTH
120
- );
121
- const colSpan = colSpan2 ? colSpan2 : 1;
122
- if (colSpan > responsiveNumColumns) {
123
- return responsiveNumColumns;
124
- }
125
- return colSpan;
126
- });
127
- const childrenArray = React.Children.toArray(children);
128
- const rowItemsCount = arrangeChildrenIntoRows({
129
- childrenArray,
130
- colSpanArr,
131
- numColumns: responsiveNumColumns,
132
- });
133
- return rowItemsCount;
134
- }, [responsiveNumColumns, children]);
135
- const childrenWithProps = React.Children.map(children, (child, index) => {
136
- if (React.isValidElement(child)) {
137
- return React.cloneElement(child, { key: index, index: index } as any);
92
+ const Grid = forwardRef<React.ComponentRef<typeof View>, IGridProps>(function Grid(
93
+ { className, _extra, children, ...props },
94
+ ref,
95
+ ) {
96
+ const [calculatedWidth, setCalculatedWidth] = useState<number | null>(null);
97
+ const gridClass = _extra?.className;
98
+ const obj = generateResponsiveNumColumns({ gridClass });
99
+ const responsiveNumColumns: any = useBreakpointValue(obj);
100
+ const itemsPerRow = useMemo(() => {
101
+ // get the colSpan of each child
102
+ const colSpanArr = React.Children.map(children, (child: any) => {
103
+ const gridItemClassName = child?.props?._extra?.className;
104
+ const colSpan2 = getBreakPointValue(generateResponsiveColSpans({ gridItemClassName }), DEVICE_WIDTH);
105
+ const colSpan = colSpan2 ? colSpan2 : 1;
106
+ if (colSpan > responsiveNumColumns) {
107
+ return responsiveNumColumns;
138
108
  }
139
- return child;
109
+ return colSpan;
140
110
  });
141
- const gridClassMerged = `${Platform.select({
142
- web: gridClass ?? '',
143
- })}`;
144
- const contextValue = useMemo(() => {
145
- return {
146
- calculatedWidth,
147
- numColumns: responsiveNumColumns,
148
- itemsPerRow,
149
- flexDirection: props?.flexDirection || 'row',
150
- gap: props?.gap || 0,
151
- columnGap: props?.columnGap || 0,
152
- };
153
- }, [calculatedWidth, itemsPerRow, responsiveNumColumns, props]);
154
- const borderLeftWidth = props?.borderLeftWidth || props?.borderWidth || 0;
155
- const borderRightWidth = props?.borderRightWidth || props?.borderWidth || 0;
156
- const borderWidthToSubtract = borderLeftWidth + borderRightWidth;
157
- return (
158
- <GridContext.Provider value={contextValue}>
159
- <View
160
- ref={ref}
161
- className={gridStyle({
162
- class: className + ' ' + gridClassMerged,
163
- })}
164
- onLayout={(event) => {
165
- const paddingLeftToSubtract =
166
- props?.paddingStart || props?.paddingLeft || props?.padding || 0;
167
- const paddingRightToSubtract =
168
- props?.paddingEnd || props?.paddingRight || props?.padding || 0;
169
- const gridWidth =
170
- Math.floor(event.nativeEvent.layout.width) -
171
- paddingLeftToSubtract -
172
- paddingRightToSubtract -
173
- borderWidthToSubtract;
174
- setCalculatedWidth(gridWidth);
175
- }}
176
- {...props}
177
- >
178
- {calculatedWidth && childrenWithProps}
179
- </View>
180
- </GridContext.Provider>
181
- );
182
- }
183
- );
111
+ const childrenArray = React.Children.toArray(children);
112
+ const rowItemsCount = arrangeChildrenIntoRows({
113
+ childrenArray,
114
+ colSpanArr,
115
+ numColumns: responsiveNumColumns,
116
+ });
117
+ return rowItemsCount;
118
+ }, [responsiveNumColumns, children]);
119
+ const childrenWithProps = React.Children.map(children, (child, index) => {
120
+ if (React.isValidElement(child)) {
121
+ return React.cloneElement(child, { key: index, index: index } as any);
122
+ }
123
+ return child;
124
+ });
125
+ const gridClassMerged = `${Platform.select({
126
+ web: gridClass ?? '',
127
+ })}`;
128
+ const contextValue = useMemo(() => {
129
+ return {
130
+ calculatedWidth,
131
+ numColumns: responsiveNumColumns,
132
+ itemsPerRow,
133
+ flexDirection: props?.flexDirection || 'row',
134
+ gap: props?.gap || 0,
135
+ columnGap: props?.columnGap || 0,
136
+ };
137
+ }, [calculatedWidth, itemsPerRow, responsiveNumColumns, props]);
138
+ const borderLeftWidth = props?.borderLeftWidth || props?.borderWidth || 0;
139
+ const borderRightWidth = props?.borderRightWidth || props?.borderWidth || 0;
140
+ const borderWidthToSubtract = borderLeftWidth + borderRightWidth;
141
+ return (
142
+ <GridContext.Provider value={contextValue}>
143
+ <View
144
+ ref={ref}
145
+ className={gridStyle({
146
+ class: className + ' ' + gridClassMerged,
147
+ })}
148
+ onLayout={(event) => {
149
+ const paddingLeftToSubtract = props?.paddingStart || props?.paddingLeft || props?.padding || 0;
150
+ const paddingRightToSubtract = props?.paddingEnd || props?.paddingRight || props?.padding || 0;
151
+ const gridWidth =
152
+ Math.floor(event.nativeEvent.layout.width) -
153
+ paddingLeftToSubtract -
154
+ paddingRightToSubtract -
155
+ borderWidthToSubtract;
156
+ setCalculatedWidth(gridWidth);
157
+ }}
158
+ {...props}
159
+ >
160
+ {calculatedWidth && childrenWithProps}
161
+ </View>
162
+ </GridContext.Provider>
163
+ );
164
+ });
184
165
  cssInterop(Grid, {
185
166
  className: {
186
167
  target: 'style',
@@ -207,77 +188,59 @@ type IGridItemProps = ViewProps &
207
188
  className: string;
208
189
  };
209
190
  };
210
- const GridItem = forwardRef<React.ComponentRef<typeof View>, IGridItemProps>(
211
- function GridItem({ className, _extra, ...props }, ref) {
212
- const {
213
- calculatedWidth,
214
- numColumns,
215
- itemsPerRow,
216
- flexDirection,
217
- gap,
218
- columnGap,
219
- } = useContext(GridContext);
220
- const gridItemClass = _extra?.className;
221
- const responsiveColSpan = (useBreakpointValue(
222
- generateResponsiveColSpans({ gridItemClassName: gridItemClass })
223
- ) ?? 1) as number;
224
- const flexBasisValue = useMemo(() => {
225
- if (!calculatedWidth || !numColumns || responsiveColSpan <= 0) {
226
- return 'auto';
227
- }
228
- if (flexDirection?.includes('column')) {
229
- return 'auto';
230
- }
231
- // Find which row this item is in
232
- const row = Object.keys(itemsPerRow).find((key) => {
233
- return itemsPerRow[key].includes(props?.index);
234
- });
235
- if (!row) {
236
- return 'auto';
237
- }
238
- const rowColsCount = itemsPerRow[row]?.length || 1;
239
- const space = columnGap || gap || 0;
240
- // Calculate available width accounting for gaps
241
- const totalGapWidth = space * (rowColsCount - 1);
242
- const availableWidth = calculatedWidth - totalGapWidth;
243
- // Calculate the width for this item based on its column span
244
- const itemWidth = (availableWidth * responsiveColSpan) / numColumns;
245
- // Return the width directly instead of percentage for better native compatibility
246
- return Math.max(0, Math.floor(itemWidth));
247
- }, [
248
- calculatedWidth,
249
- responsiveColSpan,
250
- numColumns,
251
- columnGap,
252
- gap,
253
- flexDirection,
254
- itemsPerRow,
255
- props?.index,
256
- ]);
257
- return (
258
- <View
259
- ref={ref}
260
- // @ts-expect-error : internal implementation for r-19/react-native-web
261
- gridItemClass={gridItemClass}
262
- className={gridItemStyle({
263
- class: className,
264
- })}
265
- {...props}
266
- style={[
267
- {
268
- width:
269
- typeof flexBasisValue === 'number' ? flexBasisValue : undefined,
270
- flexBasis:
271
- typeof flexBasisValue === 'string' ? flexBasisValue : undefined,
272
- flexShrink: 0,
273
- flexGrow: 0,
274
- },
275
- props.style,
276
- ]}
277
- />
278
- );
279
- }
280
- );
191
+ const GridItem = forwardRef<React.ComponentRef<typeof View>, IGridItemProps>(function GridItem(
192
+ { className, _extra, ...props },
193
+ ref,
194
+ ) {
195
+ const { calculatedWidth, numColumns, itemsPerRow, flexDirection, gap, columnGap } = useContext(GridContext);
196
+ const gridItemClass = _extra?.className;
197
+ const responsiveColSpan = (useBreakpointValue(generateResponsiveColSpans({ gridItemClassName: gridItemClass })) ??
198
+ 1) as number;
199
+ const flexBasisValue = useMemo(() => {
200
+ if (!calculatedWidth || !numColumns || responsiveColSpan <= 0) {
201
+ return 'auto';
202
+ }
203
+ if (flexDirection?.includes('column')) {
204
+ return 'auto';
205
+ }
206
+ // Find which row this item is in
207
+ const row = Object.keys(itemsPerRow).find((key) => {
208
+ return itemsPerRow[key].includes(props?.index);
209
+ });
210
+ if (!row) {
211
+ return 'auto';
212
+ }
213
+ const rowColsCount = itemsPerRow[row]?.length || 1;
214
+ const space = columnGap || gap || 0;
215
+ // Calculate available width accounting for gaps
216
+ const totalGapWidth = space * (rowColsCount - 1);
217
+ const availableWidth = calculatedWidth - totalGapWidth;
218
+ // Calculate the width for this item based on its column span
219
+ const itemWidth = (availableWidth * responsiveColSpan) / numColumns;
220
+ // Return the width directly instead of percentage for better native compatibility
221
+ return Math.max(0, Math.floor(itemWidth));
222
+ }, [calculatedWidth, responsiveColSpan, numColumns, columnGap, gap, flexDirection, itemsPerRow, props?.index]);
223
+ return (
224
+ <View
225
+ ref={ref}
226
+ // @ts-expect-error : internal implementation for r-19/react-native-web
227
+ gridItemClass={gridItemClass}
228
+ className={gridItemStyle({
229
+ class: className,
230
+ })}
231
+ {...props}
232
+ style={[
233
+ {
234
+ width: typeof flexBasisValue === 'number' ? flexBasisValue : undefined,
235
+ flexBasis: typeof flexBasisValue === 'string' ? flexBasisValue : undefined,
236
+ flexShrink: 0,
237
+ flexGrow: 0,
238
+ },
239
+ props.style,
240
+ ]}
241
+ />
242
+ );
243
+ });
281
244
  Grid.displayName = 'Grid';
282
245
  GridItem.displayName = 'GridItem';
283
246
  export { Grid, GridItem };
@@ -19,10 +19,7 @@ type IGridProps = React.ComponentPropsWithoutRef<'div'> &
19
19
  };
20
20
  };
21
21
 
22
- const Grid = React.forwardRef<HTMLDivElement, IGridProps>(function Grid(
23
- { className, _extra, ...props },
24
- ref
25
- ) {
22
+ const Grid = React.forwardRef<HTMLDivElement, IGridProps>(function Grid({ className, _extra, ...props }, ref) {
26
23
  const gridClass = _extra?.className;
27
24
  const finalGridClass = gridClass ?? '';
28
25
  return (
@@ -43,22 +40,23 @@ type IGridItemProps = React.ComponentPropsWithoutRef<'div'> &
43
40
  className: string;
44
41
  };
45
42
  };
46
- const GridItem = React.forwardRef<HTMLDivElement, IGridItemProps>(
47
- function GridItem({ className, _extra, ...props }, ref) {
48
- const gridItemClass = _extra?.className;
43
+ const GridItem = React.forwardRef<HTMLDivElement, IGridItemProps>(function GridItem(
44
+ { className, _extra, ...props },
45
+ ref,
46
+ ) {
47
+ const gridItemClass = _extra?.className;
49
48
 
50
- const finalGridItemClass = gridItemClass ?? '';
51
- return (
52
- <div
53
- ref={ref}
54
- className={gridItemStyle({
55
- class: className + ' ' + finalGridItemClass,
56
- })}
57
- {...props}
58
- />
59
- );
60
- }
61
- );
49
+ const finalGridItemClass = gridItemClass ?? '';
50
+ return (
51
+ <div
52
+ ref={ref}
53
+ className={gridItemStyle({
54
+ class: className + ' ' + finalGridItemClass,
55
+ })}
56
+ {...props}
57
+ />
58
+ );
59
+ });
62
60
 
63
61
  Grid.displayName = 'Grid';
64
62
  GridItem.displayName = 'GridItem';
@@ -1,9 +1,7 @@
1
1
  import { tva } from '@gluestack-ui/utils/nativewind-utils';
2
2
  import { isWeb } from '@gluestack-ui/utils/nativewind-utils';
3
3
 
4
- const gridBaseStyle = isWeb
5
- ? 'grid grid-cols-12'
6
- : 'box-border flex-row flex-wrap justify-start';
4
+ const gridBaseStyle = isWeb ? 'grid grid-cols-12' : 'box-border flex-row flex-wrap justify-start';
7
5
  const gridItemBaseStyle = isWeb ? 'w-auto col-span-1' : '';
8
6
 
9
7
  export const gridStyle = tva({