aport-tools 4.4.1 → 4.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/forms/FormContext.d.ts +3 -1
- package/dist/forms/Stepper.d.ts +2 -0
- package/dist/index.esm.js +148 -87
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +147 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
@@ -8,11 +8,13 @@ interface FormContextProps {
|
|
8
8
|
}
|
9
9
|
export declare const useFormContext: () => FormContextProps;
|
10
10
|
interface StepperProps {
|
11
|
-
steps
|
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;
|
package/dist/forms/Stepper.d.ts
CHANGED
@@ -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
|
+
/*! aport-tools v4.4.3 | ISC */
|
2
2
|
import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
|
3
|
-
import { StyleSheet, Animated, View, TouchableOpacity,
|
3
|
+
import { StyleSheet, Text as Text$1, Animated, View, TouchableOpacity, Image, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, 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,53 @@ 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
|
+
var stepIcon = icon[index];
|
216
|
+
if (typeof stepIcon === "string") {
|
217
|
+
return /*#__PURE__*/React.createElement(Image, {
|
218
|
+
source: {
|
219
|
+
uri: stepIcon
|
220
|
+
},
|
221
|
+
style: {
|
222
|
+
width: 24,
|
223
|
+
height: 24
|
224
|
+
},
|
225
|
+
resizeMode: "contain"
|
226
|
+
});
|
227
|
+
} else {
|
228
|
+
console.error("Invalid icon value for step ".concat(index, ". Expected a string URI."));
|
229
|
+
return null;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
if (typeof icon === "string") {
|
233
|
+
return /*#__PURE__*/React.createElement(Image, {
|
234
|
+
source: {
|
235
|
+
uri: icon
|
236
|
+
},
|
237
|
+
style: {
|
238
|
+
width: 24,
|
239
|
+
height: 24
|
240
|
+
},
|
241
|
+
resizeMode: "contain"
|
242
|
+
});
|
243
|
+
}
|
244
|
+
console.error("Icon prop must be a string or an array of strings.");
|
245
|
+
return null;
|
246
|
+
case "empty":
|
247
|
+
return null;
|
248
|
+
case "number":
|
249
|
+
default:
|
250
|
+
return /*#__PURE__*/React.createElement(Text, {
|
251
|
+
style: {
|
252
|
+
fontSize: 16,
|
253
|
+
fontWeight: "bold"
|
254
|
+
}
|
255
|
+
}, index + 1);
|
256
|
+
}
|
257
|
+
};
|
124
258
|
return /*#__PURE__*/React.createElement(View, {
|
125
259
|
style: styles$9.container
|
126
260
|
}, Array.from({
|
@@ -137,10 +271,12 @@ var Stepper = function Stepper(_a) {
|
|
137
271
|
return _onPress && _onPress(index);
|
138
272
|
}
|
139
273
|
}, /*#__PURE__*/React.createElement(View, {
|
140
|
-
style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index &&
|
141
|
-
|
142
|
-
|
143
|
-
|
274
|
+
style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && {
|
275
|
+
backgroundColor: colors.primary.hex
|
276
|
+
}, {
|
277
|
+
backgroundColor: colors.body.hex
|
278
|
+
}]
|
279
|
+
}, renderStepContent(index)), steps && /*#__PURE__*/React.createElement(Text, {
|
144
280
|
style: styles$9.stepText
|
145
281
|
}, steps[index])), index < totalSteps - 1 && (/*#__PURE__*/React.createElement(View, {
|
146
282
|
style: styles$9.separatorContainer
|
@@ -148,7 +284,8 @@ var Stepper = function Stepper(_a) {
|
|
148
284
|
style: styles$9.separatorBackground
|
149
285
|
}), /*#__PURE__*/React.createElement(Animated.View, {
|
150
286
|
style: [styles$9.separatorProgress, {
|
151
|
-
width: getSeparatorWidth(index)
|
287
|
+
width: getSeparatorWidth(index),
|
288
|
+
backgroundColor: colors.primary.hex
|
152
289
|
}]
|
153
290
|
}))));
|
154
291
|
}));
|
@@ -169,7 +306,6 @@ var styles$9 = StyleSheet.create({
|
|
169
306
|
height: 30,
|
170
307
|
borderRadius: 15,
|
171
308
|
// Default to circular
|
172
|
-
backgroundColor: "#aaaaaa",
|
173
309
|
alignItems: "center",
|
174
310
|
justifyContent: "center",
|
175
311
|
marginBottom: 4
|
@@ -177,9 +313,6 @@ var styles$9 = StyleSheet.create({
|
|
177
313
|
squareStep: {
|
178
314
|
borderRadius: 5 // Square shape
|
179
315
|
},
|
180
|
-
activeStep: {
|
181
|
-
backgroundColor: "#3498db"
|
182
|
-
},
|
183
316
|
stepLabel: {
|
184
317
|
color: "#ffffff",
|
185
318
|
fontWeight: "bold"
|
@@ -205,7 +338,6 @@ var styles$9 = StyleSheet.create({
|
|
205
338
|
separatorProgress: {
|
206
339
|
position: "absolute",
|
207
340
|
height: "100%",
|
208
|
-
backgroundColor: "#3498db",
|
209
341
|
borderRadius: 2
|
210
342
|
}
|
211
343
|
});
|
@@ -268,83 +400,12 @@ var Form = function Form(_a) {
|
|
268
400
|
currentStep: stepper.step,
|
269
401
|
presseable: stepper.presseable,
|
270
402
|
onPress: stepper.onPress,
|
271
|
-
totalSteps: stepper.totalSteps
|
403
|
+
totalSteps: stepper.totalSteps,
|
404
|
+
stepType: stepper.stepType,
|
405
|
+
icon: stepper.icon
|
272
406
|
})), children);
|
273
407
|
};
|
274
408
|
|
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
409
|
// src/forms/ErrorList.tsx
|
349
410
|
var ErrorList = function ErrorList(_a) {
|
350
411
|
var errors = _a.errors;
|