react-form-builder-more-flexibility 1.0.17 → 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.
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-builder-more-flexibility",
3
- "version": "1.0.17",
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",