@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
@@ -1,6 +1,9 @@
1
- /* biome-ignore-all lint: TODO: needs a refactor maybe */
1
+ /* biome-ignore-all lint: is deprecated and refactored */
2
2
  type status = "active" | "deprecated" | "sunset" | "retired";
3
3
 
4
+ /**
5
+ * @deprecated API Register specific function (moved and refactored to `apps/api-register/src/components/`)
6
+ */
4
7
  export function getDate(object?: Partial<Record<"status" | status, any>>) {
5
8
  if (!object) return;
6
9
 
@@ -24,6 +27,9 @@ export function getDate(object?: Partial<Record<"status" | status, any>>) {
24
27
  );
25
28
  }
26
29
 
30
+ /**
31
+ * @deprecated API Register specific function (moved and refactored to `apps/api-register/src/components/`)
32
+ */
27
33
  export default function getAppearance(
28
34
  object?: Partial<Record<"status" | status, any>>,
29
35
  ) {
package/src/index.ts CHANGED
@@ -2,6 +2,10 @@
2
2
  export { type AlertProps, default as Alert } from "./alert/Alert";
3
3
  export { type AlignBoxProps, default as AlignBox } from "./alignBox/AlignBox";
4
4
  export { default as Article } from "./article/Article";
5
+ export {
6
+ type BadgeListProps,
7
+ default as BadgeList,
8
+ } from "./badgeList/BadgeList";
5
9
  export { type BlockProps, default as Block } from "./block/Block";
6
10
  export { default as Button } from "./button/Button";
7
11
  export {
@@ -28,6 +32,12 @@ export {
28
32
  type DataSummaryItemProps,
29
33
  default as DataSummaryItem,
30
34
  } from "./dataSummary/DataSummaryItem";
35
+ export {
36
+ default as FacetFilters,
37
+ type FacetFiltersProps,
38
+ type FilterData,
39
+ getSelectedFilters,
40
+ } from "./facetFilters/FacetFilters";
31
41
  export { default as Fieldset } from "./fieldset/FieldSet";
32
42
  export { default as Filters } from "./filters/Filters";
33
43
  export {
@@ -35,10 +45,19 @@ export {
35
45
  default as Footer,
36
46
  type FooterProps,
37
47
  } from "./footer/Footer";
48
+ export { default as FormFieldCheckboxGroup } from "./formFieldCheckboxGroup/FormFieldCheckboxGroup";
49
+ export { default as FormFieldCheckboxOption } from "./formFieldCheckboxOption/FormFieldCheckboxOption";
38
50
  export { default as FormFieldLabel } from "./formFieldLabel/FormFieldLabel";
51
+ export { default as FormFieldRadioGroup } from "./formFieldRadioGroup/FormFieldRadioGroup";
52
+ export { default as FormFieldRadioOption } from "./formFieldRadioOption/FormFieldRadioOption";
53
+ export { default as FormFieldSwitch } from "./formFieldSwitch/FormFieldSwitch";
39
54
  export { default as FormFieldTextInput } from "./formFieldTextInput/FormFieldTextInput";
40
55
  export { default as Header, type HeaderProps } from "./header/Header";
41
- export { default as Heading } from "./heading/Heading";
56
+ export {
57
+ clampHeadingLevel,
58
+ default as Heading,
59
+ type HeadingProps,
60
+ } from "./heading/Heading";
42
61
  export {
43
62
  default as HeadingGroup,
44
63
  type HeadingGroupProps,
@@ -50,12 +69,17 @@ export {
50
69
  } from "./iconBadge/IconBadge";
51
70
  export { default as Icon } from "./iconsSprite/Icon";
52
71
  export { default as IconsSprite } from "./iconsSprite/IconsSprite";
72
+ export {
73
+ default as InfoButton,
74
+ type InfoButtonProps,
75
+ } from "./infoButton/InfoButton";
53
76
  export { default as Link } from "./link/Link";
54
77
  export {
55
78
  default as Markdown,
56
79
  type HeadingLevels,
57
80
  type MarkdownProps,
58
81
  } from "./markdown/Markdown";
82
+ export { default as Overlay } from "./overlay/Overlay";
59
83
  export {
60
84
  default as Pagination,
61
85
  type PaginationProps,
@@ -72,6 +96,8 @@ export {
72
96
  } from "./scoreBadge/ScoreBadge";
73
97
  export { default as Search, type SearchProps } from "./search/Search";
74
98
  export { default as SiteLogo } from "./siteLogo/SiteLogo";
99
+ export { default as Switch, type SwitchProps } from "./switch/Switch";
100
+ export { default as ToolTip } from "./toolTip/ToolTip";
75
101
  export {
76
102
  default as TopNavigation,
77
103
  type NavBarItem,
@@ -0,0 +1,45 @@
1
+ import clsx from "clsx";
2
+ import type { ButtonHTMLAttributes, HTMLProps } from "react";
3
+ import Icon from "../iconsSprite/Icon";
4
+ import styles from "./styles.module.css";
5
+
6
+ export interface InfoButtonProps extends HTMLProps<HTMLButtonElement> {
7
+ iconSize?: "small" | "default" | "large";
8
+ iconColor?: "default" | "current";
9
+ type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
10
+ commandfor?: string;
11
+ command?:
12
+ | "show-modal"
13
+ | "close"
14
+ | "request-close"
15
+ | "show-popover"
16
+ | "hide-popover"
17
+ | "toggle-popover"
18
+ | `--${string}`;
19
+ interestfor?: string;
20
+ }
21
+
22
+ const InfoButton = (props: InfoButtonProps) => {
23
+ const {
24
+ iconSize = "default",
25
+ iconColor = "default",
26
+ type = "button",
27
+ ...restProps
28
+ } = props;
29
+
30
+ return (
31
+ <button
32
+ className={clsx(
33
+ styles.infoButton,
34
+ styles[`${iconSize}Size`],
35
+ styles[`${iconColor}Color`],
36
+ )}
37
+ type={type}
38
+ {...restProps}
39
+ >
40
+ <Icon name="info" />
41
+ </button>
42
+ );
43
+ };
44
+
45
+ export default InfoButton;
@@ -0,0 +1,43 @@
1
+ :root {
2
+ --don-info-button-color: var(--rhc-color-hemelblauw-500);
3
+ }
4
+
5
+ .infoButton {
6
+ display: grid;
7
+ place-content: center;
8
+ padding: 0;
9
+ margin: 0;
10
+ appearance: none;
11
+ cursor: pointer;
12
+ background: none;
13
+ border: none;
14
+ }
15
+
16
+ .defaultColor {
17
+ color: var(--don-info-button-color, currentColor);
18
+ }
19
+
20
+ .currentColor {
21
+ color: currentColor;
22
+ }
23
+
24
+ .smallSize {
25
+ svg {
26
+ width: 1rem;
27
+ height: 1rem;
28
+ }
29
+ }
30
+
31
+ .defaultSize {
32
+ svg {
33
+ width: 1.5rem;
34
+ height: 1.5rem;
35
+ }
36
+ }
37
+
38
+ .largeSize {
39
+ svg {
40
+ width: 2rem;
41
+ height: 2rem;
42
+ }
43
+ }
@@ -0,0 +1,18 @@
1
+ import clsx from "clsx";
2
+ import styles from "./styles.module.css";
3
+
4
+ const Overlay = ({
5
+ children,
6
+ active,
7
+ }: {
8
+ children?: React.ReactNode;
9
+ active: boolean;
10
+ }) => {
11
+ return (
12
+ <div className={clsx(styles.overlay, active && styles.active)}>
13
+ {children}
14
+ </div>
15
+ );
16
+ };
17
+
18
+ export default Overlay;
@@ -0,0 +1,15 @@
1
+ .overlay {
2
+ display: none;
3
+
4
+ &.active {
5
+ position: absolute;
6
+ top: 0;
7
+ left: -1px;
8
+ z-index: 999;
9
+ display: block;
10
+ width: 100%;
11
+ height: 100%;
12
+ background-color: rgba(255, 255, 255, 0.25);
13
+ backdrop-filter: blur(1px);
14
+ }
15
+ }
@@ -1,10 +1,24 @@
1
1
  import {
2
- type ParagraphProps,
3
2
  Paragraph as RHCParagraph,
3
+ type ParagraphProps as RHCParagraphProps,
4
4
  } from "@rijkshuisstijl-community/components-react";
5
+ import clsx from "clsx";
6
+ import styles from "./styles.module.css";
7
+
8
+ interface ParagraphProps extends RHCParagraphProps {
9
+ purpose?: "lead" | "short";
10
+ }
5
11
 
6
12
  const Paragraph = (props: ParagraphProps) => {
7
- return <RHCParagraph {...props} />;
13
+ const { className, purpose } = props;
14
+
15
+ return (
16
+ <RHCParagraph
17
+ className={clsx(className, purpose === "short" && styles.short)}
18
+ purpose={purpose}
19
+ {...props}
20
+ />
21
+ );
8
22
  };
9
23
 
10
24
  export default Paragraph;
@@ -0,0 +1,6 @@
1
+ .short {
2
+ --nl-paragraph-font-size: 0.875rem;
3
+ --nl-paragraph-margin-block-end: 0.5rem;
4
+ padding-inline-start: 0.25rem;
5
+ border-inline-start: 1px solid var(--rhc-color-cool-grey-300);
6
+ }
@@ -14,6 +14,7 @@
14
14
  rgba(51, 51, 51, 0.25),
15
15
  rgba(204, 204, 204, 0.25)
16
16
  );
17
+ --don-pill-badge-outline-hover-color: var(--rhc-color-cool-grey-300);
17
18
  --don-pill-badge-border-width: 1px;
18
19
  }
19
20
 
@@ -33,6 +34,25 @@
33
34
  background-color: var(--don-pill-badge-background-color);
34
35
  border-radius: var(--don-pill-badge-border-radius);
35
36
 
37
+ a:any-link:has(&) {
38
+ text-decoration: none;
39
+
40
+ &:hover {
41
+ outline-width: 2px;
42
+ outline-style: auto;
43
+ outline-color: var(--don-pill-badge-outline-hover-color);
44
+ outline-offset: 0.125rem;
45
+ border-radius: var(--don-pill-badge-border-radius);
46
+ }
47
+
48
+ &:focus,
49
+ &:focus-visible {
50
+ outline-style: auto;
51
+ outline-offset: 0.125rem;
52
+ border-radius: var(--don-pill-badge-border-radius);
53
+ }
54
+ }
55
+
36
56
  /* Because Biome CSS parser does not yet support modern attr() some of the following is commented out.
37
57
  * Fixme: remove this workaround when https://github.com/biomejs/biome/issues/6183 is closed and tested */
38
58
 
@@ -17,6 +17,7 @@ export interface ScoreBadgeProps {
17
17
  };
18
18
  }
19
19
 
20
+ /** @deprecated */
20
21
  export default function ScoreBadge(props: ScoreBadgeProps) {
21
22
  const defaultcolors: ScoreBadgeProps["colors"] = {
22
23
  background: "#CBD5E1",
@@ -0,0 +1,86 @@
1
+ import clsx from "clsx";
2
+ import {
3
+ type ForwardedRef,
4
+ forwardRef,
5
+ type InputHTMLAttributes,
6
+ useId,
7
+ } from "react";
8
+ import styles from "./styles.module.css";
9
+
10
+ export interface SwitchLabels {
11
+ on: string;
12
+ off: string;
13
+ }
14
+
15
+ export interface SwitchProps
16
+ extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "readOnly"> {
17
+ invalid?: boolean;
18
+ labels?: SwitchLabels;
19
+ }
20
+
21
+ const Switch = forwardRef(
22
+ (props: SwitchProps, ref: ForwardedRef<HTMLInputElement>) => {
23
+ const genId = useId();
24
+ const {
25
+ id = genId,
26
+ disabled,
27
+ invalid,
28
+ required,
29
+ hidden,
30
+ checked,
31
+ defaultChecked,
32
+ role,
33
+ tabIndex,
34
+ className,
35
+ labels = { on: "ON", off: "OFF" },
36
+ ...restProps
37
+ } = props;
38
+
39
+ return (
40
+ <div
41
+ className={clsx(
42
+ "utrecht-form-toggle",
43
+ "utrecht-form-toggle--html-checkbox",
44
+ {
45
+ "utrecht-form-toggle--disabled": disabled,
46
+ "utrecht-form-toggle--invalid": invalid,
47
+ "utrecht-form-toggle--required": required,
48
+ },
49
+ styles.switch,
50
+ className,
51
+ )}
52
+ hidden={hidden}
53
+ >
54
+ <input
55
+ id={id}
56
+ aria-invalid={invalid || undefined}
57
+ type="checkbox"
58
+ className="utrecht-form-toggle__checkbox"
59
+ checked={checked}
60
+ defaultChecked={defaultChecked || undefined}
61
+ disabled={disabled || undefined}
62
+ required={required}
63
+ ref={ref}
64
+ role={role}
65
+ tabIndex={tabIndex}
66
+ {...restProps}
67
+ />
68
+ <label
69
+ htmlFor={id}
70
+ className={clsx(
71
+ "utrecht-form-toggle__track",
72
+ "utrecht-form-toggle__track--html-label",
73
+ )}
74
+ >
75
+ <div className="utrecht-form-toggle__thumb">
76
+ <span className="sr-only">
77
+ {checked || defaultChecked ? labels.on : labels.off}
78
+ </span>
79
+ </div>
80
+ </label>
81
+ </div>
82
+ );
83
+ },
84
+ );
85
+
86
+ export default Switch;
@@ -0,0 +1,7 @@
1
+ .switch {
2
+ &:hover {
3
+ :global(.utrecht-form-toggle__track) {
4
+ background-color: var(--utrecht-form-toggle-hover-background-color);
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ type ButtonHTMLAttributes,
3
+ type HTMLAttributes,
4
+ type HTMLProps,
5
+ type PropsWithChildren,
6
+ useId,
7
+ } from "react";
8
+ import Infobutton, { type InfoButtonProps } from "../infoButton/InfoButton";
9
+ import styles from "./styles.module.css";
10
+
11
+ interface ToolTipProps extends HTMLProps<HTMLButtonElement> {
12
+ id?: string;
13
+ className?: string;
14
+ text: string;
15
+ type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
16
+ command?: InfoButtonProps["command"];
17
+ commandfor?: InfoButtonProps["commandfor"];
18
+ interestfor?: InfoButtonProps["interestfor"];
19
+ popover?: HTMLAttributes<HTMLDivElement>["popover"];
20
+ }
21
+
22
+ const ToolTip = (props: PropsWithChildren<ToolTipProps>) => {
23
+ const genId: string = useId();
24
+ const {
25
+ id = genId,
26
+ className,
27
+ text,
28
+ command = "toggle-popover",
29
+ commandfor = genId,
30
+ interestfor = genId,
31
+ popover = "manual",
32
+ children,
33
+ ...restProps
34
+ } = props;
35
+
36
+ return (
37
+ <>
38
+ {children ? (
39
+ children
40
+ ) : (
41
+ <Infobutton
42
+ interestfor={interestfor}
43
+ commandfor={commandfor}
44
+ command={command}
45
+ {...restProps}
46
+ />
47
+ )}
48
+ <div className={styles.toolTip} id={id} popover={popover} role="tooltip">
49
+ {text}
50
+ </div>
51
+ </>
52
+ );
53
+ };
54
+
55
+ export default ToolTip;
@@ -0,0 +1,48 @@
1
+ :root {
2
+ --don-tooltip-border-color: var(--rhc-color-cool-grey-300);
3
+ --don-tooltip-background-color: var(--rhc-color-cool-grey-50);
4
+ --don-tooltip-border-radius: var(--rhc-border-radius-md);
5
+ --don-tooltip-font-size: 0.875rem;
6
+ --don-tooltip-font-weigth: normal;
7
+ }
8
+
9
+ .triggerButton {
10
+ appearance: none;
11
+ cursor: pointer;
12
+ background: none;
13
+ border: none;
14
+ }
15
+
16
+ .toolTip {
17
+ position-area: block-end span-all;
18
+ border: var(--don-tooltip-border-width, 1px) solid
19
+ var(--don-tooltip-border-color, #cbd5e1);
20
+ border-radius: var(--don-tooltip-border-radius, 5px);
21
+ background-color: var(--don-tooltip-background-color, #f8fafc);
22
+ box-shadow: 0 0 1px 2px rgb(127, 127, 127, 0.05);
23
+ font-size: var(--don-tooltip-font-size, inherit);
24
+ font-weight: var(--don-tooltip-font-weigth, normal);
25
+ padding-block: var(--don-tooltip-padding-block, 0.5rem);
26
+ padding-inline: var(
27
+ --don-tooltip-padding-inline,
28
+ var(--don-tooltip-padding-block, 0.5rem)
29
+ );
30
+
31
+ /* needed for triangle */
32
+ margin: 5px;
33
+ overflow: visible;
34
+
35
+ &::before {
36
+ content: '';
37
+ display: block;
38
+ position: absolute;
39
+ position-area: top;
40
+ top: -5px;
41
+ width: 0;
42
+ height: 0;
43
+ border-left: 5px solid transparent;
44
+ border-right: 5px solid transparent;
45
+
46
+ border-bottom: 5px solid var(--don-tooltip-border-color, #cbd5e1);
47
+ }
48
+ }