aport-tools 4.3.5 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/forms/FormContext.d.ts +7 -0
- package/dist/forms/Stepper.d.ts +9 -0
- package/dist/index.esm.js +82 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +81 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! aport-tools v4.
|
1
|
+
/*! aport-tools v4.4.0 | ISC */
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
var React = require('react');
|
@@ -118,6 +118,66 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
118
118
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
119
119
|
};
|
120
120
|
|
121
|
+
var Stepper = function Stepper(_a) {
|
122
|
+
var steps = _a.steps,
|
123
|
+
currentStep = _a.currentStep,
|
124
|
+
_b = _a.presseable,
|
125
|
+
presseable = _b === void 0 ? false : _b,
|
126
|
+
_onPress = _a.onPress;
|
127
|
+
return /*#__PURE__*/React.createElement(reactNative.View, {
|
128
|
+
style: styles$9.container
|
129
|
+
}, steps.map(function (label, index) {
|
130
|
+
return /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
|
131
|
+
key: index,
|
132
|
+
style: [styles$9.stepContainer, index <= currentStep ? styles$9.activeStep : styles$9.inactiveStep],
|
133
|
+
disabled: !presseable,
|
134
|
+
onPress: function onPress() {
|
135
|
+
return _onPress && _onPress(index);
|
136
|
+
}
|
137
|
+
}, /*#__PURE__*/React.createElement(reactNative.View, {
|
138
|
+
style: styles$9.stepCircle
|
139
|
+
}, /*#__PURE__*/React.createElement(reactNative.Text, {
|
140
|
+
style: styles$9.stepLabel
|
141
|
+
}, index + 1)), /*#__PURE__*/React.createElement(reactNative.Text, {
|
142
|
+
style: styles$9.stepText
|
143
|
+
}, label));
|
144
|
+
}));
|
145
|
+
};
|
146
|
+
var styles$9 = reactNative.StyleSheet.create({
|
147
|
+
container: {
|
148
|
+
flexDirection: "row",
|
149
|
+
alignItems: "center",
|
150
|
+
justifyContent: "space-between",
|
151
|
+
marginBottom: 16
|
152
|
+
},
|
153
|
+
stepContainer: {
|
154
|
+
alignItems: "center",
|
155
|
+
flex: 1
|
156
|
+
},
|
157
|
+
stepCircle: {
|
158
|
+
width: 30,
|
159
|
+
height: 30,
|
160
|
+
borderRadius: 15,
|
161
|
+
alignItems: "center",
|
162
|
+
justifyContent: "center",
|
163
|
+
marginBottom: 4
|
164
|
+
},
|
165
|
+
activeStep: {
|
166
|
+
backgroundColor: "#3498db"
|
167
|
+
},
|
168
|
+
inactiveStep: {
|
169
|
+
backgroundColor: "#aaaaaa"
|
170
|
+
},
|
171
|
+
stepLabel: {
|
172
|
+
color: "#ffffff",
|
173
|
+
fontWeight: "bold"
|
174
|
+
},
|
175
|
+
stepText: {
|
176
|
+
fontSize: 12,
|
177
|
+
textAlign: "center"
|
178
|
+
}
|
179
|
+
});
|
180
|
+
|
121
181
|
// src/forms/FormContext.tsx
|
122
182
|
var FormContext = /*#__PURE__*/React.createContext(undefined);
|
123
183
|
var useFormContext = function useFormContext() {
|
@@ -129,7 +189,8 @@ var useFormContext = function useFormContext() {
|
|
129
189
|
};
|
130
190
|
var Form = function Form(_a) {
|
131
191
|
var children = _a.children,
|
132
|
-
onSubmit = _a.onSubmit
|
192
|
+
onSubmit = _a.onSubmit,
|
193
|
+
stepper = _a.stepper;
|
133
194
|
var _b = React.useState({}),
|
134
195
|
formValues = _b[0],
|
135
196
|
setFormValues = _b[1];
|
@@ -170,7 +231,12 @@ var Form = function Form(_a) {
|
|
170
231
|
setErrors: setErrors,
|
171
232
|
handleSubmit: handleSubmit
|
172
233
|
}
|
173
|
-
},
|
234
|
+
}, stepper && (/*#__PURE__*/React.createElement(Stepper, {
|
235
|
+
steps: stepper.steps,
|
236
|
+
currentStep: stepper.step,
|
237
|
+
presseable: stepper.presseable,
|
238
|
+
onPress: stepper.onPress
|
239
|
+
})), children);
|
174
240
|
};
|
175
241
|
|
176
242
|
// src/fonts/Text.tsx
|
@@ -746,7 +812,8 @@ var InputCheck = function InputCheck(_a) {
|
|
746
812
|
disabled = _e === void 0 ? false : _e;
|
747
813
|
var _f = useFormContext(),
|
748
814
|
formValues = _f.formValues,
|
749
|
-
setFormValue = _f.setFormValue
|
815
|
+
setFormValue = _f.setFormValue,
|
816
|
+
formErrors = _f.errors;
|
750
817
|
var _g = React.useState(formValues[name] || []),
|
751
818
|
selectedValues = _g[0],
|
752
819
|
setSelectedValues = _g[1];
|
@@ -805,7 +872,9 @@ var InputCheck = function InputCheck(_a) {
|
|
805
872
|
}]
|
806
873
|
}, item.label));
|
807
874
|
};
|
808
|
-
return /*#__PURE__*/React.createElement(
|
875
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
876
|
+
style: styles$2.title
|
877
|
+
}, name), /*#__PURE__*/React.createElement(reactNative.FlatList, {
|
809
878
|
data: options,
|
810
879
|
renderItem: renderItem,
|
811
880
|
keyExtractor: function keyExtractor(item) {
|
@@ -814,7 +883,9 @@ var InputCheck = function InputCheck(_a) {
|
|
814
883
|
numColumns: rowAmount,
|
815
884
|
columnWrapperStyle: rowAmount > 1 ? styles$2.row : undefined,
|
816
885
|
scrollEnabled: false
|
817
|
-
})
|
886
|
+
}), formErrors[name] && formErrors[name].length > 0 && (/*#__PURE__*/React.createElement(ErrorList, {
|
887
|
+
errors: formErrors[name]
|
888
|
+
})));
|
818
889
|
};
|
819
890
|
var styles$2 = reactNative.StyleSheet.create({
|
820
891
|
card: {
|
@@ -827,6 +898,10 @@ var styles$2 = reactNative.StyleSheet.create({
|
|
827
898
|
alignItems: "center",
|
828
899
|
justifyContent: "center"
|
829
900
|
},
|
901
|
+
title: {
|
902
|
+
marginBottom: 4,
|
903
|
+
fontSize: 14
|
904
|
+
},
|
830
905
|
cardDisabled: {
|
831
906
|
opacity: 0.5
|
832
907
|
},
|