aport-tools 4.4.0 → 4.4.2
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.
- package/dist/forms/FormContext.d.ts +4 -1
- package/dist/forms/Stepper.d.ts +5 -1
- package/dist/index.esm.js +178 -93
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +177 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
@@ -8,10 +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
|
+
totalSteps: number;
|
16
|
+
stepType?: "number" | "icon" | "empty";
|
17
|
+
icon?: React.ReactNode | React.ReactNode[];
|
15
18
|
}
|
16
19
|
interface FormProps {
|
17
20
|
children: ReactNode;
|
package/dist/forms/Stepper.d.ts
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
import React from "react";
|
2
2
|
interface StepperProps {
|
3
|
-
steps
|
3
|
+
steps?: string[];
|
4
4
|
currentStep: number;
|
5
5
|
presseable?: boolean;
|
6
6
|
onPress?: (stepIndex: number) => void;
|
7
|
+
stepStyle?: "circular" | "square";
|
8
|
+
totalSteps: number;
|
9
|
+
stepType?: "number" | "icon" | "empty";
|
10
|
+
icon?: React.ReactNode | React.ReactNode[];
|
7
11
|
}
|
8
12
|
declare const Stepper: React.FC<StepperProps>;
|
9
13
|
export default Stepper;
|
package/dist/index.esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
/*! aport-tools v4.4.
|
1
|
+
/*! aport-tools v4.4.2 | ISC */
|
2
2
|
import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
|
3
|
-
import { StyleSheet,
|
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,29 +97,166 @@ 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,
|
103
176
|
_b = _a.presseable,
|
104
177
|
presseable = _b === void 0 ? false : _b,
|
105
|
-
_onPress = _a.onPress
|
178
|
+
_onPress = _a.onPress,
|
179
|
+
_c = _a.stepStyle,
|
180
|
+
stepStyle = _c === void 0 ? "circular" : _c,
|
181
|
+
totalSteps = _a.totalSteps,
|
182
|
+
_d = _a.stepType,
|
183
|
+
stepType = _d === void 0 ? "number" : _d,
|
184
|
+
icon = _a.icon;
|
185
|
+
var progressAnim = React.useRef(new Animated.Value(0)).current;
|
186
|
+
var theme = useContext(ThemeContext).theme;
|
187
|
+
var colors = theme.colors;
|
188
|
+
React.useEffect(function () {
|
189
|
+
Animated.timing(progressAnim, {
|
190
|
+
toValue: currentStep,
|
191
|
+
duration: 300,
|
192
|
+
useNativeDriver: false
|
193
|
+
}).start();
|
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]);
|
204
|
+
var getSeparatorWidth = function getSeparatorWidth(index) {
|
205
|
+
if (currentStep > index && currentStep < index + 1) {
|
206
|
+
// Return the fractional percentage for odd steps
|
207
|
+
return "".concat(((currentStep - index) * 100).toFixed(0), "%");
|
208
|
+
}
|
209
|
+
return currentStep > index ? "100%" : "0%";
|
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
|
+
};
|
106
228
|
return /*#__PURE__*/React.createElement(View, {
|
107
229
|
style: styles$9.container
|
108
|
-
},
|
109
|
-
|
110
|
-
|
111
|
-
|
230
|
+
}, Array.from({
|
231
|
+
length: totalSteps
|
232
|
+
}, function (_, index) {
|
233
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
234
|
+
key: index
|
235
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
236
|
+
style: [styles$9.stepContainer, presseable && {
|
237
|
+
cursor: "pointer"
|
238
|
+
}],
|
112
239
|
disabled: !presseable,
|
113
240
|
onPress: function onPress() {
|
114
241
|
return _onPress && _onPress(index);
|
115
242
|
}
|
116
243
|
}, /*#__PURE__*/React.createElement(View, {
|
117
|
-
style: styles$9.
|
118
|
-
|
119
|
-
|
120
|
-
|
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, {
|
121
250
|
style: styles$9.stepText
|
122
|
-
},
|
251
|
+
}, steps[index])), index < totalSteps - 1 && (/*#__PURE__*/React.createElement(View, {
|
252
|
+
style: styles$9.separatorContainer
|
253
|
+
}, /*#__PURE__*/React.createElement(View, {
|
254
|
+
style: styles$9.separatorBackground
|
255
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
256
|
+
style: [styles$9.separatorProgress, {
|
257
|
+
width: getSeparatorWidth(index)
|
258
|
+
}]
|
259
|
+
}))));
|
123
260
|
}));
|
124
261
|
};
|
125
262
|
var styles$9 = StyleSheet.create({
|
@@ -133,19 +270,17 @@ var styles$9 = StyleSheet.create({
|
|
133
270
|
alignItems: "center",
|
134
271
|
flex: 1
|
135
272
|
},
|
136
|
-
|
273
|
+
step: {
|
137
274
|
width: 30,
|
138
275
|
height: 30,
|
139
276
|
borderRadius: 15,
|
277
|
+
// Default to circular
|
140
278
|
alignItems: "center",
|
141
279
|
justifyContent: "center",
|
142
280
|
marginBottom: 4
|
143
281
|
},
|
144
|
-
|
145
|
-
|
146
|
-
},
|
147
|
-
inactiveStep: {
|
148
|
-
backgroundColor: "#aaaaaa"
|
282
|
+
squareStep: {
|
283
|
+
borderRadius: 5 // Square shape
|
149
284
|
},
|
150
285
|
stepLabel: {
|
151
286
|
color: "#ffffff",
|
@@ -153,7 +288,27 @@ var styles$9 = StyleSheet.create({
|
|
153
288
|
},
|
154
289
|
stepText: {
|
155
290
|
fontSize: 12,
|
156
|
-
textAlign: "center"
|
291
|
+
textAlign: "center",
|
292
|
+
marginTop: 4
|
293
|
+
},
|
294
|
+
separatorContainer: {
|
295
|
+
flex: 1,
|
296
|
+
height: 4,
|
297
|
+
marginHorizontal: 8,
|
298
|
+
position: "relative"
|
299
|
+
},
|
300
|
+
separatorBackground: {
|
301
|
+
position: "absolute",
|
302
|
+
width: "100%",
|
303
|
+
height: "100%",
|
304
|
+
backgroundColor: "#aaaaaa",
|
305
|
+
borderRadius: 2
|
306
|
+
},
|
307
|
+
separatorProgress: {
|
308
|
+
position: "absolute",
|
309
|
+
height: "100%",
|
310
|
+
backgroundColor: "#3498db",
|
311
|
+
borderRadius: 2
|
157
312
|
}
|
158
313
|
});
|
159
314
|
|
@@ -214,83 +369,13 @@ var Form = function Form(_a) {
|
|
214
369
|
steps: stepper.steps,
|
215
370
|
currentStep: stepper.step,
|
216
371
|
presseable: stepper.presseable,
|
217
|
-
onPress: stepper.onPress
|
372
|
+
onPress: stepper.onPress,
|
373
|
+
totalSteps: stepper.totalSteps,
|
374
|
+
stepType: stepper.stepType,
|
375
|
+
icon: stepper.icon
|
218
376
|
})), children);
|
219
377
|
};
|
220
378
|
|
221
|
-
// src/fonts/Text.tsx
|
222
|
-
/**
|
223
|
-
* A dynamic Text component that supports HTML-like formatting.
|
224
|
-
* Integrates with the Theme system for consistent styling.
|
225
|
-
*
|
226
|
-
* @param children - The content to be displayed inside the Text component.
|
227
|
-
* @param size - Size of the text. Defaults to 'medium'.
|
228
|
-
* @param b - If true, applies bold styling.
|
229
|
-
* @param i - If true, applies italic styling.
|
230
|
-
* @param type - Type of Text component. Defaults to 'text'.
|
231
|
-
* @param typeFont - Type of Font component. Defaults to 'body'.
|
232
|
-
* @param u - If true, applies underline styling.
|
233
|
-
* @param align - Paragraph alignment. Defaults to 'left'.
|
234
|
-
* @param h - Header level. Accepts 0 (none), 1, 2, or 3. Defaults to 0.
|
235
|
-
* @param style - Additional styles to apply.
|
236
|
-
*/
|
237
|
-
var Text = function Text(_a) {
|
238
|
-
var _b;
|
239
|
-
var children = _a.children,
|
240
|
-
_c = _a.size,
|
241
|
-
size = _c === void 0 ? 14 : _c,
|
242
|
-
_d = _a.b,
|
243
|
-
b = _d === void 0 ? false : _d,
|
244
|
-
_e = _a.i,
|
245
|
-
i = _e === void 0 ? false : _e,
|
246
|
-
_f = _a.u,
|
247
|
-
u = _f === void 0 ? false : _f,
|
248
|
-
_g = _a.align,
|
249
|
-
align = _g === void 0 ? 'left' : _g,
|
250
|
-
_h = _a.type,
|
251
|
-
type = _h === void 0 ? 'text' : _h,
|
252
|
-
_j = _a.typeFont,
|
253
|
-
typeFont = _j === void 0 ? 'body' : _j,
|
254
|
-
_k = _a.h,
|
255
|
-
h = _k === void 0 ? 0 : _k,
|
256
|
-
style = _a.style;
|
257
|
-
var theme = useContext(ThemeContext).theme;
|
258
|
-
var colors = theme.colors,
|
259
|
-
fonts = theme.fonts;
|
260
|
-
// Determine font family and size based on 'typeFont'
|
261
|
-
var fontSettings = fonts[typeFont] || fonts.body;
|
262
|
-
var fontFamily = fontSettings.fontFamily;
|
263
|
-
var fontSize = fontSettings.fontSize || size;
|
264
|
-
// Calculate header size based on 'h' prop
|
265
|
-
if (h === 1) fontSize = 32;else if (h === 2) fontSize = 24;else if (h === 3) fontSize = 18;
|
266
|
-
// Define font weight based on bold prop
|
267
|
-
var fontWeight = b ? '700' : fontSettings.fontWeight || '400';
|
268
|
-
// Define font style based on italic prop
|
269
|
-
var fontStyle = i ? 'italic' : 'normal';
|
270
|
-
// Define text decoration based on underline prop
|
271
|
-
var textDecorationLine = u ? 'underline' : 'none';
|
272
|
-
// Define text alignment
|
273
|
-
var textAlign = align;
|
274
|
-
// Map the 'type' prop to the correct color from the theme
|
275
|
-
var textColor = ((_b = colors[type]) === null || _b === void 0 ? void 0 : _b.hex) || colors.text.hex;
|
276
|
-
// Combine all styles
|
277
|
-
var textStyles = {
|
278
|
-
fontSize: fontSize,
|
279
|
-
fontWeight: fontWeight,
|
280
|
-
fontFamily: fontFamily,
|
281
|
-
fontStyle: fontStyle,
|
282
|
-
textDecorationLine: textDecorationLine,
|
283
|
-
textAlign: textAlign,
|
284
|
-
color: textColor
|
285
|
-
};
|
286
|
-
return /*#__PURE__*/React.createElement(Text$1, {
|
287
|
-
style: [textStyles, style]
|
288
|
-
}, children);
|
289
|
-
};
|
290
|
-
StyleSheet.create({
|
291
|
-
// Define any default styles if needed
|
292
|
-
});
|
293
|
-
|
294
379
|
// src/forms/ErrorList.tsx
|
295
380
|
var ErrorList = function ErrorList(_a) {
|
296
381
|
var errors = _a.errors;
|