@data-driven-forms/carbon-component-mapper 3.11.4 → 3.13.0
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/README.md +5 -74
- package/checkbox/checkbox.js +16 -7
- package/checkbox/index.js +7 -2
- package/component-mapper/index.js +7 -2
- package/date-picker/date-picker.js +3 -1
- package/date-picker/index.js +7 -2
- package/dual-list-select/dual-list-select.js +4 -4
- package/dual-list-select/index.js +7 -2
- package/esm/checkbox/checkbox.js +9 -5
- package/esm/date-picker/date-picker.js +2 -1
- package/esm/dual-list-select/dual-list-select.js +7 -7
- package/esm/field-array/field-array.js +6 -4
- package/esm/form-template/form-template.js +10 -5
- package/esm/plain-text/plain-text.js +4 -3
- package/esm/prepare-props/prepare-props.js +3 -2
- package/esm/radio/radio.js +4 -2
- package/esm/select/select.js +16 -8
- package/esm/slider/slider.js +2 -1
- package/esm/sub-form/sub-form.js +3 -2
- package/esm/switch/switch.js +6 -4
- package/esm/tabs/tabs.js +4 -2
- package/esm/text-field/text-field.js +2 -1
- package/esm/textarea/textarea.js +2 -1
- package/esm/time-picker/time-picker.js +9 -148
- package/esm/time-picker-base/index.js +2 -0
- package/esm/time-picker-base/time-picker-base.js +100 -0
- package/esm/time-picker-date/index.js +2 -0
- package/esm/time-picker-date/time-picker-date.js +129 -0
- package/esm/time-picker-string/index.js +2 -0
- package/esm/time-picker-string/time-picker-string.js +88 -0
- package/esm/with-description/with-description.js +1 -1
- package/esm/wizard/wizard.js +7 -4
- package/field-array/field-array.js +13 -6
- package/field-array/index.js +7 -2
- package/form-template/form-template.js +10 -5
- package/form-template/index.js +7 -2
- package/helper-text-block/index.js +7 -2
- package/index.d.ts +6 -0
- package/index.js +6 -2
- package/is-required/index.js +7 -2
- package/package.json +12 -38
- package/plain-text/index.js +7 -2
- package/plain-text/plain-text.js +5 -3
- package/prepare-props/index.js +7 -2
- package/prepare-props/prepare-props.js +4 -2
- package/radio/index.js +7 -2
- package/radio/radio.js +5 -2
- package/select/index.js +7 -2
- package/select/select.js +23 -10
- package/slider/index.js +7 -2
- package/slider/slider.js +3 -1
- package/sub-form/index.js +7 -2
- package/sub-form/sub-form.js +3 -2
- package/switch/index.js +7 -2
- package/switch/switch.js +7 -4
- package/tabs/index.js +7 -2
- package/tabs/tabs.js +4 -2
- package/text-field/index.js +7 -2
- package/text-field/text-field.js +3 -1
- package/textarea/index.js +7 -2
- package/textarea/textarea.js +3 -1
- package/time-picker/index.js +7 -2
- package/time-picker/time-picker.d.ts +5 -13
- package/time-picker/time-picker.js +9 -155
- package/time-picker-base/index.d.ts +2 -0
- package/time-picker-base/index.js +32 -0
- package/time-picker-base/package.json +1 -0
- package/time-picker-base/time-picker-base.d.ts +29 -0
- package/time-picker-base/time-picker-base.js +116 -0
- package/time-picker-date/index.d.ts +2 -0
- package/time-picker-date/index.js +32 -0
- package/time-picker-date/package.json +1 -0
- package/time-picker-date/time-picker-date.d.ts +21 -0
- package/time-picker-date/time-picker-date.js +153 -0
- package/time-picker-string/index.d.ts +2 -0
- package/time-picker-string/index.js +32 -0
- package/time-picker-string/package.json +1 -0
- package/time-picker-string/time-picker-string.d.ts +21 -0
- package/time-picker-string/time-picker-string.js +112 -0
- package/with-description/index.js +7 -2
- package/with-description/with-description.js +1 -1
- package/wizard/index.js +7 -2
- package/wizard/wizard.js +14 -6
package/esm/select/select.js
CHANGED
|
@@ -2,6 +2,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
5
|
+
var _excluded = ["options"],
|
|
6
|
+
_excluded2 = ["invalidText", "hideSelectedOptions", "noOptionsMessage", "onInputChange", "options", "isFetching", "invalid", "isMulti", "classNamePrefix", "closeMenuOnSelect", "onChange", "originalOnChange", "carbonLabel", "placeholder", "isDisabled"],
|
|
7
|
+
_excluded3 = ["invalidText", "hideSelectedOptions", "noOptionsMessage", "onInputChange", "options", "isFetching", "invalid", "isMulti", "classNamePrefix", "closeMenuOnSelect", "onChange", "originalOnChange", "carbonLabel", "placeholder", "isDisabled"],
|
|
8
|
+
_excluded4 = ["isSearchable", "isClearable", "isDisabled", "isMulti", "invalidText", "hideSelectedOptions", "noOptionsMessage", "onInputChange", "options", "isFetching", "invalid", "classNamePrefix", "closeMenuOnSelect", "originalOnChange", "placeholder", "value"],
|
|
9
|
+
_excluded5 = ["isSearchable", "isClearable", "isDisabled", "isMulti", "invalidText", "hideSelectedOptions", "noOptionsMessage", "onInputChange", "options", "isFetching", "invalid", "classNamePrefix", "closeMenuOnSelect", "originalOnChange", "placeholder", "labelText", "onChange", "value"],
|
|
10
|
+
_excluded6 = ["isMulti", "isSearchable", "isClearable", "loadOptions", "input", "meta", "validateOnMount", "helperText"];
|
|
5
11
|
import React, { useState, useEffect } from 'react';
|
|
6
12
|
import PropTypes from 'prop-types';
|
|
7
13
|
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
@@ -34,7 +40,7 @@ export var getMultiValue = function getMultiValue(value, options) {
|
|
|
34
40
|
var renderOptions = function renderOptions(options) {
|
|
35
41
|
return options.map(function (option, index) {
|
|
36
42
|
var options = option.options,
|
|
37
|
-
rest = _objectWithoutProperties(option,
|
|
43
|
+
rest = _objectWithoutProperties(option, _excluded);
|
|
38
44
|
|
|
39
45
|
if (options) {
|
|
40
46
|
return /*#__PURE__*/React.createElement(SelectItemGroup, _extends({
|
|
@@ -66,7 +72,7 @@ var ClearedMultiSelectFilterable = function ClearedMultiSelectFilterable(_ref3)
|
|
|
66
72
|
carbonLabel = _ref3.carbonLabel,
|
|
67
73
|
placeholder = _ref3.placeholder,
|
|
68
74
|
isDisabled = _ref3.isDisabled,
|
|
69
|
-
rest = _objectWithoutProperties(_ref3,
|
|
75
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
70
76
|
|
|
71
77
|
return /*#__PURE__*/React.createElement(MultiSelect.Filterable, _extends({
|
|
72
78
|
disabled: isDisabled
|
|
@@ -117,7 +123,7 @@ var ClearedMultiSelect = function ClearedMultiSelect(_ref4) {
|
|
|
117
123
|
carbonLabel = _ref4.carbonLabel,
|
|
118
124
|
placeholder = _ref4.placeholder,
|
|
119
125
|
isDisabled = _ref4.isDisabled,
|
|
120
|
-
rest = _objectWithoutProperties(_ref4,
|
|
126
|
+
rest = _objectWithoutProperties(_ref4, _excluded3);
|
|
121
127
|
|
|
122
128
|
return /*#__PURE__*/React.createElement(MultiSelect, _extends({
|
|
123
129
|
disabled: isDisabled
|
|
@@ -173,7 +179,7 @@ var ClearedSelect = function ClearedSelect(_ref5) {
|
|
|
173
179
|
originalOnChange = _ref5.originalOnChange,
|
|
174
180
|
placeholder = _ref5.placeholder,
|
|
175
181
|
value = _ref5.value,
|
|
176
|
-
rest = _objectWithoutProperties(_ref5,
|
|
182
|
+
rest = _objectWithoutProperties(_ref5, _excluded4);
|
|
177
183
|
|
|
178
184
|
return /*#__PURE__*/React.createElement(CarbonSelect, _extends({
|
|
179
185
|
value: getSelectValue(value, isMulti),
|
|
@@ -242,7 +248,8 @@ var ClearedSelectSearchable = function ClearedSelectSearchable(_ref7) {
|
|
|
242
248
|
placeholder = _ref7.placeholder,
|
|
243
249
|
labelText = _ref7.labelText,
|
|
244
250
|
onChange = _ref7.onChange,
|
|
245
|
-
|
|
251
|
+
value = _ref7.value,
|
|
252
|
+
rest = _objectWithoutProperties(_ref7, _excluded5);
|
|
246
253
|
|
|
247
254
|
return /*#__PURE__*/React.createElement(ComboBox, _extends({
|
|
248
255
|
disabled: isFetching
|
|
@@ -250,7 +257,7 @@ var ClearedSelectSearchable = function ClearedSelectSearchable(_ref7) {
|
|
|
250
257
|
id: rest.name,
|
|
251
258
|
invalid: Boolean(invalidText),
|
|
252
259
|
invalidText: invalidText,
|
|
253
|
-
initialSelectedItem: getComboInitialValue(
|
|
260
|
+
initialSelectedItem: getComboInitialValue(value, options),
|
|
254
261
|
items: options,
|
|
255
262
|
placeholder: placeholder,
|
|
256
263
|
titleText: labelText,
|
|
@@ -277,7 +284,8 @@ ClearedSelectSearchable.propTypes = {
|
|
|
277
284
|
isRequired: PropTypes.bool,
|
|
278
285
|
isSearchable: PropTypes.bool,
|
|
279
286
|
isClearable: PropTypes.bool,
|
|
280
|
-
labelText: PropTypes.string
|
|
287
|
+
labelText: PropTypes.string,
|
|
288
|
+
value: PropTypes.any
|
|
281
289
|
};
|
|
282
290
|
|
|
283
291
|
var Select = function Select(props) {
|
|
@@ -290,7 +298,7 @@ var Select = function Select(props) {
|
|
|
290
298
|
meta = _useFieldApi.meta,
|
|
291
299
|
validateOnMount = _useFieldApi.validateOnMount,
|
|
292
300
|
helperText = _useFieldApi.helperText,
|
|
293
|
-
rest = _objectWithoutProperties(_useFieldApi,
|
|
301
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded6);
|
|
294
302
|
|
|
295
303
|
var _useState = useState(0),
|
|
296
304
|
_useState2 = _slicedToArray(_useState, 2),
|
package/esm/slider/slider.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["input", "meta", "isRequired", "validateOnMount", "helperText", "WrapperProps"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
@@ -15,7 +16,7 @@ var Slider = function Slider(props) {
|
|
|
15
16
|
validateOnMount = _useFieldApi.validateOnMount,
|
|
16
17
|
helperText = _useFieldApi.helperText,
|
|
17
18
|
WrapperProps = _useFieldApi.WrapperProps,
|
|
18
|
-
rest = _objectWithoutProperties(_useFieldApi,
|
|
19
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded);
|
|
19
20
|
|
|
20
21
|
var invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
|
|
21
22
|
var warnText = (meta.touched || validateOnMount) && meta.warning;
|
package/esm/sub-form/sub-form.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["fields", "component", "title", "description", "TitleElement", "DescriptionElement", "TitleProps", "DescriptionProps", "HeaderProps"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import clsx from 'clsx';
|
|
@@ -23,7 +24,7 @@ var SubForm = function SubForm(_ref) {
|
|
|
23
24
|
TitleProps = _ref.TitleProps,
|
|
24
25
|
DescriptionProps = _ref.DescriptionProps,
|
|
25
26
|
HeaderProps = _ref.HeaderProps,
|
|
26
|
-
rest = _objectWithoutProperties(_ref,
|
|
27
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
|
|
28
29
|
var formOptions = useFormApi();
|
|
29
30
|
|
|
@@ -32,7 +33,7 @@ var SubForm = function SubForm(_ref) {
|
|
|
32
33
|
|
|
33
34
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
34
35
|
className: clsx(tab, rest.className)
|
|
35
|
-
}), (title || description) && /*#__PURE__*/React.createElement("div", HeaderProps, title && React.createElement(TitleElement, TitleProps, title), description && React.createElement(DescriptionElement, DescriptionProps, description)), formOptions.renderForm(fields, formOptions));
|
|
36
|
+
}), (title || description) && /*#__PURE__*/React.createElement("div", HeaderProps, title && /*#__PURE__*/React.createElement(TitleElement, TitleProps, title), description && /*#__PURE__*/React.createElement(DescriptionElement, DescriptionProps, description)), formOptions.renderForm(fields, formOptions));
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
SubForm.propTypes = {
|
package/esm/switch/switch.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["input", "meta", "onText", "offText", "validateOnMount", "helperText", "WrapperProps"],
|
|
5
|
+
_excluded2 = ["checked"];
|
|
4
6
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
8
|
|
|
7
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
10
|
|
|
9
11
|
import React from 'react';
|
|
10
12
|
import PropTypes from 'prop-types';
|
|
11
13
|
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
12
|
-
import Toggle from "carbon-components-react/es/components/Toggle/Toggle.js";
|
|
14
|
+
import Toggle from "carbon-components-react/es/components/Toggle/next/Toggle.js";
|
|
13
15
|
import prepareProps from '../prepare-props';
|
|
14
16
|
import HelperTextBlock from '../helper-text-block/helper-text-block';
|
|
15
17
|
|
|
@@ -24,13 +26,13 @@ var Switch = function Switch(props) {
|
|
|
24
26
|
validateOnMount = _useFieldApi.validateOnMount,
|
|
25
27
|
helperText = _useFieldApi.helperText,
|
|
26
28
|
WrapperProps = _useFieldApi.WrapperProps,
|
|
27
|
-
rest = _objectWithoutProperties(_useFieldApi,
|
|
29
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded);
|
|
28
30
|
|
|
29
31
|
var invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
|
|
30
32
|
var warnText = (meta.touched || validateOnMount) && meta.warning;
|
|
31
33
|
|
|
32
34
|
var checked = input.checked,
|
|
33
|
-
inputRest = _objectWithoutProperties(input,
|
|
35
|
+
inputRest = _objectWithoutProperties(input, _excluded2);
|
|
34
36
|
|
|
35
37
|
return /*#__PURE__*/React.createElement("div", WrapperProps, /*#__PURE__*/React.createElement(Toggle, _extends({}, inputRest, {
|
|
36
38
|
toggled: checked,
|
package/esm/tabs/tabs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["fields", "component", "name", "TabWrapperProps"],
|
|
4
|
+
_excluded2 = ["fields", "name", "label", "title"];
|
|
3
5
|
import React from 'react';
|
|
4
6
|
import PropTypes from 'prop-types';
|
|
5
7
|
import clsx from 'clsx';
|
|
@@ -20,7 +22,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
20
22
|
component = _ref.component,
|
|
21
23
|
name = _ref.name,
|
|
22
24
|
TabWrapperProps = _ref.TabWrapperProps,
|
|
23
|
-
props = _objectWithoutProperties(_ref,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
26
|
|
|
25
27
|
var formOptions = useFormApi();
|
|
26
28
|
|
|
@@ -32,7 +34,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
32
34
|
name = _ref2.name,
|
|
33
35
|
label = _ref2.label,
|
|
34
36
|
title = _ref2.title,
|
|
35
|
-
rest = _objectWithoutProperties(_ref2,
|
|
37
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
36
38
|
|
|
37
39
|
return /*#__PURE__*/React.createElement(Tab, _extends({}, rest, {
|
|
38
40
|
id: name,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["input", "meta", "validateOnMount", "labelText"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
@@ -13,7 +14,7 @@ var TextField = function TextField(props) {
|
|
|
13
14
|
meta = _useFieldApi.meta,
|
|
14
15
|
validateOnMount = _useFieldApi.validateOnMount,
|
|
15
16
|
labelText = _useFieldApi.labelText,
|
|
16
|
-
rest = _objectWithoutProperties(_useFieldApi,
|
|
17
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded);
|
|
17
18
|
|
|
18
19
|
var Component = input.type === 'number' ? NumberInput : TextInput;
|
|
19
20
|
|
package/esm/textarea/textarea.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["input", "meta", "validateOnMount", "helperText"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
@@ -12,7 +13,7 @@ var Textarea = function Textarea(props) {
|
|
|
12
13
|
meta = _useFieldApi.meta,
|
|
13
14
|
validateOnMount = _useFieldApi.validateOnMount,
|
|
14
15
|
helperText = _useFieldApi.helperText,
|
|
15
|
-
rest = _objectWithoutProperties(_useFieldApi,
|
|
16
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded);
|
|
16
17
|
|
|
17
18
|
var invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
|
|
18
19
|
var text = (meta.touched || validateOnMount) && meta.warning || helperText;
|
|
@@ -1,157 +1,18 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
2
|
+
var _excluded = ["useStringFormat"];
|
|
3
|
+
import React from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import TimePickerSelect from "carbon-components-react/es/components/TimePickerSelect/TimePickerSelect.js";
|
|
9
|
-
import SelectItem from "carbon-components-react/es/components/SelectItem/SelectItem.js";
|
|
10
|
-
import prepareProps from '../prepare-props';
|
|
11
|
-
import HelperTextBlock from '../helper-text-block/helper-text-block';
|
|
5
|
+
import TimePickerString from '../time-picker-string/time-picker-string';
|
|
6
|
+
import TimePickerDate from '../time-picker-date';
|
|
12
7
|
|
|
13
|
-
var TimePicker = function TimePicker(
|
|
14
|
-
var
|
|
8
|
+
var TimePicker = function TimePicker(_ref) {
|
|
9
|
+
var useStringFormat = _ref.useStringFormat,
|
|
10
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
input = _useFieldApi.input,
|
|
18
|
-
meta = _useFieldApi.meta,
|
|
19
|
-
twelveHoursFormat = _useFieldApi.twelveHoursFormat,
|
|
20
|
-
timezones = _useFieldApi.timezones,
|
|
21
|
-
validateOnMount = _useFieldApi.validateOnMount,
|
|
22
|
-
helperText = _useFieldApi.helperText,
|
|
23
|
-
WrapperProps = _useFieldApi.WrapperProps,
|
|
24
|
-
rest = _objectWithoutProperties(_useFieldApi, ["input", "meta", "twelveHoursFormat", "timezones", "validateOnMount", "helperText", "WrapperProps"]);
|
|
25
|
-
|
|
26
|
-
var _useState = useState(timezones ? (_timezones$ = timezones[0]) === null || _timezones$ === void 0 ? void 0 : _timezones$.value : ''),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
timezone = _useState2[0],
|
|
29
|
-
selectTimezone = _useState2[1];
|
|
30
|
-
|
|
31
|
-
var _useState3 = useState('AM'),
|
|
32
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
-
format = _useState4[0],
|
|
34
|
-
selectFormat = _useState4[1];
|
|
35
|
-
|
|
36
|
-
var isMounted = useRef(false);
|
|
37
|
-
var invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
|
|
38
|
-
var warnText = (meta.touched || validateOnMount) && meta.warning;
|
|
39
|
-
var finalValue = input.value;
|
|
40
|
-
|
|
41
|
-
if (input.value instanceof Date) {
|
|
42
|
-
var _timezones$find;
|
|
43
|
-
|
|
44
|
-
var _input$value$toLocale = input.value.toLocaleTimeString('en-us', {
|
|
45
|
-
hour12: !!twelveHoursFormat,
|
|
46
|
-
timeZone: timezones === null || timezones === void 0 ? void 0 : (_timezones$find = timezones.find(function (_ref) {
|
|
47
|
-
var value = _ref.value;
|
|
48
|
-
return value === timezone;
|
|
49
|
-
})) === null || _timezones$find === void 0 ? void 0 : _timezones$find.showAs
|
|
50
|
-
}).split(':'),
|
|
51
|
-
_input$value$toLocale2 = _slicedToArray(_input$value$toLocale, 2),
|
|
52
|
-
_input$value$toLocale3 = _input$value$toLocale2[0],
|
|
53
|
-
hours = _input$value$toLocale3 === void 0 ? '00' : _input$value$toLocale3,
|
|
54
|
-
_input$value$toLocale4 = _input$value$toLocale2[1],
|
|
55
|
-
minutes = _input$value$toLocale4 === void 0 ? '00' : _input$value$toLocale4;
|
|
56
|
-
|
|
57
|
-
finalValue = "".concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0'));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var enhnancedOnBlur = function enhnancedOnBlur() {
|
|
61
|
-
var _finalValue;
|
|
62
|
-
|
|
63
|
-
var _ref2 = ((_finalValue = finalValue) === null || _finalValue === void 0 ? void 0 : _finalValue.split(':')) || [],
|
|
64
|
-
_ref3 = _slicedToArray(_ref2, 2),
|
|
65
|
-
_ref3$ = _ref3[0],
|
|
66
|
-
hours = _ref3$ === void 0 ? '00' : _ref3$,
|
|
67
|
-
_ref3$2 = _ref3[1],
|
|
68
|
-
minutes = _ref3$2 === void 0 ? '00' : _ref3$2;
|
|
69
|
-
|
|
70
|
-
if (!hours || isNaN(hours)) {
|
|
71
|
-
hours = '00';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!minutes || isNaN(minutes)) {
|
|
75
|
-
minutes = '00';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (twelveHoursFormat) {
|
|
79
|
-
hours = hours % 12;
|
|
80
|
-
|
|
81
|
-
if (format === 'PM') {
|
|
82
|
-
hours = hours + 12;
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
hours = hours % 24;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
minutes = minutes % 59;
|
|
89
|
-
var enhancedValue = new Date("Jan 1 2000 ".concat(hours, ":").concat(minutes, ":00 ").concat(timezone));
|
|
90
|
-
input.onChange(enhancedValue);
|
|
91
|
-
input.onBlur();
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
useEffect(function () {
|
|
95
|
-
if (isMounted.current === true) {
|
|
96
|
-
enhnancedOnBlur();
|
|
97
|
-
} else {
|
|
98
|
-
isMounted.current = true;
|
|
99
|
-
}
|
|
100
|
-
}, [timezone, format]);
|
|
101
|
-
return /*#__PURE__*/React.createElement("div", WrapperProps, /*#__PURE__*/React.createElement(CarbonTimePicker, _extends({}, input, {
|
|
102
|
-
value: finalValue,
|
|
103
|
-
onBlur: enhnancedOnBlur,
|
|
104
|
-
key: input.name,
|
|
105
|
-
id: input.name,
|
|
106
|
-
invalid: Boolean(invalid),
|
|
107
|
-
invalidText: invalid || ''
|
|
108
|
-
}, rest), twelveHoursFormat && /*#__PURE__*/React.createElement(TimePickerSelect, {
|
|
109
|
-
labelText: "Period",
|
|
110
|
-
id: "".concat(rest.id || input.name, "-12h"),
|
|
111
|
-
onChange: function onChange(_ref4) {
|
|
112
|
-
var value = _ref4.target.value;
|
|
113
|
-
return selectFormat(value);
|
|
114
|
-
}
|
|
115
|
-
}, /*#__PURE__*/React.createElement(SelectItem, {
|
|
116
|
-
value: "AM",
|
|
117
|
-
text: "AM"
|
|
118
|
-
}), /*#__PURE__*/React.createElement(SelectItem, {
|
|
119
|
-
value: "PM",
|
|
120
|
-
text: "PM"
|
|
121
|
-
})), timezones && /*#__PURE__*/React.createElement(TimePickerSelect, {
|
|
122
|
-
labelText: "Timezone",
|
|
123
|
-
id: "".concat(rest.id || input.name, "-timezones"),
|
|
124
|
-
onChange: function onChange(_ref5) {
|
|
125
|
-
var value = _ref5.target.value;
|
|
126
|
-
return selectTimezone(value);
|
|
127
|
-
}
|
|
128
|
-
}, timezones.map(function (_ref6) {
|
|
129
|
-
var showAs = _ref6.showAs,
|
|
130
|
-
tz = _objectWithoutProperties(_ref6, ["showAs"]);
|
|
131
|
-
|
|
132
|
-
return /*#__PURE__*/React.createElement(SelectItem, _extends({
|
|
133
|
-
key: tz.value,
|
|
134
|
-
text: tz.label
|
|
135
|
-
}, tz));
|
|
136
|
-
}))), /*#__PURE__*/React.createElement(HelperTextBlock, {
|
|
137
|
-
helperText: !invalid && helperText,
|
|
138
|
-
warnText: warnText
|
|
139
|
-
}));
|
|
12
|
+
return useStringFormat ? /*#__PURE__*/React.createElement(TimePickerString, props) : /*#__PURE__*/React.createElement(TimePickerDate, props);
|
|
140
13
|
};
|
|
141
14
|
|
|
142
15
|
TimePicker.propTypes = {
|
|
143
|
-
|
|
144
|
-
isReadOnly: PropTypes.bool,
|
|
145
|
-
isRequired: PropTypes.bool,
|
|
146
|
-
label: PropTypes.node,
|
|
147
|
-
labelText: PropTypes.node,
|
|
148
|
-
description: PropTypes.node,
|
|
149
|
-
twelveHoursFormat: PropTypes.bool,
|
|
150
|
-
timezones: PropTypes.arrayOf(PropTypes.shape({
|
|
151
|
-
value: PropTypes.string.isRequired,
|
|
152
|
-
label: PropTypes.node.isRequired,
|
|
153
|
-
showAs: PropTypes.string.isRequired
|
|
154
|
-
})),
|
|
155
|
-
WrapperProps: PropTypes.object
|
|
16
|
+
useStringFormat: PropTypes.bool
|
|
156
17
|
};
|
|
157
18
|
export default TimePicker;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["WrapperProps", "input", "enhnancedOnBlur", "enhancedOnChange", "finalValue", "invalid", "twelveHoursFormat", "timezones", "helperText", "warnText", "selectFormat", "selectTimezone"],
|
|
4
|
+
_excluded2 = ["showAs"];
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import CarbonTimePicker from "carbon-components-react/es/components/TimePicker/TimePicker.js";
|
|
8
|
+
import TimePickerSelect from "carbon-components-react/es/components/TimePickerSelect/TimePickerSelect.js";
|
|
9
|
+
import SelectItem from "carbon-components-react/es/components/SelectItem/SelectItem.js";
|
|
10
|
+
import HelperTextBlock from '../helper-text-block/helper-text-block';
|
|
11
|
+
|
|
12
|
+
var TimePickerBase = function TimePickerBase(_ref) {
|
|
13
|
+
var WrapperProps = _ref.WrapperProps,
|
|
14
|
+
input = _ref.input,
|
|
15
|
+
enhnancedOnBlur = _ref.enhnancedOnBlur,
|
|
16
|
+
enhancedOnChange = _ref.enhancedOnChange,
|
|
17
|
+
finalValue = _ref.finalValue,
|
|
18
|
+
invalid = _ref.invalid,
|
|
19
|
+
twelveHoursFormat = _ref.twelveHoursFormat,
|
|
20
|
+
timezones = _ref.timezones,
|
|
21
|
+
helperText = _ref.helperText,
|
|
22
|
+
warnText = _ref.warnText,
|
|
23
|
+
selectFormat = _ref.selectFormat,
|
|
24
|
+
selectTimezone = _ref.selectTimezone,
|
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", WrapperProps, /*#__PURE__*/React.createElement(CarbonTimePicker, _extends({}, input, enhnancedOnBlur && {
|
|
28
|
+
onBlur: enhnancedOnBlur
|
|
29
|
+
}, enhancedOnChange && {
|
|
30
|
+
onChange: function onChange(e) {
|
|
31
|
+
return enhancedOnChange(e.target.value);
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
onBlur: enhnancedOnBlur,
|
|
35
|
+
value: finalValue,
|
|
36
|
+
key: input.name,
|
|
37
|
+
id: input.name,
|
|
38
|
+
invalid: Boolean(invalid),
|
|
39
|
+
invalidText: invalid || ''
|
|
40
|
+
}, rest), twelveHoursFormat && /*#__PURE__*/React.createElement(TimePickerSelect, {
|
|
41
|
+
labelText: "Period",
|
|
42
|
+
id: "".concat(rest.id || input.name, "-12h"),
|
|
43
|
+
onChange: function onChange(_ref2) {
|
|
44
|
+
var value = _ref2.target.value;
|
|
45
|
+
return selectFormat(value);
|
|
46
|
+
}
|
|
47
|
+
}, /*#__PURE__*/React.createElement(SelectItem, {
|
|
48
|
+
value: "AM",
|
|
49
|
+
text: "AM"
|
|
50
|
+
}), /*#__PURE__*/React.createElement(SelectItem, {
|
|
51
|
+
value: "PM",
|
|
52
|
+
text: "PM"
|
|
53
|
+
})), timezones && /*#__PURE__*/React.createElement(TimePickerSelect, {
|
|
54
|
+
labelText: "Timezone",
|
|
55
|
+
id: "".concat(rest.id || input.name, "-timezones"),
|
|
56
|
+
onChange: function onChange(_ref3) {
|
|
57
|
+
var value = _ref3.target.value;
|
|
58
|
+
return selectTimezone(value);
|
|
59
|
+
}
|
|
60
|
+
}, timezones.map(function (_ref4) {
|
|
61
|
+
var showAs = _ref4.showAs,
|
|
62
|
+
tz = _objectWithoutProperties(_ref4, _excluded2);
|
|
63
|
+
|
|
64
|
+
return /*#__PURE__*/React.createElement(SelectItem, _extends({
|
|
65
|
+
key: tz.value,
|
|
66
|
+
text: tz.label
|
|
67
|
+
}, tz));
|
|
68
|
+
}))), /*#__PURE__*/React.createElement(HelperTextBlock, {
|
|
69
|
+
helperText: !invalid && helperText,
|
|
70
|
+
warnText: warnText
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
TimePickerBase.propTypes = {
|
|
75
|
+
isDisabled: PropTypes.bool,
|
|
76
|
+
isReadOnly: PropTypes.bool,
|
|
77
|
+
isRequired: PropTypes.bool,
|
|
78
|
+
label: PropTypes.node,
|
|
79
|
+
labelText: PropTypes.node,
|
|
80
|
+
description: PropTypes.node,
|
|
81
|
+
twelveHoursFormat: PropTypes.bool,
|
|
82
|
+
timezones: PropTypes.arrayOf(PropTypes.shape({
|
|
83
|
+
value: PropTypes.string.isRequired,
|
|
84
|
+
label: PropTypes.node.isRequired,
|
|
85
|
+
showAs: PropTypes.string
|
|
86
|
+
})),
|
|
87
|
+
WrapperProps: PropTypes.object,
|
|
88
|
+
input: PropTypes.shape({
|
|
89
|
+
name: PropTypes.string
|
|
90
|
+
}).isRequired,
|
|
91
|
+
enhnancedOnBlur: PropTypes.func,
|
|
92
|
+
enhancedOnChange: PropTypes.func,
|
|
93
|
+
finalValue: PropTypes.any,
|
|
94
|
+
invalid: PropTypes.node,
|
|
95
|
+
helperText: PropTypes.node,
|
|
96
|
+
warnText: PropTypes.node,
|
|
97
|
+
selectFormat: PropTypes.func.isRequired,
|
|
98
|
+
selectTimezone: PropTypes.func.isRequired
|
|
99
|
+
};
|
|
100
|
+
export default TimePickerBase;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["input", "meta", "twelveHoursFormat", "timezones", "validateOnMount", "helperText", "WrapperProps"];
|
|
5
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import useFieldApi from "@data-driven-forms/react-form-renderer/use-field-api";
|
|
8
|
+
import prepareProps from '../prepare-props';
|
|
9
|
+
import TimePickerBase from '../time-picker-base';
|
|
10
|
+
|
|
11
|
+
var TimePickerDate = function TimePickerDate(props) {
|
|
12
|
+
var _timezones$;
|
|
13
|
+
|
|
14
|
+
var _useFieldApi = useFieldApi(prepareProps(props)),
|
|
15
|
+
input = _useFieldApi.input,
|
|
16
|
+
meta = _useFieldApi.meta,
|
|
17
|
+
twelveHoursFormat = _useFieldApi.twelveHoursFormat,
|
|
18
|
+
timezones = _useFieldApi.timezones,
|
|
19
|
+
validateOnMount = _useFieldApi.validateOnMount,
|
|
20
|
+
helperText = _useFieldApi.helperText,
|
|
21
|
+
WrapperProps = _useFieldApi.WrapperProps,
|
|
22
|
+
rest = _objectWithoutProperties(_useFieldApi, _excluded);
|
|
23
|
+
|
|
24
|
+
var _useState = useState(timezones ? (_timezones$ = timezones[0]) === null || _timezones$ === void 0 ? void 0 : _timezones$.value : ''),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
timezone = _useState2[0],
|
|
27
|
+
selectTimezone = _useState2[1];
|
|
28
|
+
|
|
29
|
+
var _useState3 = useState('AM'),
|
|
30
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
31
|
+
format = _useState4[0],
|
|
32
|
+
selectFormat = _useState4[1];
|
|
33
|
+
|
|
34
|
+
var isMounted = useRef(false);
|
|
35
|
+
var invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
|
|
36
|
+
var warnText = (meta.touched || validateOnMount) && meta.warning;
|
|
37
|
+
var finalValue = input.value;
|
|
38
|
+
|
|
39
|
+
if (input.value instanceof Date) {
|
|
40
|
+
var _timezones$find;
|
|
41
|
+
|
|
42
|
+
var _input$value$toLocale = input.value.toLocaleTimeString('en-us', {
|
|
43
|
+
hour12: !!twelveHoursFormat,
|
|
44
|
+
timeZone: timezones === null || timezones === void 0 ? void 0 : (_timezones$find = timezones.find(function (_ref) {
|
|
45
|
+
var value = _ref.value;
|
|
46
|
+
return value === timezone;
|
|
47
|
+
})) === null || _timezones$find === void 0 ? void 0 : _timezones$find.showAs
|
|
48
|
+
}).split(':'),
|
|
49
|
+
_input$value$toLocale2 = _slicedToArray(_input$value$toLocale, 2),
|
|
50
|
+
_input$value$toLocale3 = _input$value$toLocale2[0],
|
|
51
|
+
hours = _input$value$toLocale3 === void 0 ? '00' : _input$value$toLocale3,
|
|
52
|
+
_input$value$toLocale4 = _input$value$toLocale2[1],
|
|
53
|
+
minutes = _input$value$toLocale4 === void 0 ? '00' : _input$value$toLocale4;
|
|
54
|
+
|
|
55
|
+
finalValue = "".concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0'));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var enhnancedOnBlur = function enhnancedOnBlur() {
|
|
59
|
+
var _finalValue;
|
|
60
|
+
|
|
61
|
+
var _ref2 = ((_finalValue = finalValue) === null || _finalValue === void 0 ? void 0 : _finalValue.split(':')) || [],
|
|
62
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
63
|
+
_ref3$ = _ref3[0],
|
|
64
|
+
hours = _ref3$ === void 0 ? '00' : _ref3$,
|
|
65
|
+
_ref3$2 = _ref3[1],
|
|
66
|
+
minutes = _ref3$2 === void 0 ? '00' : _ref3$2;
|
|
67
|
+
|
|
68
|
+
if (!hours || isNaN(hours)) {
|
|
69
|
+
hours = '00';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!minutes || isNaN(minutes)) {
|
|
73
|
+
minutes = '00';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (twelveHoursFormat) {
|
|
77
|
+
hours = hours % 12;
|
|
78
|
+
|
|
79
|
+
if (format === 'PM') {
|
|
80
|
+
hours = hours + 12;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
hours = hours % 24;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
minutes = minutes % 59;
|
|
87
|
+
var enhancedValue = new Date("Jan 1 2000 ".concat(hours, ":").concat(minutes, ":00 ").concat(timezone));
|
|
88
|
+
input.onChange(enhancedValue);
|
|
89
|
+
input.onBlur();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
if (isMounted.current === true) {
|
|
94
|
+
enhnancedOnBlur();
|
|
95
|
+
} else {
|
|
96
|
+
isMounted.current = true;
|
|
97
|
+
}
|
|
98
|
+
}, [timezone, format]);
|
|
99
|
+
return /*#__PURE__*/React.createElement(TimePickerBase, _extends({
|
|
100
|
+
WrapperProps: WrapperProps,
|
|
101
|
+
input: input,
|
|
102
|
+
enhnancedOnBlur: enhnancedOnBlur,
|
|
103
|
+
finalValue: finalValue,
|
|
104
|
+
invalid: invalid,
|
|
105
|
+
twelveHoursFormat: twelveHoursFormat,
|
|
106
|
+
timezones: timezones,
|
|
107
|
+
helperText: helperText,
|
|
108
|
+
warnText: warnText,
|
|
109
|
+
selectFormat: selectFormat,
|
|
110
|
+
selectTimezone: selectTimezone
|
|
111
|
+
}, rest));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
TimePickerDate.propTypes = {
|
|
115
|
+
isDisabled: PropTypes.bool,
|
|
116
|
+
isReadOnly: PropTypes.bool,
|
|
117
|
+
isRequired: PropTypes.bool,
|
|
118
|
+
label: PropTypes.node,
|
|
119
|
+
labelText: PropTypes.node,
|
|
120
|
+
description: PropTypes.node,
|
|
121
|
+
twelveHoursFormat: PropTypes.bool,
|
|
122
|
+
timezones: PropTypes.arrayOf(PropTypes.shape({
|
|
123
|
+
value: PropTypes.string.isRequired,
|
|
124
|
+
label: PropTypes.node.isRequired,
|
|
125
|
+
showAs: PropTypes.string
|
|
126
|
+
})),
|
|
127
|
+
WrapperProps: PropTypes.object
|
|
128
|
+
};
|
|
129
|
+
export default TimePickerDate;
|