@plesk/ui-library 3.35.8 → 3.35.9
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/cjs/components/Action/Action.js +2 -2
- package/cjs/components/Card/Card.js +2 -2
- package/cjs/components/Card/helpers.js +1 -0
- package/cjs/components/CardList/CardList.js +2 -2
- package/cjs/components/CardList/CardListToolbar.js +2 -2
- package/cjs/components/CodeEditor/CodeEditor.js +25 -85
- package/cjs/components/CodeEditor/CodeMirror.js +1 -4
- package/cjs/components/Columns/Columns.js +2 -2
- package/cjs/components/ComboBox/ComboBox.js +2 -2
- package/cjs/components/ComboBoxDropdown/ComboBoxDropdown.js +2 -2
- package/cjs/components/ComboBoxDropdown/index.js +2 -2
- package/cjs/components/Dialog/Dialog.js +2 -2
- package/cjs/components/Drawer/DrawerProgress.js +2 -2
- package/cjs/components/Dropdown/index.js +2 -2
- package/cjs/components/Figure/index.js +2 -2
- package/cjs/components/Form/Form.js +2 -2
- package/cjs/components/Form/index.js +2 -2
- package/cjs/components/FormField/FormField.js +47 -167
- package/cjs/components/FormField/index.js +2 -2
- package/cjs/components/FormFieldPassword/PasswordMeter.js +2 -2
- package/cjs/components/FormFieldRadioButtons/FormFieldRadioButtons.js +2 -2
- package/cjs/components/Heading/Heading.js +2 -2
- package/cjs/components/Icon/index.js +2 -2
- package/cjs/components/Icon/utils.js +2 -2
- package/cjs/components/Item/Item.js +2 -2
- package/cjs/components/ItemList/ItemList.js +3 -3
- package/cjs/components/Layer/index.js +2 -2
- package/cjs/components/List/List.js +5 -2
- package/cjs/components/LocaleProvider/index.js +2 -2
- package/cjs/components/Media/Media.js +2 -2
- package/cjs/components/Menu/MenuBaseItem.js +2 -2
- package/cjs/components/Pagination/index.js +2 -2
- package/cjs/components/Popper/index.js +2 -2
- package/cjs/components/ProgressStep/ProgressStep.js +2 -2
- package/cjs/components/ProgressStep/index.js +2 -2
- package/cjs/components/Section/Section.js +2 -2
- package/cjs/components/Section/index.js +2 -2
- package/cjs/components/SegmentedControl/SegmentedControl.js +2 -2
- package/cjs/components/SegmentedControl/index.js +2 -2
- package/cjs/components/Select/Select.js +2 -2
- package/cjs/components/SplitButton/index.js +2 -2
- package/cjs/components/Subnav/index.js +2 -2
- package/cjs/components/Tabs/SearchBar.js +2 -2
- package/cjs/components/Tabs/Tabs.js +2 -2
- package/cjs/components/Toast/index.js +2 -2
- package/cjs/components/Toolbar/Toolbar.js +2 -2
- package/cjs/components/Toolbar/ToolbarGroup.js +2 -2
- package/cjs/components/Toolbar/ToolbarMenu.js +2 -2
- package/cjs/components/VerticalContext/index.js +2 -2
- package/cjs/components/index.js +2 -2
- package/cjs/index.js +1 -1
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +202 -381
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +6 -6
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Card/helpers.js +1 -0
- package/esm/components/CodeEditor/CodeEditor.js +23 -83
- package/esm/components/CodeEditor/CodeMirror.js +0 -3
- package/esm/components/FormField/FormField.js +48 -167
- package/esm/components/ItemList/ItemList.js +1 -1
- package/esm/components/List/List.js +3 -0
- package/esm/index.js +1 -1
- package/package.json +21 -19
- package/styleguide/build/bundle.6dff330b.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/CodeEditor/CodeEditor.d.ts +188 -0
- package/types/src/components/CodeEditor/CodeMirror.d.ts +9 -0
- package/types/src/components/CodeEditor/index.d.ts +2 -0
- package/types/src/components/FormField/FormField.d.ts +158 -0
- package/types/src/components/FormField/index.d.ts +3 -0
- package/types/src/components/FormFieldSelect/FormFieldSelect.d.ts +1 -1
- package/types/src/components/ItemList/ItemList.d.ts +3 -3
- package/types/src/components/index.d.ts +2 -0
- package/styleguide/build/bundle.50841a29.js +0 -2
- /package/styleguide/build/{bundle.50841a29.js.LICENSE.txt → bundle.6dff330b.js.LICENSE.txt} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { Component, createRef } from 'react';
|
|
5
5
|
import { safeInvoke } from '../utils';
|
|
6
6
|
import { isRtl } from '../../utils';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
import classNames from 'classnames';
|
|
9
8
|
import { CLS_PREFIX } from '../../constants';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -36,10 +35,16 @@ class CodeEditor extends Component {
|
|
|
36
35
|
direction: isRtl() ? 'rtl' : 'ltr'
|
|
37
36
|
}
|
|
38
37
|
});
|
|
38
|
+
_defineProperty(this, "textareaNode", /*#__PURE__*/createRef());
|
|
39
|
+
_defineProperty(this, "CodeMirror", void 0);
|
|
40
|
+
_defineProperty(this, "codeMirror", void 0);
|
|
39
41
|
_defineProperty(this, "handleScroll", () => {
|
|
40
42
|
const {
|
|
41
43
|
onScroll
|
|
42
44
|
} = this.props;
|
|
45
|
+
if (!this.codeMirror) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
43
48
|
safeInvoke(onScroll, this.codeMirror.getScrollInfo());
|
|
44
49
|
});
|
|
45
50
|
_defineProperty(this, "handleChange", (doc, changes) => {
|
|
@@ -80,7 +85,7 @@ class CodeEditor extends Component {
|
|
|
80
85
|
let {
|
|
81
86
|
CodeMirror
|
|
82
87
|
} = _ref2;
|
|
83
|
-
if (!this.textareaNode) {
|
|
88
|
+
if (!this.textareaNode.current) {
|
|
84
89
|
return;
|
|
85
90
|
}
|
|
86
91
|
this.CodeMirror = CodeMirror;
|
|
@@ -91,17 +96,19 @@ class CodeEditor extends Component {
|
|
|
91
96
|
const {
|
|
92
97
|
options
|
|
93
98
|
} = this.state;
|
|
94
|
-
this.codeMirror = CodeMirror.fromTextArea(this.textareaNode, options);
|
|
99
|
+
this.codeMirror = CodeMirror.fromTextArea(this.textareaNode.current, options);
|
|
95
100
|
this.codeMirror.on('scroll', this.handleScroll);
|
|
96
101
|
if (scrollPosition) {
|
|
97
102
|
this.codeMirror.scrollTo(scrollPosition.left, scrollPosition.top);
|
|
98
103
|
}
|
|
99
104
|
this.updateMode(this.props);
|
|
105
|
+
// Save fn typing is missed by some reason.
|
|
106
|
+
// @ts-ignore
|
|
100
107
|
CodeMirror.commands.save = this.props.onSave;
|
|
101
108
|
CodeMirror.commands.find = CodeMirror.commands.findPersistent;
|
|
102
109
|
CodeMirror.commands.findNext = CodeMirror.commands.findPersistentNext;
|
|
103
110
|
CodeMirror.commands.findPrev = CodeMirror.commands.findPersistentPrev;
|
|
104
|
-
safeInvoke(onInit, this.codeMirror.
|
|
111
|
+
safeInvoke(onInit, this.codeMirror.getWrapperElement());
|
|
105
112
|
this.codeMirror.on('change', this.handleChange);
|
|
106
113
|
});
|
|
107
114
|
}
|
|
@@ -109,8 +116,9 @@ class CodeEditor extends Component {
|
|
|
109
116
|
if (!this.codeMirror) {
|
|
110
117
|
return;
|
|
111
118
|
}
|
|
112
|
-
Object.
|
|
113
|
-
|
|
119
|
+
Object.entries(this.state.options).forEach(_ref3 => {
|
|
120
|
+
let [key, value] = _ref3;
|
|
121
|
+
this.codeMirror?.setOption(key, value);
|
|
114
122
|
});
|
|
115
123
|
const {
|
|
116
124
|
children,
|
|
@@ -131,7 +139,7 @@ class CodeEditor extends Component {
|
|
|
131
139
|
if (autofocus) {
|
|
132
140
|
this.codeMirror.focus();
|
|
133
141
|
}
|
|
134
|
-
} else if (scrollPosition !== prevProps.scrollPosition) {
|
|
142
|
+
} else if (scrollPosition && scrollPosition !== prevProps.scrollPosition) {
|
|
135
143
|
this.codeMirror.scrollTo(scrollPosition.left, scrollPosition.top);
|
|
136
144
|
}
|
|
137
145
|
}
|
|
@@ -142,24 +150,24 @@ class CodeEditor extends Component {
|
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
findModeByFileName(fileName) {
|
|
145
|
-
const modeInfo = this.CodeMirror
|
|
153
|
+
const modeInfo = this.CodeMirror?.findModeByFileName(fileName);
|
|
146
154
|
if (modeInfo) {
|
|
147
155
|
return modeInfo.mode;
|
|
148
156
|
}
|
|
149
157
|
return null;
|
|
150
158
|
}
|
|
151
|
-
updateMode(
|
|
159
|
+
updateMode(_ref4) {
|
|
152
160
|
let {
|
|
153
161
|
mode,
|
|
154
162
|
fileName
|
|
155
|
-
} =
|
|
163
|
+
} = _ref4;
|
|
156
164
|
if (!mode && fileName) {
|
|
157
165
|
mode = this.findModeByFileName(fileName);
|
|
158
166
|
}
|
|
159
167
|
if (!mode) {
|
|
160
168
|
return;
|
|
161
169
|
}
|
|
162
|
-
this.
|
|
170
|
+
this.codeMirror?.setOption('mode', mode);
|
|
163
171
|
}
|
|
164
172
|
getLineSeparator() {
|
|
165
173
|
let content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
@@ -190,82 +198,14 @@ class CodeEditor extends Component {
|
|
|
190
198
|
style: {
|
|
191
199
|
display: 'none'
|
|
192
200
|
},
|
|
193
|
-
ref:
|
|
201
|
+
ref: this.textareaNode,
|
|
194
202
|
className: classNames(baseClassName, className),
|
|
195
203
|
defaultValue: content,
|
|
196
204
|
...props
|
|
197
205
|
});
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
|
-
CodeEditor
|
|
201
|
-
/**
|
|
202
|
-
* The mode to use. When not given, this will default to the first mode that was loaded.
|
|
203
|
-
* @since 0.0.61
|
|
204
|
-
*/
|
|
205
|
-
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
206
|
-
/**
|
|
207
|
-
* CodeEditor can detect mode by file name. Will be ignored if you set mode property.
|
|
208
|
-
* @since 0.0.61
|
|
209
|
-
*/
|
|
210
|
-
fileName: PropTypes.string,
|
|
211
|
-
/**
|
|
212
|
-
* Content of the `CodeEditor`.
|
|
213
|
-
* @since 0.0.61
|
|
214
|
-
*/
|
|
215
|
-
children: PropTypes.string,
|
|
216
|
-
/**
|
|
217
|
-
* Set read only.
|
|
218
|
-
* @since 0.0.61
|
|
219
|
-
*/
|
|
220
|
-
readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
221
|
-
/**
|
|
222
|
-
* Set auto focus.
|
|
223
|
-
* @since 0.0.61
|
|
224
|
-
*/
|
|
225
|
-
autofocus: PropTypes.bool,
|
|
226
|
-
/**
|
|
227
|
-
* onInit event handler.
|
|
228
|
-
* @since 0.0.61
|
|
229
|
-
*/
|
|
230
|
-
onInit: PropTypes.func,
|
|
231
|
-
/**
|
|
232
|
-
* onChange event handler.
|
|
233
|
-
* @since 0.0.61
|
|
234
|
-
*/
|
|
235
|
-
onChange: PropTypes.func,
|
|
236
|
-
/**
|
|
237
|
-
* onSave event handler.
|
|
238
|
-
* @since 0.0.61
|
|
239
|
-
*/
|
|
240
|
-
onSave: PropTypes.func,
|
|
241
|
-
/**
|
|
242
|
-
* See all supported options in [CodeMirror](https://codemirror.net/doc/manual.html#config) documentation.
|
|
243
|
-
* @since 0.0.61
|
|
244
|
-
*/
|
|
245
|
-
options: PropTypes.object,
|
|
246
|
-
/**
|
|
247
|
-
* Set scroll position.
|
|
248
|
-
* @since 1.12.4
|
|
249
|
-
*/
|
|
250
|
-
scrollPosition: PropTypes.shape({
|
|
251
|
-
left: PropTypes.number,
|
|
252
|
-
top: PropTypes.number
|
|
253
|
-
}),
|
|
254
|
-
/**
|
|
255
|
-
* onScroll event handler.
|
|
256
|
-
* @since 1.12.4
|
|
257
|
-
*/
|
|
258
|
-
onScroll: PropTypes.func,
|
|
259
|
-
/**
|
|
260
|
-
* @ignore
|
|
261
|
-
*/
|
|
262
|
-
className: PropTypes.string,
|
|
263
|
-
/**
|
|
264
|
-
* @ignore
|
|
265
|
-
*/
|
|
266
|
-
baseClassName: PropTypes.string
|
|
267
|
-
};
|
|
268
|
-
CodeEditor.defaultProps = {
|
|
208
|
+
_defineProperty(CodeEditor, "defaultProps", {
|
|
269
209
|
mode: '',
|
|
270
210
|
fileName: '',
|
|
271
211
|
children: '',
|
|
@@ -279,5 +219,5 @@ CodeEditor.defaultProps = {
|
|
|
279
219
|
baseClassName: `${CLS_PREFIX}code-editor`,
|
|
280
220
|
scrollPosition: undefined,
|
|
281
221
|
onScroll: undefined
|
|
282
|
-
};
|
|
222
|
+
});
|
|
283
223
|
export default CodeEditor;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { Component, useContext } from 'react';
|
|
5
5
|
import { scrollIntoView, safeInvoke } from '../utils';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
6
|
import classNames from 'classnames';
|
|
8
7
|
import { CLS_PREFIX } from '../../constants';
|
|
9
8
|
import { SectionItem } from '../Section';
|
|
@@ -21,13 +20,33 @@ import ScrollableElementFormContext from '../Form/ScrollableElementFormContext';
|
|
|
21
20
|
import DisabledContext from '../Form/DisabledContext';
|
|
22
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
export const BASE_FORM_FIELD_CLASS_NAME = `${CLS_PREFIX}form-field`;
|
|
24
24
|
const defaultValue = undefined;
|
|
25
|
+
const defaultProps = {
|
|
26
|
+
id: undefined,
|
|
27
|
+
name: undefined,
|
|
28
|
+
value: defaultValue,
|
|
29
|
+
onChange: null,
|
|
30
|
+
label: undefined,
|
|
31
|
+
description: undefined,
|
|
32
|
+
errors: {},
|
|
33
|
+
required: false,
|
|
34
|
+
children: undefined,
|
|
35
|
+
multi: undefined,
|
|
36
|
+
disabled: undefined,
|
|
37
|
+
locale: undefined,
|
|
38
|
+
addMoreValidator: undefined,
|
|
39
|
+
onRemoveRow: null,
|
|
40
|
+
fullDescription: undefined,
|
|
41
|
+
className: undefined,
|
|
42
|
+
baseClassName: BASE_FORM_FIELD_CLASS_NAME,
|
|
43
|
+
form: undefined,
|
|
44
|
+
vertical: undefined,
|
|
45
|
+
scrollableElement: undefined
|
|
46
|
+
};
|
|
25
47
|
|
|
26
48
|
/**
|
|
27
|
-
* Simple helper to handle situations when we expecting only array
|
|
28
|
-
* @param value
|
|
29
|
-
* @param nonEmpty
|
|
30
|
-
* @returns {Array}
|
|
49
|
+
* Simple helper to handle situations when we're expecting only array
|
|
31
50
|
*/
|
|
32
51
|
const getArrayHelper = function (value) {
|
|
33
52
|
let nonEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -40,9 +59,7 @@ const getArrayHelper = function (value) {
|
|
|
40
59
|
}
|
|
41
60
|
return result;
|
|
42
61
|
};
|
|
43
|
-
const isControlled = props => props.value !== undefined;
|
|
44
62
|
const isEmpty = value => !value && value !== 0 || Array.isArray(value) && value.length === 0 || !Array.isArray(value) && typeof value === 'object' && Object.values(value).filter(t => Boolean(t)).length === 0;
|
|
45
|
-
|
|
46
63
|
/**
|
|
47
64
|
* @since 0.0.54
|
|
48
65
|
*/
|
|
@@ -51,16 +68,18 @@ class FormField extends Component {
|
|
|
51
68
|
var _this;
|
|
52
69
|
super(_props);
|
|
53
70
|
_this = this;
|
|
71
|
+
_defineProperty(this, "fieldApi", void 0);
|
|
72
|
+
_defineProperty(this, "targetRefs", void 0);
|
|
73
|
+
_defineProperty(this, "focusTimer", null);
|
|
54
74
|
/**
|
|
55
75
|
* Field API provided to field
|
|
56
|
-
* @param index
|
|
57
|
-
* @returns {Object}
|
|
58
76
|
*/
|
|
59
77
|
_defineProperty(this, "getFieldApi", index => {
|
|
60
78
|
if (!this.props.multi) {
|
|
61
79
|
return this.fieldApi;
|
|
62
80
|
}
|
|
63
81
|
return {
|
|
82
|
+
getValues: () => this.fieldApi.getValues(),
|
|
64
83
|
getId: () => {
|
|
65
84
|
const id = this.fieldApi.getId();
|
|
66
85
|
return id ? `${id}-${index}` : id;
|
|
@@ -96,7 +115,7 @@ class FormField extends Component {
|
|
|
96
115
|
getSeparator: () => /*#__PURE__*/_jsx("span", {
|
|
97
116
|
className: `${this.props.baseClassName}__separator`
|
|
98
117
|
}),
|
|
99
|
-
isDisabled: () => this.props.disabled,
|
|
118
|
+
isDisabled: () => !!this.props.disabled,
|
|
100
119
|
getFullDescription: () => {
|
|
101
120
|
if (index === 0) {
|
|
102
121
|
return this.fieldApi.getFullDescription();
|
|
@@ -134,11 +153,10 @@ class FormField extends Component {
|
|
|
134
153
|
});
|
|
135
154
|
/**
|
|
136
155
|
* Handler for clicks on 'Remove'
|
|
137
|
-
* @param index
|
|
138
156
|
*/
|
|
139
157
|
_defineProperty(this, "handleRemove", index => {
|
|
140
158
|
const values = getArrayHelper(this.fieldApi.getValue());
|
|
141
|
-
this.fieldApi.setValue(values.filter((
|
|
159
|
+
this.fieldApi.setValue(values.filter((_, valueIndex) => valueIndex !== index));
|
|
142
160
|
|
|
143
161
|
// Can be used for removing errors from form properties
|
|
144
162
|
safeInvoke(this.props.onRemoveRow, index);
|
|
@@ -147,7 +165,7 @@ class FormField extends Component {
|
|
|
147
165
|
this.setState(prevState => {
|
|
148
166
|
if (prevState.errors && prevState.errors.filter) {
|
|
149
167
|
return {
|
|
150
|
-
errors: prevState.errors.filter((
|
|
168
|
+
errors: prevState.errors.filter((_, errorIndex) => errorIndex !== index)
|
|
151
169
|
};
|
|
152
170
|
}
|
|
153
171
|
return {};
|
|
@@ -157,9 +175,7 @@ class FormField extends Component {
|
|
|
157
175
|
this.targetRefs[index] = node;
|
|
158
176
|
});
|
|
159
177
|
/**
|
|
160
|
-
* Renders 'Remove' button for each row
|
|
161
|
-
* @param index
|
|
162
|
-
* @returns {null|React.ReactElement}
|
|
178
|
+
* Renders 'Remove' button for each row.
|
|
163
179
|
*/
|
|
164
180
|
_defineProperty(this, "renderRemoveButton", index => {
|
|
165
181
|
const {
|
|
@@ -187,9 +203,7 @@ class FormField extends Component {
|
|
|
187
203
|
});
|
|
188
204
|
});
|
|
189
205
|
/**
|
|
190
|
-
* Renders description for last row
|
|
191
|
-
* @param index
|
|
192
|
-
* @returns {null|React.ReactElement}
|
|
206
|
+
* Renders description for last row.
|
|
193
207
|
*/
|
|
194
208
|
_defineProperty(this, "renderDescription", index => {
|
|
195
209
|
const {
|
|
@@ -207,9 +221,7 @@ class FormField extends Component {
|
|
|
207
221
|
});
|
|
208
222
|
});
|
|
209
223
|
/**
|
|
210
|
-
* Renders one field
|
|
211
|
-
* @param index
|
|
212
|
-
* @returns {React.ReactElement}
|
|
224
|
+
* Renders one field.
|
|
213
225
|
*/
|
|
214
226
|
_defineProperty(this, "renderField", function () {
|
|
215
227
|
let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
@@ -311,7 +323,7 @@ class FormField extends Component {
|
|
|
311
323
|
if (this.props.name) {
|
|
312
324
|
return this.props.name.replace(/[[\]]+/g, '-').replace(/-+$/, '');
|
|
313
325
|
}
|
|
314
|
-
return
|
|
326
|
+
return undefined;
|
|
315
327
|
},
|
|
316
328
|
getName: () => this.props.name,
|
|
317
329
|
getValues: () => {
|
|
@@ -383,39 +395,41 @@ class FormField extends Component {
|
|
|
383
395
|
prevErrors,
|
|
384
396
|
prevRequired
|
|
385
397
|
} = state;
|
|
386
|
-
if (
|
|
398
|
+
if (props.value !== undefined) {
|
|
387
399
|
nextState.value = props.value;
|
|
388
400
|
}
|
|
389
401
|
if (errors !== prevErrors) {
|
|
390
402
|
nextState.errors = errors;
|
|
391
403
|
}
|
|
392
|
-
if (form && required !== prevRequired) {
|
|
393
|
-
form.setRequiredField(name, required);
|
|
404
|
+
if (name && form && required !== prevRequired) {
|
|
405
|
+
form.setRequiredField(name, !!required);
|
|
394
406
|
}
|
|
395
407
|
nextState.prevErrors = errors;
|
|
396
408
|
nextState.prevRequired = required;
|
|
397
409
|
return nextState;
|
|
398
410
|
}
|
|
399
411
|
componentDidMount() {
|
|
400
|
-
if (this.props.form) {
|
|
401
|
-
this.props.form.setRequiredField(this.props.name, this.props.required);
|
|
412
|
+
if (this.props.form && this.props.name) {
|
|
413
|
+
this.props.form.setRequiredField(this.props.name, !!this.props.required);
|
|
402
414
|
this.props.form.registerField(this.props.name, {
|
|
403
415
|
focus: this.focus
|
|
404
416
|
});
|
|
405
417
|
}
|
|
406
418
|
}
|
|
407
419
|
componentWillUnmount() {
|
|
408
|
-
if (this.props.form) {
|
|
420
|
+
if (this.props.form && this.props.name) {
|
|
409
421
|
this.props.form.setRequiredField(this.props.name, false);
|
|
410
422
|
this.props.form.unregisterField(this.props.name);
|
|
411
423
|
}
|
|
412
|
-
|
|
424
|
+
if (this.focusTimer) {
|
|
425
|
+
clearTimeout(this.focusTimer);
|
|
426
|
+
}
|
|
413
427
|
}
|
|
414
428
|
render() {
|
|
415
429
|
if (!this.props.multi) {
|
|
416
430
|
return this.renderField();
|
|
417
431
|
}
|
|
418
|
-
const max = this.props.multi.max
|
|
432
|
+
const max = typeof this.props.multi === 'object' && this.props.multi.max ? this.props.multi.max : Infinity;
|
|
419
433
|
let index = 0;
|
|
420
434
|
const count = (this.fieldApi.getValue() || []).length || 1;
|
|
421
435
|
const lines = [];
|
|
@@ -425,137 +439,6 @@ class FormField extends Component {
|
|
|
425
439
|
return lines;
|
|
426
440
|
}
|
|
427
441
|
}
|
|
428
|
-
const propTypes = {
|
|
429
|
-
/**
|
|
430
|
-
* Field ID.
|
|
431
|
-
* @since 0.0.59
|
|
432
|
-
*/
|
|
433
|
-
id: PropTypes.string,
|
|
434
|
-
/**
|
|
435
|
-
* Field name.
|
|
436
|
-
* @since 0.0.54
|
|
437
|
-
*/
|
|
438
|
-
name: PropTypes.string,
|
|
439
|
-
/**
|
|
440
|
-
* Field value.
|
|
441
|
-
* @deprecated Use [Form](#!/Form) values.
|
|
442
|
-
* @since 0.0.57
|
|
443
|
-
*/
|
|
444
|
-
value: PropTypes.any,
|
|
445
|
-
/**
|
|
446
|
-
* A callback function, can be executed when the value is changing.
|
|
447
|
-
* @since 0.4.1
|
|
448
|
-
*/
|
|
449
|
-
onChange: PropTypes.func,
|
|
450
|
-
/**
|
|
451
|
-
* Field label.
|
|
452
|
-
* @since 0.0.54
|
|
453
|
-
*/
|
|
454
|
-
label: PropTypes.any,
|
|
455
|
-
/**
|
|
456
|
-
* Field description.
|
|
457
|
-
* @since 0.0.57
|
|
458
|
-
*/
|
|
459
|
-
description: PropTypes.any,
|
|
460
|
-
/**
|
|
461
|
-
* Show long descriptions in popover after clicking on "( i )" icon
|
|
462
|
-
* @since 3.14.0
|
|
463
|
-
*/
|
|
464
|
-
fullDescription: PropTypes.node,
|
|
465
|
-
/**
|
|
466
|
-
* Field errors.
|
|
467
|
-
* @deprecated Use [Form](#!/Form) errors.
|
|
468
|
-
* @since 0.0.57
|
|
469
|
-
*/
|
|
470
|
-
errors: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
471
|
-
/**
|
|
472
|
-
* Indicates whether field is required.
|
|
473
|
-
* @since 0.0.54
|
|
474
|
-
*/
|
|
475
|
-
required: PropTypes.bool,
|
|
476
|
-
/**
|
|
477
|
-
* Content of the `FormField`.
|
|
478
|
-
* @since 0.0.54
|
|
479
|
-
*/
|
|
480
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
481
|
-
/**
|
|
482
|
-
* If 'true', a field will be multiple. You can also limit the number of fields with a value like { max: 5 }.
|
|
483
|
-
* @since 1.12.0
|
|
484
|
-
*/
|
|
485
|
-
multi: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
486
|
-
max: PropTypes.number.isRequired
|
|
487
|
-
})]),
|
|
488
|
-
/**
|
|
489
|
-
* @ignore Disabled state of multiple field.
|
|
490
|
-
*/
|
|
491
|
-
disabled: PropTypes.bool,
|
|
492
|
-
/**
|
|
493
|
-
* Localization messages
|
|
494
|
-
* @since 1.12.0
|
|
495
|
-
*/
|
|
496
|
-
locale: PropTypes.shape({
|
|
497
|
-
addMore: PropTypes.node,
|
|
498
|
-
remove: PropTypes.node
|
|
499
|
-
}),
|
|
500
|
-
/**
|
|
501
|
-
* Callback which called for all values. If it returns 'true' a pseudo-link 'Add more' will be disabled
|
|
502
|
-
* @ignore
|
|
503
|
-
* @deprecated
|
|
504
|
-
*/
|
|
505
|
-
addMoreValidator: PropTypes.func,
|
|
506
|
-
/**
|
|
507
|
-
* A callback function, can be executed when the row is removed.
|
|
508
|
-
* @since 1.12.0
|
|
509
|
-
*/
|
|
510
|
-
onRemoveRow: PropTypes.func,
|
|
511
|
-
/**
|
|
512
|
-
* @ignore
|
|
513
|
-
*/
|
|
514
|
-
className: PropTypes.string,
|
|
515
|
-
/**
|
|
516
|
-
* @ignore
|
|
517
|
-
*/
|
|
518
|
-
baseClassName: PropTypes.string,
|
|
519
|
-
/**
|
|
520
|
-
* @ignore
|
|
521
|
-
*/
|
|
522
|
-
form: PropTypes.object,
|
|
523
|
-
/**
|
|
524
|
-
* Vertical or horizontal field view.
|
|
525
|
-
* If it is not defined explicitly, the vertical mode will use from Form or Section components.
|
|
526
|
-
* @since 3.13.0
|
|
527
|
-
*/
|
|
528
|
-
vertical: PropTypes.bool,
|
|
529
|
-
/**
|
|
530
|
-
* @ignore
|
|
531
|
-
*/
|
|
532
|
-
scrollableElement: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.instanceOf(Window)])
|
|
533
|
-
};
|
|
534
|
-
const BASE_FORM_FIELD_CLASS_NAME = `${CLS_PREFIX}form-field`;
|
|
535
|
-
const defaultProps = {
|
|
536
|
-
id: undefined,
|
|
537
|
-
name: undefined,
|
|
538
|
-
value: defaultValue,
|
|
539
|
-
onChange: null,
|
|
540
|
-
label: undefined,
|
|
541
|
-
description: undefined,
|
|
542
|
-
errors: {},
|
|
543
|
-
required: false,
|
|
544
|
-
children: undefined,
|
|
545
|
-
multi: undefined,
|
|
546
|
-
disabled: undefined,
|
|
547
|
-
locale: undefined,
|
|
548
|
-
addMoreValidator: undefined,
|
|
549
|
-
onRemoveRow: null,
|
|
550
|
-
fullDescription: undefined,
|
|
551
|
-
className: undefined,
|
|
552
|
-
baseClassName: BASE_FORM_FIELD_CLASS_NAME,
|
|
553
|
-
form: undefined,
|
|
554
|
-
vertical: undefined,
|
|
555
|
-
scrollableElement: undefined
|
|
556
|
-
};
|
|
557
|
-
FormField.propTypes = propTypes;
|
|
558
|
-
FormField.defaultProps = defaultProps;
|
|
559
442
|
|
|
560
443
|
/**
|
|
561
444
|
* `FormField` component is used for showing of parameter values in Form or
|
|
@@ -566,7 +449,7 @@ FormField.defaultProps = defaultProps;
|
|
|
566
449
|
* * [FormFieldSelect](#!/FormFieldSelect), [FormFieldCheckbox](#!/FormFieldCheckbox),
|
|
567
450
|
* [FormFieldRadioButtons](#!/FormFieldRadioButtons) for selecting options.
|
|
568
451
|
*/
|
|
569
|
-
|
|
452
|
+
_defineProperty(FormField, "defaultProps", defaultProps);
|
|
570
453
|
const FormFieldWrapper = props => {
|
|
571
454
|
const form = useContext(FormContext);
|
|
572
455
|
const verticalContext = useContext(VerticalContext);
|
|
@@ -582,7 +465,5 @@ const FormFieldWrapper = props => {
|
|
|
582
465
|
});
|
|
583
466
|
};
|
|
584
467
|
FormFieldWrapper.displayName = 'FormField';
|
|
585
|
-
FormFieldWrapper.propTypes = propTypes;
|
|
586
468
|
FormFieldWrapper.defaultProps = defaultProps;
|
|
587
|
-
export default FormFieldWrapper;
|
|
588
|
-
export { BASE_FORM_FIELD_CLASS_NAME };
|
|
469
|
+
export default FormFieldWrapper;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
3
|
|
|
4
|
-
import { Component, Children, cloneElement, isValidElement } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import { CLS_PREFIX } from '../../constants';
|
|
7
6
|
import Grid from '../Grid';
|
|
8
7
|
import GridCol from '../GridCol';
|
|
9
8
|
import { safeInvoke } from '../utils';
|
|
9
|
+
import { Component, Children, cloneElement, isValidElement } from 'react';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
const getNextSelectedValue = (value, prevValue, toggleable) => {
|
|
12
12
|
if (Array.isArray(prevValue)) {
|
|
@@ -1246,6 +1246,9 @@ class List extends Component {
|
|
|
1246
1246
|
if (sidebar) {
|
|
1247
1247
|
content = /*#__PURE__*/_jsxs(Columns, {
|
|
1248
1248
|
gap: "md",
|
|
1249
|
+
className: classNames(`${baseClassName}__content`, {
|
|
1250
|
+
[`${baseClassName}__content--vertical`]: vertical
|
|
1251
|
+
}),
|
|
1249
1252
|
children: [/*#__PURE__*/_jsx(Column, {
|
|
1250
1253
|
fill: true,
|
|
1251
1254
|
children: content
|
package/esm/index.js
CHANGED