@developer-overheid-nl/don-register-components 1.0.1 → 1.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/package.json +11 -8
  3. package/src/alignBox/AlignBox.tsx +6 -2
  4. package/src/alignBox/styles.module.css +4 -0
  5. package/src/amountLabel/AmountLabel.tsx +16 -0
  6. package/src/amountLabel/styles.module.css +11 -0
  7. package/src/analytics/PiwikPro.tsx +94 -0
  8. package/src/analytics/index.ts +1 -0
  9. package/src/badgeList/BadgeList.tsx +26 -0
  10. package/src/badgeList/styles.module.css +24 -0
  11. package/src/client.ts +5 -0
  12. package/src/copyButton/CopyButton.tsx +6 -6
  13. package/src/dataBadgeLink/DataBadgeLink.tsx +3 -0
  14. package/src/dataBadgeLink/styles.module.css +26 -0
  15. package/src/dataSummary/styles.module.css +10 -5
  16. package/src/facetFilters/FacetFilters.tsx +313 -0
  17. package/src/facetFilters/styles.module.css +3 -0
  18. package/src/formFieldCheckboxGroup/FormFieldCheckboxGroup.tsx +16 -0
  19. package/src/formFieldCheckboxGroup/styles.module.css +5 -0
  20. package/src/formFieldCheckboxOption/FormFieldCheckboxOption.tsx +26 -0
  21. package/src/formFieldCheckboxOption/styles.module.css +22 -0
  22. package/src/formFieldRadioGroup/FormFieldRadioGroup.tsx +13 -0
  23. package/src/formFieldRadioGroup/styles.module.css +5 -0
  24. package/src/formFieldRadioOption/FormFieldRadioOption.tsx +75 -0
  25. package/src/formFieldRadioOption/styles.module.css +49 -0
  26. package/src/formFieldSwitch/FormFieldSwitch.tsx +79 -0
  27. package/src/formFieldSwitch/styles.module.css +32 -0
  28. package/src/heading/Heading.tsx +5 -0
  29. package/src/i18n.ts +1 -0
  30. package/src/iconBadge/IconBadge.tsx +3 -0
  31. package/src/iconBadge/getAppearance.ts +7 -1
  32. package/src/index.ts +27 -1
  33. package/src/infoButton/InfoButton.tsx +45 -0
  34. package/src/infoButton/styles.module.css +43 -0
  35. package/src/overlay/Overlay.tsx +18 -0
  36. package/src/overlay/styles.module.css +15 -0
  37. package/src/paragraph/Paragraph.tsx +16 -2
  38. package/src/paragraph/styles.module.css +6 -0
  39. package/src/pillBadge/styles.module.css +20 -0
  40. package/src/scoreBadge/ScoreBadge.tsx +1 -0
  41. package/src/switch/Switch.tsx +86 -0
  42. package/src/switch/styles.module.css +7 -0
  43. package/src/toolTip/ToolTip.tsx +55 -0
  44. package/src/toolTip/styles.module.css +48 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,85 @@
