@superrb/react-addons 3.0.0-2 → 3.0.0-20

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 (64) hide show
  1. package/actions.d.ts +6 -0
  2. package/actions.d.ts.map +1 -0
  3. package/actions.js +18 -0
  4. package/components/accordion.d.ts +10 -0
  5. package/components/accordion.d.ts.map +1 -0
  6. package/components/accordion.js +50 -0
  7. package/components/button.d.ts +1 -1
  8. package/components/context-wrapper.d.ts.map +1 -1
  9. package/components/cookie-banner.d.ts +22 -16
  10. package/components/cookie-banner.d.ts.map +1 -1
  11. package/components/cookie-banner.js +10 -10
  12. package/components/form/field.d.ts.map +1 -1
  13. package/components/form/field.js +3 -0
  14. package/components/form/submit-button.d.ts +1 -1
  15. package/components/form/submit-button.d.ts.map +1 -1
  16. package/components/form.d.ts +1 -1
  17. package/components/form.d.ts.map +1 -1
  18. package/components/form.js +25 -15
  19. package/components/modal.d.ts.map +1 -1
  20. package/components/slideshow-buttons.d.ts +9 -0
  21. package/components/slideshow-buttons.d.ts.map +1 -0
  22. package/components/slideshow-buttons.js +6 -0
  23. package/components/slideshow-pagination.d.ts +6 -0
  24. package/components/slideshow-pagination.d.ts.map +1 -0
  25. package/components/slideshow-pagination.js +3 -0
  26. package/components.d.ts +4 -1
  27. package/components.d.ts.map +1 -1
  28. package/components.js +4 -1
  29. package/context/cookies-context-provider.d.ts +13 -0
  30. package/context/cookies-context-provider.d.ts.map +1 -0
  31. package/context/cookies-context-provider.js +54 -0
  32. package/context/modal-context-provider.d.ts +13 -0
  33. package/context/modal-context-provider.d.ts.map +1 -0
  34. package/context/modal-context-provider.js +31 -0
  35. package/context/nav-context-provider.js +26 -0
  36. package/context.d.ts +2 -1
  37. package/context.d.ts.map +1 -1
  38. package/context.js +2 -1
  39. package/hooks/use-async.d.ts.map +1 -1
  40. package/hooks/use-draggable-scroll.d.ts.map +1 -1
  41. package/hooks/use-event-listener.d.ts +1 -1
  42. package/hooks/use-event-listener.d.ts.map +1 -1
  43. package/hooks/use-event-listener.js +2 -9
  44. package/hooks/use-hide-on-scroll.js +1 -1
  45. package/hooks/use-is-in-viewport.d.ts +1 -1
  46. package/hooks/use-is-in-viewport.d.ts.map +1 -1
  47. package/hooks/use-is-in-viewport.js +15 -12
  48. package/hooks/use-is-overflowing.d.ts.map +1 -1
  49. package/hooks/use-slideshow.d.ts +19 -0
  50. package/hooks/use-slideshow.d.ts.map +1 -0
  51. package/hooks/use-slideshow.js +110 -0
  52. package/hooks.d.ts +2 -1
  53. package/hooks.d.ts.map +1 -1
  54. package/hooks.js +2 -1
  55. package/package.json +3 -4
  56. package/store/cookies.d.ts +3 -0
  57. package/store/cookies.d.ts.map +1 -1
  58. package/store/cookies.js +25 -22
  59. package/tsconfig.tsbuildinfo +1 -1
  60. package/utils/animate.d.ts.map +1 -1
  61. package/utils/is-external-link.js +4 -4
  62. package/utils.d.ts +2 -1
  63. package/utils.d.ts.map +1 -1
  64. package/utils.js +2 -1
