aport-tools 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,13 @@ interface FormContextProps {
8
8
  }
9
9
  export declare const useFormContext: () => FormContextProps;
10
10
  interface StepperProps {
11
- steps: string[];
11
+ steps?: string[];
12
12
  presseable?: boolean;
13
13
  onPress?: (stepIndex: number) => void;
14
14
  step: number;
15
15
  totalSteps: number;
16
+ stepType?: "number" | "icon" | "empty";
17
+ icon?: React.ReactNode | React.ReactNode[];
16
18
  }
17
19
  interface FormProps {
18
20
  children: ReactNode;
@@ -6,6 +6,8 @@ interface StepperProps {
6
6
  onPress?: (stepIndex: number) => void;
7
7
  stepStyle?: "circular" | "square";
8
8
  totalSteps: number;
9
+ stepType?: "number" | "icon" | "empty";
10
+ icon?: React.ReactNode | React.ReactNode[];
9
11
  }
10
12
  declare const Stepper: React.FC<StepperProps>;
11
13
  export default Stepper;
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- /*! aport-tools v4.4.1 | ISC */
1
+ /*! aport-tools v4.4.2 | ISC */
2
2
  import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
3
- import { StyleSheet, Animated, View, TouchableOpacity, Text as Text$1, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Image, Alert, ActivityIndicator } from 'react-native';
3
+ import { StyleSheet, Text as Text$1, Animated, View, TouchableOpacity, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Image, Alert, ActivityIndicator } from 'react-native';
4
4
  import { ThemeContext } from 'aport-themes';
5
5
  import * as ImagePicker from 'expo-image-picker';
6
6
 
@@ -97,6 +97,79 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
97
97
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
98
98
  };
99
99
 
