Skip to content

Commit 8fe1c6f

Browse files
authored
Create a new dist version 0.0.9 (#23)
Collecting: - Fix [Wizard] remove hasSteps logic (#18) - add isOpen prop in FormSelect (#19) - Impl [Models] Add `FormKeyValueTable` component (#20) - Update form.util.js (#21) - Fix [FormKeyValue] fix last row (#22)
1 parent 5a545d8 commit 8fe1c6f

File tree

14 files changed

+724
-240
lines changed

14 files changed

+724
-240
lines changed

commit_message

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22

3-
Create a new dist version 0.0.8
3+
Create a new dist version 0.0.9
44

55
Collecting:
6-
- Fix [Form] wizard and form input (#16)
6+
- Fix [Wizard] remove hasSteps logic (#18)
7+
- add isOpen prop in FormSelect (#19)
8+
- Impl [Models] Add `FormKeyValueTable` component (#20)
9+
- Update form.util.js (#21)
10+
- Fix [FormKeyValue] fix last row (#22)

dist/components/FormInput/FormInput.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var _Tooltip = _interopRequireDefault(require("../Tooltip/Tooltip"));
2727

2828
var _ValidationTemplate = _interopRequireDefault(require("../../elements/ValidationTemplate/ValidationTemplate"));
2929

30-
var _validationService = require("../../utils/validationService");
30+
var _validation = require("../../utils/validation.util");
3131

3232
var _useDetectOutsideClick = require("../../hooks/useDetectOutsideClick");
3333

@@ -145,6 +145,11 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
145145
(0, _react.useEffect)(function () {
146146
setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
147147
}, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
148+
(0, _react.useEffect)(function () {
149+
if (meta.valid && showValidationRules) {
150+
setShowValidationRules(false);
151+
}
152+
}, [meta.valid, showValidationRules]);
148153
(0, _react.useEffect)(function () {
149154
if (showValidationRules) {
150155
window.addEventListener('scroll', handleScroll, true);
@@ -227,8 +232,8 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
227232
var valueToValidate = value !== null && value !== void 0 ? value : '';
228233
var validationError = null;
229234

230-
if (!(0, _lodash.isEmpty)(validationRules) && valueToValidate !== typedValue) {
231-
var _checkPatternsValidit = (0, _validationService.checkPatternsValidity)(rules, valueToValidate),
235+
if (!(0, _lodash.isEmpty)(validationRules)) {
236+
var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(rules, valueToValidate),
232237
_checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
233238
newRules = _checkPatternsValidit2[0],
234239
isValidField = _checkPatternsValidit2[1];
@@ -245,13 +250,9 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
245250
};
246251
});
247252
}
248-
249-
if (isValidField && showValidationRules || required && valueToValidate === '') {
250-
setShowValidationRules(false);
251-
}
252253
}
253254

254-
if (!validationError) {
255+
if ((0, _lodash.isEmpty)(validationError)) {
255256
if (pattern && !validationPattern.test(valueToValidate)) {
256257
validationError = {
257258
name: 'pattern',

dist/components/FormInput/formInput.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@import '../../scss/shadows';
44
@import '../../scss/mixins';
55

6-
@include formField;
7-
86
.form-field {
7+
@include formField;
8+
99
&__label {
1010
&-icon {
1111
display: inline-flex;
@@ -34,6 +34,7 @@
3434
input {
3535
border: 0;
3636
color: inherit;
37+
background-color: transparent;
3738
padding: 0;
3839
width: 100%;
3940

dist/components/FormKeyValueTable/FormKeyValueTable.js

Lines changed: 353 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
@import '../../scss/borders';
2+
@import '../../scss/colors';
3+
$actionsBlockWidth: 72px;
4+
5+
.form-key-value-table {
6+
max-height: 280px;
7+
overflow: hidden;
8+
overflow-y: auto;
9+
background-color: $white;
10+
11+
&__btn {
12+
visibility: hidden;
13+
}
14+
15+
&__body {
16+
background-color: inherit;
17+
}
18+
19+
.table-row {
20+
display: flex;
21+
align-items: center;
22+
min-height: 56px;
23+
border-bottom: $primaryBorder;
24+
25+
&:not(.no-hover):hover {
26+
background-color: $alabaster;
27+
28+
.key-value-table__btn {
29+
visibility: visible;
30+
}
31+
}
32+
33+
&__last {
34+
position: sticky;
35+
bottom: 0;
36+
z-index: 3;
37+
background-color: inherit;
38+
border: 0;
39+
}
40+
}
41+
42+
.table-row__header {
43+
position: sticky;
44+
top: 0;
45+
z-index: 3;
46+
font-weight: bold;
47+
font-size: 18px;
48+
background-color: inherit;
49+
border-top: $primaryBorder;
50+
}
51+
52+
.table-cell {
53+
display: flex;
54+
align-items: center;
55+
padding: 8px 5px 8px 10px;
56+
color: $primary;
57+
}
58+
59+
.table-cell__inputs-wrapper {
60+
display: flex;
61+
width: calc(100% - #{$actionsBlockWidth});
62+
}
63+
64+
.table-cell__key {
65+
width: 50%;
66+
}
67+
68+
.table-cell__value {
69+
width: 50%;
70+
}
71+
72+
.table-cell__actions {
73+
justify-content: flex-end;
74+
min-width: $actionsBlockWidth;
75+
padding: 0;
76+
77+
& > * {
78+
margin: 0 5px 0 0;
79+
}
80+
}
81+
82+
.add-new-item-btn {
83+
display: flex;
84+
align-items: center;
85+
justify-content: space-between;
86+
min-width: 44px;
87+
padding: 10px;
88+
color: $cornflowerBlue;
89+
font-size: 15px;
90+
line-height: 18px;
91+
92+
svg {
93+
width: 20px;
94+
height: 20px;
95+
96+
rect {
97+
fill: $cornflowerBlue;
98+
}
99+
}
100+
}
101+
102+
.input-wrapper {
103+
width: 100%;
104+
105+
.input {
106+
width: 100%;
107+
108+
&_edit {
109+
border: $primaryBorder;
110+
}
111+
112+
&_invalid {
113+
border: $errorBorder;
114+
}
115+
}
116+
}
117+
}

dist/components/FormSelect/FormSelect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ var FormSelect = function FormSelect(_ref) {
261261
variant: selectedItemAction.confirm.btnConfirmType
262262
},
263263
header: selectedItemAction.confirm.title,
264+
isOpen: isConfirmDialogOpen,
264265
message: selectedItemAction.confirm.message
265266
}), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopUpDialog.default, {
266267
className: "form-field__select__options-list",

dist/components/FormSelect/formSelect.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
@import '../../scss/colors';
33
@import '../../scss/shadows';
44

5-
@include formField;
6-
75
.form-field {
6+
@include formField;
7+
88
&__wrapper {
99
&-active {
1010
background: $alabaster;

dist/components/Wizard/Wizard.js

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var Wizard = function Wizard(_ref) {
5959
var children = _ref.children,
6060
className = _ref.className,
6161
confirmClose = _ref.confirmClose,
62-
FormState = _ref.FormState,
62+
formState = _ref.formState,
6363
isWizardOpen = _ref.isWizardOpen,
6464
onWizardResolve = _ref.onWizardResolve,
6565
onWizardSubmit = _ref.onWizardSubmit,
@@ -79,11 +79,6 @@ var Wizard = function Wizard(_ref) {
7979
var totalSteps = (0, _react.useMemo)(function () {
8080
return _react.default.Children.count(children) - 1 || 0;
8181
}, [children]);
82-
var hasSteps = (0, _react.useMemo)(function () {
83-
return stepsConfig.some(function (step) {
84-
return step.id;
85-
});
86-
}, [stepsConfig]);
8782
var isLastStep = (0, _react.useMemo)(function () {
8883
return activeStepNumber === totalSteps;
8984
}, [activeStepNumber, totalSteps]);
@@ -95,7 +90,7 @@ var Wizard = function Wizard(_ref) {
9590
};
9691
})) || [];
9792
}, [stepsConfig]);
98-
var wizardClasses = (0, _classnames.default)('wizard-form', className, hasSteps && 'wizard-form__with-steps');
93+
var wizardClasses = (0, _classnames.default)('wizard-form', className);
9994

10095
var goToNextStep = function goToNextStep() {
10196
setActiveStepNumber(function (prevStep) {
@@ -114,7 +109,7 @@ var Wizard = function Wizard(_ref) {
114109
};
115110

116111
var handleOnClose = function handleOnClose() {
117-
if (confirmClose && FormState && FormState.dirty) {
112+
if (confirmClose && formState && formState.dirty) {
118113
(0, _common.openPopUp)(_ConfirmDialog.default, {
119114
cancelButton: {
120115
label: 'Cancel',
@@ -134,52 +129,38 @@ var Wizard = function Wizard(_ref) {
134129
};
135130

136131
var handleSubmit = function handleSubmit() {
137-
FormState.handleSubmit();
132+
formState.handleSubmit();
138133

139-
if (FormState.valid) {
134+
if (formState.valid) {
140135
if (isLastStep) {
141-
onWizardSubmit(FormState.values);
136+
onWizardSubmit(formState.values);
142137
} else {
143138
goToNextStep();
144139
}
145140
}
146141
};
147142

148143
var getDefaultActions = function getDefaultActions() {
149-
if (hasSteps) {
150-
return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
151-
onClick: goToPreviousStep,
152-
disabled: activeStepNumber === 0,
153-
label: "Back",
154-
type: "button"
155-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
156-
onClick: handleSubmit,
157-
disabled: FormState.submitting || FormState.invalid && FormState.submitFailed,
158-
label: isLastStep ? submitButtonLabel : 'Next',
159-
type: "button",
160-
variant: _constants.SECONDARY_BUTTON
161-
})];
162-
} else {
163-
return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
164-
onClick: handleOnClose,
165-
label: "Cancel",
166-
type: "button"
167-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
168-
onClick: handleSubmit,
169-
disabled: FormState.submitting || FormState.invalid && FormState.submitFailed,
170-
label: submitButtonLabel,
171-
type: "button",
172-
variant: _constants.SECONDARY_BUTTON
173-
})];
174-
}
144+
return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
145+
onClick: goToPreviousStep,
146+
disabled: activeStepNumber === 0,
147+
label: "Back",
148+
type: "button"
149+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
150+
onClick: handleSubmit,
151+
disabled: formState.submitting || formState.invalid && formState.submitFailed,
152+
label: isLastStep ? submitButtonLabel : 'Next',
153+
type: "button",
154+
variant: _constants.SECONDARY_BUTTON
155+
})];
175156
};
176157

177158
var renderModalActions = function renderModalActions() {
178159
var _stepsConfig$activeSt;
179160

180161
if ((_stepsConfig$activeSt = stepsConfig[activeStepNumber]) !== null && _stepsConfig$activeSt !== void 0 && _stepsConfig$activeSt.getActions) {
181162
return stepsConfig[activeStepNumber].getActions({
182-
FormState: FormState,
163+
formState: formState,
183164
goToNextStep: goToNextStep,
184165
goToPreviousStep: goToPreviousStep,
185166
handleOnClose: handleOnClose,
@@ -199,7 +180,7 @@ var Wizard = function Wizard(_ref) {
199180
show: isWizardOpen,
200181
size: size,
201182
title: title,
202-
children: [hasSteps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardSteps.default, {
183+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_WizardSteps.default, {
203184
activeStepNumber: activeStepNumber,
204185
jumpToStep: jumpToStep,
205186
steps: stepsMenu
@@ -220,10 +201,10 @@ Wizard.defaultProps = {
220201
Wizard.propsTypes = {
221202
className: _propTypes.default.string,
222203
confirmClose: _propTypes.default.bool,
223-
FormState: _propTypes.default.object.isRequired,
224-
isOpen: _propTypes.default.bool.isRequired,
225-
onResolve: _propTypes.default.func.isRequired,
226-
onSubmit: _propTypes.default.func.isRequired,
204+
formState: _propTypes.default.object.isRequired,
205+
isWizardOpen: _propTypes.default.bool.isRequired,
206+
onWizardResolve: _propTypes.default.func.isRequired,
207+
onWizardSubmit: _propTypes.default.func.isRequired,
227208
size: _types.MODAL_SIZES,
228209
title: _propTypes.default.string.isRequired,
229210
stepsConfig: _types.WIZARD_STEPS_CONFIG,

dist/components/Wizard/Wizard.scss

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
.wizard-form {
2-
&__with-steps {
3-
.modal__body {
4-
display: flex;
5-
flex-flow: row nowrap;
6-
overflow: hidden;
7-
padding-right: 0;
8-
}
2+
.modal__body {
3+
display: flex;
4+
flex-flow: row nowrap;
5+
overflow: hidden;
6+
padding-right: 0;
7+
}
98

10-
.wizard-form__content {
11-
overflow-y: auto;
12-
height: 100%;
13-
width: 100%;
14-
padding-right: 2rem;
15-
}
9+
.wizard-form__content {
10+
overflow-y: auto;
11+
height: 100%;
12+
width: 100%;
13+
padding-right: 2rem;
1614
}
1715
}

0 commit comments

Comments
 (0)