package/actions.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare class RecaptchaError extends Error {
2
+ message: string;
3
+ }
4
+ export type RecaptchaifiedAction<T> = (data: T, token: string) => void;
5
+ export declare const recaptchaify: <T>(callback: (data: T) => void) => RecaptchaifiedAction<T>;
6
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["src/actions.ts"],"names":[],"mappings":"AAEA,qBAAa,cAAe,SAAQ,KAAK;IACvC,OAAO,SAAkC;CAC1C;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;AAEtE,eAAO,MAAM,YAAY,gBAA0B,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,4BAcnE,CAAA"}
package/actions.js ADDED
@@ -0,0 +1,18 @@
1
+ import { GoogleReCaptcha } from '@superrb/netlify-function-helpers';
2
+ export class RecaptchaError extends Error {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.message = 'Recaptcha verification failed';
6
+ }
7
+ }
8
+ export const recaptchaify = function (callback) {
9
+ return (async (data, token) => {
10
+ try {
11
+ await GoogleReCaptcha.verify(token, process.env.RECAPTCHA_SECRET_KEY, process.env.RECAPTCHA_MINSCORE);
12
+ }
13
+ catch (error) {
14
+ throw new RecaptchaError();
15
+ }
16
+ callback(data);
17
+ });
18
+ };
@@ -0,0 +1,10 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare const AccordionItem: ({ title, expanded, children, }: PropsWithChildren<{
3
+ title: string;
4
+ expanded?: boolean;
5
+ }>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const Accordion: ({ multiple, children, }: PropsWithChildren<{
7
+ multiple?: boolean;
8
+ }>) => import("react/jsx-runtime").JSX.Element;
9
+ export default Accordion;
10
+ //# sourceMappingURL=accordion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../src/components/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EAMlB,MAAM,OAAO,CAAA;AAcd,eAAO,MAAM,aAAa,mCAIvB,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,4CA4D1D,CAAA;AAED,eAAO,MAAM,SAAS,4BAGnB,iBAAiB,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,4CAwB3C,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { createContext, useContext, useState, useEffect, useId, } from 'react';
4
+ const AccordionContext = createContext({
5
+ multiple: false,
6
+ expandedItems: [],
7
+ setExpandedItems: () => { },
8
+ });
9
+ export const AccordionItem = ({ title, expanded = false, children, }) => {
10
+ const { multiple, expandedItems, setExpandedItems } = useContext(AccordionContext);
11
+ const id = useId();
12
+ useEffect(() => {
13
+ if (expanded === true) {
14
+ setExpandedItems((expandedItems) => {
15
+ expandedItems.push(id);
16
+ return expandedItems;
17
+ });
18
+ }
19
+ }, []);
20
+ const toggle = () => {
21
+ setExpandedItems((expandedItems) => {
22
+ const isExpanded = expandedItems.includes(id);
23
+ if (isExpanded) {
24
+ console.log('Close', id);
25
+ return expandedItems.filter((item) => item !== id);
26
+ }
27
+ if (!multiple) {
28
+ console.log('Open only', id);
29
+ return [id];
30
+ }
31
+ return [...expandedItems, id];
32
+ });
33
+ };
34
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { "aria-selected": expandedItems.includes(id), "aria-controls": `${id}-panel`, className: "accordion__trigger", onClick: toggle, role: "tab", "aria-label": title, id: `${id}-trigger`, children: [_jsx("span", { className: "screenreader-text", children: expandedItems ? 'Close' : 'Expand' }), title] }), _jsx("div", { className: "accordion__content", role: "tabpanel", "aria-labelledby": `${id}-trigger`, id: `${id}-panel`, children: children })] }));
35
+ };
36
+ export const Accordion = ({ multiple = false, children, }) => {
37
+ const [expandedItemsStorage, setExpandedItemsStorage] = useState([]);
38
+ const setExpandedItems = (newState) => {
39
+ setExpandedItemsStorage((items) => [...new Set(newState(items))]);
40
+ };
41
+ useEffect(() => {
42
+ console.log(expandedItemsStorage);
43
+ }, [expandedItemsStorage]);
44
+ return (_jsx(AccordionContext.Provider, { value: {
45
+ multiple,
46
+ expandedItems: expandedItemsStorage,
47
+ setExpandedItems,
48
+ }, children: _jsx("div", { className: "accordion", role: "tablist", "aria-multiselectable": multiple, children: children }) }));
49
+ };
50
+ export default Accordion;
@@ -6,7 +6,7 @@ type Props = (PropsWithChildren<HTMLAttributes<HTMLButtonElement | HTMLAnchorEle
6
6
  className?: string;
7
7
  href?: string;
8
8
  };
9
- declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>>;
9
+ declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>>;
10
10
  export default _default;
11
11
  export type { Props as ButtonProps };
12
12
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-wrapper.d.ts","sourceRoot":"","sources":["../src/components/context-wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGzC,QAAA,MAAM,cAAc,iBAAkB,kBAAkB,EAAE,CAAC,4CAM1D,CAAA;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"context-wrapper.d.ts","sourceRoot":"","sources":["../src/components/context-wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGzC,QAAA,MAAM,cAAc,iBAAkB,iBAAiB,CAAC,EAAE,CAAC,4CAM1D,CAAA;AAED,eAAe,cAAc,CAAA"}
@@ -1,20 +1,26 @@
1
1
  import { ReactNode } from 'react';
2
- declare const CookieBanner: ({ allowCustomisation, allowReject, title, text, formText, policyLink, policyLabel, acceptLabel, acceptAllLabel, rejectLabel, customiseLabel, renderAcceptButton, renderCustomiseButton, renderRejectButton, renderSubmitButton, }: {
3
- allowCustomisation?: boolean | undefined;
4
- allowReject?: boolean | undefined;
5
- title?: string | undefined;
6
- text?: string | undefined;
7
- formText?: string | undefined;
8
- policyLink?: string | undefined;
9
- policyLabel?: string | undefined;
10
- acceptLabel?: string | undefined;
11
- acceptAllLabel?: string | undefined;
12
- rejectLabel?: string | undefined;
13
- customiseLabel?: string | undefined;
14
- renderAcceptButton?: ((props: {}) => ReactNode) | undefined;
15
- renderCustomiseButton?: ((props: {}) => ReactNode) | undefined;
16
- renderRejectButton?: ((props: {}) => ReactNode) | undefined;
17
- renderSubmitButton?: (() => ReactNode) | undefined;
2
+ declare const CookieBanner: ({ allowCustomisation, allowReject, title, text, formText, policyLink, policyLabel, acceptLabel, acceptAllLabel, rejectLabel, customiseLabel, tracking, necessary, renderAcceptButton, renderCustomiseButton, renderRejectButton, renderSubmitButton, }: {
3
+ allowCustomisation?: boolean;
4
+ allowReject?: boolean;
5
+ title?: string;
6
+ text?: string;
7
+ formText?: string;
8
+ policyLink?: string;
9
+ policyLabel?: string;
10
+ acceptLabel?: string;
11
+ acceptAllLabel?: string;
12
+ rejectLabel?: string;
13
+ customiseLabel?: string;
14
+ tracking?: {
15
+ [key: string]: string;
16
+ };
17
+ necessary?: {
18
+ [key: string]: string;
19
+ };
20
+ renderAcceptButton?: (props: {}) => ReactNode;
21
+ renderCustomiseButton?: (props: {}) => ReactNode;
22
+ renderRejectButton?: (props: {}) => ReactNode;
23
+ renderSubmitButton?: () => ReactNode;
18
24
  }) => import("react/jsx-runtime").JSX.Element;
19
25
  export default CookieBanner;
20
26
  //# sourceMappingURL=cookie-banner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie-banner.d.ts","sourceRoot":"","sources":["../src/components/cookie-banner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAA;AA6BtD,QAAA,MAAM,YAAY;;;;;;;;;;;;kCA4Ba,EAAE,KAAK,SAAS;qCACb,EAAE,KAAK,SAAS;kCACnB,EAAE,KAAK,SAAS;gCAClB,SAAS;6CA0JrC,CAAA;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"cookie-banner.d.ts","sourceRoot":"","sources":["../src/components/cookie-banner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAA;AA6BtD,QAAA,MAAM,YAAY,2PAkBf;IACD,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACpC,SAAS,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACrC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,SAAS,CAAA;IAC7C,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,SAAS,CAAA;IAChD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,SAAS,CAAA;IAC7C,kBAAkB,CAAC,EAAE,MAAM,SAAS,CAAA;CACrC,4CA4JA,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -25,11 +25,8 @@ const content = {
25
25
  description: 'These cookies are necessary for the website to function and cannot be switched off.',
26
26
  },
27
27
  };
