react-form-builder-more-flexibility 1.0.16 → 1.0.18

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.
@@ -20,7 +20,7 @@ var _componentLabel = _interopRequireDefault(require("./component-label"));
20
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; }
21
21
  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) { (0, _defineProperty2["default"])(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; }
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } // import ReactDatePicker from '../utils/custom-date-picker';
23
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
24
  // This is the utility function that will attempt to parse a date string
25
25
  // using several different formats until it finds one that works.
26
26
  function parseDate(dateStr, formatMask) {
@@ -88,8 +88,39 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
88
88
  return _this;
89
89
  }
90
90
  (0, _createClass2["default"])(DatePicker, [{
91
+ key: "handleBirthdayFocus",
92
+ value: function handleBirthdayFocus() {
93
+ this.setState({
94
+ birthdayFocused: true
95
+ }, function () {
96
+ document.getElementById('year').placeholder = 'YYYY';
97
+ document.getElementById('day').placeholder = 'DD';
98
+ document.getElementById('month').placeholder = 'MM';
99
+ });
100
+ }
101
+ }, {
102
+ key: "handleDateChange",
103
+ value: function handleDateChange(event) {
104
+ var value = event.target.value;
105
+ if (event.target.name === 'month') {
106
+ if (value > 12) {
107
+ value = '12';
108
+ }
109
+ } else if (event.target.name === 'day') {
110
+ if (value > 31) {
111
+ value = '31';
112
+ }
113
+ } else if (event.target.name === 'year') {
114
+ if (value > new Date().getFullYear()) {
115
+ value = new Date().getFullYear().toString();
116
+ }
117
+ }
118
+ this.setState((0, _defineProperty2["default"])({}, event.target.name, value));
119
+ }
120
+ }, {
91
121
  key: "render",
92
122
  value: function render() {
123
+ var _this2 = this;
93
124
  var _this$props$data = this.props.data,
94
125
  showTimeSelect = _this$props$data.showTimeSelect,
95
126
  showTimeSelectOnly = _this$props$data.showTimeSelectOnly,
@@ -122,14 +153,92 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
122
153
  placeholder: this.state.placeholder,
123
154
  value: this.state.value,
124
155
  className: "form-control"
125
- }), iOS && !readOnly && /*#__PURE__*/_react["default"].createElement("input", {
126
- type: "date",
127
- name: props.name,
128
- ref: props.ref,
129
- onChange: this.handleChange,
130
- value: this.state.value,
131
- className: "form-control"
132
- }), !iOS && !readOnly && /*#__PURE__*/_react["default"].createElement(_reactDatepicker["default"], {
156
+ }), iOS && !readOnly && /*#__PURE__*/_react["default"].createElement("div", {
157
+ className: "input-group",
158
+ style: {
159
+ border: '1px solid #ced4da',
160
+ borderRadius: '0.25rem',
161
+ marginTop: 10
162
+ }
163
+ }, /*#__PURE__*/_react["default"].createElement("input", {
164
+ value: this.state.month,
165
+ onKeyUp: function onKeyUp(e) {
166
+ return e.target.value && e.target.value.length === 2 && document.getElementById('day').focus();
167
+ },
168
+ name: "month",
169
+ id: "month",
170
+ onChange: function onChange(e) {
171
+ return _this2.handleDateChange(e);
172
+ },
173
+ className: "form-control",
174
+ type: "text",
175
+ style: {
176
+ border: 'none',
177
+ fontFamily: 'Oswald'
178
+ },
179
+ onFocus: function onFocus(e) {
180
+ return _this2.handleBirthdayFocus();
181
+ },
182
+ placeholder: "Birthday",
183
+ maxLength: "2",
184
+ pattern: "\\d*"
185
+ }), this.state.birthdayFocused && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
186
+ style: {
187
+ display: this.state.year || this.state.day || this.state.month ? '' : 'none',
188
+ alignSelf: 'center'
189
+ }
190
+ }, "/"), /*#__PURE__*/_react["default"].createElement("input", {
191
+ value: this.state.day,
192
+ onKeyUp: function onKeyUp(e) {
193
+ return e.target.value && e.target.value.length === 2 && document.getElementById('year').focus();
194
+ },
195
+ name: "day",
196
+ id: "day",
197
+ className: "form-control",
198
+ type: "text",
199
+ style: {
200
+ border: 'none',
201
+ fontFamily: 'Oswald'
202
+ },
203
+ onChange: function onChange(e) {
204
+ return _this2.handleDateChange(e);
205
+ },
206
+ onFocus: function onFocus(e) {
207
+ return _this2.handleBirthdayFocus();
208
+ },
209
+ maxLength: "2",
210
+ pattern: "\\d*"
211
+ }), /*#__PURE__*/_react["default"].createElement("span", {
212
+ style: {
213
+ display: this.state.year || this.state.day || this.state.month ? '' : 'none',
214
+ alignSelf: 'center'
215
+ }
216
+ }, "/"), /*#__PURE__*/_react["default"].createElement("input", {
217
+ value: this.state.year,
218
+ name: "year",
219
+ id: "year",
220
+ className: "form-control",
221
+ type: "text",
222
+ style: {
223
+ border: 'none',
224
+ fontFamily: 'Oswald'
225
+ },
226
+ onFocus: function onFocus(e) {
227
+ return _this2.handleBirthdayFocus();
228
+ },
229
+ maxLength: "4",
230
+ pattern: "\\d*",
231
+ onChange: function onChange(e) {
232
+ return _this2.handleDateChange(e);
233
+ }
234
+ })))
235
+ // <input type="date"
236
+ // name={props.name}
237
+ // ref={props.ref}
238
+ // onChange={this.handleChange}
239
+ // value={this.state.value}
240
+ // className = "form-control" />
241
+ , !iOS && !readOnly && /*#__PURE__*/_react["default"].createElement(_reactDatepicker["default"], {
133
242
  name: props.name,
134
243
  ref: props.ref,
135
244
  onChange: this.handleChange,
@@ -41,10 +41,10 @@ function DatePickerComponent(props) {
41
41
  className: "form-control",
42
42
  showTimeSelect: props.showTimeSelect,
43
43
  showTimeSelectOnly: props.showTimeSelectOnly,
44
+ showTimeInput: showTimeInput,
44
45
  autoComplete: "off",
45
46
  placeholderText: props.placeholderText,
46
47
  portalId: portalId,
47
- showTimeInput: showTimeInput,
48
48
  dateFormat: dateFormat,
49
49
  isClearable: isClearable,
50
50
  customInput: /*#__PURE__*/_react["default"].createElement(ButtonDatePicker, null),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-builder-more-flexibility",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "A complete form builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",