1
+ # @developer-overheid-nl/don-register-components
2
+
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b404400: Nieuwe components:
8
+
9
+ - FacetFilters, met de types:
10
+ - toggle: boolean filter (switch)
11
+ - multi-select: multiple options, multiple selectable (checkboxes)
12
+ - single-select: multiple options, single selectable (radiobuttons)
13
+ - AmountLabel: label with amount, used in FacetFilters
14
+ - FormFieldCheckboxGroup
15
+ - FormFieldCheckboxOption, with amount label
16
+ - FormFieldRadioGroup
17
+ - FormFieldRadioOption, with amount label
18
+ - Switch: toggle (checkbox)
19
+ - FormFieldSwitch, with amount label
20
+ - InfoButton
21
+ - Tooltip: html popover tooltip; default met InfoButton
22
+ - Overlay: overlay component, blurs the background
23
+ - BadgeList, list for Badge components
24
+
25
+ - Changed components:
26
+
27
+ - AlignBox: wrap toegevoegd
28
+ - DataBadgeLink: tabIndex toegevoegd met default `undefined`, omdat RHC tabindex=0 op `span` had gezet, fixed Focus styling.
29
+ - Heading: HeadingProps, clampHeadingLevel exported
30
+ - Paragraph: `short` property en styling toegevoegd
31
+ - PillBadge: focus and hover styling toegevoegd
32
+
33
+ - Nieuwe translation keys toegevoegd
34
+
35
+ - 4bc38b3: Refactor PiwikPro component to deprecate pageTitle prop and introduce customEvent for event tracking
36
+
37
+ ### Patch Changes
38
+
39
+ - a7a1405: Small bugfixes, server error details in action, future test file setup
40
+ - Updated dependencies [b404400]
41
+ - Updated dependencies [b404400]
42
+ - Updated dependencies [a7a1405]
43
+ - @developer-overheid-nl/don-register-locales@1.1.0
44
+
45
+ ## 1.1.0
46
+
47
+ ### Minor Changes
48
+
49
+ - 804dc03: Added Analytics component.
50
+ - Added `PiwikPro` component to encapsulate Piwik analytics tracking.
51
+ - Added restProps to `AlignBox` component and `CopyButton` component.
52
+
53
+ ### Patch Changes
54
+
55
+ - 4447980: Updated dependencies
56
+
57
+ Removed standalone postcss.config.cjs files from apps (integrated into astro.config.mjs)
58
+
59
+ - f7034b9: Updated dependencies:
60
+ - @rijkshuisstijl-community/components-css
61
+ - @rijkshuisstijl-community/components-react
62
+ - ded15aa: fix: exclude 'current' property when mapping NavBar items
63
+
64
+ ## 1.0.0
65
+
66
+ ### Major Changes
67
+
68
+ - d8d2e78: Version 1.0!
69
+ - 8dde9ed: Nieuwe componenten
70
+
71
+ - Button
72
+ - Fieldset
73
+ - FormFieldLabel
74
+ - FormFieldTextInput
75
+
76
+ Wijzigingen
77
+
78
+ - ReadOnlyTextInput: fontVariant toegevoegd.
79
+
80
+ ### Patch Changes
81
+
82
+ - 3b4f506: Change value to defaultValue in search form.
83
+ - Updated dependencies [8dde9ed]
84
+ - Updated dependencies [d8d2e78]
85
+ - @developer-overheid-nl/don-register-locales@1.0.0
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "license": "EUPL-1.2",
6
6
  "private": false,
7
7
  "type": "module",
8
- "version": "1.0.1",
8
+ "version": "1.2.0",
9
9
  "keywords": [],
