@developer-overheid-nl/don-register-components 1.3.0 → 1.6.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/CHANGELOG.md +170 -118
- package/LICENSE.md +291 -291
- package/README.md +20 -20
- package/package.json +10 -8
- package/src/Introduction.mdx +31 -0
- package/src/alert/Alert.stories.tsx +57 -0
- package/src/alert/Alert.tsx +19 -19
- package/src/alert/styles.module.css +3 -3
- package/src/alignBox/AlignBox.stories.tsx +84 -0
- package/src/alignBox/AlignBox.tsx +114 -114
- package/src/alignBox/styles.module.css +110 -110
- package/src/amountLabel/AmountLabel.stories.tsx +28 -0
- package/src/amountLabel/AmountLabel.tsx +21 -16
- package/src/amountLabel/styles.module.css +11 -11
- package/src/analytics/PiwikPro.tsx +94 -94
- package/src/analytics/index.ts +1 -1
- package/src/article/Article.stories.tsx +53 -0
- package/src/article/Article.tsx +10 -10
- package/src/badgeList/BadgeList.tsx +34 -34
- package/src/badgeList/styles.module.css +37 -37
- package/src/block/Block.stories.tsx +58 -0
- package/src/block/Block.tsx +35 -35
- package/src/block/styles.module.css +29 -29
- package/src/button/Button.stories.tsx +56 -0
- package/src/button/Button.tsx +3 -3
- package/src/button/ButtonAction.stories.tsx +62 -0
- package/src/button/ButtonAction.tsx +51 -0
- package/src/cardAsLink/CardAsLink.stories.tsx +81 -0
- package/src/cardAsLink/CardAsLink.tsx +21 -21
- package/src/cardAsLink/styles.module.css +23 -23
- package/src/cardsList/CardsList.tsx +56 -54
- package/src/cardsList/styles.module.css +18 -19
- package/src/client.ts +7 -7
- package/src/container/Container.stories.tsx +21 -0
- package/src/container/Container.tsx +10 -10
- package/src/container/styles.module.css +28 -28
- package/src/copyButton/CopyButton.stories.tsx +41 -0
- package/src/copyButton/CopyButton.tsx +45 -39
- package/src/copyButton/styles.module.css +13 -13
- package/src/dataBadgeLink/DataBadgeLink.stories.tsx +137 -0
- package/src/dataBadgeLink/DataBadgeLink.tsx +59 -53
- package/src/dataBadgeLink/styles.module.css +89 -89
- package/src/dataSummary/DataSummary.tsx +22 -22
- package/src/dataSummary/DataSummaryItem.tsx +21 -21
- package/src/dataSummary/styles.module.css +75 -75
- package/src/facetFilters/FacetFilters.stories.tsx +93 -0
- package/src/facetFilters/FacetFilters.tsx +424 -367
- package/src/facetFilters/styles.module.css +3 -3
- package/src/fieldset/FieldSet.stories.tsx +45 -0
- package/src/fieldset/FieldSet.tsx +3 -3
- package/src/filters/Filters.stories.tsx +45 -0
- package/src/filters/Filters.tsx +116 -116
- package/src/filters/styles.module.css +26 -26
- package/src/footer/Footer.stories.tsx +127 -0
- package/src/footer/Footer.tsx +81 -76
- package/src/footer/styles.module.css +103 -103
- package/src/formFieldCheckboxGroup/FormFieldCheckboxGroup.stories.tsx +48 -0
- package/src/formFieldCheckboxGroup/FormFieldCheckboxGroup.tsx +16 -16
- package/src/formFieldCheckboxGroup/styles.module.css +5 -5
- package/src/formFieldCheckboxOption/FormFieldCheckboxOption.stories.tsx +61 -0
- package/src/formFieldCheckboxOption/FormFieldCheckboxOption.tsx +26 -26
- package/src/formFieldCheckboxOption/styles.module.css +22 -22
- package/src/formFieldLabel/FormFieldLabel.stories.tsx +21 -0
- package/src/formFieldLabel/FormFieldLabel.tsx +23 -23
- package/src/formFieldRadioGroup/FormFieldRadioGroup.stories.tsx +57 -0
- package/src/formFieldRadioGroup/FormFieldRadioGroup.tsx +13 -13
- package/src/formFieldRadioGroup/styles.module.css +5 -5
- package/src/formFieldRadioOption/FormFieldRadioOption.stories.tsx +48 -0
- package/src/formFieldRadioOption/FormFieldRadioOption.tsx +75 -75
- package/src/formFieldRadioOption/styles.module.css +49 -49
- package/src/formFieldSwitch/FormFieldSwitch.stories.tsx +61 -0
- package/src/formFieldSwitch/FormFieldSwitch.tsx +82 -79
- package/src/formFieldSwitch/styles.module.css +32 -32
- package/src/formFieldTextInput/FormFieldTextInput.stories.tsx +45 -0
- package/src/formFieldTextInput/FormFieldTextInput.tsx +3 -3
- package/src/grid/Grid.stories.tsx +37 -0
- package/src/grid/Grid.tsx +48 -0
- package/src/grid/styles.module.css +24 -0
- package/src/header/Header.stories.tsx +54 -0
- package/src/header/Header.tsx +137 -137
- package/src/header/styles.module.css +71 -71
- package/src/heading/Heading.stories.tsx +60 -0
- package/src/heading/Heading.tsx +15 -15
- package/src/headingGroup/HeadingGroup.stories.tsx +57 -0
- package/src/headingGroup/HeadingGroup.tsx +48 -48
- package/src/headingGroup/styles.module.css +3 -3
- package/src/i18n.ts +24 -25
- package/src/iconBadge/IconBadge.stories.tsx +46 -0
- package/src/iconBadge/IconBadge.tsx +35 -35
- package/src/iconBadge/getAppearance.ts +53 -53
- package/src/iconBadge/styles.module.css +19 -19
- package/src/iconsSprite/Icon.stories.tsx +73 -0
- package/src/iconsSprite/Icon.tsx +17 -17
- package/src/iconsSprite/IconsSprite.tsx +5 -5
- package/src/index.ts +117 -107
- package/src/infoButton/InfoButton.stories.tsx +52 -0
- package/src/infoButton/InfoButton.tsx +45 -45
- package/src/infoButton/styles.module.css +43 -43
- package/src/link/Link.stories.tsx +49 -0
- package/src/link/Link.tsx +10 -10
- package/src/markdown/Markdown.stories.tsx +48 -0
- package/src/markdown/Markdown.tsx +42 -42
- package/src/overlay/Overlay.stories.tsx +38 -0
- package/src/overlay/Overlay.tsx +18 -18
- package/src/overlay/styles.module.css +15 -15
- package/src/pagination/Pagination.stories.tsx +91 -0
- package/src/pagination/Pagination.tsx +267 -267
- package/src/pagination/styles.module.css +28 -28
- package/src/paragraph/Paragraph.stories.tsx +45 -0
- package/src/paragraph/Paragraph.tsx +24 -24
- package/src/paragraph/styles.module.css +6 -6
- package/src/pillBadge/PillBadge.examples.tsx +107 -107
- package/src/pillBadge/PillBadge.stories.tsx +257 -0
- package/src/pillBadge/PillBadge.tsx +60 -51
- package/src/pillBadge/styles.module.css +214 -214
- package/src/readOnlyTextInput/ReadOnlyTextInput.stories.tsx +49 -0
- package/src/readOnlyTextInput/ReadOnlyTextInput.tsx +24 -24
- package/src/readOnlyTextInput/styles.module.css +19 -19
- package/src/scoreBadge/ScoreBadge.stories.tsx +45 -0
- package/src/scoreBadge/ScoreBadge.tsx +135 -133
- package/src/search/Search.stories.tsx +65 -0
- package/src/search/Search.tsx +82 -82
- package/src/search/styles.module.css +40 -39
- package/src/siteLogo/ExampleLogo.stories.tsx +40 -0
- package/src/siteLogo/SiteLogo.stories.tsx +28 -0
- package/src/siteLogo/SiteLogo.tsx +24 -24
- package/src/sortForm/SortForm.stories.tsx +111 -0
- package/src/sortForm/SortForm.tsx +121 -0
- package/src/sortForm/styles.module.css +40 -0
- package/src/switch/Switch.stories.tsx +68 -0
- package/src/switch/Switch.tsx +152 -86
- package/src/switch/styles.module.css +54 -7
- package/src/toolTip/ToolTip.stories.tsx +131 -0
- package/src/toolTip/ToolTip.tsx +55 -55
- package/src/toolTip/styles.module.css +49 -49
- package/src/topNavigation/TopNavigation.stories.tsx +71 -0
- package/src/topNavigation/TopNavigation.tsx +67 -67
- package/src/topNavigation/styles.module.css +54 -54
- package/tsconfig.json +122 -121
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CustomFormFieldProps,
|
|
3
|
-
FormField,
|
|
4
|
-
Radio as RHCRadio,
|
|
5
|
-
} from "@rijkshuisstijl-community/components-react";
|
|
6
|
-
import clsx from "clsx";
|
|
7
|
-
import { Fragment, useId } from "react";
|
|
8
|
-
import AmountLabel, { type AmountLabelProps } from "../amountLabel/AmountLabel";
|
|
9
|
-
import styles from "./styles.module.css";
|
|
10
|
-
|
|
11
|
-
export interface FormFieldRadioOptionProps
|
|
12
|
-
extends Omit<
|
|
13
|
-
CustomFormFieldProps,
|
|
14
|
-
"label" | "statusId" | "errorMessageId" | "descriptionId" | "input"
|
|
15
|
-
>,
|
|
16
|
-
AmountLabelProps {
|
|
17
|
-
name: string;
|
|
18
|
-
value: string;
|
|
19
|
-
checked?: boolean;
|
|
20
|
-
defaultChecked?: boolean;
|
|
21
|
-
statusId?: CustomFormFieldProps["statusId"];
|
|
22
|
-
errorMessageId?: CustomFormFieldProps["errorMessageId"];
|
|
23
|
-
descriptionId?: CustomFormFieldProps["descriptionId"];
|
|
24
|
-
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const FormFieldRadioOption = (props: FormFieldRadioOptionProps) => {
|
|
28
|
-
const genId = useId();
|
|
29
|
-
const {
|
|
30
|
-
id = genId,
|
|
31
|
-
statusId = genId,
|
|
32
|
-
errorMessageId = genId,
|
|
33
|
-
descriptionId = genId,
|
|
34
|
-
name,
|
|
35
|
-
value,
|
|
36
|
-
defaultChecked,
|
|
37
|
-
checked,
|
|
38
|
-
amount,
|
|
39
|
-
label,
|
|
40
|
-
className,
|
|
41
|
-
children,
|
|
42
|
-
onChange,
|
|
43
|
-
...restProps
|
|
44
|
-
} = props;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<FormField
|
|
48
|
-
type="radio" // although not exposed by RHC
|
|
49
|
-
className={clsx("utrecht-form-field--radio", styles.radio, className)}
|
|
50
|
-
statusId={statusId}
|
|
51
|
-
errorMessageId={errorMessageId}
|
|
52
|
-
descriptionId={descriptionId}
|
|
53
|
-
label={
|
|
54
|
-
<Fragment>
|
|
55
|
-
<RHCRadio
|
|
56
|
-
id={id}
|
|
57
|
-
name={name}
|
|
58
|
-
value={value}
|
|
59
|
-
checked={checked}
|
|
60
|
-
defaultChecked={defaultChecked}
|
|
61
|
-
className="utrecht-checkbox--custom utrecht-form-field__input"
|
|
62
|
-
onChange={onChange}
|
|
63
|
-
/>
|
|
64
|
-
<AmountLabel label={label} amount={amount} />
|
|
65
|
-
</Fragment>
|
|
66
|
-
}
|
|
67
|
-
input={null}
|
|
68
|
-
{...restProps}
|
|
69
|
-
>
|
|
70
|
-
<span className={styles.info}>{children}</span>
|
|
71
|
-
</FormField>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default FormFieldRadioOption;
|
|
1
|
+
import {
|
|
2
|
+
type CustomFormFieldProps,
|
|
3
|
+
FormField,
|
|
4
|
+
Radio as RHCRadio,
|
|
5
|
+
} from "@rijkshuisstijl-community/components-react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { Fragment, useId } from "react";
|
|
8
|
+
import AmountLabel, { type AmountLabelProps } from "../amountLabel/AmountLabel";
|
|
9
|
+
import styles from "./styles.module.css";
|
|
10
|
+
|
|
11
|
+
export interface FormFieldRadioOptionProps
|
|
12
|
+
extends Omit<
|
|
13
|
+
CustomFormFieldProps,
|
|
14
|
+
"label" | "statusId" | "errorMessageId" | "descriptionId" | "input"
|
|
15
|
+
>,
|
|
16
|
+
AmountLabelProps {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
defaultChecked?: boolean;
|
|
21
|
+
statusId?: CustomFormFieldProps["statusId"];
|
|
22
|
+
errorMessageId?: CustomFormFieldProps["errorMessageId"];
|
|
23
|
+
descriptionId?: CustomFormFieldProps["descriptionId"];
|
|
24
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const FormFieldRadioOption = (props: FormFieldRadioOptionProps) => {
|
|
28
|
+
const genId = useId();
|
|
29
|
+
const {
|
|
30
|
+
id = genId,
|
|
31
|
+
statusId = genId,
|
|
32
|
+
errorMessageId = genId,
|
|
33
|
+
descriptionId = genId,
|
|
34
|
+
name,
|
|
35
|
+
value,
|
|
36
|
+
defaultChecked,
|
|
37
|
+
checked,
|
|
38
|
+
amount,
|
|
39
|
+
label,
|
|
40
|
+
className,
|
|
41
|
+
children,
|
|
42
|
+
onChange,
|
|
43
|
+
...restProps
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<FormField
|
|
48
|
+
type="radio" // although not exposed by RHC
|
|
49
|
+
className={clsx("utrecht-form-field--radio", styles.radio, className)}
|
|
50
|
+
statusId={statusId}
|
|
51
|
+
errorMessageId={errorMessageId}
|
|
52
|
+
descriptionId={descriptionId}
|
|
53
|
+
label={
|
|
54
|
+
<Fragment>
|
|
55
|
+
<RHCRadio
|
|
56
|
+
id={id}
|
|
57
|
+
name={name}
|
|
58
|
+
value={value}
|
|
59
|
+
checked={checked}
|
|
60
|
+
defaultChecked={defaultChecked}
|
|
61
|
+
className="utrecht-checkbox--custom utrecht-form-field__input"
|
|
62
|
+
onChange={onChange}
|
|
63
|
+
/>
|
|
64
|
+
<AmountLabel label={label} amount={amount} />
|
|
65
|
+
</Fragment>
|
|
66
|
+
}
|
|
67
|
+
input={null}
|
|
68
|
+
{...restProps}
|
|
69
|
+
>
|
|
70
|
+
<span className={styles.info}>{children}</span>
|
|
71
|
+
</FormField>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default FormFieldRadioOption;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
.radio.radio {
|
|
2
|
-
--utrecht-form-field-label-margin-block-end: 0;
|
|
3
|
-
|
|
4
|
-
grid-template-areas:
|
|
5
|
-
'input label info'
|
|
6
|
-
'input description description'
|
|
7
|
-
'input error-message error-message'
|
|
8
|
-
'input status status';
|
|
9
|
-
|
|
10
|
-
:global(.utrecht-form-field--radio .utrecht-form-field__label) {
|
|
11
|
-
display: block;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:global(.utrecht-form-label) {
|
|
15
|
-
/* like checkbox */
|
|
16
|
-
display: flex;
|
|
17
|
-
font-weight: var(
|
|
18
|
-
--utrecht-form-label-checkbox-font-weight,
|
|
19
|
-
var(--utrecht-form-label-font-weight)
|
|
20
|
-
);
|
|
21
|
-
color: var(
|
|
22
|
-
--utrecht-form-label-checkbox-color,
|
|
23
|
-
var(--utrecht-form-label-color)
|
|
24
|
-
);
|
|
25
|
-
cursor: var(--utrecht-action-activate-cursor, revert);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
:global(.utrecht-radio-button) {
|
|
29
|
-
order: initial;
|
|
30
|
-
margin-block-start: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:global(
|
|
34
|
-
.utrecht-form-field--radio
|
|
35
|
-
|
|
36
|
-
) {
|
|
37
|
-
margin-inline-start: calc(
|
|
38
|
-
-1 *
|
|
39
|
-
(
|
|
40
|
-
var(--utrecht-radio-button-size) +
|
|
41
|
-
var(--utrecht-checkbox-margin-inline-end, 12px)
|
|
42
|
-
)
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.info {
|
|
48
|
-
grid-area: info;
|
|
49
|
-
}
|
|
1
|
+
.radio.radio {
|
|
2
|
+
--utrecht-form-field-label-margin-block-end: 0;
|
|
3
|
+
|
|
4
|
+
grid-template-areas:
|
|
5
|
+
'input label info'
|
|
6
|
+
'input description description'
|
|
7
|
+
'input error-message error-message'
|
|
8
|
+
'input status status';
|
|
9
|
+
|
|
10
|
+
:global(.utrecht-form-field--radio .utrecht-form-field__label) {
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:global(.utrecht-form-label) {
|
|
15
|
+
/* like checkbox */
|
|
16
|
+
display: flex;
|
|
17
|
+
font-weight: var(
|
|
18
|
+
--utrecht-form-label-checkbox-font-weight,
|
|
19
|
+
var(--utrecht-form-label-font-weight)
|
|
20
|
+
);
|
|
21
|
+
color: var(
|
|
22
|
+
--utrecht-form-label-checkbox-color,
|
|
23
|
+
var(--utrecht-form-label-color)
|
|
24
|
+
);
|
|
25
|
+
cursor: var(--utrecht-action-activate-cursor, revert);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:global(.utrecht-radio-button) {
|
|
29
|
+
order: initial;
|
|
30
|
+
margin-block-start: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:global(
|
|
34
|
+
.utrecht-form-field--radio
|
|
35
|
+
.utrecht-form-field__label:has(.utrecht-form-field__input)
|
|
36
|
+
) {
|
|
37
|
+
margin-inline-start: calc(
|
|
38
|
+
-1 *
|
|
39
|
+
(
|
|
40
|
+
var(--utrecht-radio-button-size) +
|
|
41
|
+
var(--utrecht-checkbox-margin-inline-end, 12px)
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.info {
|
|
48
|
+
grid-area: info;
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import FormFieldSwitch from "./FormFieldSwitch";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FormFieldSwitch is een aan/uit-schakelaar binnen een formulierveld,
|
|
6
|
+
* bijvoorbeeld voor een boolean filter. Ondersteunt een `explicit`-modus met
|
|
7
|
+
* twee losse radio-opties (aan/uit) in plaats van één toggle.
|
|
8
|
+
*/
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "Components/Form/FormFieldSwitch",
|
|
11
|
+
component: FormFieldSwitch,
|
|
12
|
+
tags: ["autodocs", "custom"],
|
|
13
|
+
args: {
|
|
14
|
+
label: "",
|
|
15
|
+
labelledById: "publiccode-label",
|
|
16
|
+
labels: { on: "Aan", off: "Uit" },
|
|
17
|
+
name: "publiccode",
|
|
18
|
+
value: "true",
|
|
19
|
+
},
|
|
20
|
+
argTypes: {
|
|
21
|
+
checked: { control: "boolean" },
|
|
22
|
+
defaultChecked: { control: "boolean" },
|
|
23
|
+
explicit: { control: "boolean" },
|
|
24
|
+
},
|
|
25
|
+
decorators: [
|
|
26
|
+
(Story) => (
|
|
27
|
+
<>
|
|
28
|
+
<span id="publiccode-label" className="utrecht-form-label">
|
|
29
|
+
Heeft publiccode.yml
|
|
30
|
+
</span>
|
|
31
|
+
<Story />
|
|
32
|
+
</>
|
|
33
|
+
),
|
|
34
|
+
],
|
|
35
|
+
} satisfies Meta<typeof FormFieldSwitch>;
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
|
|
40
|
+
export const Default: Story = {};
|
|
41
|
+
|
|
42
|
+
export const WithAmount: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
amount: 9,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const CheckedOn: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
amount: 9,
|
|
51
|
+
defaultChecked: true,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Explicit: Story = {
|
|
56
|
+
name: "Explicit (aan/uit als losse opties)",
|
|
57
|
+
args: {
|
|
58
|
+
explicit: true,
|
|
59
|
+
value: ["true", "false"],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -1,79 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CustomFormFieldProps,
|
|
3
|
-
FormField,
|
|
4
|
-
} from "@rijkshuisstijl-community/components-react";
|
|
5
|
-
import clsx from "clsx";
|
|
6
|
-
import { useId } from "react";
|
|
7
|
-
import AmountLabel, { type AmountLabelProps } from "../amountLabel/AmountLabel";
|
|
8
|
-
import Switch, { type SwitchLabels } from "../switch/Switch";
|
|
9
|
-
import styles from "./styles.module.css";
|
|
10
|
-
|
|
11
|
-
export interface FormFieldSwitchProps
|
|
12
|
-
extends Omit<
|
|
13
|
-
CustomFormFieldProps,
|
|
14
|
-
"label" | "statusId" | "errorMessageId" | "descriptionId" | "input"
|
|
15
|
-
>,
|
|
16
|
-
AmountLabelProps {
|
|
17
|
-
name
|
|
18
|
-
value: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
import {
|
|
2
|
+
type CustomFormFieldProps,
|
|
3
|
+
FormField,
|
|
4
|
+
} from "@rijkshuisstijl-community/components-react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import AmountLabel, { type AmountLabelProps } from "../amountLabel/AmountLabel";
|
|
8
|
+
import Switch, { type SwitchLabels } from "../switch/Switch";
|
|
9
|
+
import styles from "./styles.module.css";
|
|
10
|
+
|
|
11
|
+
export interface FormFieldSwitchProps
|
|
12
|
+
extends Omit<
|
|
13
|
+
CustomFormFieldProps,
|
|
14
|
+
"label" | "statusId" | "errorMessageId" | "descriptionId" | "input"
|
|
15
|
+
>,
|
|
16
|
+
AmountLabelProps {
|
|
17
|
+
name?: string;
|
|
18
|
+
value: string | string[];
|
|
19
|
+
explicit?: boolean;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
defaultChecked?: boolean;
|
|
22
|
+
statusId?: CustomFormFieldProps["statusId"];
|
|
23
|
+
errorMessageId?: CustomFormFieldProps["errorMessageId"];
|
|
24
|
+
descriptionId?: CustomFormFieldProps["descriptionId"];
|
|
25
|
+
labelledById?: string;
|
|
26
|
+
labels?: SwitchLabels;
|
|
27
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const FormFieldSwitch = (props: FormFieldSwitchProps) => {
|
|
31
|
+
const genId = useId();
|
|
32
|
+
const {
|
|
33
|
+
id = genId,
|
|
34
|
+
statusId = genId,
|
|
35
|
+
errorMessageId = genId,
|
|
36
|
+
descriptionId = genId,
|
|
37
|
+
labelledById,
|
|
38
|
+
name,
|
|
39
|
+
value,
|
|
40
|
+
explicit,
|
|
41
|
+
defaultChecked,
|
|
42
|
+
checked,
|
|
43
|
+
amount,
|
|
44
|
+
label,
|
|
45
|
+
labels,
|
|
46
|
+
onChange,
|
|
47
|
+
className,
|
|
48
|
+
children,
|
|
49
|
+
...restProps
|
|
50
|
+
} = props;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<FormField
|
|
54
|
+
id={id}
|
|
55
|
+
type="checkbox"
|
|
56
|
+
className={clsx("utrecht-form-field--checkbox", styles.switch, className)}
|
|
57
|
+
statusId={statusId}
|
|
58
|
+
errorMessageId={errorMessageId}
|
|
59
|
+
descriptionId={descriptionId}
|
|
60
|
+
label={<AmountLabel label={label} amount={amount} />}
|
|
61
|
+
input={
|
|
62
|
+
<Switch
|
|
63
|
+
id={id}
|
|
64
|
+
name={name}
|
|
65
|
+
value={value}
|
|
66
|
+
explicit={explicit}
|
|
67
|
+
checked={checked}
|
|
68
|
+
defaultChecked={defaultChecked}
|
|
69
|
+
className="utrecht-form-field__input"
|
|
70
|
+
labels={labels}
|
|
71
|
+
aria-labelledby={`${labelledById} ${id}`}
|
|
72
|
+
onChange={onChange}
|
|
73
|
+
/>
|
|
74
|
+
}
|
|
75
|
+
{...restProps}
|
|
76
|
+
>
|
|
77
|
+
<span className={styles.info}>{children}</span>
|
|
78
|
+
</FormField>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default FormFieldSwitch;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
.switch.switch {
|
|
2
|
-
--utrecht-form-field-label-margin-block-end: 0;
|
|
3
|
-
--utrecht-checkbox-size: var(--utrecht-form-toggle-width);
|
|
4
|
-
|
|
5
|
-
grid-template-areas:
|
|
6
|
-
'input label info'
|
|
7
|
-
'input description description'
|
|
8
|
-
'input error-message error-message'
|
|
9
|
-
'input status status';
|
|
10
|
-
|
|
11
|
-
:global(.utrecht-form-field--radio .utrecht-form-field__label) {
|
|
12
|
-
display: block;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:global(.utrecht-form-label) {
|
|
16
|
-
/* like checkbox */
|
|
17
|
-
display: flex;
|
|
18
|
-
font-weight: var(
|
|
19
|
-
--utrecht-form-label-checkbox-font-weight,
|
|
20
|
-
var(--utrecht-form-label-font-weight)
|
|
21
|
-
);
|
|
22
|
-
color: var(
|
|
23
|
-
--utrecht-form-label-checkbox-color,
|
|
24
|
-
var(--utrecht-form-label-color)
|
|
25
|
-
);
|
|
26
|
-
cursor: var(--utrecht-action-activate-cursor, revert);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.info {
|
|
31
|
-
grid-area: info;
|
|
32
|
-
}
|
|
1
|
+
.switch.switch {
|
|
2
|
+
--utrecht-form-field-label-margin-block-end: 0;
|
|
3
|
+
--utrecht-checkbox-size: var(--utrecht-form-toggle-width);
|
|
4
|
+
|
|
5
|
+
grid-template-areas:
|
|
6
|
+
'input label info'
|
|
7
|
+
'input description description'
|
|
8
|
+
'input error-message error-message'
|
|
9
|
+
'input status status';
|
|
10
|
+
|
|
11
|
+
:global(.utrecht-form-field--radio .utrecht-form-field__label) {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:global(.utrecht-form-label) {
|
|
16
|
+
/* like checkbox */
|
|
17
|
+
display: flex;
|
|
18
|
+
font-weight: var(
|
|
19
|
+
--utrecht-form-label-checkbox-font-weight,
|
|
20
|
+
var(--utrecht-form-label-font-weight)
|
|
21
|
+
);
|
|
22
|
+
color: var(
|
|
23
|
+
--utrecht-form-label-checkbox-color,
|
|
24
|
+
var(--utrecht-form-label-color)
|
|
25
|
+
);
|
|
26
|
+
cursor: var(--utrecht-action-activate-cursor, revert);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.info {
|
|
31
|
+
grid-area: info;
|
|
32
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import FormFieldTextInput from "./FormFieldTextInput";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FormFieldTextInput is een tekstinvoerveld met label, beschrijving en
|
|
6
|
+
* foutmelding.
|
|
7
|
+
*/
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Components/Form/FormFieldTextInput",
|
|
10
|
+
component: FormFieldTextInput,
|
|
11
|
+
tags: ["autodocs", "re-export"],
|
|
12
|
+
args: {
|
|
13
|
+
label: "E-mailadres",
|
|
14
|
+
placeholder: "naam@voorbeeld.nl",
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
disabled: { control: "boolean" },
|
|
18
|
+
invalid: { control: "boolean" },
|
|
19
|
+
required: { control: "boolean" },
|
|
20
|
+
},
|
|
21
|
+
} satisfies Meta<typeof FormFieldTextInput>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {};
|
|
27
|
+
|
|
28
|
+
export const WithDescription: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
description: "We gebruiken dit e-mailadres alleen om contact op te nemen.",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Invalid: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
invalid: true,
|
|
37
|
+
errorMessage: "Vul een geldig e-mailadres in.",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Disabled: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
disabled: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FormFieldTextInput } from "@rijkshuisstijl-community/components-react";
|
|
2
|
-
|
|
3
|
-
export default FormFieldTextInput;
|
|
1
|
+
import { FormFieldTextInput } from "@rijkshuisstijl-community/components-react";
|
|
2
|
+
|
|
3
|
+
export default FormFieldTextInput;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import Grid from "./Grid";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Grid is een hulpcomponent voor een responsieve CSS-grid: kolommen vullen
|
|
6
|
+
* automatisch aan op basis van `minColumnWidth`, met een gap-schaal
|
|
7
|
+
* (`none`, `small`, `medium`, `large`).
|
|
8
|
+
*
|
|
9
|
+
* Wordt op dit moment alleen gebruikt in Storybook, nog niet in de
|
|
10
|
+
* registersites zelf.
|
|
11
|
+
*/
|
|
12
|
+
const meta = {
|
|
13
|
+
title: "Components/Grid",
|
|
14
|
+
component: Grid,
|
|
15
|
+
tags: ["autodocs", "code-only", "beta"],
|
|
16
|
+
argTypes: {
|
|
17
|
+
gap: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: ["none", "small", "medium", "large"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
args: {
|
|
23
|
+
minColumnWidth: "6rem",
|
|
24
|
+
gap: "medium",
|
|
25
|
+
children: Array.from({ length: 42 }, (_, index) => (
|
|
26
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: static placeholder list
|
|
27
|
+
<div key={index} style={{ background: "#e0e0e0", padding: "1rem" }}>
|
|
28
|
+
Item {index + 1}
|
|
29
|
+
</div>
|
|
30
|
+
)),
|
|
31
|
+
},
|
|
32
|
+
} satisfies Meta<typeof Grid>;
|
|
33
|
+
|
|
34
|
+
export default meta;
|
|
35
|
+
type Story = StoryObj<typeof meta>;
|
|
36
|
+
|
|
37
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
import styles from "./styles.module.css";
|
|
4
|
+
|
|
5
|
+
export interface GridProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
minColumnWidth?: string;
|
|
7
|
+
gap?: "none" | "small" | "medium" | "large";
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getGapClass = (gap: NonNullable<GridProps["gap"]>): string => {
|
|
12
|
+
switch (gap) {
|
|
13
|
+
case "none":
|
|
14
|
+
return styles.gapNone;
|
|
15
|
+
case "small":
|
|
16
|
+
return styles.gapSmall;
|
|
17
|
+
case "large":
|
|
18
|
+
return styles.gapLarge;
|
|
19
|
+
default:
|
|
20
|
+
return styles.gapMedium;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Grid = ({
|
|
25
|
+
minColumnWidth = "8rem",
|
|
26
|
+
gap = "medium",
|
|
27
|
+
className,
|
|
28
|
+
style,
|
|
29
|
+
children,
|
|
30
|
+
...restProps
|
|
31
|
+
}: GridProps) => {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
className={clsx(styles.grid, getGapClass(gap), className)}
|
|
35
|
+
style={
|
|
36
|
+
{
|
|
37
|
+
"--grid-min-column-width": minColumnWidth,
|
|
38
|
+
...style,
|
|
39
|
+
} as CSSProperties
|
|
40
|
+
}
|
|
41
|
+
{...restProps}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default Grid;
|