@norges-domstoler/dds-components 10.1.1 → 10.2.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/dist/cjs/components/FormGenerator/FormGenerator.types.d.ts +27 -2
- package/dist/cjs/index.js +26 -1
- package/dist/components/FormGenerator/FormGenerator.js +31 -2
- package/dist/components/FormGenerator/FormGenerator.types.d.ts +27 -2
- package/dist/hooks/useScreenSize.js +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { ButtonProps } from '../Button';
|
|
|
4
4
|
import { CardProps } from '../Card';
|
|
5
5
|
import { CheckboxGroupProps, CheckboxProps } from '../Checkbox';
|
|
6
6
|
import { DatepickerProps } from '../Datepicker';
|
|
7
|
+
import { DescriptionListProps, DescriptionListDescProps, DescriptionListGroupProps, DescriptionListTermProps } from '../DescriptionList';
|
|
7
8
|
import { DividerProps } from '../Divider';
|
|
8
9
|
import { GlobalMessageProps } from '../GlobalMessage';
|
|
9
10
|
import { InputMessageProps } from '../InputMessage';
|
|
@@ -28,8 +29,8 @@ export declare type FormGeneratorRow = {
|
|
|
28
29
|
fields: FormGeneratorField[];
|
|
29
30
|
};
|
|
30
31
|
export declare type FormGeneratorField = FieldWithChildren | FieldWithoutChildren;
|
|
31
|
-
declare type FieldWithChildren = CheckboxGroupField | ListField | RadioButtonGroupField | ToggleButtonGroupField;
|
|
32
|
-
declare type FieldWithoutChildren = ButtonField | CardField | CheckboxField | DatepickerField | DividerField | GlobalMessageField | HeadingField | InputMessageField | LabelField | LinkField | ListItemField | LocalMessageField | ParagraphField | RadioButtonField | SelectField | SpinnerField | TextInputField | ToggleButtonField | TypographyField | VisuallyHiddenField;
|
|
32
|
+
declare type FieldWithChildren = CheckboxGroupField | DescriptionListField | DescriptionListGroupField | ListField | RadioButtonGroupField | ToggleButtonGroupField;
|
|
33
|
+
declare type FieldWithoutChildren = ButtonField | CardField | CheckboxField | DatepickerField | DescriptionListTermField | DescriptionListDescField | DividerField | GlobalMessageField | HeadingField | InputMessageField | LabelField | LinkField | ListItemField | LocalMessageField | ParagraphField | RadioButtonField | SelectField | SpinnerField | TextInputField | ToggleButtonField | TypographyField | VisuallyHiddenField;
|
|
33
34
|
declare type ButtonField = {
|
|
34
35
|
component: 'Button';
|
|
35
36
|
props: ButtonProps;
|
|
@@ -57,6 +58,30 @@ declare type DatepickerField = {
|
|
|
57
58
|
props: DatepickerProps;
|
|
58
59
|
hide?: boolean;
|
|
59
60
|
};
|
|
61
|
+
declare type DescriptionListField = {
|
|
62
|
+
component: 'DescriptionList';
|
|
63
|
+
props: DescriptionListProps;
|
|
64
|
+
hide?: boolean;
|
|
65
|
+
children: DescriptionListGroupField[];
|
|
66
|
+
};
|
|
67
|
+
declare type DescriptionListGroupField = {
|
|
68
|
+
component: 'DescriptionListGroup';
|
|
69
|
+
props: DescriptionListGroupProps;
|
|
70
|
+
hide?: boolean;
|
|
71
|
+
children: (DescriptionListTermField | DescriptionListDescField)[];
|
|
72
|
+
};
|
|
73
|
+
declare type DescriptionListTermField = {
|
|
74
|
+
component: 'DescriptionListTerm';
|
|
75
|
+
props: DescriptionListTermProps;
|
|
76
|
+
hide?: boolean;
|
|
77
|
+
innerHTML: JSX.Element | string;
|
|
78
|
+
};
|
|
79
|
+
declare type DescriptionListDescField = {
|
|
80
|
+
component: 'DescriptionListDesc';
|
|
81
|
+
props: DescriptionListDescProps;
|
|
82
|
+
hide?: boolean;
|
|
83
|
+
innerHTML: JSX.Element | string;
|
|
84
|
+
};
|
|
60
85
|
declare type DividerField = {
|
|
61
86
|
component: 'Divider';
|
|
62
87
|
props: DividerProps;
|
package/dist/cjs/index.js
CHANGED
|
@@ -5532,6 +5532,7 @@ var useScreenSize = function useScreenSize() {
|
|
|
5532
5532
|
_iterator.f();
|
|
5533
5533
|
}
|
|
5534
5534
|
}
|
|
5535
|
+
listener();
|
|
5535
5536
|
window.addEventListener('resize', listener);
|
|
5536
5537
|
return function () {
|
|
5537
5538
|
return window.removeEventListener('resize', listener);
|
|
@@ -10663,6 +10664,10 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
10663
10664
|
var _props$fields = props.fields,
|
|
10664
10665
|
fields = _props$fields === void 0 ? [] : _props$fields,
|
|
10665
10666
|
stateOnChange = props.stateOnChange;
|
|
10667
|
+
var id = props.id,
|
|
10668
|
+
className = props.className,
|
|
10669
|
+
htmlProps = props.htmlProps,
|
|
10670
|
+
rest = tslib.__rest(props, ["id", "className", "htmlProps"]);
|
|
10666
10671
|
var _useState = React.useState({}),
|
|
10667
10672
|
_useState2 = _slicedToArray(_useState, 2),
|
|
10668
10673
|
myState = _useState2[0],
|
|
@@ -10719,6 +10724,26 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
10719
10724
|
key: index,
|
|
10720
10725
|
onChange: fieldOnChange
|
|
10721
10726
|
}));
|
|
10727
|
+
case 'DescriptionList':
|
|
10728
|
+
return /*#__PURE__*/React.createElement(DescriptionList, Object.assign({}, field.props, {
|
|
10729
|
+
key: index
|
|
10730
|
+
}), field.children.map(function (child, childIndex) {
|
|
10731
|
+
return !child.hide && GetComponent(child, childIndex);
|
|
10732
|
+
}));
|
|
10733
|
+
case 'DescriptionListGroup':
|
|
10734
|
+
return /*#__PURE__*/React.createElement(DescriptionListGroup, Object.assign({}, field.props, {
|
|
10735
|
+
key: index
|
|
10736
|
+
}), field.children.map(function (child, childIndex) {
|
|
10737
|
+
return !child.hide && GetComponent(child, childIndex);
|
|
10738
|
+
}));
|
|
10739
|
+
case 'DescriptionListDesc':
|
|
10740
|
+
return /*#__PURE__*/React.createElement(DescriptionListDesc, Object.assign({}, field.props, {
|
|
10741
|
+
key: index
|
|
10742
|
+
}), field.innerHTML);
|
|
10743
|
+
case 'DescriptionListTerm':
|
|
10744
|
+
return /*#__PURE__*/React.createElement(DescriptionListTerm, Object.assign({}, field.props, {
|
|
10745
|
+
key: index
|
|
10746
|
+
}), field.innerHTML);
|
|
10722
10747
|
case 'Divider':
|
|
10723
10748
|
return /*#__PURE__*/React.createElement(Divider, Object.assign({}, field.props, {
|
|
10724
10749
|
key: index
|
|
@@ -10816,7 +10841,7 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
10816
10841
|
return obj.rowType !== undefined;
|
|
10817
10842
|
};
|
|
10818
10843
|
var screenSize = useScreenSize();
|
|
10819
|
-
return jsxRuntime.jsx(Grid, Object.assign({
|
|
10844
|
+
return jsxRuntime.jsx(Grid, Object.assign({}, getBaseHTMLProps(id, className, htmlProps, rest), {
|
|
10820
10845
|
as: "form",
|
|
10821
10846
|
rowGap: formGeneratorTokens.rowGaps
|
|
10822
10847
|
}, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { __rest } from 'tslib';
|
|
2
3
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
4
|
import { useState, createElement } from 'react';
|
|
4
5
|
import { Button } from '../Button/Button.js';
|
|
@@ -9,6 +10,10 @@ import '../Card/CardAccordion/CardAccordionBody.js';
|
|
|
9
10
|
import { Checkbox } from '../Checkbox/Checkbox.js';
|
|
10
11
|
import { CheckboxGroup } from '../Checkbox/CheckboxGroup.js';
|
|
11
12
|
import { Datepicker } from '../Datepicker/Datepicker.js';
|
|
13
|
+
import { DescriptionList } from '../DescriptionList/DescriptionList.js';
|
|
14
|
+
import { DescriptionListTerm } from '../DescriptionList/DescriptionListTerm.js';
|
|
15
|
+
import { DescriptionListDesc } from '../DescriptionList/DescriptionListDesc.js';
|
|
16
|
+
import { DescriptionListGroup } from '../DescriptionList/DescriptionListGroup.js';
|
|
12
17
|
import { Divider } from '../Divider/Divider.js';
|
|
13
18
|
import { GlobalMessage } from '../GlobalMessage/GlobalMessage.js';
|
|
14
19
|
import { InputMessage } from '../InputMessage/InputMessage.js';
|
|
@@ -27,7 +32,7 @@ import { Label } from '../Typography/Label/Label.js';
|
|
|
27
32
|
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
28
33
|
import { Heading } from '../Typography/Heading/Heading.js';
|
|
29
34
|
import { Link } from '../Typography/Link/Link.js';
|
|
30
|
-
import '
|
|
35
|
+
import { getBaseHTMLProps } from '../../types/BaseComponentProps.js';
|
|
31
36
|
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.js';
|
|
32
37
|
import { Grid } from '../Grid/Grid.js';
|
|
33
38
|
import { GridChild } from '../Grid/GridChild.js';
|
|
@@ -39,6 +44,10 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
39
44
|
var _props$fields = props.fields,
|
|
40
45
|
fields = _props$fields === void 0 ? [] : _props$fields,
|
|
41
46
|
stateOnChange = props.stateOnChange;
|
|
47
|
+
var id = props.id,
|
|
48
|
+
className = props.className,
|
|
49
|
+
htmlProps = props.htmlProps,
|
|
50
|
+
rest = __rest(props, ["id", "className", "htmlProps"]);
|
|
42
51
|
var _useState = useState({}),
|
|
43
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
53
|
myState = _useState2[0],
|
|
@@ -95,6 +104,26 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
95
104
|
key: index,
|
|
96
105
|
onChange: fieldOnChange
|
|
97
106
|
}));
|
|
107
|
+
case 'DescriptionList':
|
|
108
|
+
return /*#__PURE__*/createElement(DescriptionList, Object.assign({}, field.props, {
|
|
109
|
+
key: index
|
|
110
|
+
}), field.children.map(function (child, childIndex) {
|
|
111
|
+
return !child.hide && GetComponent(child, childIndex);
|
|
112
|
+
}));
|
|
113
|
+
case 'DescriptionListGroup':
|
|
114
|
+
return /*#__PURE__*/createElement(DescriptionListGroup, Object.assign({}, field.props, {
|
|
115
|
+
key: index
|
|
116
|
+
}), field.children.map(function (child, childIndex) {
|
|
117
|
+
return !child.hide && GetComponent(child, childIndex);
|
|
118
|
+
}));
|
|
119
|
+
case 'DescriptionListDesc':
|
|
120
|
+
return /*#__PURE__*/createElement(DescriptionListDesc, Object.assign({}, field.props, {
|
|
121
|
+
key: index
|
|
122
|
+
}), field.innerHTML);
|
|
123
|
+
case 'DescriptionListTerm':
|
|
124
|
+
return /*#__PURE__*/createElement(DescriptionListTerm, Object.assign({}, field.props, {
|
|
125
|
+
key: index
|
|
126
|
+
}), field.innerHTML);
|
|
98
127
|
case 'Divider':
|
|
99
128
|
return /*#__PURE__*/createElement(Divider, Object.assign({}, field.props, {
|
|
100
129
|
key: index
|
|
@@ -192,7 +221,7 @@ var FormGenerator = function FormGenerator(props) {
|
|
|
192
221
|
return obj.rowType !== undefined;
|
|
193
222
|
};
|
|
194
223
|
var screenSize = useScreenSize();
|
|
195
|
-
return jsx(Grid, Object.assign({
|
|
224
|
+
return jsx(Grid, Object.assign({}, getBaseHTMLProps(id, className, htmlProps, rest), {
|
|
196
225
|
as: "form",
|
|
197
226
|
rowGap: formGeneratorTokens.rowGaps
|
|
198
227
|
}, {
|
|
@@ -4,6 +4,7 @@ import { ButtonProps } from '../Button';
|
|
|
4
4
|
import { CardProps } from '../Card';
|
|
5
5
|
import { CheckboxGroupProps, CheckboxProps } from '../Checkbox';
|
|
6
6
|
import { DatepickerProps } from '../Datepicker';
|
|
7
|
+
import { DescriptionListProps, DescriptionListDescProps, DescriptionListGroupProps, DescriptionListTermProps } from '../DescriptionList';
|
|
7
8
|
import { DividerProps } from '../Divider';
|
|
8
9
|
import { GlobalMessageProps } from '../GlobalMessage';
|
|
9
10
|
import { InputMessageProps } from '../InputMessage';
|
|
@@ -28,8 +29,8 @@ export declare type FormGeneratorRow = {
|
|
|
28
29
|
fields: FormGeneratorField[];
|
|
29
30
|
};
|
|
30
31
|
export declare type FormGeneratorField = FieldWithChildren | FieldWithoutChildren;
|
|
31
|
-
declare type FieldWithChildren = CheckboxGroupField | ListField | RadioButtonGroupField | ToggleButtonGroupField;
|
|
32
|
-
declare type FieldWithoutChildren = ButtonField | CardField | CheckboxField | DatepickerField | DividerField | GlobalMessageField | HeadingField | InputMessageField | LabelField | LinkField | ListItemField | LocalMessageField | ParagraphField | RadioButtonField | SelectField | SpinnerField | TextInputField | ToggleButtonField | TypographyField | VisuallyHiddenField;
|
|
32
|
+
declare type FieldWithChildren = CheckboxGroupField | DescriptionListField | DescriptionListGroupField | ListField | RadioButtonGroupField | ToggleButtonGroupField;
|
|
33
|
+
declare type FieldWithoutChildren = ButtonField | CardField | CheckboxField | DatepickerField | DescriptionListTermField | DescriptionListDescField | DividerField | GlobalMessageField | HeadingField | InputMessageField | LabelField | LinkField | ListItemField | LocalMessageField | ParagraphField | RadioButtonField | SelectField | SpinnerField | TextInputField | ToggleButtonField | TypographyField | VisuallyHiddenField;
|
|
33
34
|
declare type ButtonField = {
|
|
34
35
|
component: 'Button';
|
|
35
36
|
props: ButtonProps;
|
|
@@ -57,6 +58,30 @@ declare type DatepickerField = {
|
|
|
57
58
|
props: DatepickerProps;
|
|
58
59
|
hide?: boolean;
|
|
59
60
|
};
|
|
61
|
+
declare type DescriptionListField = {
|
|
62
|
+
component: 'DescriptionList';
|
|
63
|
+
props: DescriptionListProps;
|
|
64
|
+
hide?: boolean;
|
|
65
|
+
children: DescriptionListGroupField[];
|
|
66
|
+
};
|
|
67
|
+
declare type DescriptionListGroupField = {
|
|
68
|
+
component: 'DescriptionListGroup';
|
|
69
|
+
props: DescriptionListGroupProps;
|
|
70
|
+
hide?: boolean;
|
|
71
|
+
children: (DescriptionListTermField | DescriptionListDescField)[];
|
|
72
|
+
};
|
|
73
|
+
declare type DescriptionListTermField = {
|
|
74
|
+
component: 'DescriptionListTerm';
|
|
75
|
+
props: DescriptionListTermProps;
|
|
76
|
+
hide?: boolean;
|
|
77
|
+
innerHTML: JSX.Element | string;
|
|
78
|
+
};
|
|
79
|
+
declare type DescriptionListDescField = {
|
|
80
|
+
component: 'DescriptionListDesc';
|
|
81
|
+
props: DescriptionListDescProps;
|
|
82
|
+
hide?: boolean;
|
|
83
|
+
innerHTML: JSX.Element | string;
|
|
84
|
+
};
|
|
60
85
|
declare type DividerField = {
|
|
61
86
|
component: 'Divider';
|
|
62
87
|
props: DividerProps;
|