10
10
  "publishConfig": {
11
11
  "access": "public"
@@ -13,31 +13,34 @@
13
13
  "exports": {
14
14
  ".": "./src/index.ts",
15
15
  "./client": "./src/client.ts",
16
+ "./analytics": "./src/analytics/index.ts",
16
17
  "./i18n": "./src/i18n.ts"
17
18
  },
18
19
  "main": "./src/index.ts",
19
20
  "files": [
20
21
  "src/",
21
- "tsconfig.json"
22
+ "tsconfig.json",
23
+ "CHANGELOG.md"
22
24
  ],
23
25
  "dependencies": {
24
- "@rijkshuisstijl-community/components-css": "11.0.0",
25
- "@rijkshuisstijl-community/components-react": "10.0.0",
26
+ "@piwikpro/react-piwik-pro": "2.5.0",
27
+ "@rijkshuisstijl-community/components-css": "12.0.0",
28
+ "@rijkshuisstijl-community/components-react": "11.0.0",
26
29
  "@rijkshuisstijl-community/design-tokens": "11.0.0",
27
30
  "@types/parse-link-header": "^2.0.3",
28
31
  "clsx": "2.1.1",
29
- "i18next": "25.7.3",
32
+ "i18next": "25.8.4",
30
33
  "parse-link-header": "^2.0.0",
31
- "react-i18next": "16.5.1",
34
+ "react-i18next": "16.5.4",
32
35
  "react-markdown": "10.1.0",
33
36
  "remark-behead": "^3.1.0",
34
- "@developer-overheid-nl/don-register-locales": "1.0.0"
37
+ "@developer-overheid-nl/don-register-locales": "1.1.0"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@vitejs/plugin-react": "^5.1.2",
38
41
  "rimraf": "^6.1.2",
39
42
  "typescript": "5.9.3",
40
- "vite": "7.3.0",
43
+ "vite": "7.1.7",
41
44
  "vite-plugin-dts": "^4.5.4"
42
45
  },
43
46
  "peerDependencies": {
@@ -21,12 +21,12 @@ type Align =
21
21
 
22
22
  type Gap = "none" | "small" | "medium" | "large";
23
23
 
24
- export interface AlignBoxProps {
24
+ export interface AlignBoxProps extends React.HTMLAttributes<HTMLDivElement> {
25
25
  align?: Align;
26
26
  gap?: Gap;
27
27
  direction?: "row" | "column";
28
+ wrap?: boolean;
28
29
  display?: "block" | "inline";
29
- className?: string;
30
30
  children: ReactNode;
31
31
  }
32
32
 
@@ -84,9 +84,11 @@ const AlignBox: React.FC<AlignBoxProps> = ({
84
84
  align = "center",
85
85
  gap = "none",
86
86
  direction = "row",
87
+ wrap = false,
87
88
  display = "block",
88
89
  className,
89
90
  children,
91
+ ...restProps
90
92
  }) => {
91
93
  const alignmentClass = getAlignmentClass(align);
92
94
  const gapClass = getGapClass(gap);
@@ -96,11 +98,13 @@ const AlignBox: React.FC<AlignBoxProps> = ({
96
98
  className={clsx(
97
99
  styles.alignBox,
98
100
  styles[direction],
101
+ wrap && styles.wrap,
99
102
  styles[display],
100
103
  alignmentClass,
101
104
  gapClass,
102
105
  className ?? "",
103
106
  )}
107
+ {...restProps}
104
108
  >
105
109
  {children}
106
110
  </div>
@@ -23,6 +23,10 @@
23
23
  flex-direction: column;
24
24
  }
25
25
 
26
+ .wrap {
27
+ flex-wrap: wrap;
28
+ }
29
+
26
30
  .left {
27
31
  align-items: center;
28
32
  justify-content: flex-start;
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ import styles from "./styles.module.css";
3
+
4
+ export interface AmountLabelProps {
5
+ label: ReactNode;
6
+ amount?: string | number;
7
+ }
8
+
9
+ const AmountLabel = ({ label, amount }: AmountLabelProps) => (
10
+ <div className={styles.amountLabel}>
11
+ <span className={styles.labelText}>{label}</span>&nbsp;
12
+ {amount ? <span className={styles.amountText}>({amount})</span> : null}
13
+ </div>
14
+ );
15
+
16
+ export default AmountLabel;
@@ -0,0 +1,11 @@
1
+ .amountLabel {
2
+ display: inline-block;
3
+ }
4
+
5
+ .labelText {
6
+ word-break: break-word;
7
+ }
8
+
9
+ .amountText {
10
+ font-size: smaller;
11
+ }
@@ -0,0 +1,94 @@
1
+ "use client";
2
+
3
+ import PiwikPro, {
4
+ ContentTracking,
5
+ CustomEvent,
6
+ type Dimensions,
7
+ DownloadAndOutlink,
8
+ ErrorTracking,
9
+ SiteSearch,
10
+ } from "@piwikpro/react-piwik-pro";
11
+ import { useEffect } from "react";
12
+
13
+ declare global {
14
+ interface Window {
15
+ _paq: unknown[];
16
+ }
17
+ }
18
+
19
+ interface AnalyticsProps {
20
+ siteId: string;
21
+ accountAddress: string;
22
+ dataLayerName?: string;
23
+ trackJSErrors?: boolean;
24
+ downloadExtensions?: string[];
25
+ /**
26
+ * @deprecated This property is deprecated.
27
+ */
28
+ pageTitle?: string;
29
+ customEvent?: { category?: string; action?: string; name: string };
30
+ isSearchPage?: boolean;
31
+ searchObject?: {
32
+ keyword: string;
33
+ category?: string;
34
+ searchCount?: number;
35
+ dimensions?: Dimensions;
36
+ };
37
+ }
38
+
39
+ // Default extra download extensions in addition to the standard ones tracked by Piwik Pro.
40
+ const DOWNLOAD_EXTENSIONS = ["json", "yaml", "yml"];
41
+
42
+ export default function Analytics(props: AnalyticsProps) {
43
+ /* const nonce = `n.${Math.random() * 1000000}`; // TODO: replace with nanoid or uuid */
44
+ const {
45
+ siteId,
46
+ accountAddress,
47
+ dataLayerName,
48
+ trackJSErrors = true,
49
+ pageTitle,
50
+ customEvent,
51
+ isSearchPage,
52
+ searchObject,
53
+ } = props;
54
+ const downloadExtensions = [
55
+ ...DOWNLOAD_EXTENSIONS,
56
+ ...(props.downloadExtensions || []),
57
+ ];
58
+
59
+ if (pageTitle) {
60
+ console.warn(
61
+ "The 'pageTitle' property is deprecated and will be removed in future versions.",
62
+ );
63
+ }
64
+
65
+ PiwikPro.initialize(siteId, accountAddress, {
66
+ /* nonce, */
67
+ dataLayerName,
68
+ });
69
+
70
+ DownloadAndOutlink.addDownloadExtensions(downloadExtensions);
71
+
72
+ ContentTracking.trackAllContentImpressions();
73
+ ContentTracking.trackVisibleContentImpressions(true);
74
+
75
+ if (trackJSErrors) {
76
+ ErrorTracking.enableJSErrorTracking();
77
+ }
78
+
79
+ useEffect(() => {
80
+ if (customEvent) {
81
+ CustomEvent.trackEvent(
82
+ customEvent.category || "Pages",
83
+ customEvent.action || "view",
84
+ customEvent.name,
85
+ );
86
+ }
87
+ if (isSearchPage && searchObject?.keyword) {
88
+ const { keyword, category, searchCount, dimensions } = searchObject;
89
+ SiteSearch.trackSiteSearch(keyword, category, searchCount, dimensions);
90
+ }
91
+ }, [customEvent, isSearchPage, searchObject]);
92
+
93
+ return null;
94
+ }
@@ -0,0 +1 @@
1
+ export { default as PiwikPro } from "./PiwikPro";
@@ -0,0 +1,26 @@
1
+ import clsx from "clsx";
2
+ import type { HTMLAttributes } from "react";
3
+ import styles from "./styles.module.css";
4
+
5
+ export interface BadgeListProps extends HTMLAttributes<HTMLUListElement> {
6
+ direction?: "row" | "column";
7
+ }
8
+
9
+ const BadgeList = (props: BadgeListProps) => {
10
+ const { direction = "row", className, children, ...restProps } = props;
11
+
12
+ return (
13
+ <ul
14
+ className={clsx(
15
+ styles.badgelist,
16
+ styles[`badgelist--${direction}`],
17
+ className,
18
+ )}
19
+ {...restProps}
20
+ >
21
+ {children}
22
+ </ul>
23
+ );
24
+ };
25
+
26
+ export default BadgeList;
@@ -0,0 +1,24 @@
1
+ .badgelist {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ gap: 0.25rem;
5
+ padding: 0;
6
+ list-style: none;
7
+
8
+ &:empty {
9
+ display: none;
10
+ }
11
+ }
12
+
13
+ .badgelist--row {
14
+ flex-direction: row;
15
+ }
16
+
17
+ .badgelist--row > * {
18
+ display: inline-flex;
19
+ gap: 0.25rem;
20
+ }
21
+
22
+ .badgelist--column {
23
+ flex-direction: column;
24
+ }
package/src/client.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  // Barrel export for client-side components
2
2
  export { default as CopyButton } from "./copyButton/CopyButton";
3
+ export {
4
+ default as FacetFilters,
5
+ type FacetFiltersProps,
6
+ type FilterData,
7
+ } from "./facetFilters/FacetFilters";
@@ -5,13 +5,12 @@ import clsx from "clsx";
5
5
  import Icon from "../iconsSprite/Icon";
6
6
  import styles from "./styles.module.css";
7
7
 
8
- const CopyButton = ({
9
- text,
10
- className,
11
- }: {
8
+ interface CopyButtonProps
9
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
12
10
  text?: string;
13
- className?: string;
14
- }) => {
11
+ }
12
+
13
+ const CopyButton = ({ text, className, ...restProps }: CopyButtonProps) => {
15
14
  const handleCopy = async () => {
16
15
  if ("clipboard" in navigator) {
17
16
  await navigator.clipboard.writeText(
@@ -29,6 +28,7 @@ const CopyButton = ({
29
28
  onClick={handleCopy}
30
29
  title="Kopieer naar klembord"
31
30
  aria-label="Kopieer naar klembord"
31
+ {...restProps}
32
32
  >
33
33
  <Icon className={styles.icon} name="kopieer-inline" />
34
34
  </SecondaryActionButton>
@@ -24,6 +24,7 @@ const DataBadgeLink = (props: DataBadgeLinkProps) => {
24
24
  children,
25
25
  className,
26
26
  role,
27
+ tabIndex = undefined,
27
28
  appearance = "primary",
28
29
  ...restProps
29
30
  } = props;
@@ -33,6 +34,8 @@ const DataBadgeLink = (props: DataBadgeLinkProps) => {
33
34
  /* biome-ignore lint/a11y/useValidAriaValues: {null} is needed to remove it */
34
35
  aria-pressed={undefined}
35
36
  role={role}
37
+ /* RHC DataBadgeButton had a tabindex=0 on the span, and a focus ring, but no interaction */
38
+ tabIndex={tabIndex}
36
39
  {...restProps}
37
40
  >
38
41
  <a
@@ -33,6 +33,13 @@
33
33
  background-color: var(--rhc-color-cool-grey-500);
34
34
  }
35
35
  }
36
+
37
+ &:focus-within {
38
+ outline-width: var(--utrecht-focus-outline-width, revert);
39
+ outline-style: var(--utrecht-focus-outline-style, revert);
40
+ outline-color: var(--utrecht-focus-outline-color, revert);
41
+ outline-offset: var(--utrecht-focus-outline-offset, revert);
42
+ }
36
43
  }
37
44
 
38
45
  .badgeLink {
@@ -40,4 +47,23 @@
40
47
  padding-block: 0.25rem;
41
48
  color: inherit;
42
49
  text-decoration: inherit;
50
+
51
+ &:focus-visible {
52
+ outline: none;
53
+ }
54
+
55
+ /* fix for non-clickable icons bug */
56
+ &::before {
57
+ position: absolute;
58
+ top: 0;
59
+ left: 0;
60
+ display: block;
61
+ width: 100%;
62
+ height: 100%;
63
+ content: '';
64
+ border-radius: var(
65
+ --utrecht-data-badge-border-radius,
66
+ var(--utrecht-badge-border-radius, 0.5ch)
67
+ );
68
+ }
43
69
  }
@@ -14,15 +14,15 @@
14
14
  --rhc-data-summary-item-key-row-padding-inline-start: 0;
15
15
  --rhc-data-summary-item-key-row-padding-inline-end: 0;
16
16
  --rhc-data-summary-item-key-row-padding-block-start: 0;
17
- --rhc-data-summary-item-key-row-padding-block-end: 0.75rem;
17
+ --rhc-data-summary-item-key-row-padding-block-end: 0.5rem;
18
18
  --rhc-data-summary-item-value-row-padding-inline-start: 0;
19
19
  --rhc-data-summary-item-value-row-padding-inline-end: 0;
20
20
  --rhc-data-summary-item-value-row-padding-block-start: 0;
21
- --rhc-data-summary-item-value-row-padding-block-end: 0.75rem;
21
+ --rhc-data-summary-item-value-row-padding-block-end: 0.5rem;
22
22
  --rhc-data-summary-item-action-row-padding-inline-start: 0;
23
23
  --rhc-data-summary-item-action-row-padding-inline-end: 0;
24
24
  --rhc-data-summary-item-action-row-padding-block-start: 0;
25
- --rhc-data-summary-item-action-row-padding-block-end: 0.75rem;
25
+ --rhc-data-summary-item-action-row-padding-block-end: 0.5rem;
26
26
  display: flex;
27
27
  flex-direction: column;
28
28
  row-gap: 0.75rem;
@@ -31,7 +31,7 @@
31
31
  }
32
32
 
33
33
  :global(.rhc-data-summary__item) {
34
- row-gap: 0.75rem;
34
+ row-gap: 0.25rem;
35
35
  column-gap: 1rem;
36
36
  }
37
37
 
@@ -62,9 +62,14 @@
62
62
  }
63
63
 
64
64
  .isContained {
65
- margin-block-end: 0;
65
+ &:last-child {
66
+ margin-block-end: 0;
67
+ }
68
+
66
69
  :global(.rhc-data-summary__item:last-child) {
67
70
  --rhc-data-summary-item-border-block-end-style: none;
68
71
  --rhc-data-summary-item-key-row-padding-block-end: 0;
72
+ --rhc-data-summary-item-value-row-padding-block-end: 0;
73
+ --rhc-data-summary-item-action-row-padding-block-end: 0;
69
74
  }
70
75
  }