100
+ // src/fonts/Text.tsx
101
+ /**
102
+ * A dynamic Text component that supports HTML-like formatting.
103
+ * Integrates with the Theme system for consistent styling.
104
+ *
105
+ * @param children - The content to be displayed inside the Text component.
106
+ * @param size - Size of the text. Defaults to 'medium'.
107
+ * @param b - If true, applies bold styling.
108
+ * @param i - If true, applies italic styling.
109
+ * @param type - Type of Text component. Defaults to 'text'.
110
+ * @param typeFont - Type of Font component. Defaults to 'body'.
111
+ * @param u - If true, applies underline styling.
112
+ * @param align - Paragraph alignment. Defaults to 'left'.
113
+ * @param h - Header level. Accepts 0 (none), 1, 2, or 3. Defaults to 0.
114
+ * @param style - Additional styles to apply.
115
+ */
116
+ var Text = function Text(_a) {
117
+ var _b;
118
+ var children = _a.children,
119
+ _c = _a.size,
120
+ size = _c === void 0 ? 14 : _c,
121
+ _d = _a.b,
122
+ b = _d === void 0 ? false : _d,
123
+ _e = _a.i,
124
+ i = _e === void 0 ? false : _e,
125
+ _f = _a.u,
126
+ u = _f === void 0 ? false : _f,
127
+ _g = _a.align,
128
+ align = _g === void 0 ? 'left' : _g,
129
+ _h = _a.type,
130
+ type = _h === void 0 ? 'text' : _h,
131
+ _j = _a.typeFont,
132
+ typeFont = _j === void 0 ? 'body' : _j,
133
+ _k = _a.h,
134
+ h = _k === void 0 ? 0 : _k,
135
+ style = _a.style;
136
+ var theme = useContext(ThemeContext).theme;
137
+ var colors = theme.colors,
138
+ fonts = theme.fonts;
139
+ // Determine font family and size based on 'typeFont'
140
+ var fontSettings = fonts[typeFont] || fonts.body;
141
+ var fontFamily = fontSettings.fontFamily;
142
+ var fontSize = fontSettings.fontSize || size;
143
+ // Calculate header size based on 'h' prop
144
+ if (h === 1) fontSize = 32;else if (h === 2) fontSize = 24;else if (h === 3) fontSize = 18;
145
+ // Define font weight based on bold prop
146
+ var fontWeight = b ? '700' : fontSettings.fontWeight || '400';
147
+ // Define font style based on italic prop
148
+ var fontStyle = i ? 'italic' : 'normal';
149
+ // Define text decoration based on underline prop
150
+ var textDecorationLine = u ? 'underline' : 'none';
151
+ // Define text alignment
152
+ var textAlign = align;
153
+ // Map the 'type' prop to the correct color from the theme
154
+ var textColor = ((_b = colors[type]) === null || _b === void 0 ? void 0 : _b.hex) || colors.text.hex;
155
+ // Combine all styles
156
+ var textStyles = {
157
+ fontSize: fontSize,
158
+ fontWeight: fontWeight,
159
+ fontFamily: fontFamily,
160
+ fontStyle: fontStyle,
161
+ textDecorationLine: textDecorationLine,
162
+ textAlign: textAlign,
163
+ color: textColor
164
+ };
165
+ return /*#__PURE__*/React.createElement(Text$1, {
166
+ style: [textStyles, style]
167
+ }, children);
168
+ };
169
+ StyleSheet.create({
170
+ // Define any default styles if needed
171
+ });
172
+
100
173
  var Stepper = function Stepper(_a) {
101
174
  var steps = _a.steps,
102
175
  currentStep = _a.currentStep,
@@ -105,8 +178,13 @@ var Stepper = function Stepper(_a) {
105
178
  _onPress = _a.onPress,
106
179
  _c = _a.stepStyle,
107
180
  stepStyle = _c === void 0 ? "circular" : _c,
108
- totalSteps = _a.totalSteps;
181
+ totalSteps = _a.totalSteps,
182
+ _d = _a.stepType,
183
+ stepType = _d === void 0 ? "number" : _d,
184
+ icon = _a.icon;
109
185
  var progressAnim = React.useRef(new Animated.Value(0)).current;
186
+ var theme = useContext(ThemeContext).theme;
187
+ var colors = theme.colors;
110
188
  React.useEffect(function () {
111
189
  Animated.timing(progressAnim, {
112
190
  toValue: currentStep,
@@ -114,6 +192,15 @@ var Stepper = function Stepper(_a) {
114
192
  useNativeDriver: false
115
193
  }).start();
116
194
  }, [currentStep]);
195
+ React.useEffect(function () {
196
+ if (stepType === "icon") {
197
+ if (!icon) {
198
+ console.error("Stepper: `icon` is required when stepType is 'icon'.");
199
+ } else if (Array.isArray(icon) && icon.length !== totalSteps) {
200
+ console.error("Stepper: Number of icons (".concat(icon.length, ") must match totalSteps (").concat(totalSteps, ")."));
201
+ }
202
+ }
203
+ }, [stepType, icon, totalSteps]);
117
204
  var getSeparatorWidth = function getSeparatorWidth(index) {
118
205
  if (currentStep > index && currentStep < index + 1) {
119
206
  // Return the fractional percentage for odd steps
@@ -121,6 +208,23 @@ var Stepper = function Stepper(_a) {
121
208
  }
122
209
  return currentStep > index ? "100%" : "0%";
123
210
  };
211
+ var renderStepContent = function renderStepContent(index) {
212
+ switch (stepType) {
213
+ case "icon":
214
+ if (Array.isArray(icon)) {
215
+ return icon[index]; // Render individual icon for each step
216
+ }
217
+ return icon;
218
+ // Render the same icon for all steps
219
+ case "empty":
220
+ return null;
221
+ // Render nothing inside the step circle
222
+ case "number":
223
+ default:
224
+ return index + 1;
225
+ // Default to rendering step numbers
226
+ }
227
+ };
124
228
  return /*#__PURE__*/React.createElement(View, {
125
229
  style: styles$9.container
126
230
  }, Array.from({
@@ -137,10 +241,12 @@ var Stepper = function Stepper(_a) {
137
241
  return _onPress && _onPress(index);
138
242
  }
139
243
  }, /*#__PURE__*/React.createElement(View, {
140
- style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && styles$9.activeStep]
141
- }, /*#__PURE__*/React.createElement(Text$1, {
142
- style: styles$9.stepLabel
143
- }, index + 1)), steps && /*#__PURE__*/React.createElement(Text$1, {
244
+ style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && {
245
+ backgroundColor: colors.primary.hex
246
+ }, {
247
+ backgroundColor: colors.body.hex
248
+ }]
249
+ }, renderStepContent(index)), steps && /*#__PURE__*/React.createElement(Text, {
144
250
  style: styles$9.stepText
145
251
  }, steps[index])), index < totalSteps - 1 && (/*#__PURE__*/React.createElement(View, {
146
252
  style: styles$9.separatorContainer
@@ -169,7 +275,6 @@ var styles$9 = StyleSheet.create({
169
275
  height: 30,
170
276
  borderRadius: 15,
171
277
  // Default to circular
172
- backgroundColor: "#aaaaaa",
173
278
  alignItems: "center",
174
279
  justifyContent: "center",
175
280
  marginBottom: 4
@@ -177,9 +282,6 @@ var styles$9 = StyleSheet.create({
177
282
  squareStep: {
178
283
  borderRadius: 5 // Square shape
179
284
  },
180
- activeStep: {
181
- backgroundColor: "#3498db"
182
- },
183
285
  stepLabel: {
184
286
  color: "#ffffff",
185
287
  fontWeight: "bold"
@@ -268,83 +370,12 @@ var Form = function Form(_a) {
268
370
  currentStep: stepper.step,
269
371
  presseable: stepper.presseable,
270
372
  onPress: stepper.onPress,
271
- totalSteps: stepper.totalSteps
373
+ totalSteps: stepper.totalSteps,
374
+ stepType: stepper.stepType,
375
+ icon: stepper.icon
272
376
  })), children);
273
377
  };
274
378
 
275
- // src/fonts/Text.tsx
276
- /**
277
- * A dynamic Text component that supports HTML-like formatting.
278
- * Integrates with the Theme system for consistent styling.
279
- *
280
- * @param children - The content to be displayed inside the Text component.
281
- * @param size - Size of the text. Defaults to 'medium'.
282
- * @param b - If true, applies bold styling.
283
- * @param i - If true, applies italic styling.
284
- * @param type - Type of Text component. Defaults to 'text'.
285
- * @param typeFont - Type of Font component. Defaults to 'body'.
286
- * @param u - If true, applies underline styling.
287
- * @param align - Paragraph alignment. Defaults to 'left'.
288
- * @param h - Header level. Accepts 0 (none), 1, 2, or 3. Defaults to 0.
289
- * @param style - Additional styles to apply.
290
- */
291
- var Text = function Text(_a) {
292
- var _b;
293
- var children = _a.children,
294
- _c = _a.size,
295
- size = _c === void 0 ? 14 : _c,
296
- _d = _a.b,
297
- b = _d === void 0 ? false : _d,
298
- _e = _a.i,
299
- i = _e === void 0 ? false : _e,
300
- _f = _a.u,
301
- u = _f === void 0 ? false : _f,
302
- _g = _a.align,
303
- align = _g === void 0 ? 'left' : _g,
304
- _h = _a.type,
305
- type = _h === void 0 ? 'text' : _h,
306
- _j = _a.typeFont,
307
- typeFont = _j === void 0 ? 'body' : _j,
308
- _k = _a.h,
309
- h = _k === void 0 ? 0 : _k,
310
- style = _a.style;
311
- var theme = useContext(ThemeContext).theme;
312
- var colors = theme.colors,
313
- fonts = theme.fonts;
314
- // Determine font family and size based on 'typeFont'
315
- var fontSettings = fonts[typeFont] || fonts.body;
316
- var fontFamily = fontSettings.fontFamily;
317
- var fontSize = fontSettings.fontSize || size;
318
- // Calculate header size based on 'h' prop
319
- if (h === 1) fontSize = 32;else if (h === 2) fontSize = 24;else if (h === 3) fontSize = 18;
320
- // Define font weight based on bold prop
321
- var fontWeight = b ? '700' : fontSettings.fontWeight || '400';
322
- // Define font style based on italic prop
323
- var fontStyle = i ? 'italic' : 'normal';
324
- // Define text decoration based on underline prop
325
- var textDecorationLine = u ? 'underline' : 'none';
326
- // Define text alignment
327
- var textAlign = align;
328
- // Map the 'type' prop to the correct color from the theme
329
- var textColor = ((_b = colors[type]) === null || _b === void 0 ? void 0 : _b.hex) || colors.text.hex;
330
- // Combine all styles
331
- var textStyles = {
332
- fontSize: fontSize,
333
- fontWeight: fontWeight,
334
- fontFamily: fontFamily,
335
- fontStyle: fontStyle,
336
- textDecorationLine: textDecorationLine,
337
- textAlign: textAlign,
338
- color: textColor
339
- };
340
- return /*#__PURE__*/React.createElement(Text$1, {
341
- style: [textStyles, style]
342
- }, children);
343
- };
344
- StyleSheet.create({
345
- // Define any default styles if needed
346
- });
347
-
348
379
  // src/forms/ErrorList.tsx
349
380
  var ErrorList = function ErrorList(_a) {
350
381
  var errors = _a.errors;