@norges-domstoler/dds-components 10.4.0 → 10.4.1
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/dist/cjs/index.js
CHANGED
|
@@ -10730,6 +10730,50 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
10730
10730
|
_useState2 = _slicedToArray(_useState, 2),
|
|
10731
10731
|
myState = _useState2[0],
|
|
10732
10732
|
setState = _useState2[1];
|
|
10733
|
+
var addFieldToState = function addFieldToState(field, state) {
|
|
10734
|
+
var key = '';
|
|
10735
|
+
switch (field.component) {
|
|
10736
|
+
case exports.FormGeneratorSupportedFields.Checkbox:
|
|
10737
|
+
case exports.FormGeneratorSupportedFields.ToggleButton:
|
|
10738
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
10739
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultChecked));
|
|
10740
|
+
return state;
|
|
10741
|
+
case exports.FormGeneratorSupportedFields.CheckboxGroup:
|
|
10742
|
+
case exports.FormGeneratorSupportedFields.ToggleButtonGroup:
|
|
10743
|
+
field.children.forEach(function (child) {
|
|
10744
|
+
state = addFieldToState(child, state);
|
|
10745
|
+
});
|
|
10746
|
+
return state;
|
|
10747
|
+
case exports.FormGeneratorSupportedFields.RadioButton:
|
|
10748
|
+
case exports.FormGeneratorSupportedFields.RadioButtonGroup:
|
|
10749
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
10750
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.value));
|
|
10751
|
+
return state;
|
|
10752
|
+
case exports.FormGeneratorSupportedFields.Select:
|
|
10753
|
+
key = field.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
10754
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultValue));
|
|
10755
|
+
return state;
|
|
10756
|
+
case exports.FormGeneratorSupportedFields.Datepicker:
|
|
10757
|
+
case exports.FormGeneratorSupportedFields.TextInput:
|
|
10758
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
10759
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultValue));
|
|
10760
|
+
return state;
|
|
10761
|
+
}
|
|
10762
|
+
return state;
|
|
10763
|
+
};
|
|
10764
|
+
React.useEffect(function () {
|
|
10765
|
+
var state = {};
|
|
10766
|
+
fields.forEach(function (field) {
|
|
10767
|
+
if (isFormGeneratorRow(field)) {
|
|
10768
|
+
field.fields.forEach(function (field) {
|
|
10769
|
+
state = addFieldToState(field, state);
|
|
10770
|
+
});
|
|
10771
|
+
} else {
|
|
10772
|
+
state = addFieldToState(field, state);
|
|
10773
|
+
}
|
|
10774
|
+
});
|
|
10775
|
+
setState(state);
|
|
10776
|
+
}, []);
|
|
10733
10777
|
var fieldOnChange = function fieldOnChange(event) {
|
|
10734
10778
|
var _event$target = event.target,
|
|
10735
10779
|
id = _event$target.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { useState, createElement } from 'react';
|
|
4
|
+
import { useState, useEffect, createElement } from 'react';
|
|
5
5
|
import { Button } from '../Button/Button.js';
|
|
6
6
|
import { Card } from '../Card/Card.js';
|
|
7
7
|
import '../Card/CardAccordion/CardAccordion.js';
|
|
@@ -53,6 +53,50 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
53
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
54
|
myState = _useState2[0],
|
|
55
55
|
setState = _useState2[1];
|
|
56
|
+
var addFieldToState = function addFieldToState(field, state) {
|
|
57
|
+
var key = '';
|
|
58
|
+
switch (field.component) {
|
|
59
|
+
case FormGeneratorSupportedFields.Checkbox:
|
|
60
|
+
case FormGeneratorSupportedFields.ToggleButton:
|
|
61
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
62
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultChecked));
|
|
63
|
+
return state;
|
|
64
|
+
case FormGeneratorSupportedFields.CheckboxGroup:
|
|
65
|
+
case FormGeneratorSupportedFields.ToggleButtonGroup:
|
|
66
|
+
field.children.forEach(function (child) {
|
|
67
|
+
state = addFieldToState(child, state);
|
|
68
|
+
});
|
|
69
|
+
return state;
|
|
70
|
+
case FormGeneratorSupportedFields.RadioButton:
|
|
71
|
+
case FormGeneratorSupportedFields.RadioButtonGroup:
|
|
72
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
73
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.value));
|
|
74
|
+
return state;
|
|
75
|
+
case FormGeneratorSupportedFields.Select:
|
|
76
|
+
key = field.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
77
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultValue));
|
|
78
|
+
return state;
|
|
79
|
+
case FormGeneratorSupportedFields.Datepicker:
|
|
80
|
+
case FormGeneratorSupportedFields.TextInput:
|
|
81
|
+
key = field.props.name || field.props.id || 'FIELD_MISSING_NAME_OR_ID';
|
|
82
|
+
state = Object.assign(Object.assign({}, state), _defineProperty({}, key, field.props.defaultValue));
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
return state;
|
|
86
|
+
};
|
|
87
|
+
useEffect(function () {
|
|
88
|
+
var state = {};
|
|
89
|
+
fields.forEach(function (field) {
|
|
90
|
+
if (isFormGeneratorRow(field)) {
|
|
91
|
+
field.fields.forEach(function (field) {
|
|
92
|
+
state = addFieldToState(field, state);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
state = addFieldToState(field, state);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
setState(state);
|
|
99
|
+
}, []);
|
|
56
100
|
var fieldOnChange = function fieldOnChange(event) {
|
|
57
101
|
var _event$target = event.target,
|
|
58
102
|
id = _event$target.id,
|