28
- const CookieBanner = ({ allowCustomisation = true, allowReject = false, title = content.title, text = content.text, formText = content.form_text, policyLink = content.policyLink, policyLabel = content.policyLabel, acceptLabel = content.acceptLabel, acceptAllLabel = content.acceptAllLabel, rejectLabel = content.rejectLabel, customiseLabel = content.customiseLabel, renderAcceptButton, renderCustomiseButton, renderRejectButton, renderSubmitButton, }) => {
29
- const cookiesAccepted = useCookieStore((state) => state.cookiesAccepted);
30
- const setCookiesAccepted = useCookieStore((state) => state.setCookiesAccepted);
31
- const trackingCookiesAccepted = useCookieStore((state) => state.trackingCookiesAccepted);
32
- const setTrackingCookiesAccepted = useCookieStore((state) => state.setTrackingCookiesAccepted);
28
+ const CookieBanner = ({ allowCustomisation = true, allowReject = false, title = content.title, text = content.text, formText = content.form_text, policyLink = content.policyLink, policyLabel = content.policyLabel, acceptLabel = content.acceptLabel, acceptAllLabel = content.acceptAllLabel, rejectLabel = content.rejectLabel, customiseLabel = content.customiseLabel, tracking = content.tracking, necessary = content.necessary, renderAcceptButton, renderCustomiseButton, renderRejectButton, renderSubmitButton, }) => {
29
+ const { cookiesAccepted, setCookiesAccepted, trackingCookiesAccepted, setTrackingCookiesAccepted, popupOpen, closePopup, } = useCookieStore();
33
30
  const [animate, setAnimate] = useState(false);
34
31
  const [formOpen, setFormOpen] = useState(false);
35
32
  const [rejected, setRejected] = useState(!!session.getItem('cookies-rejected'));
@@ -42,6 +39,7 @@ const CookieBanner = ({ allowCustomisation = true, allowReject = false, title =
42
39
  session.setItem('cookies-rejected', 'true');
43
40
  };
44
41
  const accept = (necessary, tracking) => {
42
+ closePopup();
45
43
  setAnimate(true);
46
44
  setTimeout(() => {
47
45
  setCookiesAccepted(necessary);
@@ -49,29 +47,31 @@ const CookieBanner = ({ allowCustomisation = true, allowReject = false, title =
49
47
  }, 800);
50
48
  };
51
49
  const acceptAll = () => {
50
+ closePopup();
52
51
  accept(true, true);
53
52
  };
54
53
  const submit = (data) => {
54
+ closePopup();
55
55
  accept(true, !!data.tracking);
56
56
  };
57
57
  const trueAcceptLabel = !allowCustomisation || formOpen ? acceptLabel : acceptAllLabel;
58
58
  const schema = Yup.object().shape({
59
59
  tracking: Yup.boolean().required().default(trackingCookiesAccepted).label(`
60
- <strong>${content.tracking?.title}</strong>
61
- <p>${content.tracking?.description}</p>
60
+ <strong>${tracking?.title}</strong>
61
+ <p>${tracking?.description}</p>
62
62
  `),
63
63
  necessary: Yup.boolean()
64
64
  .required()
65
65
  .default(true)
66
66
  .label(`
67
- <strong>${content.necessary?.title}</strong>
68
- <p>${content.necessary?.description}</p>
67
+ <strong>${necessary?.title}</strong>
68
+ <p>${necessary?.description}</p>
69
69
  `)
70
70
  .meta({ disabled: true }),
71
71
  });
72
72
  useEffect(() => {
73
73
  setReady(true);
74
74
  }, []);
75
- return (_jsx(_Fragment, { children: ready && !rejected && !cookiesAccepted ? (_jsx("div", { className: `cookie-banner ${animate ? ' cookie-banner--hide' : ''} `, children: _jsx("div", { className: "cookie-banner__container container", children: _jsxs("div", { className: "cookie-banner__inner", children: [allowCustomisation && (_jsxs("div", { className: "cookie-banner__form", "aria-hidden": !formOpen, children: [formText && (_jsx("p", { className: "cookie-banner__form-text", children: formText })), _jsx(Form, { useRecaptcha: false, className: "cookie-banner__form", schema: schema, onSubmit: submit, renderSubmit: () => renderSubmitButton ? (renderSubmitButton()) : (_jsx(SubmitButton, { label: acceptLabel })), renderSuccessMessage: false })] })), _jsxs("div", { className: "cookie-banner__main", children: [_jsxs("div", { className: "cookie-banner__message", "aria-hidden": formOpen, children: [title && _jsx("h2", { className: "cookie-banner__title", children: title }), text && (_jsxs("p", { className: "cookie-banner__text", children: [text, " ", _jsx("a", { href: policyLink, children: policyLabel })] }))] }), _jsxs("div", { className: "cookie-banner__buttons", children: [allowCustomisation && !formOpen && (_jsx(_Fragment, { children: renderCustomiseButton ? (renderCustomiseButton({ onClick: openForm })) : (_jsx(Button, { onClick: openForm, className: "cookie-banner__customise", label: customiseLabel })) })), allowReject && !formOpen && (_jsx(_Fragment, { children: renderRejectButton ? (renderRejectButton({ onClick: reject })) : (_jsx(Button, { onClick: reject, className: "cookie-banner__reject", label: rejectLabel })) })), !formOpen && (_jsx(_Fragment, { children: renderAcceptButton ? (renderAcceptButton({ onClick: acceptAll })) : (_jsx(Button, { onClick: acceptAll, className: "cookie-banner__accept", label: trueAcceptLabel })) }))] })] })] }) }) })) : ('') }));
75
+ return (_jsx(_Fragment, { children: ready && ((!rejected && !cookiesAccepted) || popupOpen) ? (_jsx("div", { className: `cookie-banner ${animate ? ' cookie-banner--hide' : ''} `, children: _jsx("div", { className: "cookie-banner__container container", children: _jsxs("div", { className: "cookie-banner__inner", children: [allowCustomisation && (_jsxs("div", { className: "cookie-banner__form", "aria-hidden": !formOpen, children: [formText && (_jsx("p", { className: "cookie-banner__form-text", children: formText })), _jsx(Form, { useRecaptcha: false, className: "cookie-banner__form", schema: schema, onSubmit: submit, renderSubmit: () => renderSubmitButton ? (renderSubmitButton()) : (_jsx(SubmitButton, { label: acceptLabel })), renderSuccessMessage: false })] })), _jsxs("div", { className: "cookie-banner__main", children: [_jsxs("div", { className: "cookie-banner__message", "aria-hidden": formOpen, children: [title && _jsx("h2", { className: "cookie-banner__title", children: title }), text && (_jsxs("p", { className: "cookie-banner__text", children: [text, " ", _jsx("a", { href: policyLink, children: policyLabel })] }))] }), _jsxs("div", { className: "cookie-banner__buttons", children: [allowCustomisation && !formOpen && (_jsx(_Fragment, { children: renderCustomiseButton ? (renderCustomiseButton({ onClick: openForm })) : (_jsx(Button, { onClick: openForm, className: "cookie-banner__customise", label: customiseLabel })) })), allowReject && !formOpen && (_jsx(_Fragment, { children: renderRejectButton ? (renderRejectButton({ onClick: reject })) : (_jsx(Button, { onClick: reject, className: "cookie-banner__reject", label: rejectLabel })) })), !formOpen && (_jsx(_Fragment, { children: renderAcceptButton ? (renderAcceptButton({ onClick: acceptAll })) : (_jsx(Button, { onClick: acceptAll, className: "cookie-banner__accept", label: trueAcceptLabel })) }))] })] })] }) }) })) : ('') }));
76
76
  };
77
77
  export default CookieBanner;
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/components/form/field.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,gBAAgB,EAAuB,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,UAAU,KAAK;IACb,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;CACxC;AAED,QAAA,MAAM,SAAS,sCAAuC,KAAK,4CAuE1D,CAAA;AAED,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/components/form/field.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,gBAAgB,EAAuB,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,UAAU,KAAK;IACb,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;CACxC;AAED,QAAA,MAAM,SAAS,sCAAuC,KAAK,4CA0E1D,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -14,6 +14,9 @@ const FormField = ({ register, schema, id, onInput }) => {
14
14
  ...(schema?.spec?.meta?.placeholder
15
15
  ? { placeholder: schema?.spec?.meta?.placeholder }
16
16
  : {}),
17
+ ...(schema?.spec?.meta?.autocomplete
18
+ ? { autocomplete: schema?.spec?.meta?.autocomplete }
19
+ : {}),
17
20
  onInput: (event) => {
18
21
  setTouched(true);
19
22
  if (onInput) {
@@ -1,5 +1,5 @@
1
1
  declare const SubmitButton: ({ label }: {
2
- label?: string | undefined;
2
+ label?: string;
3
3
  }) => import("react/jsx-runtime").JSX.Element;
4
4
  export default SubmitButton;
5
5
  //# sourceMappingURL=submit-button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"submit-button.d.ts","sourceRoot":"","sources":["../../src/components/form/submit-button.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;6CAIjB,CAAA;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"submit-button.d.ts","sourceRoot":"","sources":["../../src/components/form/submit-button.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY,cAAe;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,4CAIlD,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -6,7 +6,7 @@ import { FieldRenderer } from './form/types';
6
6
  export interface FormProps<T extends ObjectSchema<any>> {
7
7
  schema: T;
8
8
  name?: string;
9
- action?: string | ((formData: FormData) => any);
9
+ action?: string | ((data: InferType<T>, token: string) => any);
10
10
  className?: string;
11
11
  method?: string;
12
12
  initialData?: {
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/components/form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,EAQV,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAExD,OAAO,EAAE,UAAU,EAAW,MAAM,iBAAiB,CAAA;AAErD,OAAiB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAU5C,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC;IACpD,MAAM,EAAE,CAAC,CAAA;IACT,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAA;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE;SAAG,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,GAAG;KAAE,CAAA;IACzC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACvC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,oBAAoB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,GAAG,KAAK,CAAA;IAClE,kBAAkB,CAAC,EAAE,CACnB,KAAK,CAAC,EAAE,UAAU,EAClB,WAAW,CAAC,EAAE,SAAS,KACpB,SAAS,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,SAAS,CAAA;IAC9B,SAAS,CAAC,EAAE;SAAG,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,aAAa;KAAE,CAAA;IACjD,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;;AAyPD,wBAA+B"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/components/form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,EAQV,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAExD,OAAO,EAAE,UAAU,EAAW,MAAM,iBAAiB,CAAA;AAErD,OAAiB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAa5C,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC;IACpD,MAAM,EAAE,CAAC,CAAA;IACT,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,CAAA;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE;SAAG,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,GAAG;KAAE,CAAA;IACzC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACvC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,oBAAoB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,GAAG,KAAK,CAAA;IAClE,kBAAkB,CAAC,EAAE,CACnB,KAAK,CAAC,EAAE,UAAU,EAClB,WAAW,CAAC,EAAE,SAAS,KACpB,SAAS,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,SAAS,CAAA;IAC9B,SAAS,CAAC,EAAE;SAAG,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,aAAa;KAAE,CAAA;IACjD,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;;AA8QD,wBAA+B"}
@@ -10,7 +10,7 @@ import ErrorMessage from './form/error-message';
10
10
  import FormField from './form/field';
11
11
  import SubmitButton from './form/submit-button';
12
12
  import messages from './form/messages.json';
13
- import { useGoogleReCaptcha } from 'react-google-recaptcha-v3';
13
+ import { GoogleReCaptchaProvider, useGoogleReCaptcha, } from 'react-google-recaptcha-v3';
14
14
  const toBase64 = (file) => new Promise((resolve, reject) => {
15
15
  const reader = new FileReader();
16
16
  reader.onloadend = () => {
@@ -24,7 +24,7 @@ const toBase64 = (file) => new Promise((resolve, reject) => {
24
24
  reader.readAsDataURL(file);
25
25
  reader.onerror = reject;
26
26
  });
27
- function Form({ schema, name, action, className, initialData, onSubmit, method = 'post', onStatusChange = () => { }, renderSuccessMessage = (data) => _jsx(SuccessMessage, {}), renderErrorMessage = (error, fieldSchema) => (_jsx(ErrorMessage, { error: error, fieldSchema: fieldSchema })), renderSubmit = () => _jsx(SubmitButton, {}), renderers = {}, useRecaptcha = true, ...props }, ref) {
27
+ const FormInner = forwardRef(function FormInner({ schema, name, action, className, initialData, onSubmit, method, onStatusChange = () => { }, renderSuccessMessage = (data) => _jsx(SuccessMessage, {}), renderErrorMessage = (error, fieldSchema) => (_jsx(ErrorMessage, { error: error, fieldSchema: fieldSchema })), renderSubmit = () => _jsx(SubmitButton, {}), renderers = {}, useRecaptcha = true, ...props }, ref) {
28
28
  const [data, setData] = useState({});
29
29
  const fieldRefs = useRef({});
30
30
  const { executeRecaptcha } = useGoogleReCaptcha();
@@ -42,12 +42,15 @@ function Form({ schema, name, action, className, initialData, onSubmit, method =
42
42
  if (onSubmit) {
43
43
  return onSubmit(data);
44
44
  }
45
+ // if recaptcha is enabled generate a token and add to the data
46
+ if (useRecaptcha && executeRecaptcha) {
47
+ const token = await executeRecaptcha();
48
+ data['recaptchaToken'] = token;
49
+ }
50
+ // Intercept submissions for Next server actions
45
51
  if (typeof action === 'function') {
46
- const formData = new FormData();
47
- for (const [key, value] of Object.entries(data)) {
48
- formData.append(key, value);
49
- }
50
- return action(formData);
52
+ const { recaptchaToken, ...formData } = data;
53
+ return action(formData, recaptchaToken);
51
54
  }
52
55
  for (const [key, value] of Object.entries(data)) {
53
56
  if (value instanceof FileList) {
@@ -65,11 +68,6 @@ function Form({ schema, name, action, className, initialData, onSubmit, method =
65
68
  }
66
69
  }
67
70
  }
68
- // if recaptcha is enabled generate a token and add to the data
69
- if (useRecaptcha && executeRecaptcha) {
70
- const token = await executeRecaptcha();
71
- data['recaptchaToken'] = token;
72
- }
73
71
  const response = await fetch(action, {
74
72
  method: 'post',
75
73
  headers: {
@@ -101,16 +99,28 @@ function Form({ schema, name, action, className, initialData, onSubmit, method =
101
99
  field.spec.label = sentenceCase(fieldName);
102
100
  }
103
101
  });
104
- return (_jsx(_Fragment, { children: status === 'success' && renderSuccessMessage !== false ? (_jsx(_Fragment, { children: renderSuccessMessage(data) })) : (_jsxs("form", { className: `form ${className}`, action: action, method: method, onSubmit: handleSubmit(execute), noValidate: true, ref: ref, ...props, children: [error && renderErrorMessage({ message: error }), Object.keys(schema.fields).map((fieldName, key) => {
102
+ return (_jsx(_Fragment, { children: status === 'success' && renderSuccessMessage !== false ? (_jsx(_Fragment, { children: renderSuccessMessage(data) })) : (_jsxs("form", { className: `form ${className}`, action: action, ...(method ? { method } : {}), onSubmit: handleSubmit(execute), noValidate: true, ref: ref, ...props, children: [error && renderErrorMessage({ message: error }), Object.keys(schema.fields).map((fieldName, key) => {
105
103
  const field = schema.fields[fieldName];
106
104
  return (_jsx(Fragment, { children: field?.spec?.meta?.hidden === true ? (_jsx(FormField, { register: register(fieldName), schema: field })) : (_jsx("div", { className: `form__group form__group--${paramCase(fieldName)} ${fieldName in errors ? 'form__group--error' : ''} ${field?.type === 'boolean' ? 'form__group--checkbox' : ''}`, ref: (ref) => {
107
105
  fieldRefs.current[fieldName] = ref;
108
106
  }, children: _jsxs("label", { className: "form__label", htmlFor: `${name}__${paramCase(fieldName)}`, children: [_jsx("span", { className: "form__label-text", dangerouslySetInnerHTML: {
109
- __html: `${field?.spec?.label} ${!field?.spec?.optional ? '*' : ''}`,
107
+ __html: `${field?.spec?.label} ${!field?.spec?.optional
108
+ ? '<span class="form__required-indicator">*</span>'
109
+ : ''}`,
110
110
  } }), fieldName in renderers ? (renderers[fieldName](register(fieldName), errors[fieldName], field)) : (_jsxs(_Fragment, { children: [_jsx(FormField, { register: register(fieldName), id: `${name}__${paramCase(fieldName)}`, schema: field, onInput: (event) => {
111
111
  fieldRefs.current[fieldName]?.classList.add('form__group--filled');
112
112
  } }), fieldName in errors &&
113
113
  renderErrorMessage(errors[fieldName], field)] }))] }) })) }, key));
114
114
  }), renderSubmit(), useRecaptcha && (_jsxs("p", { className: "form__recaptcha-message", children: ["This site is protected by reCAPTCHA and the Google", ' ', _jsx("a", { href: "https://policies.google.com/privacy", target: "_blank", rel: "noopener", children: "Privacy Policy" }), ' ', "and", ' ', _jsx("a", { href: "https://policies.google.com/terms", target: "_blank", rel: "noopener", children: "Terms of Service" }), ' ', "apply."] }))] })) }));
115
- }
115
+ });
116
+ const Form = (props, ref) => {
117
+ if (props.useRecaptcha === false) {
118
+ return _jsx(FormInner, { ...props, ref: ref });
119
+ }
120
+ const key = process.env.NEXT_PUBLIC_RECAPTCHA_KEY;
121
+ if (!key) {
122
+ throw new Error('Env var NEXT_PUBLIC_RECAPTCHA_KEY is not set');
123
+ }
124
+ return (_jsx(GoogleReCaptchaProvider, { reCaptchaKey: process.env.NEXT_PUBLIC_RECAPTCHA_KEY, children: _jsx(FormInner, { ...props, ref: ref }) }));
125
+ };
116
126
  export default forwardRef(Form);
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../src/components/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAKlB,MAAM,OAAO,CAAA;AAId,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,QAAA,MAAM,KAAK,2DAMR,kBAAkB,KAAK,CAAC,4CAyC1B,CAAA;AAED,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../src/components/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAKlB,MAAM,OAAO,CAAA;AAId,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,QAAA,MAAM,KAAK,2DAMR,iBAAiB,CAAC,KAAK,CAAC,4CAyC1B,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { ButtonProps } from './button';
3
+ import { Slideshow } from '@/hooks/use-slideshow';
4
+ declare const SlideshowButtons: ({ slideshow: { currentSlide, goTo, slideshowRef, atStart, atEnd }, ButtonComponent, }: {
5
+ slideshow: Slideshow;
6
+ ButtonComponent?: FC<ButtonProps>;
7
+ }) => JSX.Element;
8
+ export default SlideshowButtons;
9
+ //# sourceMappingURL=slideshow-buttons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slideshow-buttons.d.ts","sourceRoot":"","sources":["../src/components/slideshow-buttons.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC1B,OAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,QAAA,MAAM,gBAAgB,0FAGnB;IACD,SAAS,EAAE,SAAS,CAAA;IACpB,eAAe,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAA;CAClC,KAAG,GAAG,CAAC,OAqBP,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Button from './button';
3
+ const SlideshowButtons = ({ slideshow: { currentSlide, goTo, slideshowRef, atStart, atEnd }, ButtonComponent = Button, }) => {
4
+ return (_jsxs("nav", { className: "slideshow-buttons", children: [_jsx(ButtonComponent, { label: "Previous slide", onClick: () => goTo(currentSlide - 1), disabled: atStart, "aria-controls": slideshowRef.current?.getAttribute('id') }), _jsx(ButtonComponent, { label: "Next slide", onClick: () => goTo(currentSlide + 1), disabled: atEnd, "aria-controls": slideshowRef.current?.getAttribute('id') })] }));
5
+ };
6
+ export default SlideshowButtons;
@@ -0,0 +1,6 @@
1
+ import { Slideshow } from '@/hooks/use-slideshow';
2
+ declare const SlideshowPagination: ({ slideshow: { currentSlide, slideCount, goTo }, }: {
3
+ slideshow: Slideshow;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default SlideshowPagination;
6
+ //# sourceMappingURL=slideshow-pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slideshow-pagination.d.ts","sourceRoot":"","sources":["../src/components/slideshow-pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,QAAA,MAAM,mBAAmB,uDAEtB;IACD,SAAS,EAAE,SAAS,CAAA;CACrB,4CAaA,CAAA;AAED,eAAe,mBAAmB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ const SlideshowPagination = ({ slideshow: { currentSlide, slideCount, goTo }, }) => (_jsx("nav", { className: "slideshow-pagination", children: Array.from({ length: slideCount }, (_, i) => (_jsx("button", { className: "slideshow-pagination__button", "aria-current": currentSlide === i ? 'true' : 'false', onClick: () => goTo(i), children: _jsxs("span", { children: ["Slide ", i + 1] }) }, i))) }));
3
+ export default SlideshowPagination;
package/components.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Components
3
3
  */
4
+ import { Accordion, AccordionItem } from './components/accordion';
4
5
  import BackToTop from './components/back-to-top';
5
6
  import Button from './components/button';
6
7
  import CookieBanner from './components/cookie-banner';
@@ -8,5 +9,7 @@ import Form from './components/form';
8
9
  import MenuToggle from './components/menu-toggle';
9
10
  import Modal from './components/modal';
10
11
  import SkipTo from './components/skip-to';
11
- export { BackToTop, Button, CookieBanner, Form, MenuToggle, Modal, SkipTo, };
12
+ import SlideshowButtons from './components/slideshow-buttons';
13
+ import SlideshowPagination from './components/slideshow-pagination';
14
+ export { Accordion, AccordionItem, BackToTop, Button, CookieBanner, Form, MenuToggle, Modal, SkipTo, SlideshowButtons, SlideshowPagination, };
12
15
  //# sourceMappingURL=components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["src/components.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,SAAS,MAAM,0BAA0B,CAAA;AAChD,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,YAAY,MAAM,4BAA4B,CAAA;AACrD,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,MAAM,oBAAoB,CAAA;AACtC,OAAO,MAAM,MAAM,sBAAsB,CAAA;AAEzC,OAAO,EACL,SAAS,EACT,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,GACP,CAAA"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["src/components.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,SAAS,MAAM,0BAA0B,CAAA;AAChD,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,YAAY,MAAM,4BAA4B,CAAA;AACrD,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,MAAM,oBAAoB,CAAA;AACtC,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,gBAAgB,MAAM,gCAAgC,CAAA;AAC7D,OAAO,mBAAmB,MAAM,mCAAmC,CAAA;AAEnE,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,gBAAgB,EAChB,mBAAmB,GACpB,CAAA"}
package/components.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Components
3
3
  */
4
+ import { Accordion, AccordionItem } from './components/accordion';
4
5
  import BackToTop from './components/back-to-top';
5
6
  import Button from './components/button';
6
7
  import CookieBanner from './components/cookie-banner';
@@ -8,4 +9,6 @@ import Form from './components/form';
8
9
  import MenuToggle from './components/menu-toggle';
9
10
  import Modal from './components/modal';
10
11
  import SkipTo from './components/skip-to';
11
- export { BackToTop, Button, CookieBanner, Form, MenuToggle, Modal, SkipTo, };
12
+ import SlideshowButtons from './components/slideshow-buttons';
13
+ import SlideshowPagination from './components/slideshow-pagination';
14
+ export { Accordion, AccordionItem, BackToTop, Button, CookieBanner, Form, MenuToggle, Modal, SkipTo, SlideshowButtons, SlideshowPagination, };
@@ -0,0 +1,13 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare const CookiesContext: import("react").Context<{
3
+ cookiesAccepted: boolean;
4
+ setCookiesAccepted: (accepted: boolean) => void;
5
+ trackingCookiesAccepted: boolean;
6
+ setTrackingCookiesAccepted: (accepted: boolean) => void;
7
+ popupOpen: boolean;
8
+ openPopup: () => void;
9
+ closePopup: () => void;
10
+ }>;
11
+ export declare const CookiesContextProvider: ({ children }: PropsWithChildren<{}>) => import("react/jsx-runtime").JSX.Element;
12
+ export default CookiesContextProvider;
13
+ //# sourceMappingURL=cookies-context-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies-context-provider.d.ts","sourceRoot":"","sources":["../src/context/cookies-context-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EAKlB,MAAM,OAAO,CAAA;AAGd,eAAO,MAAM,cAAc;;mCAEM,OAAO;;2CAEC,OAAO;;;;EAI9C,CAAA;AAEF,eAAO,MAAM,sBAAsB,iBAAkB,iBAAiB,CAAC,EAAE,CAAC,4CA2DzE,CAAA;AAED,eAAe,sBAAsB,CAAA"}
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useEffect, useState, } from 'react';
4
+ import Cookies from 'js-cookie';
5
+ export const CookiesContext = createContext({
6
+ cookiesAccepted: false,
7
+ setCookiesAccepted: (accepted) => { },
8
+ trackingCookiesAccepted: false,
9
+ setTrackingCookiesAccepted: (accepted) => { },
10
+ popupOpen: false,
11
+ openPopup: () => { },
12
+ closePopup: () => { },
13
+ });
14
+ export const CookiesContextProvider = ({ children }) => {
15
+ const [cookiesAccepted, setCookiesAcceptedStorage] = useState(false);
16
+ const [popupOpen, setPopupOpenStorage] = useState(false);
17
+ const [trackingCookiesAccepted, setTrackingCookiesAcceptedStorage] = useState(false);
18
+ useEffect(() => {
19
+ const accepted = Cookies.get('accepted-cookies') || false;
20
+ setCookiesAcceptedStorage(!!accepted);
21
+ }, [setCookiesAcceptedStorage]);
22
+ useEffect(() => {
23
+ const accepted = Cookies.get('accepted-tracking-cookies') || false;
24
+ setTrackingCookiesAcceptedStorage(!!accepted);
25
+ }, [setTrackingCookiesAcceptedStorage]);
26
+ const setCookiesAccepted = useCallback((accepted) => {
27
+ Cookies.set('accepted-cookies', accepted.toString(), {
28
+ expires: 30,
29
+ });
30
+ setCookiesAcceptedStorage(accepted);
31
+ }, [setCookiesAcceptedStorage]);
32
+ const setTrackingCookiesAccepted = useCallback((accepted) => {
33
+ Cookies.set('accepted-tracking-cookies', accepted.toString(), {
34
+ expires: 30,
35
+ });
36
+ setTrackingCookiesAcceptedStorage(accepted);
37
+ }, [setTrackingCookiesAcceptedStorage]);
38
+ const openPopup = useCallback(() => {
39
+ setPopupOpenStorage(true);
40
+ }, [setPopupOpenStorage]);
41
+ const closePopup = useCallback(() => {
42
+ setPopupOpenStorage(false);
43
+ }, [setPopupOpenStorage]);
44
+ return (_jsx(CookiesContext.Provider, { value: {
45
+ cookiesAccepted,
46
+ setCookiesAccepted,
47
+ trackingCookiesAccepted,
48
+ setTrackingCookiesAccepted,
49
+ popupOpen,
50
+ openPopup,
51
+ closePopup,
52
+ }, children: children }));
53
+ };
54
+ export default CookiesContextProvider;
@@ -0,0 +1,13 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare const ModalContext: import("react").Context<{
3
+ openState: OpenState;
4
+ isOpen: (name: string) => boolean;
5
+ openModal: (name: string) => void;
6
+ closeModal: (name: string) => void;
7
+ }>;
8
+ interface OpenState {
9
+ [key: string]: boolean;
10
+ }
11
+ export declare const ModalContextProvider: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
12
+ export default ModalContextProvider;
13
+ //# sourceMappingURL=modal-context-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-context-provider.d.ts","sourceRoot":"","sources":["../src/context/modal-context-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAA;AAElE,eAAO,MAAM,YAAY;eACN,SAAS;mBACX,MAAM,KAAc,OAAO;sBACxB,MAAM;uBACL,MAAM;EACzB,CAAA;AAEF,UAAU,SAAS;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,oBAAoB,iBAAkB,iBAAiB,4CA8BnE,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useState } from 'react';
4
+ export const ModalContext = createContext({
5
+ openState: {},
6
+ isOpen: (name) => false,
7
+ openModal: (name) => { },
8
+ closeModal: (name) => { },
9
+ });
10
+ export const ModalContextProvider = ({ children }) => {
11
+ const [openState, setOpenState] = useState({});
12
+ const isOpen = (name) => {
13
+ return openState[name] || false;
14
+ };
15
+ const openModal = (name) => {
16
+ setOpenState((state) => {
17
+ const newState = { ...state };
18
+ newState[name] = true;
19
+ return newState;
20
+ });
21
+ };
22
+ const closeModal = (name) => {
23
+ setOpenState((state) => {
24
+ const newState = { ...state };
25
+ newState[name] = false;
26
+ return newState;
27
+ });
28
+ };
29
+ return (_jsx(ModalContext.Provider, { value: { openState, isOpen, openModal, closeModal }, children: children }));
30
+ };
31
+ export default ModalContextProvider;
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useLockBodyScroll } from '../hooks';
4
+ import { createContext, useCallback, useState } from 'react';
5
+ export const NavContext = createContext({
6
+ navOpen: false,
7
+ toggleNav: () => { },
8
+ openNav: () => { },
9
+ closeNav: () => { },
10
+ });
11
+ export const NavContextProvider = ({ children }) => {
12
+ const [navOpen, setNavOpen] = useState(false);
13
+ useLockBodyScroll(navOpen);
14
+ const toggleNav = useCallback(() => {
15
+ setNavOpen((navOpen) => !navOpen);
16
+ }, [setNavOpen]);
17
+ const openNav = useCallback(() => {
18
+ setNavOpen(true);
19
+ }, [setNavOpen]);
20
+ const closeNav = useCallback(() => {
21
+ setNavOpen(false);
22
+ document.activeElement?.blur();
23
+ }, [setNavOpen]);
24
+ return (_jsx(NavContext.Provider, { value: { navOpen, toggleNav, openNav, closeNav }, children: children }));
25
+ };
26
+ export default NavContextProvider;
package/context.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Context
3
3
  */
4
+ import { CookiesContext, CookiesContextProvider } from './context/cookies-context-provider';
4
5
  import { ModalContext, ModalContextProvider } from './context/modal-context-provider';
5
6
  import { NavContext, NavContextProvider } from './context/nav-context-provider';
6
- export { ModalContext, ModalContextProvider, NavContext, NavContextProvider, };
7
+ export { CookiesContext, CookiesContextProvider, ModalContext, ModalContextProvider, NavContext, NavContextProvider, };
7
8
  //# sourceMappingURL=context.d.ts.map
package/context.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["src/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,YAAY,EACZ,oBAAoB,EACrB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,kBAAkB,GACnB,CAAA"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["src/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,cAAc,EACd,sBAAsB,EACvB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,YAAY,EACZ,oBAAoB,EACrB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,kBAAkB,GACnB,CAAA"}