@insticc/genericform 1.0.11 → 2.0.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/build/Demo.js +559 -0
- package/build/Demo2.js +495 -0
- package/build/FormFields/CustomAccordion.js +105 -0
- package/build/FormFields/CustomCheckbox.js +38 -62
- package/build/FormFields/CustomCheckboxGroup.js +87 -0
- package/build/FormFields/CustomComponent.js +42 -0
- package/build/FormFields/CustomDatePicker.js +51 -68
- package/build/FormFields/CustomDropdown.js +103 -26
- package/build/FormFields/CustomInput.js +51 -46
- package/build/FormFields/CustomJson.js +148 -0
- package/build/FormFields/CustomLabel.js +8 -14
- package/build/FormFields/CustomMultiDropdown.js +88 -0
- package/build/FormFields/CustomNumberInput.js +47 -44
- package/build/FormFields/CustomRadioGroup.js +91 -0
- package/build/FormFields/CustomSearch.js +56 -30
- package/build/FormFields/CustomSeparator.js +24 -0
- package/build/FormFields/CustomTextArea.js +52 -46
- package/build/FormFields/CustomToggle.js +73 -0
- package/build/FormFields/defaults.js +32 -0
- package/build/index.css +450 -12
- package/build/index.js +739 -385
- package/package.json +28 -14
- package/build/FormFields/CustomRadioButton.js +0 -57
- package/build/FormFields/MultipleCheckbox.js +0 -92
- package/build/FormFields/MultipleDropdown.js +0 -76
- package/build/FormFields/MultipleRadioButton.js +0 -90
- package/build/FormFields/YearDatePicker.js +0 -115
|
@@ -1,48 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _defaults = require("./defaults");
|
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fontSize: "10pt",
|
|
19
|
-
textAlign: "center",
|
|
20
|
-
margin: "0 5px"
|
|
21
|
-
},
|
|
22
|
-
component: {
|
|
23
|
-
display: "inline-block",
|
|
24
|
-
margin: 0
|
|
25
|
-
},
|
|
26
|
-
tooltip: {}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* A reusable checkbox with optional tooltip and label positioning.
|
|
31
|
-
*
|
|
32
|
-
* @param {Object} props
|
|
33
|
-
* @param {function(string, boolean):void} props.onChange - Callback when checkbox value changes.
|
|
34
|
-
* @param {string} props.name - Unique name of the checkbox.
|
|
35
|
-
* @param {string} props.displayName - Label text displayed next to the checkbox.
|
|
36
|
-
* @param {boolean} [props.checked=false] - Whether the checkbox is checked.
|
|
37
|
-
* @param {boolean} [props.disabled=false] - Whether the checkbox is disabled.
|
|
38
|
-
* @param {boolean} [props.showHelp=false] - Show a help icon with tooltip.
|
|
39
|
-
* @param {string} [props.tooltip=""] - Tooltip text (if showHelp is true).
|
|
40
|
-
* @param {Object} [props.mainDivStyle] - Custom style for outer container.
|
|
41
|
-
* @param {Object} [props.labelStyle] - Custom style for the label element.
|
|
42
|
-
* @param {Object} [props.componentStyle] - Custom style for the checkbox element.
|
|
43
|
-
* @param {Object} [props.tooltipStyle] - Custom style for the tooltip icon.
|
|
44
|
-
*/
|
|
45
|
-
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
46
17
|
var CustomCheckbox = function CustomCheckbox(_ref) {
|
|
47
18
|
var onChange = _ref.onChange,
|
|
48
19
|
name = _ref.name,
|
|
@@ -51,42 +22,44 @@ var CustomCheckbox = function CustomCheckbox(_ref) {
|
|
|
51
22
|
checked = _ref$checked === void 0 ? false : _ref$checked,
|
|
52
23
|
_ref$disabled = _ref.disabled,
|
|
53
24
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
25
|
+
_ref$required = _ref.required,
|
|
26
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
54
27
|
_ref$showHelp = _ref.showHelp,
|
|
55
28
|
showHelp = _ref$showHelp === void 0 ? false : _ref$showHelp,
|
|
29
|
+
_ref$helpText = _ref.helpText,
|
|
30
|
+
helpText = _ref$helpText === void 0 ? "" : _ref$helpText,
|
|
56
31
|
_ref$tooltip = _ref.tooltip,
|
|
57
32
|
tooltip = _ref$tooltip === void 0 ? "" : _ref$tooltip,
|
|
33
|
+
error = _ref.error,
|
|
58
34
|
_ref$mainDivStyle = _ref.mainDivStyle,
|
|
59
|
-
mainDivStyle = _ref$mainDivStyle === void 0 ?
|
|
35
|
+
mainDivStyle = _ref$mainDivStyle === void 0 ? {} : _ref$mainDivStyle,
|
|
60
36
|
_ref$labelStyle = _ref.labelStyle,
|
|
61
|
-
labelStyle = _ref$labelStyle === void 0 ?
|
|
62
|
-
_ref$
|
|
63
|
-
|
|
37
|
+
labelStyle = _ref$labelStyle === void 0 ? {} : _ref$labelStyle,
|
|
38
|
+
_ref$spanStyle = _ref.spanStyle,
|
|
39
|
+
spanStyle = _ref$spanStyle === void 0 ? {} : _ref$spanStyle,
|
|
40
|
+
_ref$inputStyle = _ref.inputStyle,
|
|
41
|
+
inputStyle = _ref$inputStyle === void 0 ? {} : _ref$inputStyle,
|
|
64
42
|
_ref$tooltipStyle = _ref.tooltipStyle,
|
|
65
|
-
tooltipStyle = _ref$tooltipStyle === void 0 ?
|
|
66
|
-
var handleChange = (0, _react.useCallback)(function (e
|
|
67
|
-
|
|
68
|
-
onChange === null || onChange === void 0 || onChange(name, checked);
|
|
43
|
+
tooltipStyle = _ref$tooltipStyle === void 0 ? {} : _ref$tooltipStyle;
|
|
44
|
+
var handleChange = (0, _react.useCallback)(function (e) {
|
|
45
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(name, e.target.checked);
|
|
69
46
|
}, [onChange, name]);
|
|
70
|
-
return /*#__PURE__*/
|
|
71
|
-
className: "
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "ufg-checkbox-item",
|
|
72
49
|
id: name,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
style: _objectSpread({
|
|
51
|
+
margin: "0 0 5px"
|
|
52
|
+
}, mainDivStyle)
|
|
53
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
76
54
|
id: "form-input-".concat(name),
|
|
77
55
|
type: "checkbox",
|
|
78
|
-
|
|
56
|
+
name: name,
|
|
79
57
|
checked: checked,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, displayName, " ", showHelp && tooltip && /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
86
|
-
name: "help circle",
|
|
87
|
-
title: tooltip,
|
|
88
|
-
style: tooltipStyle
|
|
89
|
-
})));
|
|
58
|
+
disabled: disabled,
|
|
59
|
+
required: required,
|
|
60
|
+
style: inputStyle,
|
|
61
|
+
onChange: handleChange
|
|
62
|
+
}), (0, _defaults.labelJsx)(name, labelStyle, displayName, required, spanStyle, showHelp, helpText), (0, _defaults.errorJsx)(error), (0, _defaults.tooltipJsx)(tooltip, tooltipStyle));
|
|
90
63
|
};
|
|
91
64
|
CustomCheckbox.propTypes = {
|
|
92
65
|
onChange: _propTypes["default"].func.isRequired,
|
|
@@ -94,11 +67,14 @@ CustomCheckbox.propTypes = {
|
|
|
94
67
|
displayName: _propTypes["default"].string,
|
|
95
68
|
checked: _propTypes["default"].bool,
|
|
96
69
|
disabled: _propTypes["default"].bool,
|
|
70
|
+
required: _propTypes["default"].bool,
|
|
97
71
|
showHelp: _propTypes["default"].bool,
|
|
72
|
+
helpText: _propTypes["default"].string,
|
|
98
73
|
tooltip: _propTypes["default"].string,
|
|
74
|
+
error: _propTypes["default"].string,
|
|
99
75
|
mainDivStyle: _propTypes["default"].object,
|
|
100
76
|
labelStyle: _propTypes["default"].object,
|
|
101
|
-
|
|
77
|
+
inputStyle: _propTypes["default"].object,
|
|
102
78
|
tooltipStyle: _propTypes["default"].object
|
|
103
79
|
};
|
|
104
80
|
var _default = exports["default"] = CustomCheckbox;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _defaults = require("./defaults");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
15
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
var CustomCheckboxGroup = function CustomCheckboxGroup(_ref) {
|
|
18
|
+
var onChange = _ref.onChange,
|
|
19
|
+
onOptionChange = _ref.onOptionChange,
|
|
20
|
+
name = _ref.name,
|
|
21
|
+
_ref$checked = _ref.checked,
|
|
22
|
+
checked = _ref$checked === void 0 ? [] : _ref$checked,
|
|
23
|
+
displayName = _ref.displayName,
|
|
24
|
+
_ref$options = _ref.options,
|
|
25
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
26
|
+
_ref$required = _ref.required,
|
|
27
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
28
|
+
error = _ref.error,
|
|
29
|
+
_ref$tooltip = _ref.tooltip,
|
|
30
|
+
tooltip = _ref$tooltip === void 0 ? "" : _ref$tooltip,
|
|
31
|
+
_ref$mainDivStyle = _ref.mainDivStyle,
|
|
32
|
+
mainDivStyle = _ref$mainDivStyle === void 0 ? {} : _ref$mainDivStyle,
|
|
33
|
+
_ref$labelStyle = _ref.labelStyle,
|
|
34
|
+
labelStyle = _ref$labelStyle === void 0 ? {} : _ref$labelStyle,
|
|
35
|
+
_ref$spanStyle = _ref.spanStyle,
|
|
36
|
+
spanStyle = _ref$spanStyle === void 0 ? {} : _ref$spanStyle,
|
|
37
|
+
_ref$inputStyle = _ref.inputStyle,
|
|
38
|
+
inputStyle = _ref$inputStyle === void 0 ? {} : _ref$inputStyle,
|
|
39
|
+
_ref$tooltipStyle = _ref.tooltipStyle,
|
|
40
|
+
tooltipStyle = _ref$tooltipStyle === void 0 ? {} : _ref$tooltipStyle;
|
|
41
|
+
var handleChange = (0, _react.useCallback)(function (value, state) {
|
|
42
|
+
var data = state ? checked.includes(value) ? checked : [].concat(_toConsumableArray(checked), [value]) : checked.filter(function (v) {
|
|
43
|
+
return v !== value;
|
|
44
|
+
});
|
|
45
|
+
onChange === null || onChange === void 0 || onChange(name, data);
|
|
46
|
+
onOptionChange === null || onOptionChange === void 0 || onOptionChange(data);
|
|
47
|
+
}, [onChange, onOptionChange, name, checked]);
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "ufg-field-group",
|
|
50
|
+
id: name,
|
|
51
|
+
style: mainDivStyle
|
|
52
|
+
}, (0, _defaults.labelJsx)(name, labelStyle, displayName, required, spanStyle), /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "ufg-checkbox-group"
|
|
54
|
+
}, options.map(function (opt, idx) {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
key: opt.name || opt.value,
|
|
57
|
+
className: "ufg-checkbox-item"
|
|
58
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
59
|
+
id: "".concat(name, "-").concat(idx),
|
|
60
|
+
type: "checkbox",
|
|
61
|
+
checked: checked.includes(opt.name || opt.value),
|
|
62
|
+
disabled: !!opt.disabled,
|
|
63
|
+
style: inputStyle,
|
|
64
|
+
onChange: function onChange(e) {
|
|
65
|
+
return handleChange(opt.name || opt.value, e.target.checked);
|
|
66
|
+
}
|
|
67
|
+
}), /*#__PURE__*/React.createElement("label", {
|
|
68
|
+
htmlFor: "".concat(name, "-").concat(idx)
|
|
69
|
+
}, opt.label || opt.text));
|
|
70
|
+
})), (0, _defaults.errorJsx)(error), (0, _defaults.tooltipJsx)(tooltip, tooltipStyle));
|
|
71
|
+
};
|
|
72
|
+
CustomCheckboxGroup.propTypes = {
|
|
73
|
+
onChange: _propTypes["default"].func.isRequired,
|
|
74
|
+
onOptionChange: _propTypes["default"].func,
|
|
75
|
+
name: _propTypes["default"].string.isRequired,
|
|
76
|
+
displayName: _propTypes["default"].string,
|
|
77
|
+
options: _propTypes["default"].array.isRequired,
|
|
78
|
+
required: _propTypes["default"].bool,
|
|
79
|
+
error: _propTypes["default"].string,
|
|
80
|
+
tooltip: _propTypes["default"].string,
|
|
81
|
+
mainDivStyle: _propTypes["default"].object,
|
|
82
|
+
labelStyle: _propTypes["default"].object,
|
|
83
|
+
spanStyle: _propTypes["default"].object,
|
|
84
|
+
inputStyle: _propTypes["default"].object,
|
|
85
|
+
tooltipStyle: _propTypes["default"].object
|
|
86
|
+
};
|
|
87
|
+
var _default = exports["default"] = CustomCheckboxGroup;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _defaults = require("./defaults");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
/**
|
|
12
|
+
* Pass-through wrapper for arbitrary React nodes.
|
|
13
|
+
* No onChange / value — purely structural.
|
|
14
|
+
*/
|
|
15
|
+
var CustomComponent = function CustomComponent(_ref) {
|
|
16
|
+
var name = _ref.name,
|
|
17
|
+
displayName = _ref.displayName,
|
|
18
|
+
component = _ref.component,
|
|
19
|
+
_ref$required = _ref.required,
|
|
20
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
21
|
+
_ref$mainDivStyle = _ref.mainDivStyle,
|
|
22
|
+
mainDivStyle = _ref$mainDivStyle === void 0 ? {} : _ref$mainDivStyle,
|
|
23
|
+
_ref$labelStyle = _ref.labelStyle,
|
|
24
|
+
labelStyle = _ref$labelStyle === void 0 ? {} : _ref$labelStyle,
|
|
25
|
+
_ref$spanStyle = _ref.spanStyle,
|
|
26
|
+
spanStyle = _ref$spanStyle === void 0 ? {} : _ref$spanStyle;
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
28
|
+
className: "ufg-component-wrapper",
|
|
29
|
+
id: name,
|
|
30
|
+
style: mainDivStyle
|
|
31
|
+
}, displayName && (0, _defaults.labelJsx)(name, labelStyle, displayName, required, spanStyle), component);
|
|
32
|
+
};
|
|
33
|
+
CustomComponent.propTypes = {
|
|
34
|
+
name: _propTypes["default"].string,
|
|
35
|
+
displayName: _propTypes["default"].string,
|
|
36
|
+
component: _propTypes["default"].node,
|
|
37
|
+
required: _propTypes["default"].bool,
|
|
38
|
+
mainDivStyle: _propTypes["default"].object,
|
|
39
|
+
labelStyle: _propTypes["default"].object,
|
|
40
|
+
spanStyle: _propTypes["default"].object
|
|
41
|
+
};
|
|
42
|
+
var _default = exports["default"] = CustomComponent;
|
|
@@ -1,55 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = require("react");
|
|
10
9
|
var _reactDatetime = _interopRequireDefault(require("react-datetime"));
|
|
10
|
+
var _defaults = require("./defaults");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
gap: "8px"
|
|
19
|
-
},
|
|
20
|
-
label: {
|
|
21
|
-
width: 160,
|
|
22
|
-
fontSize: "10pt",
|
|
23
|
-
textAlign: "left"
|
|
24
|
-
},
|
|
25
|
-
component: {
|
|
26
|
-
maxWidth: 350,
|
|
27
|
-
display: "inline-block"
|
|
28
|
-
},
|
|
29
|
-
tooltip: {
|
|
30
|
-
fontSize: "11px",
|
|
31
|
-
color: "#666"
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Custom date picker component.
|
|
37
|
-
* @param {Object} props
|
|
38
|
-
* @param {function(string, any):void} props.onChange - Callback when date value changes.
|
|
39
|
-
* @param {string} props.name - Unique name of the date picker.
|
|
40
|
-
* @param {string} props.displayName - Label text displayed next to the date picker.
|
|
41
|
-
* @param {any} props.value - Current value of the date picker.
|
|
42
|
-
* @param {boolean} [props.disabled=false] - Whether the date picker is disabled.
|
|
43
|
-
* @param {boolean} [props.required=false] - Whether the date picker is required.
|
|
44
|
-
* @param {string} [props.tooltip=""] - Tooltip text displayed below the date picker.
|
|
45
|
-
* @param {Object} [props.mainDivStyle] - Custom style for outer container.
|
|
46
|
-
* @param {Object} [props.labelStyle] - Custom style for the label element.
|
|
47
|
-
* @param {Object} [props.componentStyle] - Custom style for the date picker element.
|
|
48
|
-
* @param {Object} [props.tooltipStyle] - Custom style for the tooltip text.
|
|
49
|
-
* @param {string} [props.dateFormat="DD/MM/YYYY"] - Date format for the picker.
|
|
50
|
-
* @param {boolean} [props.timeFormat=false] - Whether to include time selection.
|
|
12
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
|
+
/**
|
|
14
|
+
* Date / datetime / time picker.
|
|
15
|
+
* onChange(date, name) — keeps the existing signature that parent onChangeTime expects.
|
|
16
|
+
* Set dateFormat=false + timeFormat="HH:mm" for time-only mode.
|
|
17
|
+
* Set timeFormat="HH:mm" alongside dateFormat for datetime mode.
|
|
51
18
|
*/
|
|
52
|
-
|
|
53
19
|
var CustomDatePicker = function CustomDatePicker(_ref) {
|
|
54
20
|
var onChange = _ref.onChange,
|
|
55
21
|
name = _ref.name,
|
|
@@ -59,45 +25,57 @@ var CustomDatePicker = function CustomDatePicker(_ref) {
|
|
|
59
25
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
60
26
|
_ref$required = _ref.required,
|
|
61
27
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
28
|
+
_ref$placeholder = _ref.placeholder,
|
|
29
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
30
|
+
_ref$dateFormat = _ref.dateFormat,
|
|
31
|
+
dateFormat = _ref$dateFormat === void 0 ? "DD/MM/YYYY" : _ref$dateFormat,
|
|
32
|
+
_ref$timeFormat = _ref.timeFormat,
|
|
33
|
+
timeFormat = _ref$timeFormat === void 0 ? false : _ref$timeFormat,
|
|
34
|
+
error = _ref.error,
|
|
62
35
|
_ref$tooltip = _ref.tooltip,
|
|
63
36
|
tooltip = _ref$tooltip === void 0 ? "" : _ref$tooltip,
|
|
37
|
+
_ref$showHelp = _ref.showHelp,
|
|
38
|
+
showHelp = _ref$showHelp === void 0 ? false : _ref$showHelp,
|
|
39
|
+
_ref$helpText = _ref.helpText,
|
|
40
|
+
helpText = _ref$helpText === void 0 ? "" : _ref$helpText,
|
|
64
41
|
_ref$mainDivStyle = _ref.mainDivStyle,
|
|
65
|
-
mainDivStyle = _ref$mainDivStyle === void 0 ?
|
|
42
|
+
mainDivStyle = _ref$mainDivStyle === void 0 ? {} : _ref$mainDivStyle,
|
|
66
43
|
_ref$labelStyle = _ref.labelStyle,
|
|
67
|
-
labelStyle = _ref$labelStyle === void 0 ?
|
|
68
|
-
_ref$
|
|
69
|
-
|
|
44
|
+
labelStyle = _ref$labelStyle === void 0 ? {} : _ref$labelStyle,
|
|
45
|
+
_ref$spanStyle = _ref.spanStyle,
|
|
46
|
+
spanStyle = _ref$spanStyle === void 0 ? {} : _ref$spanStyle,
|
|
47
|
+
_ref$inputStyle = _ref.inputStyle,
|
|
48
|
+
inputStyle = _ref$inputStyle === void 0 ? {} : _ref$inputStyle,
|
|
70
49
|
_ref$tooltipStyle = _ref.tooltipStyle,
|
|
71
|
-
tooltipStyle = _ref$tooltipStyle === void 0 ?
|
|
72
|
-
_ref$dateFormat = _ref.dateFormat,
|
|
73
|
-
dateFormat = _ref$dateFormat === void 0 ? "DD/MM/YYYY" : _ref$dateFormat,
|
|
74
|
-
_ref$timeFormat = _ref.timeFormat,
|
|
75
|
-
timeFormat = _ref$timeFormat === void 0 ? false : _ref$timeFormat;
|
|
50
|
+
tooltipStyle = _ref$tooltipStyle === void 0 ? {} : _ref$tooltipStyle;
|
|
76
51
|
var handleChange = (0, _react.useCallback)(function (date) {
|
|
77
52
|
return onChange === null || onChange === void 0 ? void 0 : onChange(date, name);
|
|
78
53
|
}, [onChange, name]);
|
|
79
|
-
return /*#__PURE__*/
|
|
80
|
-
className: "
|
|
81
|
-
key: name,
|
|
54
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "ufg-field-group",
|
|
82
56
|
id: "form-dateDiv-".concat(name),
|
|
83
57
|
style: mainDivStyle
|
|
84
|
-
}, /*#__PURE__*/
|
|
85
|
-
id: "form-datelabel-".concat(name),
|
|
86
|
-
htmlFor: "form-date-".concat(name),
|
|
87
|
-
style: labelStyle
|
|
88
|
-
}, displayName), /*#__PURE__*/_react["default"].createElement(_reactDatetime["default"], {
|
|
58
|
+
}, (0, _defaults.labelJsx)(name, labelStyle, displayName, required, spanStyle, showHelp, helpText), /*#__PURE__*/React.createElement(_reactDatetime["default"], {
|
|
89
59
|
id: "form-date-".concat(name),
|
|
90
60
|
value: value,
|
|
91
61
|
dateFormat: dateFormat,
|
|
92
62
|
timeFormat: timeFormat,
|
|
93
|
-
onChange: handleChange,
|
|
94
63
|
input: true,
|
|
95
64
|
disabled: disabled,
|
|
96
65
|
required: required,
|
|
97
|
-
style:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
style: inputStyle,
|
|
67
|
+
renderInput: function renderInput(props, openCalendar) {
|
|
68
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
69
|
+
readOnly: true
|
|
70
|
+
}, props, {
|
|
71
|
+
placeholder: placeholder,
|
|
72
|
+
onClick: !disabled ? openCalendar : undefined,
|
|
73
|
+
disabled: disabled,
|
|
74
|
+
className: "ufg-input".concat(error ? " error" : "")
|
|
75
|
+
}));
|
|
76
|
+
},
|
|
77
|
+
onChange: handleChange
|
|
78
|
+
}), (0, _defaults.errorJsx)(error), (0, _defaults.tooltipJsx)(tooltip, tooltipStyle));
|
|
101
79
|
};
|
|
102
80
|
CustomDatePicker.propTypes = {
|
|
103
81
|
onChange: _propTypes["default"].func.isRequired,
|
|
@@ -106,12 +84,17 @@ CustomDatePicker.propTypes = {
|
|
|
106
84
|
value: _propTypes["default"].any,
|
|
107
85
|
disabled: _propTypes["default"].bool,
|
|
108
86
|
required: _propTypes["default"].bool,
|
|
87
|
+
placeholder: _propTypes["default"].string,
|
|
88
|
+
dateFormat: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].bool]),
|
|
89
|
+
timeFormat: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].bool]),
|
|
90
|
+
error: _propTypes["default"].string,
|
|
109
91
|
tooltip: _propTypes["default"].string,
|
|
92
|
+
showHelp: _propTypes["default"].bool,
|
|
93
|
+
helpText: _propTypes["default"].string,
|
|
110
94
|
mainDivStyle: _propTypes["default"].object,
|
|
111
95
|
labelStyle: _propTypes["default"].object,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
timeFormat: _propTypes["default"].bool
|
|
96
|
+
spanStyle: _propTypes["default"].object,
|
|
97
|
+
inputStyle: _propTypes["default"].object,
|
|
98
|
+
tooltipStyle: _propTypes["default"].object
|
|
116
99
|
};
|
|
117
100
|
var _default = exports["default"] = CustomDatePicker;
|
|
@@ -4,33 +4,110 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _defaults = require("./defaults");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
11
|
var CustomDropdown = function CustomDropdown(_ref) {
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
12
|
+
var onChange = _ref.onChange,
|
|
13
|
+
name = _ref.name,
|
|
14
|
+
displayName = _ref.displayName,
|
|
15
|
+
_ref$value = _ref.value,
|
|
16
|
+
value = _ref$value === void 0 ? "" : _ref$value,
|
|
17
|
+
_ref$options = _ref.options,
|
|
18
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
19
|
+
placeholder = _ref.placeholder,
|
|
20
|
+
_ref$disabled = _ref.disabled,
|
|
21
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
22
|
+
_ref$required = _ref.required,
|
|
23
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
24
|
+
_ref$multiple = _ref.multiple,
|
|
25
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
26
|
+
error = _ref.error,
|
|
27
|
+
_ref$tooltip = _ref.tooltip,
|
|
28
|
+
tooltip = _ref$tooltip === void 0 ? "" : _ref$tooltip,
|
|
29
|
+
_ref$showHelp = _ref.showHelp,
|
|
30
|
+
showHelp = _ref$showHelp === void 0 ? false : _ref$showHelp,
|
|
31
|
+
_ref$helpText = _ref.helpText,
|
|
32
|
+
helpText = _ref$helpText === void 0 ? "" : _ref$helpText,
|
|
33
|
+
_ref$mainDivStyle = _ref.mainDivStyle,
|
|
34
|
+
mainDivStyle = _ref$mainDivStyle === void 0 ? {} : _ref$mainDivStyle,
|
|
35
|
+
_ref$labelStyle = _ref.labelStyle,
|
|
36
|
+
labelStyle = _ref$labelStyle === void 0 ? {} : _ref$labelStyle,
|
|
37
|
+
_ref$spanStyle = _ref.spanStyle,
|
|
38
|
+
spanStyle = _ref$spanStyle === void 0 ? {} : _ref$spanStyle,
|
|
39
|
+
_ref$inputStyle = _ref.inputStyle,
|
|
40
|
+
inputStyle = _ref$inputStyle === void 0 ? {} : _ref$inputStyle,
|
|
41
|
+
_ref$tooltipStyle = _ref.tooltipStyle,
|
|
42
|
+
tooltipStyle = _ref$tooltipStyle === void 0 ? {} : _ref$tooltipStyle;
|
|
43
|
+
var resolveValue = function resolveValue(opt) {
|
|
44
|
+
var _ref2, _ref3, _ref4, _opt$value;
|
|
45
|
+
return (_ref2 = (_ref3 = (_ref4 = (_opt$value = opt === null || opt === void 0 ? void 0 : opt.value) !== null && _opt$value !== void 0 ? _opt$value : opt === null || opt === void 0 ? void 0 : opt.id) !== null && _ref4 !== void 0 ? _ref4 : opt === null || opt === void 0 ? void 0 : opt.key) !== null && _ref3 !== void 0 ? _ref3 : opt === null || opt === void 0 ? void 0 : opt.name) !== null && _ref2 !== void 0 ? _ref2 : opt;
|
|
46
|
+
};
|
|
47
|
+
var resolveLabel = function resolveLabel(opt) {
|
|
48
|
+
var _ref5, _ref6, _ref7, _opt$text;
|
|
49
|
+
return (_ref5 = (_ref6 = (_ref7 = (_opt$text = opt === null || opt === void 0 ? void 0 : opt.text) !== null && _opt$text !== void 0 ? _opt$text : opt === null || opt === void 0 ? void 0 : opt.label) !== null && _ref7 !== void 0 ? _ref7 : opt === null || opt === void 0 ? void 0 : opt.name) !== null && _ref6 !== void 0 ? _ref6 : opt === null || opt === void 0 ? void 0 : opt.key) !== null && _ref5 !== void 0 ? _ref5 : opt;
|
|
50
|
+
};
|
|
51
|
+
var handleChange = (0, _react.useCallback)(function (e) {
|
|
52
|
+
var _options$find;
|
|
53
|
+
var raw = e.target.value;
|
|
54
|
+
var full = (_options$find = options.find(function (opt) {
|
|
55
|
+
return String(resolveValue(opt)) === raw;
|
|
56
|
+
})) !== null && _options$find !== void 0 ? _options$find : null;
|
|
57
|
+
onChange === null || onChange === void 0 || onChange(name, raw, full);
|
|
58
|
+
}, [onChange, name, options]);
|
|
59
|
+
var handleMultiChange = (0, _react.useCallback)(function (e) {
|
|
60
|
+
var selected = Array.from(e.target.selectedOptions).map(function (o) {
|
|
61
|
+
return o.value;
|
|
62
|
+
});
|
|
63
|
+
var fulls = selected.map(function (v) {
|
|
64
|
+
var _options$find2;
|
|
65
|
+
return (_options$find2 = options.find(function (opt) {
|
|
66
|
+
return String(resolveValue(opt)) === v;
|
|
67
|
+
})) !== null && _options$find2 !== void 0 ? _options$find2 : null;
|
|
68
|
+
});
|
|
69
|
+
onChange === null || onChange === void 0 || onChange(name, selected, fulls);
|
|
70
|
+
}, [onChange, name, options]);
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: "ufg-field-group",
|
|
73
|
+
id: name,
|
|
74
|
+
style: mainDivStyle
|
|
75
|
+
}, (0, _defaults.labelJsx)(name, labelStyle, displayName, required, spanStyle, showHelp, helpText), /*#__PURE__*/React.createElement("select", {
|
|
76
|
+
id: "form-input-".concat(name),
|
|
77
|
+
name: name,
|
|
78
|
+
value: value,
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
multiple: multiple,
|
|
81
|
+
className: "ufg-select".concat(error ? " error" : ""),
|
|
82
|
+
style: inputStyle,
|
|
83
|
+
onChange: multiple ? handleMultiChange : handleChange
|
|
84
|
+
}, !multiple && /*#__PURE__*/React.createElement("option", {
|
|
85
|
+
value: ""
|
|
86
|
+
}, placeholder || "Select..."), (options || []).map(function (opt, idx) {
|
|
87
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
88
|
+
key: idx,
|
|
89
|
+
value: resolveValue(opt)
|
|
90
|
+
}, resolveLabel(opt));
|
|
91
|
+
})), (0, _defaults.errorJsx)(error), (0, _defaults.tooltipJsx)(tooltip, tooltipStyle));
|
|
92
|
+
};
|
|
93
|
+
CustomDropdown.propTypes = {
|
|
94
|
+
onChange: _propTypes["default"].func.isRequired,
|
|
95
|
+
name: _propTypes["default"].string.isRequired,
|
|
96
|
+
displayName: _propTypes["default"].string,
|
|
97
|
+
value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array]),
|
|
98
|
+
options: _propTypes["default"].array,
|
|
99
|
+
placeholder: _propTypes["default"].string,
|
|
100
|
+
disabled: _propTypes["default"].bool,
|
|
101
|
+
required: _propTypes["default"].bool,
|
|
102
|
+
multiple: _propTypes["default"].bool,
|
|
103
|
+
error: _propTypes["default"].string,
|
|
104
|
+
tooltip: _propTypes["default"].string,
|
|
105
|
+
showHelp: _propTypes["default"].bool,
|
|
106
|
+
helpText: _propTypes["default"].string,
|
|
107
|
+
mainDivStyle: _propTypes["default"].object,
|
|
108
|
+
labelStyle: _propTypes["default"].object,
|
|
109
|
+
spanStyle: _propTypes["default"].object,
|
|
110
|
+
inputStyle: _propTypes["default"].object,
|
|
111
|
+
tooltipStyle: _propTypes["default"].object
|
|
35
112
|
};
|
|
36
113
|
var _default = exports["default"] = CustomDropdown;
|