guestbell-forms 2.0.298 → 2.0.300
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/build/components/InputHeader/InputHeader.js +258 -323
- package/build/components/InputHeader/InputHeader.js.map +1 -1
- package/build/components/InputHeader/InputHeaderContext.js +6 -8
- package/build/components/InputHeader/InputHeaderContext.js.map +1 -1
- package/build/components/InputHeader/index.js +4 -6
- package/build/components/InputHeader/index.js.map +1 -1
- package/build/components/InputHeader/withInputHeaderContext.js +9 -13
- package/build/components/InputHeader/withInputHeaderContext.js.map +1 -1
- package/build/components/base/input/BaseInput.js +334 -418
- package/build/components/base/input/BaseInput.js.map +1 -1
- package/build/components/base/input/index.js +1 -1
- package/build/components/base/input/index.js.map +1 -1
- package/build/components/bookingCalendar/BookingCalendar.js +68 -85
- package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js +40 -71
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/index.js +2 -2
- package/build/components/bookingCalendar/bookingCalendarControls/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js +22 -41
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/index.js +2 -2
- package/build/components/bookingCalendar/bookingCalendarDatePicker/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.js +20 -24
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js +9 -12
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/index.js +2 -2
- package/build/components/bookingCalendar/bookingCalendarItem/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js +23 -28
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/index.js +2 -2
- package/build/components/bookingCalendar/bookingCalendarLane/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.js +6 -6
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js +12 -16
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js +27 -31
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.js +2 -2
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.js +19 -19
- package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/classes.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/index.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarRenderItem/index.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +133 -175
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.js +17 -19
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/classes.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/classes.js.map +1 -1
- package/build/components/bookingCalendar/classes.js +1 -1
- package/build/components/bookingCalendar/classes.js.map +1 -1
- package/build/components/bookingCalendar/common.js +5 -7
- package/build/components/bookingCalendar/common.js.map +1 -1
- package/build/components/bookingCalendar/index.js +3 -3
- package/build/components/bookingCalendar/index.js.map +1 -1
- package/build/components/bookingCalendar/utils.js +143 -205
- package/build/components/bookingCalendar/utils.js.map +1 -1
- package/build/components/button/Button.js +101 -123
- package/build/components/button/Button.js.map +1 -1
- package/build/components/button/index.js +4 -6
- package/build/components/button/index.js.map +1 -1
- package/build/components/checkbox/Checkbox.js +102 -145
- package/build/components/checkbox/Checkbox.js.map +1 -1
- package/build/components/checkbox/index.js +4 -6
- package/build/components/checkbox/index.js.map +1 -1
- package/build/components/dropdown/Dropdown.js +41 -57
- package/build/components/dropdown/Dropdown.js.map +1 -1
- package/build/components/dropdown/index.js +4 -6
- package/build/components/dropdown/index.js.map +1 -1
- package/build/components/dynamicSubmit/DynamicSubmit.js +81 -123
- package/build/components/dynamicSubmit/DynamicSubmit.js.map +1 -1
- package/build/components/dynamicSubmit/index.js +4 -6
- package/build/components/dynamicSubmit/index.js.map +1 -1
- package/build/components/form/Form.js +139 -193
- package/build/components/form/Form.js.map +1 -1
- package/build/components/form/FormContext.js +6 -8
- package/build/components/form/FormContext.js.map +1 -1
- package/build/components/form/FormValidationSummary.js +57 -105
- package/build/components/form/FormValidationSummary.js.map +1 -1
- package/build/components/form/index.js +5 -7
- package/build/components/form/index.js.map +1 -1
- package/build/components/form/withFormContext.js +9 -13
- package/build/components/form/withFormContext.js.map +1 -1
- package/build/components/inputGroup/InputGroup.js +16 -48
- package/build/components/inputGroup/InputGroup.js.map +1 -1
- package/build/components/inputGroup/index.js +4 -6
- package/build/components/inputGroup/index.js.map +1 -1
- package/build/components/money/Money.js +137 -211
- package/build/components/money/Money.js.map +1 -1
- package/build/components/money/index.js +4 -6
- package/build/components/money/index.js.map +1 -1
- package/build/components/numberInput/NumberInput.js +106 -144
- package/build/components/numberInput/NumberInput.js.map +1 -1
- package/build/components/numberInput/index.js +4 -6
- package/build/components/numberInput/index.js.map +1 -1
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js +162 -220
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js.map +1 -1
- package/build/components/openingHours/openingHoursDay/index.js +4 -6
- package/build/components/openingHours/openingHoursDay/index.js.map +1 -1
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js +114 -191
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js.map +1 -1
- package/build/components/openingHours/openingHoursSpecial/index.js +4 -6
- package/build/components/openingHours/openingHoursSpecial/index.js.map +1 -1
- package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.js +150 -209
- package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.js.map +1 -1
- package/build/components/openingHours/openingHoursWeek/index.js +4 -6
- package/build/components/openingHours/openingHoursWeek/index.js.map +1 -1
- package/build/components/openingHours/utils/OpeningHoursUtil.js +51 -76
- package/build/components/openingHours/utils/OpeningHoursUtil.js.map +1 -1
- package/build/components/radio/Radio.js +38 -75
- package/build/components/radio/Radio.js.map +1 -1
- package/build/components/radio/index.js +4 -6
- package/build/components/radio/index.js.map +1 -1
- package/build/components/radioContainer/RadioContainer.js +19 -49
- package/build/components/radioContainer/RadioContainer.js.map +1 -1
- package/build/components/radioContainer/index.js +4 -6
- package/build/components/radioContainer/index.js.map +1 -1
- package/build/components/select/Select.js +186 -264
- package/build/components/select/Select.js.map +1 -1
- package/build/components/select/index.js +4 -6
- package/build/components/select/index.js.map +1 -1
- package/build/components/submit/Submit.js +50 -87
- package/build/components/submit/Submit.js.map +1 -1
- package/build/components/submit/index.js +4 -6
- package/build/components/submit/index.js.map +1 -1
- package/build/components/submit/subComponents/SubmitValidationSummary.js +5 -7
- package/build/components/submit/subComponents/SubmitValidationSummary.js.map +1 -1
- package/build/components/tags/Tags.js +365 -565
- package/build/components/tags/Tags.js.map +1 -1
- package/build/components/tags/index.js +4 -6
- package/build/components/tags/index.js.map +1 -1
- package/build/components/tags/subComponents/TagsSuggestions.js +29 -30
- package/build/components/tags/subComponents/TagsSuggestions.js.map +1 -1
- package/build/components/text/Text.js +95 -138
- package/build/components/text/Text.js.map +1 -1
- package/build/components/text/index.js +4 -6
- package/build/components/text/index.js.map +1 -1
- package/build/components/textArea/TextArea.js +52 -91
- package/build/components/textArea/TextArea.js.map +1 -1
- package/build/components/textArea/index.js +4 -6
- package/build/components/textArea/index.js.map +1 -1
- package/build/components/themeProvider/ThemeContext.js +6 -8
- package/build/components/themeProvider/ThemeContext.js.map +1 -1
- package/build/components/themeProvider/ThemeProvider.js +3 -5
- package/build/components/themeProvider/ThemeProvider.js.map +1 -1
- package/build/components/themeProvider/index.js +4 -6
- package/build/components/themeProvider/index.js.map +1 -1
- package/build/components/themeProvider/withThemeContext.js +10 -14
- package/build/components/themeProvider/withThemeContext.js.map +1 -1
- package/build/components/time/Time.js +184 -228
- package/build/components/time/Time.js.map +1 -1
- package/build/components/time/index.js +4 -6
- package/build/components/time/index.js.map +1 -1
- package/build/components/timeSpan/TimeSpan.js +226 -280
- package/build/components/timeSpan/TimeSpan.js.map +1 -1
- package/build/components/timeSpan/index.js +4 -6
- package/build/components/timeSpan/index.js.map +1 -1
- package/build/components/utils/Guid.js +3 -5
- package/build/components/utils/Guid.js.map +1 -1
- package/build/components/utils/ShallowEqual.js +5 -11
- package/build/components/utils/ShallowEqual.js.map +1 -1
- package/build/components/utils/TimeUtil.js +8 -22
- package/build/components/utils/TimeUtil.js.map +1 -1
- package/build/components/utils/Typescript.js.map +1 -1
- package/build/dist/guestbell-forms.css +0 -6
- package/build/dist/guestbell-forms.css.map +1 -1
- package/build/dist/guestbell-forms.min.css +1 -1
- package/build/dist/guestbell-forms.min.js +1 -1
- package/build/dist/guestbell-forms.min.js.map +1 -1
- package/build/dist/report.html +2 -2
- package/build/index.js +23 -23
- package/build/index.js.map +1 -1
- package/build/types/ElementOverrideProp.js.map +1 -1
- package/build/types/Theme.js.map +1 -1
- package/build/types/ThemeOverrides.js.map +1 -1
- package/build/validators/EmailValidator.js +8 -22
- package/build/validators/EmailValidator.js.map +1 -1
- package/build/validators/LatitudeValidator.js +13 -27
- package/build/validators/LatitudeValidator.js.map +1 -1
- package/build/validators/LongitudeValidator.js +13 -27
- package/build/validators/LongitudeValidator.js.map +1 -1
- package/build/validators/NumberValidator.js +27 -39
- package/build/validators/NumberValidator.js.map +1 -1
- package/build/validators/UrlValidator.js +9 -23
- package/build/validators/UrlValidator.js.map +1 -1
- package/build/validators/base.js.map +1 -1
- package/build/validators/index.js +6 -6
- package/build/validators/index.js.map +1 -1
- package/package.json +8 -5
- package/tsconfig.json +0 -1
@@ -1,7 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
|
-
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
@@ -13,230 +11,178 @@ var _FormContext = require("./FormContext");
|
|
13
11
|
|
14
12
|
var _withThemeContext = require("../themeProvider/withThemeContext");
|
15
13
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
17
|
-
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19
|
-
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
15
|
|
22
|
-
function
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
23
17
|
|
24
|
-
function
|
18
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
25
19
|
|
26
|
-
function
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
27
21
|
|
28
|
-
function
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
29
23
|
|
30
|
-
function
|
24
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
31
25
|
|
32
|
-
|
26
|
+
class Form extends React.PureComponent {
|
27
|
+
constructor(props) {
|
28
|
+
super(props);
|
33
29
|
|
34
|
-
|
30
|
+
_defineProperty(this, "onSubmit", e => {
|
31
|
+
e.preventDefault();
|
32
|
+
this.props.onSubmit && this.props.onSubmit();
|
33
|
+
});
|
35
34
|
|
36
|
-
|
35
|
+
this.subscribe = this.subscribe.bind(this);
|
36
|
+
this.unSubscribe = this.unSubscribe.bind(this);
|
37
|
+
this.updateCallback = this.updateCallback.bind(this);
|
38
|
+
this.disableComponents = this.disableComponents.bind(this);
|
39
|
+
this.enableComponents = this.enableComponents.bind(this);
|
40
|
+
this.state = {
|
41
|
+
contextState: {
|
42
|
+
subscribe: this.subscribe,
|
43
|
+
unSubscribe: this.unSubscribe,
|
44
|
+
isFormValid: true,
|
45
|
+
updateCallback: this.updateCallback,
|
46
|
+
disableComponents: this.disableComponents,
|
47
|
+
enableComponents: this.enableComponents,
|
48
|
+
components: {}
|
49
|
+
}
|
50
|
+
};
|
51
|
+
}
|
37
52
|
|
38
|
-
|
53
|
+
disableComponents() {
|
54
|
+
const components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
39
55
|
|
40
|
-
|
56
|
+
Object.keys(components).forEach(key => {
|
57
|
+
const component = components[key];
|
58
|
+
component && component.componentApi && component.componentApi.disableComponent && component.componentApi.disableComponent();
|
59
|
+
});
|
60
|
+
}
|
41
61
|
|
42
|
-
|
62
|
+
enableComponents() {
|
63
|
+
const components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
43
64
|
|
44
|
-
|
65
|
+
Object.keys(components).forEach(key => {
|
66
|
+
const component = components[key];
|
67
|
+
component && component.componentApi && component.componentApi.enableComponent && component.componentApi.enableComponent();
|
68
|
+
});
|
69
|
+
}
|
45
70
|
|
46
|
-
|
71
|
+
touchAll() {
|
72
|
+
const components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
47
73
|
|
48
|
-
|
49
|
-
|
74
|
+
Object.keys(components).forEach(key => {
|
75
|
+
const component = components[key];
|
76
|
+
component && component.componentApi && component.componentApi.touch && component.componentApi.touch();
|
77
|
+
});
|
78
|
+
}
|
50
79
|
|
51
|
-
|
80
|
+
unTouchAll() {
|
81
|
+
const components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
52
82
|
|
53
|
-
|
54
|
-
|
83
|
+
Object.keys(components).forEach(key => {
|
84
|
+
const component = components[key];
|
85
|
+
component && component.componentApi && component.componentApi.unTouch && component.componentApi.unTouch();
|
86
|
+
});
|
87
|
+
}
|
55
88
|
|
56
|
-
|
89
|
+
render() {
|
90
|
+
return /*#__PURE__*/React.createElement(this.props.component, _extends({}, this.props.id && {
|
91
|
+
id: this.props.id
|
92
|
+
}, {
|
93
|
+
noValidate: true,
|
94
|
+
role: "form",
|
95
|
+
className: `input__form validation-form ${this.props.className ? this.props.className : ''}`,
|
96
|
+
onSubmit: this.onSubmit
|
97
|
+
}), /*#__PURE__*/React.createElement(_FormContext.FormContextProvider, {
|
98
|
+
value: this.mergeContext()
|
99
|
+
}, this.props.children));
|
100
|
+
}
|
57
101
|
|
58
|
-
|
102
|
+
mergeContext() {
|
103
|
+
if (!this.props.extraComponents) {
|
104
|
+
return this.state.contextState;
|
105
|
+
}
|
59
106
|
|
60
|
-
|
61
|
-
|
62
|
-
|
107
|
+
const isFormValid = this.state.contextState.isFormValid && this.getIsFormValid(this.props.extraComponents);
|
108
|
+
return _objectSpread(_objectSpread({}, this.state.contextState), {}, {
|
109
|
+
components: _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents),
|
110
|
+
isFormValid
|
63
111
|
});
|
64
|
-
|
65
|
-
_this.subscribe = _this.subscribe.bind(_assertThisInitialized(_this));
|
66
|
-
_this.unSubscribe = _this.unSubscribe.bind(_assertThisInitialized(_this));
|
67
|
-
_this.updateCallback = _this.updateCallback.bind(_assertThisInitialized(_this));
|
68
|
-
_this.disableComponents = _this.disableComponents.bind(_assertThisInitialized(_this));
|
69
|
-
_this.enableComponents = _this.enableComponents.bind(_assertThisInitialized(_this));
|
70
|
-
_this.state = {
|
71
|
-
contextState: {
|
72
|
-
subscribe: _this.subscribe,
|
73
|
-
unSubscribe: _this.unSubscribe,
|
74
|
-
isFormValid: true,
|
75
|
-
updateCallback: _this.updateCallback,
|
76
|
-
disableComponents: _this.disableComponents,
|
77
|
-
enableComponents: _this.enableComponents,
|
78
|
-
components: {}
|
79
|
-
}
|
80
|
-
};
|
81
|
-
return _this;
|
82
112
|
}
|
83
113
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
114
|
+
subscribe(componentId, componentState) {
|
115
|
+
if (componentId) {
|
116
|
+
this.setState(previousState => {
|
117
|
+
let components = Object.assign({}, previousState.contextState.components);
|
88
118
|
|
89
|
-
|
90
|
-
|
91
|
-
component && component.componentApi && component.componentApi.disableComponent && component.componentApi.disableComponent();
|
92
|
-
});
|
93
|
-
}
|
94
|
-
}, {
|
95
|
-
key: "enableComponents",
|
96
|
-
value: function enableComponents() {
|
97
|
-
var components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
98
|
-
|
99
|
-
Object.keys(components).forEach(function (key) {
|
100
|
-
var component = components[key];
|
101
|
-
component && component.componentApi && component.componentApi.enableComponent && component.componentApi.enableComponent();
|
102
|
-
});
|
103
|
-
}
|
104
|
-
}, {
|
105
|
-
key: "touchAll",
|
106
|
-
value: function touchAll() {
|
107
|
-
var components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
108
|
-
|
109
|
-
Object.keys(components).forEach(function (key) {
|
110
|
-
var component = components[key];
|
111
|
-
component && component.componentApi && component.componentApi.touch && component.componentApi.touch();
|
112
|
-
});
|
113
|
-
}
|
114
|
-
}, {
|
115
|
-
key: "unTouchAll",
|
116
|
-
value: function unTouchAll() {
|
117
|
-
var components = _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents);
|
118
|
-
|
119
|
-
Object.keys(components).forEach(function (key) {
|
120
|
-
var component = components[key];
|
121
|
-
component && component.componentApi && component.componentApi.unTouch && component.componentApi.unTouch();
|
122
|
-
});
|
123
|
-
}
|
124
|
-
}, {
|
125
|
-
key: "render",
|
126
|
-
value: function render() {
|
127
|
-
return /*#__PURE__*/React.createElement(this.props.component, _extends({}, this.props.id && {
|
128
|
-
id: this.props.id
|
129
|
-
}, {
|
130
|
-
noValidate: true,
|
131
|
-
role: "form",
|
132
|
-
className: "input__form validation-form ".concat(this.props.className ? this.props.className : ''),
|
133
|
-
onSubmit: this.onSubmit
|
134
|
-
}), /*#__PURE__*/React.createElement(_FormContext.FormContextProvider, {
|
135
|
-
value: this.mergeContext()
|
136
|
-
}, this.props.children));
|
137
|
-
}
|
138
|
-
}, {
|
139
|
-
key: "mergeContext",
|
140
|
-
value: function mergeContext() {
|
141
|
-
if (!this.props.extraComponents) {
|
142
|
-
return this.state.contextState;
|
143
|
-
}
|
144
|
-
|
145
|
-
var isFormValid = this.state.contextState.isFormValid && this.getIsFormValid(this.props.extraComponents);
|
146
|
-
return _objectSpread(_objectSpread({}, this.state.contextState), {}, {
|
147
|
-
components: _objectSpread(_objectSpread({}, this.state.contextState.components), this.props.extraComponents),
|
148
|
-
isFormValid: isFormValid
|
149
|
-
});
|
150
|
-
}
|
151
|
-
}, {
|
152
|
-
key: "subscribe",
|
153
|
-
value: function subscribe(componentId, componentState) {
|
154
|
-
var _this2 = this;
|
155
|
-
|
156
|
-
if (componentId) {
|
157
|
-
this.setState(function (previousState) {
|
158
|
-
var components = Object.assign({}, previousState.contextState.components);
|
159
|
-
|
160
|
-
if (componentState) {
|
161
|
-
components[componentId] = componentState;
|
162
|
-
}
|
163
|
-
|
164
|
-
var isFormValid = _this2.getIsFormValid(components);
|
165
|
-
|
166
|
-
return {
|
167
|
-
contextState: _objectSpread(_objectSpread({}, previousState.contextState), {}, {
|
168
|
-
components: components,
|
169
|
-
isFormValid: isFormValid
|
170
|
-
})
|
171
|
-
};
|
172
|
-
});
|
173
|
-
}
|
174
|
-
}
|
175
|
-
}, {
|
176
|
-
key: "unSubscribe",
|
177
|
-
value: function unSubscribe(componentId) {
|
178
|
-
var _this3 = this;
|
179
|
-
|
180
|
-
if (componentId) {
|
181
|
-
this.setState(function (previousState) {
|
182
|
-
var components = Object.assign({}, previousState.contextState.components);
|
183
|
-
delete components[componentId];
|
184
|
-
|
185
|
-
var isFormValid = _this3.getIsFormValid(components);
|
186
|
-
|
187
|
-
return {
|
188
|
-
contextState: _objectSpread(_objectSpread({}, previousState.contextState), {}, {
|
189
|
-
components: components,
|
190
|
-
isFormValid: isFormValid
|
191
|
-
})
|
192
|
-
};
|
193
|
-
});
|
194
|
-
}
|
195
|
-
}
|
196
|
-
}, {
|
197
|
-
key: "getIsFormValid",
|
198
|
-
value: function getIsFormValid() {
|
199
|
-
var components = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.contextState.components;
|
200
|
-
var initialValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
201
|
-
var isFormValid = initialValid;
|
202
|
-
Object.keys(components).forEach(function (key) {
|
203
|
-
var component = components[key];
|
204
|
-
|
205
|
-
if (component && component.validation && !component.validation.isValid) {
|
206
|
-
isFormValid = false;
|
119
|
+
if (componentState) {
|
120
|
+
components[componentId] = componentState;
|
207
121
|
}
|
122
|
+
|
123
|
+
let isFormValid = this.getIsFormValid(components);
|
124
|
+
return {
|
125
|
+
contextState: _objectSpread(_objectSpread({}, previousState.contextState), {}, {
|
126
|
+
components,
|
127
|
+
isFormValid
|
128
|
+
})
|
129
|
+
};
|
208
130
|
});
|
209
|
-
return isFormValid;
|
210
131
|
}
|
211
|
-
}
|
212
|
-
key: "updateCallback",
|
213
|
-
value: function updateCallback(componentId, componentState) {
|
214
|
-
var _this4 = this;
|
215
|
-
|
216
|
-
this.setState(function (previousState) {
|
217
|
-
var components = Object.assign({}, previousState.contextState.components);
|
218
|
-
var previousComponent = components[componentId];
|
219
|
-
|
220
|
-
if (componentState && previousComponent) {
|
221
|
-
components[componentId] = _objectSpread(_objectSpread(_objectSpread({}, previousComponent), componentState), {}, {
|
222
|
-
validation: _objectSpread(_objectSpread({}, previousComponent.validation), componentState.validation)
|
223
|
-
});
|
224
|
-
}
|
225
|
-
|
226
|
-
var isFormValid = _this4.getIsFormValid(components);
|
132
|
+
}
|
227
133
|
|
134
|
+
unSubscribe(componentId) {
|
135
|
+
if (componentId) {
|
136
|
+
this.setState(previousState => {
|
137
|
+
let components = Object.assign({}, previousState.contextState.components);
|
138
|
+
delete components[componentId];
|
139
|
+
let isFormValid = this.getIsFormValid(components);
|
228
140
|
return {
|
229
|
-
contextState: _objectSpread(_objectSpread({},
|
230
|
-
components
|
231
|
-
isFormValid
|
141
|
+
contextState: _objectSpread(_objectSpread({}, previousState.contextState), {}, {
|
142
|
+
components,
|
143
|
+
isFormValid
|
232
144
|
})
|
233
145
|
};
|
234
146
|
});
|
235
147
|
}
|
236
|
-
}
|
148
|
+
}
|
149
|
+
|
150
|
+
getIsFormValid() {
|
151
|
+
let components = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.contextState.components;
|
152
|
+
let initialValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
153
|
+
let isFormValid = initialValid;
|
154
|
+
Object.keys(components).forEach(key => {
|
155
|
+
const component = components[key];
|
156
|
+
|
157
|
+
if (component && component.validation && !component.validation.isValid) {
|
158
|
+
isFormValid = false;
|
159
|
+
}
|
160
|
+
});
|
161
|
+
return isFormValid;
|
162
|
+
}
|
163
|
+
|
164
|
+
updateCallback(componentId, componentState) {
|
165
|
+
this.setState(previousState => {
|
166
|
+
let components = Object.assign({}, previousState.contextState.components);
|
167
|
+
const previousComponent = components[componentId];
|
168
|
+
|
169
|
+
if (componentState && previousComponent) {
|
170
|
+
components[componentId] = _objectSpread(_objectSpread(_objectSpread({}, previousComponent), componentState), {}, {
|
171
|
+
validation: _objectSpread(_objectSpread({}, previousComponent.validation), componentState.validation)
|
172
|
+
});
|
173
|
+
}
|
174
|
+
|
175
|
+
let isFormValid = this.getIsFormValid(components);
|
176
|
+
return {
|
177
|
+
contextState: _objectSpread(_objectSpread({}, this.state.contextState), {}, {
|
178
|
+
components,
|
179
|
+
isFormValid
|
180
|
+
})
|
181
|
+
};
|
182
|
+
});
|
183
|
+
}
|
237
184
|
|
238
|
-
|
239
|
-
}(React.PureComponent);
|
185
|
+
}
|
240
186
|
|
241
187
|
exports.Form = Form;
|
242
188
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/components/form/Form.tsx"],"names":["Form","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touch","unTouch","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousComponent","React","PureComponent","noValidate","showExpandAll"],"mappings":";;;;;;;;;AACA;;AAGA;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,I;;;;;AAOX,gBAAYC,KAAZ,EAA8B;AAAA;;AAAA;;AAC5B,8BAAMA,KAAN;;AAD4B,+DA+GX,UAACC,CAAD,EAAwB;AACzCA,MAAAA,CAAC,CAACC,cAAF;AACA,YAAKF,KAAL,CAAWG,QAAX,IAAuB,MAAKH,KAAL,CAAWG,QAAX,EAAvB;AACD,KAlH6B;;AAE5B,UAAKC,SAAL,GAAiB,MAAKA,SAAL,CAAeC,IAAf,+BAAjB;AACA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAi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D,CAAV,iDACKQ,iBADL,GAEKP,cAFL;AAGEK,YAAAA,UAAU,kCACLE,iBAAiB,CAACF,UADb,GAELL,cAAc,CAACK,UAFV;AAHZ;AAQD;;AACD,YAAIxB,WAAW,GAAG,MAAI,CAACiB,cAAL,CAAoBhB,UAApB,CAAlB;;AACA,eAAO;AACLF,UAAAA,YAAY,kCACP,MAAI,CAACD,KAAL,CAAWC,YADJ;AAEVE,YAAAA,UAAU,EAAVA,UAFU;AAGVD,YAAAA,WAAW,EAAXA;AAHU;AADP,SAAP;AAOD,OArBD;AAsBD;;;;EAhNuB2B,KAAK,CAACC,a;;;;gBAAnBzC,I,kBACkB;AAC3B0C,EAAAA,UAAU,EAAE,KADe;AAE3BC,EAAAA,aAAa,EAAE,IAFY;AAG3BvB,EAAAA,SAAS,EAAE;AAHgB,C;;eAkNhB,wCACbpB,IADa,EAEb,MAFa,C","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n component?: keyof JSX.IntrinsicElements;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n component: 'form' as keyof JSX.IntrinsicElements,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <this.props.component\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </this.props.component>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"file":"Form.js"}
|
1
|
+
{"version":3,"file":"Form.js","names":["Form","React","PureComponent","constructor","props","e","preventDefault","onSubmit","subscribe","bind","unSubscribe","updateCallback","disableComponents","enableComponents","state","contextState","isFormValid","components","extraComponents","Object","keys","forEach","key","component","componentApi","disableComponent","enableComponent","touchAll","touch","unTouchAll","unTouch","render","id","className","mergeContext","children","getIsFormValid","componentId","componentState","setState","previousState","assign","initialValid","validation","isValid","previousComponent","noValidate","showExpandAll","withThemeContext"],"sources":["../../../src/lib/components/form/Form.tsx"],"sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport {\r\n FormContextState,\r\n FormComponentContextState,\r\n FormContextProvider,\r\n ComponentsDict,\r\n} from './FormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\nimport { ThemeContextProps } from '../themeProvider/ThemeContext';\r\n\r\nexport type FormProps = React.PropsWithChildren<\r\n ThemeContextProps & {\r\n id?: string;\r\n className?: string;\r\n noValidate?: boolean;\r\n onSubmit?: () => void;\r\n extraComponents?: ComponentsDict;\r\n component?: keyof JSX.IntrinsicElements;\r\n }\r\n>;\r\n\r\nexport interface FormState {\r\n contextState: FormContextState;\r\n}\r\n\r\nexport class Form extends React.PureComponent<FormProps, FormState> {\r\n public static defaultProps = {\r\n noValidate: false,\r\n showExpandAll: true,\r\n component: 'form' as keyof JSX.IntrinsicElements,\r\n };\r\n\r\n constructor(props: FormProps) {\r\n super(props);\r\n this.subscribe = this.subscribe.bind(this);\r\n this.unSubscribe = this.unSubscribe.bind(this);\r\n this.updateCallback = this.updateCallback.bind(this);\r\n this.disableComponents = this.disableComponents.bind(this);\r\n this.enableComponents = this.enableComponents.bind(this);\r\n this.state = {\r\n contextState: {\r\n subscribe: this.subscribe,\r\n unSubscribe: this.unSubscribe,\r\n isFormValid: true,\r\n updateCallback: this.updateCallback,\r\n disableComponents: this.disableComponents,\r\n enableComponents: this.enableComponents,\r\n components: {},\r\n },\r\n };\r\n }\r\n\r\n public disableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.disableComponent &&\r\n component.componentApi.disableComponent();\r\n });\r\n }\r\n\r\n public enableComponents() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.enableComponent &&\r\n component.componentApi.enableComponent();\r\n });\r\n }\r\n\r\n public touchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.touch &&\r\n component.componentApi.touch();\r\n });\r\n }\r\n\r\n public unTouchAll() {\r\n const components = {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n };\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n component &&\r\n component.componentApi &&\r\n component.componentApi.unTouch &&\r\n component.componentApi.unTouch();\r\n });\r\n }\r\n\r\n public render() {\r\n return (\r\n <this.props.component\r\n {...(this.props.id && { id: this.props.id })}\r\n noValidate={true}\r\n role=\"form\"\r\n className={`input__form validation-form ${\r\n this.props.className ? this.props.className : ''\r\n }`}\r\n onSubmit={this.onSubmit}\r\n >\r\n <FormContextProvider value={this.mergeContext()}>\r\n {this.props.children}\r\n </FormContextProvider>\r\n </this.props.component>\r\n );\r\n }\r\n\r\n private mergeContext(): FormContextState {\r\n if (!this.props.extraComponents) {\r\n return this.state.contextState;\r\n }\r\n const isFormValid =\r\n this.state.contextState.isFormValid &&\r\n this.getIsFormValid(this.props.extraComponents);\r\n return {\r\n ...this.state.contextState,\r\n components: {\r\n ...this.state.contextState.components,\r\n ...this.props.extraComponents,\r\n },\r\n isFormValid,\r\n };\r\n }\r\n\r\n private onSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n this.props.onSubmit && this.props.onSubmit();\r\n };\r\n\r\n private subscribe(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n if (componentState) {\r\n components[componentId] = componentState;\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private unSubscribe(componentId: string) {\r\n if (componentId) {\r\n this.setState(previousState => {\r\n let components = Object.assign(\r\n {},\r\n previousState.contextState.components\r\n );\r\n delete components[componentId];\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...previousState.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n }\r\n\r\n private getIsFormValid(\r\n components: ComponentsDict = this.state.contextState.components,\r\n initialValid: boolean = true\r\n ): boolean {\r\n let isFormValid = initialValid;\r\n Object.keys(components).forEach(key => {\r\n const component = components[key];\r\n if (component && component.validation && !component.validation.isValid) {\r\n isFormValid = false;\r\n }\r\n });\r\n return isFormValid;\r\n }\r\n\r\n private updateCallback(\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) {\r\n this.setState(previousState => {\r\n let components = Object.assign({}, previousState.contextState.components);\r\n const previousComponent = components[componentId];\r\n if (componentState && previousComponent) {\r\n components[componentId] = {\r\n ...previousComponent,\r\n ...componentState,\r\n validation: {\r\n ...previousComponent.validation,\r\n ...componentState.validation,\r\n },\r\n };\r\n }\r\n let isFormValid = this.getIsFormValid(components);\r\n return {\r\n contextState: {\r\n ...this.state.contextState,\r\n components,\r\n isFormValid,\r\n },\r\n };\r\n });\r\n }\r\n}\r\n\r\nexport default withThemeContext<FormProps, InstanceType<typeof Form>>(\r\n Form,\r\n 'form'\r\n);\r\n"],"mappings":";;;;;;;AACA;;AAGA;;AAMA;;;;;;;;;;;;;;AAkBO,MAAMA,IAAN,SAAmBC,KAAK,CAACC,aAAzB,CAA6D;EAOlEC,WAAW,CAACC,KAAD,EAAmB;IAC5B,MAAMA,KAAN;;IAD4B,kCA+GVC,CAAD,IAAwB;MACzCA,CAAC,CAACC,cAAF;MACA,KAAKF,KAAL,CAAWG,QAAX,IAAuB,KAAKH,KAAL,CAAWG,QAAX,EAAvB;IACD,CAlH6B;;IAE5B,KAAKC,SAAL,GAAiB,KAAKA,SAAL,CAAeC,IAAf,CAAoB,IAApB,CAAjB;IACA,KAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBD,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKE,cAAL,GAAsB,KAAKA,cAAL,CAAoBF,IAApB,CAAyB,IAAzB,CAAtB;IACA,KAAKG,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBH,IAAvB,CAA4B,IAA5B,CAAzB;IACA,KAAKI,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBJ,IAAtB,CAA2B,IAA3B,CAAxB;IACA,KAAKK,KAAL,GAAa;MACXC,YAAY,EAAE;QACZP,SAAS,EAAE,KAAKA,SADJ;QAEZE,WAAW,EAAE,KAAKA,WAFN;QAGZM,WAAW,EAAE,IAHD;QAIZL,cAAc,EAAE,KAAKA,cAJT;QAKZC,iBAAiB,EAAE,KAAKA,iBALZ;QAMZC,gBAAgB,EAAE,KAAKA,gBANX;QAOZI,UAAU,EAAE;MAPA;IADH,CAAb;EAWD;;EAEML,iBAAiB,GAAG;IACzB,MAAMK,UAAU,mCACX,KAAKH,KAAL,CAAWC,YAAX,CAAwBE,UADb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EACD;;EAEOL,cAAc,CACpB0B,WADoB,EAEpBC,cAFoB,EAGpB;IACA,KAAKC,QAAL,CAAcC,aAAa,IAAI;MAC7B,IAAIvB,UAAU,GAAGE,MAAM,CAACsB,MAAP,CAAc,EAAd,EAAkBD,aAAa,CAACzB,YAAd,CAA2BE,UAA7C,CAAjB;MACA,MAAM4B,iBAAiB,GAAG5B,UAAU,CAACoB,WAAD,CAApC;;MACA,IAAIC,cAAc,IAAIO,iBAAtB,EAAyC;QACvC5B,UAAU,CAACoB,WAAD,CAAV,iDACKQ,iBADL,GAEKP,cAFL;UAGEK,UAAU,kCACLE,iBAAiB,CAACF,UADb,GAELL,cAAc,CAACK,UAFV;QAHZ;MAQD;;MACD,IAAI3B,WAAW,GAAG,KAAKoB,cAAL,CAAoBnB,UAApB,CAAlB;MACA,OAAO;QACLF,YAAY,kCACP,KAAKD,KAAL,CAAWC,YADJ;UAEVE,UAFU;UAGVD;QAHU;MADP,CAAP;IAOD,CArBD;EAsBD;;AAhNiE;;;;gBAAvDhB,I,kBACkB;EAC3B8C,UAAU,EAAE,KADe;EAE3BC,aAAa,EAAE,IAFY;EAG3BxB,SAAS,EAAE;AAHgB,C;;eAkNhB,IAAAyB,kCAAA,EACbhD,IADa,EAEb,MAFa,C"}
|
@@ -1,21 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
|
-
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
8
|
-
exports.
|
6
|
+
exports.FormContextProvider = exports.FormContextConsumer = void 0;
|
9
7
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
11
9
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
13
11
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
const FormContext = /*#__PURE__*/React.createContext(undefined);
|
15
|
+
const FormContextProvider = FormContext.Provider;
|
18
16
|
exports.FormContextProvider = FormContextProvider;
|
19
|
-
|
17
|
+
const FormContextConsumer = FormContext.Consumer;
|
20
18
|
exports.FormContextConsumer = FormContextConsumer;
|
21
19
|
//# sourceMappingURL=FormContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"file":"FormContext.js","names":["FormContext","React","createContext","undefined","FormContextProvider","Provider","FormContextConsumer","Consumer"],"sources":["../../../src/lib/components/form/FormContext.ts"],"sourcesContent":["import * as React from 'react';\r\nimport { ValidationError, ComponentApi } from '../base/input';\r\nimport { DeepPartial, PartialBy } from '../utils/Typescript';\r\n\r\nexport type OmitFormContext<P extends FormContextProps> = PartialBy<\r\n P,\r\n 'formContext'\r\n>;\r\n\r\nexport interface FormComponentValidationContextState {\r\n isValid: boolean;\r\n errors: ValidationError[];\r\n name: JSX.Element | string;\r\n}\r\n\r\nexport interface FormComponentContextState {\r\n validation: FormComponentValidationContextState;\r\n componentApi: ComponentApi;\r\n}\r\n\r\nexport interface FormContextProps {\r\n formContext?: FormContextState;\r\n}\r\n\r\nexport type ComponentsDict = {\r\n [componentId: string]: FormComponentContextState;\r\n};\r\n\r\nexport interface FormContextState {\r\n subscribe: (\r\n componentId: string,\r\n componentState: FormComponentContextState\r\n ) => void;\r\n unSubscribe: (componentId: string) => void;\r\n isFormValid: boolean;\r\n updateCallback: (\r\n componentId: string,\r\n newComponentState: DeepPartial<FormComponentContextState>\r\n ) => void;\r\n disableComponents: () => void;\r\n enableComponents: () => void;\r\n components: ComponentsDict;\r\n}\r\n\r\nconst FormContext = React.createContext<FormContextState | undefined>(\r\n undefined\r\n);\r\nexport const FormContextProvider = FormContext.Provider;\r\nexport const FormContextConsumer = FormContext.Consumer;\r\n"],"mappings":";;;;;;;AAAA;;;;;;AA4CA,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAClBC,SADkB,CAApB;AAGO,MAAMC,mBAAmB,GAAGJ,WAAW,CAACK,QAAxC;;AACA,MAAMC,mBAAmB,GAAGN,WAAW,CAACO,QAAxC"}
|