@k-int/stripes-kint-components 2.2.0 → 2.3.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/CHANGELOG.md +21 -0
- package/es/index.js +124 -4
- package/es/lib/ActionList/ActionList.js +7 -2
- package/es/lib/ActionList/ActionListFieldArray.js +49 -10
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -2
- package/es/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +5 -5
- package/es/lib/CustomProperties/Config/index.js +6 -4
- package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +72 -0
- package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +133 -0
- package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +279 -0
- package/es/lib/CustomProperties/Edit/CustomPropertyField.js +370 -0
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +156 -0
- package/es/lib/CustomProperties/Edit/index.js +51 -0
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +216 -0
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +236 -0
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +159 -0
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +119 -0
- package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +173 -0
- package/es/lib/CustomProperties/Filter/index.js +59 -0
- package/es/lib/CustomProperties/Filter/useOperators.js +138 -0
- package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +97 -0
- package/es/lib/CustomProperties/Filter/useValueProps.js +101 -0
- package/es/lib/CustomProperties/View/CustomPropertiesView.js +73 -0
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +187 -0
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +204 -0
- package/es/lib/CustomProperties/View/index.js +35 -0
- package/es/lib/CustomProperties/index.js +125 -0
- package/es/lib/EditableRefdataList/EditableRefdataList.js +12 -16
- package/es/lib/FormModal/FormModal.js +18 -4
- package/es/lib/QueryTypedown/QueryTypedown.js +9 -4
- package/es/lib/constants/customProperties.js +4 -1
- package/es/lib/hooks/index.js +16 -0
- package/es/lib/hooks/typedownHooks/useTypedownData.js +9 -2
- package/es/lib/hooks/useAvailableCustomProperties.js +106 -0
- package/es/lib/hooks/useInvalidateRefdata.js +53 -0
- package/es/lib/hooks/useMutateRefdataValue.js +11 -6
- package/es/lib/hooks/useRefdata.js +1 -3
- package/es/lib/utils/groupCustomPropertiesByCtx.js +69 -0
- package/es/lib/utils/index.js +24 -0
- package/es/lib/utils/refdataQueryKey.js +48 -0
- package/es/lib/utils/typedownQueryKey.js +48 -0
- package/es/lib/utils/validators.js +60 -1
- package/git_translate.sh +8 -0
- package/package.json +1 -1
- package/src/index.js +27 -3
- package/src/lib/ActionList/ActionList.js +5 -2
- package/src/lib/ActionList/ActionListFieldArray.js +31 -8
- package/src/lib/ActionList/README.md +23 -20
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -2
- package/src/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +3 -3
- package/src/lib/CustomProperties/Config/index.js +1 -1
- package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.js +35 -0
- package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +85 -0
- package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +194 -0
- package/src/lib/CustomProperties/Edit/CustomPropertyField.js +299 -0
- package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +131 -0
- package/src/lib/CustomProperties/Edit/index.js +5 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +125 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +148 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +113 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +74 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesRule.js +122 -0
- package/src/lib/CustomProperties/Filter/index.js +6 -0
- package/src/lib/CustomProperties/Filter/useOperators.js +55 -0
- package/src/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +35 -0
- package/src/lib/CustomProperties/Filter/useValueProps.js +45 -0
- package/src/lib/CustomProperties/View/CustomPropertiesView.js +36 -0
- package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +112 -0
- package/src/lib/CustomProperties/View/CustomPropertyCard.js +177 -0
- package/src/lib/CustomProperties/View/index.js +3 -0
- package/src/lib/CustomProperties/index.js +30 -0
- package/src/lib/EditableRefdataList/EditableRefdataList.js +13 -10
- package/src/lib/FormModal/FormModal.js +37 -17
- package/src/lib/QueryTypedown/QueryTypedown.js +3 -1
- package/src/lib/constants/customProperties.js +1 -0
- package/src/lib/hooks/index.js +2 -0
- package/src/lib/hooks/typedownHooks/useTypedownData.js +9 -3
- package/src/lib/hooks/useAvailableCustomProperties.js +40 -0
- package/src/lib/hooks/useInvalidateRefdata.js +11 -0
- package/src/lib/hooks/useMutateRefdataValue.js +7 -3
- package/src/lib/hooks/useRefdata.js +2 -3
- package/src/lib/utils/groupCustomPropertiesByCtx.js +13 -0
- package/src/lib/utils/index.js +5 -0
- package/src/lib/utils/refdataQueryKey.js +9 -0
- package/src/lib/utils/typedownQueryKey.js +9 -0
- package/src/lib/utils/validators.js +40 -0
- package/translate.sh +63 -0
- package/translations/stripes-kint-components/ar.json +105 -0
- package/translations/stripes-kint-components/ca.json +1 -0
- package/translations/stripes-kint-components/cs_CZ.json +105 -0
- package/translations/stripes-kint-components/da.json +1 -0
- package/translations/stripes-kint-components/de.json +105 -0
- package/translations/stripes-kint-components/en.json +54 -2
- package/translations/stripes-kint-components/es.json +105 -0
- package/translations/stripes-kint-components/fr.json +105 -0
- package/translations/stripes-kint-components/he.json +1 -0
- package/translations/stripes-kint-components/hi_IN.json +105 -0
- package/translations/stripes-kint-components/hu.json +105 -0
- package/translations/stripes-kint-components/it_IT.json +105 -0
- package/translations/stripes-kint-components/ja.json +105 -0
- package/translations/stripes-kint-components/ko.json +105 -0
- package/translations/stripes-kint-components/nb.json +1 -0
- package/translations/stripes-kint-components/nn.json +1 -0
- package/translations/stripes-kint-components/pl.json +105 -0
- package/translations/stripes-kint-components/pt_PT.json +105 -0
- package/translations/stripes-kint-components/ru.json +105 -0
- package/translations/stripes-kint-components/sv.json +105 -0
- package/translations/stripes-kint-components/ur.json +1 -0
- package/translations/stripes-kint-components/zh_CN.json +105 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _reactFinalForm = require("react-final-form");
|
|
13
|
+
|
|
14
|
+
var _components = require("@folio/stripes/components");
|
|
15
|
+
|
|
16
|
+
var _reactIntl = require("react-intl");
|
|
17
|
+
|
|
18
|
+
var _hooks = require("../../hooks");
|
|
19
|
+
|
|
20
|
+
var _CustomPropertyFormCard = _interopRequireDefault(require("./CustomPropertyFormCard"));
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
var _excluded = ["ctx", "customProperties", "labelOverrides"];
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
(function () {
|
|
29
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
30
|
+
enterModule && enterModule(module);
|
|
31
|
+
})();
|
|
32
|
+
|
|
33
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
34
|
+
|
|
35
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
38
|
+
|
|
39
|
+
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; }
|
|
40
|
+
|
|
41
|
+
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; }
|
|
42
|
+
|
|
43
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
44
|
+
|
|
45
|
+
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."); }
|
|
46
|
+
|
|
47
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
48
|
+
|
|
49
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
50
|
+
|
|
51
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
52
|
+
|
|
53
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
54
|
+
|
|
55
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
56
|
+
|
|
57
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
58
|
+
|
|
59
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
60
|
+
|
|
61
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
62
|
+
|
|
63
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
64
|
+
return a;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var CustomPropertiesList = function CustomPropertiesList(_ref) {
|
|
68
|
+
var _labelOverrides$prima, _labelOverrides$optio, _labelOverrides$addPr;
|
|
69
|
+
|
|
70
|
+
var _ref$availableCustomP = _ref.availableCustomProperties,
|
|
71
|
+
availableCustomProperties = _ref$availableCustomP === void 0 ? [] : _ref$availableCustomP,
|
|
72
|
+
_ref$input = _ref.input,
|
|
73
|
+
name = _ref$input.name,
|
|
74
|
+
onChange = _ref$input.onChange,
|
|
75
|
+
value = _ref$input.value,
|
|
76
|
+
labelOverrides = _ref.labelOverrides,
|
|
77
|
+
pristine = _ref.meta.pristine;
|
|
78
|
+
|
|
79
|
+
var _useState = (0, _react.useState)([]),
|
|
80
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
81
|
+
customProperties = _useState2[0],
|
|
82
|
+
setCustomProperties = _useState2[1]; // This is the list of customProperties we're currently displaying for edit.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
var _useState3 = (0, _react.useState)(false),
|
|
86
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
87
|
+
dirtying = _useState4[0],
|
|
88
|
+
setDirtying = _useState4[1];
|
|
89
|
+
|
|
90
|
+
(0, _react.useEffect)(function () {
|
|
91
|
+
// When the user loads this form, we want to init the list of customProperties
|
|
92
|
+
// we're displaying (state.customProperties) with the list of customProperties that have been set
|
|
93
|
+
// either via defaults or previously-saved data. Since that data may come in
|
|
94
|
+
// _after_ we have mounted this component, we need to check if new data has come in
|
|
95
|
+
// while the form is still marked as pristine.
|
|
96
|
+
//
|
|
97
|
+
// final-form unsets `pristine` after its `onChange` is called, but we also dirty
|
|
98
|
+
// the component when we add/remove rows. That happens _before_ `onChange` is called,
|
|
99
|
+
// so internally we use `state.dirtying` to show that we just initiated an action
|
|
100
|
+
// that will result in a dirty component.
|
|
101
|
+
if (pristine && !dirtying) {
|
|
102
|
+
setCustomProperties(availableCustomProperties.filter(function (customProperty) {
|
|
103
|
+
return value[customProperty.value] !== undefined;
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
}, [availableCustomProperties, dirtying, pristine, value]);
|
|
109
|
+
|
|
110
|
+
var handleDeleteCustomProperty = function handleDeleteCustomProperty(customProperty, i) {
|
|
111
|
+
var _value$customProperty, _value$customProperty2;
|
|
112
|
+
|
|
113
|
+
var currentValue = (_value$customProperty = (_value$customProperty2 = value[customProperty.value]) === null || _value$customProperty2 === void 0 ? void 0 : _value$customProperty2[0]) !== null && _value$customProperty !== void 0 ? _value$customProperty : {};
|
|
114
|
+
|
|
115
|
+
var newCustomProperties = _toConsumableArray(customProperties);
|
|
116
|
+
|
|
117
|
+
newCustomProperties.splice(i, 1);
|
|
118
|
+
setCustomProperties(newCustomProperties);
|
|
119
|
+
setDirtying(true);
|
|
120
|
+
onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, customProperty.value, [_objectSpread(_objectSpread({}, currentValue), {}, {
|
|
121
|
+
_delete: true
|
|
122
|
+
})])));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var renderCustomProperties = function renderCustomProperties(customPropertyType) {
|
|
126
|
+
// This is necessary to track individually since "index" will span primary/optional for a given set
|
|
127
|
+
var internalPropertyCounter = 0;
|
|
128
|
+
return customProperties.map(function (customProperty, index) {
|
|
129
|
+
if (customPropertyType === 'primary' && !customProperty.primary) return undefined;
|
|
130
|
+
if (customPropertyType === 'optional' && customProperty.primary) return undefined;
|
|
131
|
+
internalPropertyCounter += 1;
|
|
132
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertyFormCard.default, {
|
|
133
|
+
availableCustomProperties: availableCustomProperties,
|
|
134
|
+
customProperty: customProperty,
|
|
135
|
+
customPropertyType: customPropertyType,
|
|
136
|
+
customProperties: customProperties,
|
|
137
|
+
handleDeleteCustomProperty: handleDeleteCustomProperty,
|
|
138
|
+
index: index,
|
|
139
|
+
internalPropertyCounter: internalPropertyCounter,
|
|
140
|
+
labelOverrides: labelOverrides,
|
|
141
|
+
name: name,
|
|
142
|
+
onChange: onChange,
|
|
143
|
+
setCustomProperties: setCustomProperties,
|
|
144
|
+
value: value
|
|
145
|
+
}, "customPropertyField-".concat(customProperty.value, "-").concat(index));
|
|
146
|
+
}).filter(function (cp) {
|
|
147
|
+
return cp !== undefined;
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
152
|
+
children: [availableCustomProperties.some(function () {
|
|
153
|
+
var customProperty = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
154
|
+
return customProperty.primary;
|
|
155
|
+
}) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.KeyValue, {
|
|
156
|
+
label: (_labelOverrides$prima = labelOverrides.primaryProperties) !== null && _labelOverrides$prima !== void 0 ? _labelOverrides$prima : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
157
|
+
id: "stripes-kint-components.customProperties.primaryProperties"
|
|
158
|
+
}),
|
|
159
|
+
value: renderCustomProperties('primary')
|
|
160
|
+
}), availableCustomProperties.some(function () {
|
|
161
|
+
var customProperty = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
162
|
+
return !customProperty.primary;
|
|
163
|
+
}) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.KeyValue, {
|
|
164
|
+
label: (_labelOverrides$optio = labelOverrides.optionalProperties) !== null && _labelOverrides$optio !== void 0 ? _labelOverrides$optio : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
165
|
+
id: "stripes-kint-components.customProperties.optionalProperties"
|
|
166
|
+
}),
|
|
167
|
+
value: renderCustomProperties('optional')
|
|
168
|
+
}), availableCustomProperties.some(function () {
|
|
169
|
+
var customProperty = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
170
|
+
return !customProperty.primary;
|
|
171
|
+
}) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
172
|
+
id: "add-customproperty-btn",
|
|
173
|
+
onClick: function onClick() {
|
|
174
|
+
setCustomProperties([].concat(_toConsumableArray(customProperties), [{}]));
|
|
175
|
+
setDirtying(true);
|
|
176
|
+
},
|
|
177
|
+
children: (_labelOverrides$addPr = labelOverrides.addProperty) !== null && _labelOverrides$addPr !== void 0 ? _labelOverrides$addPr : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
178
|
+
id: "stripes-kint-components.customProperties.addProperty"
|
|
179
|
+
})
|
|
180
|
+
})]
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
__signature__(CustomPropertiesList, "useState{[customProperties, setCustomProperties]([])}\nuseState{[dirtying, setDirtying](false)}\nuseEffect{}");
|
|
185
|
+
|
|
186
|
+
var CustomPropertiesListField = function CustomPropertiesListField(_ref2) {
|
|
187
|
+
var ctx = _ref2.ctx,
|
|
188
|
+
customProperties = _ref2.customProperties,
|
|
189
|
+
labelOverrides = _ref2.labelOverrides,
|
|
190
|
+
fieldProps = _objectWithoutProperties(_ref2, _excluded);
|
|
191
|
+
|
|
192
|
+
var fieldRef = (0, _react.useRef)();
|
|
193
|
+
var availableCustomProperties = (0, _hooks.useAvailableCustomProperties)(customProperties);
|
|
194
|
+
|
|
195
|
+
var _useFormState = (0, _reactFinalForm.useFormState)(),
|
|
196
|
+
initialValues = _useFormState.initialValues;
|
|
197
|
+
|
|
198
|
+
var getInitialValue = function getInitialValue() {
|
|
199
|
+
var cps = {};
|
|
200
|
+
(customProperties || []).filter(function (cp) {
|
|
201
|
+
return cp.primary;
|
|
202
|
+
}) // Change default to be an ignored customProperty.
|
|
203
|
+
// This means any changes without setting the value will be ignored
|
|
204
|
+
.forEach(function (cp) {
|
|
205
|
+
cps[cp.name] = [{
|
|
206
|
+
_delete: true
|
|
207
|
+
}];
|
|
208
|
+
}); // IMPORTANT -- All customproperty ctx sections are adding to the same "initialValue" field
|
|
209
|
+
// Ensure that we don't already have initialValues for this particular set before setting them,
|
|
210
|
+
// to ensure no looping behaviour
|
|
211
|
+
|
|
212
|
+
if (Object.keys(cps).every(function (key) {
|
|
213
|
+
var _initialValues$custom;
|
|
214
|
+
|
|
215
|
+
return ((_initialValues$custom = initialValues.customProperties) === null || _initialValues$custom === void 0 ? void 0 : _initialValues$custom[key]) !== undefined;
|
|
216
|
+
})) {
|
|
217
|
+
return initialValues.customProperties;
|
|
218
|
+
} // Ensure that if we already had these values in initialvalues they're not overwritten
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
return _objectSpread(_objectSpread({}, cps), initialValues.customProperties);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, _objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
225
|
+
initialValue: getInitialValue(),
|
|
226
|
+
render: function render(p) {
|
|
227
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomPropertiesList, _objectSpread({
|
|
228
|
+
ref: fieldRef,
|
|
229
|
+
availableCustomProperties: availableCustomProperties,
|
|
230
|
+
ctx: ctx,
|
|
231
|
+
labelOverrides: labelOverrides
|
|
232
|
+
}, p));
|
|
233
|
+
}
|
|
234
|
+
}));
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
__signature__(CustomPropertiesListField, "useRef{fieldRef}\nuseAvailableCustomProperties{availableCustomProperties}\nuseFormState{{ initialValues }}", function () {
|
|
238
|
+
return [_hooks.useAvailableCustomProperties, _reactFinalForm.useFormState];
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
CustomPropertiesListField.propTypes = {
|
|
242
|
+
ctx: _propTypes.default.string,
|
|
243
|
+
customProperties: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
244
|
+
labelOverrides: _propTypes.default.object
|
|
245
|
+
};
|
|
246
|
+
CustomPropertiesList.propTypes = {
|
|
247
|
+
availableCustomProperties: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
248
|
+
ctx: _propTypes.default.string,
|
|
249
|
+
input: _propTypes.default.shape({
|
|
250
|
+
name: _propTypes.default.string,
|
|
251
|
+
value: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
|
|
252
|
+
onChange: _propTypes.default.func
|
|
253
|
+
}),
|
|
254
|
+
labelOverrides: _propTypes.default.object,
|
|
255
|
+
meta: _propTypes.default.object
|
|
256
|
+
};
|
|
257
|
+
var _default = CustomPropertiesListField;
|
|
258
|
+
var _default2 = _default;
|
|
259
|
+
exports.default = _default2;
|
|
260
|
+
;
|
|
261
|
+
|
|
262
|
+
(function () {
|
|
263
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
264
|
+
|
|
265
|
+
if (!reactHotLoader) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
reactHotLoader.register(CustomPropertiesList, "CustomPropertiesList", "/home/ethan/FolioModules/stripes-kint-components/src/lib/CustomProperties/Edit/CustomPropertiesListField.js");
|
|
270
|
+
reactHotLoader.register(CustomPropertiesListField, "CustomPropertiesListField", "/home/ethan/FolioModules/stripes-kint-components/src/lib/CustomProperties/Edit/CustomPropertiesListField.js");
|
|
271
|
+
reactHotLoader.register(_default, "default", "/home/ethan/FolioModules/stripes-kint-components/src/lib/CustomProperties/Edit/CustomPropertiesListField.js");
|
|
272
|
+
})();
|
|
273
|
+
|
|
274
|
+
;
|
|
275
|
+
|
|
276
|
+
(function () {
|
|
277
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
278
|
+
leaveModule && leaveModule(module);
|
|
279
|
+
})();
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _reactIntl = require("react-intl");
|
|
13
|
+
|
|
14
|
+
var _reactFinalForm = require("react-final-form");
|
|
15
|
+
|
|
16
|
+
var _components = require("@folio/stripes/components");
|
|
17
|
+
|
|
18
|
+
var CUSTOM_PROPERTY_TYPES = _interopRequireWildcard(require("../../constants/customProperties"));
|
|
19
|
+
|
|
20
|
+
var _validators = require("../../utils/validators");
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
(function () {
|
|
31
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
32
|
+
enterModule && enterModule(module);
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
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; }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
38
|
+
|
|
39
|
+
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; }
|
|
40
|
+
|
|
41
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
42
|
+
|
|
43
|
+
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."); }
|
|
44
|
+
|
|
45
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
46
|
+
|
|
47
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
48
|
+
|
|
49
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
50
|
+
|
|
51
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
52
|
+
|
|
53
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
54
|
+
return a;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var CustomPropertyField = function CustomPropertyField(_ref) {
|
|
58
|
+
var availableCustomProperties = _ref.availableCustomProperties,
|
|
59
|
+
customProperty = _ref.customProperty,
|
|
60
|
+
customPropertyType = _ref.customPropertyType,
|
|
61
|
+
customProperties = _ref.customProperties,
|
|
62
|
+
index = _ref.index,
|
|
63
|
+
labelOverrides = _ref.labelOverrides,
|
|
64
|
+
name = _ref.name,
|
|
65
|
+
_onChange = _ref.onChange,
|
|
66
|
+
value = _ref.value,
|
|
67
|
+
setCustomProperties = _ref.setCustomProperties;
|
|
68
|
+
var intl = (0, _reactIntl.useIntl)();
|
|
69
|
+
|
|
70
|
+
var getCustomProperty = function getCustomProperty(customPropertyValue) {
|
|
71
|
+
return availableCustomProperties.find(function (cp) {
|
|
72
|
+
return cp.value === customPropertyValue;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var renderCustomPropertyName = function renderCustomPropertyName() {
|
|
77
|
+
var _customPropertyValue$, _labelOverrides$name;
|
|
78
|
+
|
|
79
|
+
var unsetCustomProperties = availableCustomProperties.filter(function (t) {
|
|
80
|
+
var _custPropValue$;
|
|
81
|
+
|
|
82
|
+
// Only optional properties can be set
|
|
83
|
+
if (t.primary) return false;
|
|
84
|
+
var custPropValue = value[t.value]; // The customProperty is unset and has no value.
|
|
85
|
+
|
|
86
|
+
if (custPropValue === undefined) return true; // The customProperty is set but is marked for deletion. Allow reuse.
|
|
87
|
+
|
|
88
|
+
if ((_custPropValue$ = custPropValue[0]) !== null && _custPropValue$ !== void 0 && _custPropValue$._delete) return true;
|
|
89
|
+
return false;
|
|
90
|
+
});
|
|
91
|
+
var customPropertyValue = value[customProperty.value];
|
|
92
|
+
var id = customPropertyValue === null || customPropertyValue === void 0 ? void 0 : (_customPropertyValue$ = customPropertyValue[0]) === null || _customPropertyValue$ === void 0 ? void 0 : _customPropertyValue$.id;
|
|
93
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Select, {
|
|
94
|
+
autoFocus: !id,
|
|
95
|
+
dataOptions: [customProperty].concat(_toConsumableArray(unsetCustomProperties)) // The selected customProperty, and the available unset customProperties
|
|
96
|
+
,
|
|
97
|
+
id: "edit-customproperty-".concat(index, "-name"),
|
|
98
|
+
label: (_labelOverrides$name = labelOverrides.name) !== null && _labelOverrides$name !== void 0 ? _labelOverrides$name : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
99
|
+
id: "stripes-kint-components.customProperty.name"
|
|
100
|
+
}),
|
|
101
|
+
onChange: function onChange(e) {
|
|
102
|
+
var _objectSpread2;
|
|
103
|
+
|
|
104
|
+
var newValue = e.target.value; // Update `state.customProperties` which controls what customProperties are being edited.
|
|
105
|
+
|
|
106
|
+
var newCustomProperties = _toConsumableArray(customProperties);
|
|
107
|
+
|
|
108
|
+
newCustomProperties[index] = getCustomProperty(newValue);
|
|
109
|
+
setCustomProperties(newCustomProperties); // Update final-form (which tracks what the values for a given customProperty are) because
|
|
110
|
+
// in essence we're deleting a customProperty and creating a new customProperty.
|
|
111
|
+
// We do this by 1) marking the current customProperty for deletion and 2) initing
|
|
112
|
+
// the new customProperty to an empty object.
|
|
113
|
+
|
|
114
|
+
var currentValue = value[customProperty.value] ? value[customProperty.value][0] : {};
|
|
115
|
+
|
|
116
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, customProperty.value, [{
|
|
117
|
+
id: currentValue.id,
|
|
118
|
+
_delete: true
|
|
119
|
+
}]), _defineProperty(_objectSpread2, newValue, [{}]), _objectSpread2)));
|
|
120
|
+
},
|
|
121
|
+
required: true,
|
|
122
|
+
value: customProperty.value
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var renderCustomPropertyValue = function renderCustomPropertyValue() {
|
|
127
|
+
var _labelOverrides$value;
|
|
128
|
+
|
|
129
|
+
var currentValue = value[customProperty.value] ? value[customProperty.value][0] : {};
|
|
130
|
+
var min = Number.MIN_SAFE_INTEGER;
|
|
131
|
+
var max = Number.MAX_SAFE_INTEGER;
|
|
132
|
+
|
|
133
|
+
var handleChange = function handleChange(e) {
|
|
134
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, customProperty.value, [_objectSpread(_objectSpread({}, currentValue), {}, {
|
|
135
|
+
_delete: e.target.value === '' ? true : undefined,
|
|
136
|
+
// Delete customProperty if removing the value.
|
|
137
|
+
value: customProperty.type === CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME || customProperty.type === CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME ? parseFloat(e.target.value) : e.target.value // send down the number for integers and decimal types
|
|
138
|
+
|
|
139
|
+
})])));
|
|
140
|
+
}; // Figure out which component we're rendering and specify its unique props.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
var fieldProps;
|
|
144
|
+
|
|
145
|
+
switch (customProperty.type) {
|
|
146
|
+
case CUSTOM_PROPERTY_TYPES.REFDATA_CLASS_NAME:
|
|
147
|
+
fieldProps = {
|
|
148
|
+
component: _components.Select,
|
|
149
|
+
dataOptions: customProperty.options,
|
|
150
|
+
format: function format(v) {
|
|
151
|
+
return v === null || v === void 0 ? void 0 : v.value;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
case CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME:
|
|
157
|
+
case CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME:
|
|
158
|
+
fieldProps = {
|
|
159
|
+
badInput: intl.formatMessage({
|
|
160
|
+
id: 'stripes-kint-components.errors.customPropertyInvalidNumber'
|
|
161
|
+
}),
|
|
162
|
+
component: _components.TextField,
|
|
163
|
+
max: max,
|
|
164
|
+
min: min,
|
|
165
|
+
rangeOverflow: intl.formatMessage({
|
|
166
|
+
id: 'stripes-kint-components.errors.customPropertyDecimalValueNotInRange'
|
|
167
|
+
}, {
|
|
168
|
+
min: min,
|
|
169
|
+
max: max
|
|
170
|
+
}),
|
|
171
|
+
rangeUnderflow: intl.formatMessage({
|
|
172
|
+
id: 'stripes-kint-components.errors.customPropertyDecimalValueNotInRange'
|
|
173
|
+
}, {
|
|
174
|
+
min: min,
|
|
175
|
+
max: max
|
|
176
|
+
}),
|
|
177
|
+
step: 'any',
|
|
178
|
+
type: 'number'
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case CUSTOM_PROPERTY_TYPES.TEXT_CLASS_NAME:
|
|
183
|
+
fieldProps = {
|
|
184
|
+
component: _components.TextArea,
|
|
185
|
+
parse: function parse(v) {
|
|
186
|
+
return v;
|
|
187
|
+
} // Lets us send an empty string instead of `undefined`
|
|
188
|
+
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
|
|
192
|
+
case CUSTOM_PROPERTY_TYPES.DATE_CLASS_NAME:
|
|
193
|
+
fieldProps = {
|
|
194
|
+
component: _components.Datepicker,
|
|
195
|
+
backendDateStandard: 'YYYY-MM-DD',
|
|
196
|
+
timeZone: 'UTC',
|
|
197
|
+
usePortal: true
|
|
198
|
+
};
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
default:
|
|
202
|
+
fieldProps = {
|
|
203
|
+
component: _components.TextField
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, _objectSpread({
|
|
209
|
+
"data-test-customproperty-value": true,
|
|
210
|
+
id: "edit-customproperty-".concat(index, "-value"),
|
|
211
|
+
label: (_labelOverrides$value = labelOverrides.value) !== null && _labelOverrides$value !== void 0 ? _labelOverrides$value : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
212
|
+
id: "stripes-kint-components.customProperty.value"
|
|
213
|
+
}),
|
|
214
|
+
name: "".concat(name, ".").concat(customProperty.value, "[0].value"),
|
|
215
|
+
onChange: handleChange,
|
|
216
|
+
required: !customProperty.primary,
|
|
217
|
+
validate: function validate(fieldValue, allValues) {
|
|
218
|
+
return (0, _validators.customPropertyValidator)(fieldValue, allValues, customProperty);
|
|
219
|
+
},
|
|
220
|
+
valueMissing: intl.formatMessage({
|
|
221
|
+
id: 'stripes-core.label.missingRequiredField'
|
|
222
|
+
})
|
|
223
|
+
}, fieldProps));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var renderCustomPropertyVisibility = function renderCustomPropertyVisibility() {
|
|
227
|
+
var _value$customProperty, _value$customProperty2, _labelOverrides$visib, _customPropertyObject;
|
|
228
|
+
|
|
229
|
+
var customPropertyObject = (_value$customProperty = (_value$customProperty2 = value[customProperty.value]) === null || _value$customProperty2 === void 0 ? void 0 : _value$customProperty2[0]) !== null && _value$customProperty !== void 0 ? _value$customProperty : {};
|
|
230
|
+
|
|
231
|
+
var handleChange = function handleChange(e) {
|
|
232
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, customProperty.value, [_objectSpread(_objectSpread({}, customPropertyObject), {}, {
|
|
233
|
+
internal: e.target.value
|
|
234
|
+
})])));
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Select, {
|
|
238
|
+
"data-test-customproperty-visibility": true,
|
|
239
|
+
dataOptions: [{
|
|
240
|
+
value: true,
|
|
241
|
+
label: intl.formatMessage({
|
|
242
|
+
id: 'stripes-kint-components.customProperty.internalTrue'
|
|
243
|
+
})
|
|
244
|
+
}, {
|
|
245
|
+
value: false,
|
|
246
|
+
label: intl.formatMessage({
|
|
247
|
+
id: 'stripes-kint-components.customProperty.internalFalse'
|
|
248
|
+
})
|
|
249
|
+
}],
|
|
250
|
+
id: "edit-customproperty-".concat(index, "-visibility"),
|
|
251
|
+
label: (_labelOverrides$visib = labelOverrides.visibility) !== null && _labelOverrides$visib !== void 0 ? _labelOverrides$visib : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
252
|
+
id: "stripes-kint-components.customProperty.visibility"
|
|
253
|
+
}),
|
|
254
|
+
onChange: handleChange,
|
|
255
|
+
value: (_customPropertyObject = customPropertyObject === null || customPropertyObject === void 0 ? void 0 : customPropertyObject.internal) !== null && _customPropertyObject !== void 0 ? _customPropertyObject : customProperty.defaultInternal
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
var renderCustomPropertyNoteInternal = function renderCustomPropertyNoteInternal() {
|
|
260
|
+
var _value$customProperty3, _value$customProperty4, _labelOverrides$inter;
|
|
261
|
+
|
|
262
|
+
var customPropertyObject = (_value$customProperty3 = (_value$customProperty4 = value[customProperty.value]) === null || _value$customProperty4 === void 0 ? void 0 : _value$customProperty4[0]) !== null && _value$customProperty3 !== void 0 ? _value$customProperty3 : {};
|
|
263
|
+
|
|
264
|
+
var handleChange = function handleChange(e) {
|
|
265
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, customProperty.value, [_objectSpread(_objectSpread({}, customPropertyObject), {}, {
|
|
266
|
+
note: e.target.value
|
|
267
|
+
})])));
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextArea, {
|
|
271
|
+
"data-test-customproperty-note": true,
|
|
272
|
+
id: "edit-customproperty-".concat(index, "-internal-note"),
|
|
273
|
+
label: (_labelOverrides$inter = labelOverrides.internalNote) !== null && _labelOverrides$inter !== void 0 ? _labelOverrides$inter : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
274
|
+
id: "stripes-kint-components.customProperty.internalNote"
|
|
275
|
+
}),
|
|
276
|
+
onChange: handleChange,
|
|
277
|
+
value: customPropertyObject === null || customPropertyObject === void 0 ? void 0 : customPropertyObject.note
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
var renderCustomPropertyNotePublic = function renderCustomPropertyNotePublic() {
|
|
282
|
+
var _value$customProperty5, _value$customProperty6, _labelOverrides$publi;
|
|
283
|
+
|
|
284
|
+
var customPropertyObject = (_value$customProperty5 = (_value$customProperty6 = value[customProperty.value]) === null || _value$customProperty6 === void 0 ? void 0 : _value$customProperty6[0]) !== null && _value$customProperty5 !== void 0 ? _value$customProperty5 : {};
|
|
285
|
+
|
|
286
|
+
var handleChange = function handleChange(e) {
|
|
287
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, customProperty.value, [_objectSpread(_objectSpread({}, customPropertyObject), {}, {
|
|
288
|
+
publicNote: e.target.value
|
|
289
|
+
})])));
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextArea, {
|
|
293
|
+
"data-test-customproperty-public-note": true,
|
|
294
|
+
id: "edit-customproperty-".concat(index, "-public-note"),
|
|
295
|
+
label: (_labelOverrides$publi = labelOverrides.publicNote) !== null && _labelOverrides$publi !== void 0 ? _labelOverrides$publi : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
296
|
+
id: "stripes-kint-components.customProperty.publicNote"
|
|
297
|
+
}),
|
|
298
|
+
onChange: handleChange,
|
|
299
|
+
value: customPropertyObject === null || customPropertyObject === void 0 ? void 0 : customPropertyObject.publicNote
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
304
|
+
children: [customPropertyType === 'optional' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Row, {
|
|
305
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
306
|
+
xs: 12,
|
|
307
|
+
children: renderCustomPropertyName()
|
|
308
|
+
})
|
|
309
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
|
|
310
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
311
|
+
md: 6,
|
|
312
|
+
xs: 12,
|
|
313
|
+
children: renderCustomPropertyValue()
|
|
314
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
315
|
+
md: 6,
|
|
316
|
+
xs: 12,
|
|
317
|
+
children: renderCustomPropertyNoteInternal()
|
|
318
|
+
})]
|
|
319
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
|
|
320
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
321
|
+
md: 6,
|
|
322
|
+
xs: 12,
|
|
323
|
+
children: renderCustomPropertyVisibility()
|
|
324
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
325
|
+
md: 6,
|
|
326
|
+
xs: 12,
|
|
327
|
+
children: renderCustomPropertyNotePublic()
|
|
328
|
+
})]
|
|
329
|
+
})]
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
__signature__(CustomPropertyField, "useIntl{intl}", function () {
|
|
334
|
+
return [_reactIntl.useIntl];
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
CustomPropertyField.propTypes = {
|
|
338
|
+
availableCustomProperties: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
339
|
+
customProperty: _propTypes.default.object,
|
|
340
|
+
customPropertyType: _propTypes.default.string,
|
|
341
|
+
customProperties: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
342
|
+
index: _propTypes.default.number,
|
|
343
|
+
labelOverrides: _propTypes.default.object,
|
|
344
|
+
name: _propTypes.default.string,
|
|
345
|
+
onChange: _propTypes.default.func,
|
|
346
|
+
setCustomProperties: _propTypes.default.func,
|
|
347
|
+
value: _propTypes.default.object
|
|
348
|
+
};
|
|
349
|
+
var _default = CustomPropertyField;
|
|
350
|
+
var _default2 = _default;
|
|
351
|
+
exports.default = _default2;
|
|
352
|
+
;
|
|
353
|
+
|
|
354
|
+
(function () {
|
|
355
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
356
|
+
|
|
357
|
+
if (!reactHotLoader) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
reactHotLoader.register(CustomPropertyField, "CustomPropertyField", "/home/ethan/FolioModules/stripes-kint-components/src/lib/CustomProperties/Edit/CustomPropertyField.js");
|
|
362
|
+
reactHotLoader.register(_default, "default", "/home/ethan/FolioModules/stripes-kint-components/src/lib/CustomProperties/Edit/CustomPropertyField.js");
|
|
363
|
+
})();
|
|
364
|
+
|
|
365
|
+
;
|
|
366
|
+
|
|
367
|
+
(function () {
|
|
368
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
369
|
+
leaveModule && leaveModule(module);
|
|
370
|
+
})();
|