@superrb/react-addons 4.0.0-9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.node-version CHANGED
@@ -1 +1 @@
1
- 20
1
+ 24
@@ -1,6 +1,7 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare function AccordionItem({ title, expanded, children, }: PropsWithChildren<{
2
+ export declare function AccordionItem({ title, id: externalID, expanded, children, }: PropsWithChildren<{
3
3
  title: string;
4
+ id?: string;
4
5
  expanded?: boolean;
5
6
  }>): import("react/jsx-runtime").JSX.Element;
6
7
  export declare function Accordion({ multiple, children, }: PropsWithChildren<{
@@ -1 +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,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAgB,EAChB,QAAQ,GACT,EAAE,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,2CA0D1D;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAgB,EAChB,QAAQ,GACT,EAAE,iBAAiB,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,2CAoB3C"}
1
+ {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../src/components/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EAMlB,MAAM,OAAO,CAAA;AAcd,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,EAAE,EAAE,UAAU,EACd,QAAgB,EAChB,QAAQ,GACT,EAAE,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,2CA2DvE;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAgB,EAChB,QAAQ,GACT,EAAE,iBAAiB,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,2CAoB3C"}
@@ -6,9 +6,10 @@ const AccordionContext = createContext({
6
6
  expandedItems: [],
7
7
  setExpandedItems: () => { },
8
8
  });
9
- export function AccordionItem({ title, expanded = false, children, }) {
9
+ export function AccordionItem({ title, id: externalID, expanded = false, children, }) {
10
10
  const { multiple, expandedItems, setExpandedItems } = useContext(AccordionContext);
11
- const id = useId();
11
+ const randomID = useId();
12
+ const id = externalID || randomID;
12
13
  useEffect(() => {
13
14
  if (expanded === true) {
14
15
  setExpandedItems((expandedItems) => {
@@ -29,7 +30,7 @@ export function AccordionItem({ title, expanded = false, children, }) {
29
30
  return [...expandedItems, id];
30
31
  });
31
32
  };
32
- 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 })] }));
33
+ 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}`, children: [_jsx("span", { className: "screenreader-text", children: expandedItems ? 'Close' : 'Expand' }), title] }), _jsx("div", { className: "accordion__content", role: "tabpanel", "aria-labelledby": `${id}`, id: `${id}-panel`, children: children })] }));
33
34
  }
34
35
  export function Accordion({ multiple = false, children, }) {
35
36
  const [expandedItemsStorage, setExpandedItemsStorage] = useState([]);
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/components/form/field.tsx"],"names":[],"mappings":"AAEA,O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;IACvC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACvC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,iBAAiB,CAAA;AAErB,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;AAC9D,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAA;AACvE,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAA;AAEjE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,aAAa,GAAG,WAAW,CAAA;;AAyHjE,wBAAoC"}
@@ -38,6 +38,11 @@ function FormField({ register, schema, id, onInput, onChange, value, disabled =
38
38
  if (schema?.spec?.meta?.options?.length > 0) {
39
39
  return (_jsxs("select", { className: "form__control form__control--select", ...fieldProps, ref: ref, children: [schema?.spec?.meta?.placeholder ? (_jsx("option", { value: "", children: schema?.spec?.meta?.placeholder }, 'placeholder')) : null, schema?.spec?.meta?.options?.map((optionValue, index) => (_jsx("option", { value: optionValue, children: optionValue }, optionValue)))] }));
40
40
  }
41
- return (_jsx(_Fragment, { children: schema?.spec?.meta?.textarea === true ? (_jsx("textarea", { className: "form__control", ...fieldProps, ref: ref })) : schema?.type === 'boolean' ? (_jsx("input", { type: "checkbox", className: "form__control form__control--checkbox", checked: !rendered ? schema?.spec?.default : null, value: "true", ...fieldProps, ref: ref })) : schema?.type === 'date' ? (_jsx("input", { type: "date", className: "form__control form__control--date", ...fieldProps, ref: ref })) : schema?.spec?.meta?.hidden === true ? (_jsx("input", { type: "hidden", className: "form__control form__control--hidden", ...fieldProps, ref: ref })) : schema?.type === 'mixed' ? (_jsx(_Fragment, { children: _jsx(FileField, { schema: schema, ...fieldProps, ref: ref }) })) : (_jsx("input", { className: "form__control", ...fieldProps, ref: ref })) }));
41
+ return (_jsx(_Fragment, { children: schema?.spec?.meta?.textarea === true ? (_jsx("textarea", { className: "form__control", ...fieldProps, ref: ref })) : schema?.type === 'boolean' ? (_jsx("input", { type: "checkbox", className: "form__control form__control--checkbox", checked: !rendered ? schema?.spec?.default : null, value: "true", ...fieldProps, ref: ref })) : schema?.type === 'date' ? (_jsx("input", { type: "date", className: "form__control form__control--date", ...{
42
+ ...fieldProps,
43
+ value: fieldProps.value && fieldProps.value instanceof Date
44
+ ? fieldProps.value.toISOString().split('T')[0]
45
+ : fieldProps.value,
46
+ }, ref: ref })) : schema?.spec?.meta?.hidden === true ? (_jsx("input", { type: "hidden", className: "form__control form__control--hidden", ...fieldProps, ref: ref })) : schema?.type === 'mixed' ? (_jsx(_Fragment, { children: _jsx(FileField, { schema: schema, ...fieldProps, ref: ref }) })) : (_jsx("input", { className: "form__control", ...fieldProps, ref: ref })) }));
42
47
  }
43
48
  export default forwardRef(FormField);
@@ -32,6 +32,7 @@ export interface FormProps<T extends ObjectSchema<any>, DataStructure extends In
32
32
  export interface FormRef<T extends ObjectSchema<any>, DataStructure extends InferType<T> = InferType<T>> {
33
33
  form: HTMLFormElement;
34
34
  setValue: (name: Path<DataStructure>, value: any) => void;
35
+ setError: (name: Path<DataStructure>, error: FieldError) => void;
35
36
  submit: () => void;
36
37
  reset: () => void;
37
38
  values: WithRecaptcha<DataStructure>;
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/components/form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,EAST,oBAAoB,EAErB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAExD,OAAO,E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E,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAChE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;IACpC,MAAM,EAAE;SACL,CAAC,IAAI,aAAa,IAAI,MAAM,CAAC,CAAC,EAAE,WAAW;KAC7C,CAAA;CACF;;AAyVD,wBAA+B"}
@@ -73,7 +73,7 @@ const FormInner = forwardRef(function FormInner({ schema, name, action, disabled
73
73
  const { execute, status, error } = useAsync(onSubmitHandler, false, [
74
74
  onSubmitHandler,
75
75
  ]);
76
- const { register, handleSubmit, formState: { errors }, getValues, setValue, reset, } = useForm({
76
+ const { register, handleSubmit, formState: { errors }, getValues, setValue, setError, reset, } = useForm({
77
77
  resolver: yupResolver(schema),
78
78
  defaultValues: initialData,
79
79
  mode: 'onTouched',
@@ -95,6 +95,7 @@ const FormInner = forwardRef(function FormInner({ schema, name, action, disabled
95
95
  [key]: value,
96
96
  }), {}),
97
97
  setValue,
98
+ setError,
98
99
  errors,
99
100
  response,
100
101
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../src/components/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAIlB,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;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,WAAmB,EACnB,aAAoB,EACpB,QAAQ,GACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,2CAuE1B"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../src/components/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAKlB,MAAM,OAAO,CAAA;AASd,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;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,WAAmB,EACnB,aAAoB,EACpB,QAAQ,GACT,EAAE,iBAAiB,CAAC,KAAK,CAAC,2CA4E1B"}
@@ -2,12 +2,13 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useEffect, useRef, useCallback, } from 'react';
4
4
  import { local } from '../storage';
5
- import { useEventListener, useLockBodyScroll, useModal } from '../hooks';
5
+ import { useEscape, useEventListener, useLockBodyScroll, useModal, } from '../hooks';
6
6
  export default function Modal({ name, className, openAfter, dismissable = false, preventScroll = true, children, }) {
7
7
  const [dismissed, setDismissed] = useState(false);
8
8
  const openTimer = useRef(null);
9
9
  const ref = useRef(null);
10
10
  const innerRef = useRef(null);
11
+ const documentRef = useRef(typeof document !== 'undefined' ? document : null);
11
12
  const { isOpen, openModal, closeModal } = useModal(name);
12
13
  useLockBodyScroll(isOpen && preventScroll);
13
14
  useEffect(() => {
@@ -21,10 +22,12 @@ export default function Modal({ name, className, openAfter, dismissable = false,
21
22
  }
22
23
  if (!dismissed && openAfter) {
23
24
  openTimer.current = setTimeout(() => {
24
- openModal();
25
+ if (!dismissed) {
26
+ openModal();
27
+ }
25
28
  }, openAfter);
26
29
  }
27
- }, [dismissed, openAfter, openModal]);
30
+ }, [isOpen, dismissed, openAfter, openModal]);
28
31
  useEffect(() => {
29
32
  if (isOpen) {
30
33
  ref.current?.showModal();
@@ -36,13 +39,18 @@ export default function Modal({ name, className, openAfter, dismissable = false,
36
39
  ref.current?.close();
37
40
  };
38
41
  }, [isOpen]);
39
- useEventListener('click', closeModal, undefined, typeof document !== 'undefined' ? document : undefined);
40
42
  const close = useCallback(() => {
43
+ if (!isOpen)
44
+ return;
41
45
  closeModal();
42
46
  if (dismissable) {
43
47
  local.setItem(`${name}-popup-dismissed`, 'true');
44
48
  setDismissed(true);
45
49
  }
46
- }, [dismissable, name, closeModal]);
50
+ }, [isOpen, dismissable, name, closeModal]);
51
+ useEventListener('click', close, undefined, documentRef);
52
+ useEscape(documentRef, close, {
53
+ requireFocus: false,
54
+ });
47
55
  return (_jsxs("dialog", { id: name, className: `modal ${className}`, ref: ref, children: [_jsxs("button", { className: 'modal__close', onClick: close, children: [_jsx("span", { className: "screenreader-text", children: "Close Modal" }), "\u00D7"] }), _jsx("div", { className: 'modal__inner', ref: innerRef, onClick: (event) => event.nativeEvent.stopImmediatePropagation(), children: children })] }));
48
56
  }
package/config.d.ts CHANGED
@@ -2,4 +2,8 @@ import { CSPDirectives } from 'csp-header';
2
2
  export type CSPPresetGenerator = (...args: any[]) => Partial<CSPDirectives>;
3
3
  export declare const cspConfig: CSPPresetGenerator;
4
4
  export declare const recaptchaCspConfig: CSPPresetGenerator;
5
+ export declare const googleTagManagerCspConfig: CSPPresetGenerator;
6
+ export declare const facebookPixelCspConfig: CSPPresetGenerator;
7
+ export declare const typekitCspConfig: CSPPresetGenerator;
8
+ export declare const cloudflareCspConfig: CSPPresetGenerator;
5
9
  //# sourceMappingURL=config.d.ts.map
package/config.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;AAE3E,eAAO,MAAM,SAAS,EAAE,kBAatB,CAAA;AAEF,eAAO,MAAM,kBAAkB,EAAE,kBAO/B,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhF,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;AAE3E,eAAO,MAAM,SAAS,EAAE,kBAatB,CAAA;AAEF,eAAO,MAAM,kBAAkB,EAAE,kBAO/B,CAAA;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAoatC,CAAA;AAEF,eAAO,MAAM,sBAAsB,EAAE,kBAInC,CAAA;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAM7B,CAAA;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAUhC,CAAA"}
package/config.js CHANGED
@@ -1,14 +1,14 @@
1
- import { EVAL, INLINE, SELF, NONE } from 'csp-header';
1
+ import { EVAL, INLINE, SELF, NONE, DATA, BLOB } from 'csp-header';
2
2
  export const cspConfig = () => ({
3
3
  'default-src': [SELF],
4
4
  'connect-src': [SELF],
5
- 'script-src': [SELF, INLINE, EVAL, 'netlify-run.netlify.app'],
5
+ 'script-src': [SELF, INLINE, EVAL],
6
6
  'style-src': [SELF, INLINE],
7
- 'img-src': [SELF, 'blob:', 'data:'],
8
- 'font-src': [SELF, 'data:'],
7
+ 'img-src': [SELF, BLOB, DATA],
8
+ 'font-src': [SELF, DATA],
9
9
  'object-src': [NONE],
10
- 'media-src': [SELF, 'blob:', 'data:'],
11
- 'frame-src': [SELF, 'app.netlify.com'],
10
+ 'media-src': [SELF, BLOB, DATA],
11
+ 'frame-src': [SELF],
12
12
  'frame-ancestors': [SELF],
13
13
  'base-uri': [SELF],
14
14
  'form-action': [SELF],
@@ -21,3 +21,447 @@ export const recaptchaCspConfig = () => ({
21
21
  ],
22
22
  'frame-src': ['https://www.google.com/recaptcha/'],
23
23
  });
24
+ export const googleTagManagerCspConfig = () => ({
25
+ 'connect-src': [
26
+ 'www.googletagmanager.com',
27
+ 'www.google.com',
28
+ 'analytics.google.com',
29
+ 'https://analytics.google.com',
30
+ 'https://*.google-analytics.com',
31
+ 'https://*.analytics.google.com',
32
+ 'https://*.googletagmanager.com',
33
+ 'https://pagead2.googlesyndication.com',
34
+ 'https://www.googleadservices.com',
35
+ 'https://googleads.g.doubleclick.net',
36
+ 'https://google.com',
37
+ 'https://stats.g.doubleclick.net',
38
+ 'https://www.google.com',
39
+ 'https://www.google.ad',
40
+ 'https://www.google.ae',
41
+ 'https://www.google.com.af',
42
+ 'https://www.google.com.ag',
43
+ 'https://www.google.al',
44
+ 'https://www.google.am',
45
+ 'https://www.google.co.ao',
46
+ 'https://www.google.com.ar',
47
+ 'https://www.google.as',
48
+ 'https://www.google.at',
49
+ 'https://www.google.com.au',
50
+ 'https://www.google.az',
51
+ 'https://www.google.ba',
52
+ 'https://www.google.com.bd',
53
+ 'https://www.google.be',
54
+ 'https://www.google.bf',
55
+ 'https://www.google.bg',
56
+ 'https://www.google.com.bh',
57
+ 'https://www.google.bi',
58
+ 'https://www.google.bj',
59
+ 'https://www.google.com.bn',
60
+ 'https://www.google.com.bo',
61
+ 'https://www.google.com.br',
62
+ 'https://www.google.bs',
63
+ 'https://www.google.bt',
64
+ 'https://www.google.co.bw',
65
+ 'https://www.google.by',
66
+ 'https://www.google.com.bz',
67
+ 'https://www.google.ca',
68
+ 'https://www.google.cd',
69
+ 'https://www.google.cf',
70
+ 'https://www.google.cg',
71
+ 'https://www.google.ch',
72
+ 'https://www.google.ci',
73
+ 'https://www.google.co.ck',
74
+ 'https://www.google.cl',
75
+ 'https://www.google.cm',
76
+ 'https://www.google.cn',
77
+ 'https://www.google.com.co',
78
+ 'https://www.google.co.cr',
79
+ 'https://www.google.com.cu',
80
+ 'https://www.google.cv',
81
+ 'https://www.google.com.cy',
82
+ 'https://www.google.cz',
83
+ 'https://www.google.de',
84
+ 'https://www.google.dj',
85
+ 'https://www.google.dk',
86
+ 'https://www.google.dm',
87
+ 'https://www.google.com.do',
88
+ 'https://www.google.dz',
89
+ 'https://www.google.com.ec',
90
+ 'https://www.google.ee',
91
+ 'https://www.google.com.eg',
92
+ 'https://www.google.es',
93
+ 'https://www.google.com.et',
94
+ 'https://www.google.fi',
95
+ 'https://www.google.com.fj',
96
+ 'https://www.google.fm',
97
+ 'https://www.google.fr',
98
+ 'https://www.google.ga',
99
+ 'https://www.google.ge',
100
+ 'https://www.google.gg',
101
+ 'https://www.google.com.gh',
102
+ 'https://www.google.com.gi',
103
+ 'https://www.google.gl',
104
+ 'https://www.google.gm',
105
+ 'https://www.google.gr',
106
+ 'https://www.google.com.gt',
107
+ 'https://www.google.gy',
108
+ 'https://www.google.com.hk',
109
+ 'https://www.google.hn',
110
+ 'https://www.google.hr',
111
+ 'https://www.google.ht',
112
+ 'https://www.google.hu',
113
+ 'https://www.google.co.id',
114
+ 'https://www.google.ie',
115
+ 'https://www.google.co.il',
116
+ 'https://www.google.im',
117
+ 'https://www.google.co.in',
118
+ 'https://www.google.iq',
119
+ 'https://www.google.is',
120
+ 'https://www.google.it',
121
+ 'https://www.google.je',
122
+ 'https://www.google.com.jm',
123
+ 'https://www.google.jo',
124
+ 'https://www.google.co.jp',
125
+ 'https://www.google.co.ke',
126
+ 'https://www.google.com.kh',
127
+ 'https://www.google.ki',
128
+ 'https://www.google.kg',
129
+ 'https://www.google.co.kr',
130
+ 'https://www.google.com.kw',
131
+ 'https://www.google.kz',
132
+ 'https://www.google.la',
133
+ 'https://www.google.com.lb',
134
+ 'https://www.google.li',
135
+ 'https://www.google.lk',
136
+ 'https://www.google.co.ls',
137
+ 'https://www.google.lt',
138
+ 'https://www.google.lu',
139
+ 'https://www.google.lv',
140
+ 'https://www.google.com.ly',
141
+ 'https://www.google.co.ma',
142
+ 'https://www.google.md',
143
+ 'https://www.google.me',
144
+ 'https://www.google.mg',
145
+ 'https://www.google.mk',
146
+ 'https://www.google.ml',
147
+ 'https://www.google.com.mm',
148
+ 'https://www.google.mn',
149
+ 'https://www.google.com.mt',
150
+ 'https://www.google.mu',
151
+ 'https://www.google.mv',
152
+ 'https://www.google.mw',
153
+ 'https://www.google.com.mx',
154
+ 'https://www.google.com.my',
155
+ 'https://www.google.co.mz',
156
+ 'https://www.google.com.na',
157
+ 'https://www.google.com.ng',
158
+ 'https://www.google.com.ni',
159
+ 'https://www.google.ne',
160
+ 'https://www.google.nl',
161
+ 'https://www.google.no',
162
+ 'https://www.google.com.np',
163
+ 'https://www.google.nr',
164
+ 'https://www.google.nu',
165
+ 'https://www.google.co.nz',
166
+ 'https://www.google.com.om',
167
+ 'https://www.google.com.pa',
168
+ 'https://www.google.com.pe',
169
+ 'https://www.google.com.pg',
170
+ 'https://www.google.com.ph',
171
+ 'https://www.google.com.pk',
172
+ 'https://www.google.pl',
173
+ 'https://www.google.pn',
174
+ 'https://www.google.com.pr',
175
+ 'https://www.google.ps',
176
+ 'https://www.google.pt',
177
+ 'https://www.google.com.py',
178
+ 'https://www.google.com.qa',
179
+ 'https://www.google.ro',
180
+ 'https://www.google.ru',
181
+ 'https://www.google.rw',
182
+ 'https://www.google.com.sa',
183
+ 'https://www.google.com.sb',
184
+ 'https://www.google.sc',
185
+ 'https://www.google.se',
186
+ 'https://www.google.com.sg',
187
+ 'https://www.google.sh',
188
+ 'https://www.google.si',
189
+ 'https://www.google.sk',
190
+ 'https://www.google.com.sl',
191
+ 'https://www.google.sn',
192
+ 'https://www.google.so',
193
+ 'https://www.google.sm',
194
+ 'https://www.google.sr',
195
+ 'https://www.google.st',
196
+ 'https://www.google.com.sv',
197
+ 'https://www.google.td',
198
+ 'https://www.google.tg',
199
+ 'https://www.google.co.th',
200
+ 'https://www.google.com.tj',
201
+ 'https://www.google.tl',
202
+ 'https://www.google.tm',
203
+ 'https://www.google.tn',
204
+ 'https://www.google.to',
205
+ 'https://www.google.com.tr',
206
+ 'https://www.google.tt',
207
+ 'https://www.google.com.tw',
208
+ 'https://www.google.co.tz',
209
+ 'https://www.google.com.ua',
210
+ 'https://www.google.co.ug',
211
+ 'https://www.google.co.uk',
212
+ 'https://www.google.com.uy',
213
+ 'https://www.google.co.uz',
214
+ 'https://www.google.com.vc',
215
+ 'https://www.google.co.ve',
216
+ 'https://www.google.co.vi',
217
+ 'https://www.google.com.vn',
218
+ 'https://www.google.vu',
219
+ 'https://www.google.ws',
220
+ 'https://www.google.rs',
221
+ 'https://www.google.co.za',
222
+ 'https://www.google.co.zm',
223
+ 'https://www.google.co.zw',
224
+ 'https://www.google.cat',
225
+ ],
226
+ 'script-src': [
227
+ 'https://www.googletagmanager.com',
228
+ 'https://googletagmanager.com',
229
+ 'https://tagmanager.google.com',
230
+ 'https://*.googletagmanager.com',
231
+ 'https://www.googleadservices.com',
232
+ 'https://www.google.com',
233
+ 'https://pagead2.googlesyndication.com',
234
+ 'https://googleads.g.doubleclick.net',
235
+ ],
236
+ 'frame-src': ['https://www.googletagmanager.com'],
237
+ 'img-src': [
238
+ 'www.googletagmanager.com',
239
+ 'https://googletagmanager.com',
240
+ 'https://ssl.gstatic.com',
241
+ 'https://www.gstatic.com',
242
+ 'https://*.google-analytics.com',
243
+ 'https://*.googletagmanager.com',
244
+ 'https://www.googletagmanager.com',
245
+ 'https://googleads.g.doubleclick.net',
246
+ 'https://www.google.com',
247
+ 'https://pagead2.googlesyndication.com',
248
+ 'https://www.googleadservices.com',
249
+ 'https://google.com',
250
+ 'https://www.google.com',
251
+ 'https://www.google.ad',
252
+ 'https://www.google.ae',
253
+ 'https://www.google.com.af',
254
+ 'https://www.google.com.ag',
255
+ 'https://www.google.al',
256
+ 'https://www.google.am',
257
+ 'https://www.google.co.ao',
258
+ 'https://www.google.com.ar',
259
+ 'https://www.google.as',
260
+ 'https://www.google.at',
261
+ 'https://www.google.com.au',
262
+ 'https://www.google.az',
263
+ 'https://www.google.ba',
264
+ 'https://www.google.com.bd',
265
+ 'https://www.google.be',
266
+ 'https://www.google.bf',
267
+ 'https://www.google.bg',
268
+ 'https://www.google.com.bh',
269
+ 'https://www.google.bi',
270
+ 'https://www.google.bj',
271
+ 'https://www.google.com.bn',
272
+ 'https://www.google.com.bo',
273
+ 'https://www.google.com.br',
274
+ 'https://www.google.bs',
275
+ 'https://www.google.bt',
276
+ 'https://www.google.co.bw',
277
+ 'https://www.google.by',
278
+ 'https://www.google.com.bz',
279
+ 'https://www.google.ca',
280
+ 'https://www.google.cd',
281
+ 'https://www.google.cf',
282
+ 'https://www.google.cg',
283
+ 'https://www.google.ch',
284
+ 'https://www.google.ci',
285
+ 'https://www.google.co.ck',
286
+ 'https://www.google.cl',
287
+ 'https://www.google.cm',
288
+ 'https://www.google.cn',
289
+ 'https://www.google.com.co',
290
+ 'https://www.google.co.cr',
291
+ 'https://www.google.com.cu',
292
+ 'https://www.google.cv',
293
+ 'https://www.google.com.cy',
294
+ 'https://www.google.cz',
295
+ 'https://www.google.de',
296
+ 'https://www.google.dj',
297
+ 'https://www.google.dk',
298
+ 'https://www.google.dm',
299
+ 'https://www.google.com.do',
300
+ 'https://www.google.dz',
301
+ 'https://www.google.com.ec',
302
+ 'https://www.google.ee',
303
+ 'https://www.google.com.eg',
304
+ 'https://www.google.es',
305
+ 'https://www.google.com.et',
306
+ 'https://www.google.fi',
307
+ 'https://www.google.com.fj',
308
+ 'https://www.google.fm',
309
+ 'https://www.google.fr',
310
+ 'https://www.google.ga',
311
+ 'https://www.google.ge',
312
+ 'https://www.google.gg',
313
+ 'https://www.google.com.gh',
314
+ 'https://www.google.com.gi',
315
+ 'https://www.google.gl',
316
+ 'https://www.google.gm',
317
+ 'https://www.google.gr',
318
+ 'https://www.google.com.gt',
319
+ 'https://www.google.gy',
320
+ 'https://www.google.com.hk',
321
+ 'https://www.google.hn',
322
+ 'https://www.google.hr',
323
+ 'https://www.google.ht',
324
+ 'https://www.google.hu',
325
+ 'https://www.google.co.id',
326
+ 'https://www.google.ie',
327
+ 'https://www.google.co.il',
328
+ 'https://www.google.im',
329
+ 'https://www.google.co.in',
330
+ 'https://www.google.iq',
331
+ 'https://www.google.is',
332
+ 'https://www.google.it',
333
+ 'https://www.google.je',
334
+ 'https://www.google.com.jm',
335
+ 'https://www.google.jo',
336
+ 'https://www.google.co.jp',
337
+ 'https://www.google.co.ke',
338
+ 'https://www.google.com.kh',
339
+ 'https://www.google.ki',
340
+ 'https://www.google.kg',
341
+ 'https://www.google.co.kr',
342
+ 'https://www.google.com.kw',
343
+ 'https://www.google.kz',
344
+ 'https://www.google.la',
345
+ 'https://www.google.com.lb',
346
+ 'https://www.google.li',
347
+ 'https://www.google.lk',
348
+ 'https://www.google.co.ls',
349
+ 'https://www.google.lt',
350
+ 'https://www.google.lu',
351
+ 'https://www.google.lv',
352
+ 'https://www.google.com.ly',
353
+ 'https://www.google.co.ma',
354
+ 'https://www.google.md',
355
+ 'https://www.google.me',
356
+ 'https://www.google.mg',
357
+ 'https://www.google.mk',
358
+ 'https://www.google.ml',
359
+ 'https://www.google.com.mm',
360
+ 'https://www.google.mn',
361
+ 'https://www.google.com.mt',
362
+ 'https://www.google.mu',
363
+ 'https://www.google.mv',
364
+ 'https://www.google.mw',
365
+ 'https://www.google.com.mx',
366
+ 'https://www.google.com.my',
367
+ 'https://www.google.co.mz',
368
+ 'https://www.google.com.na',
369
+ 'https://www.google.com.ng',
370
+ 'https://www.google.com.ni',
371
+ 'https://www.google.ne',
372
+ 'https://www.google.nl',
373
+ 'https://www.google.no',
374
+ 'https://www.google.com.np',
375
+ 'https://www.google.nr',
376
+ 'https://www.google.nu',
377
+ 'https://www.google.co.nz',
378
+ 'https://www.google.com.om',
379
+ 'https://www.google.com.pa',
380
+ 'https://www.google.com.pe',
381
+ 'https://www.google.com.pg',
382
+ 'https://www.google.com.ph',
383
+ 'https://www.google.com.pk',
384
+ 'https://www.google.pl',
385
+ 'https://www.google.pn',
386
+ 'https://www.google.com.pr',
387
+ 'https://www.google.ps',
388
+ 'https://www.google.pt',
389
+ 'https://www.google.com.py',
390
+ 'https://www.google.com.qa',
391
+ 'https://www.google.ro',
392
+ 'https://www.google.ru',
393
+ 'https://www.google.rw',
394
+ 'https://www.google.com.sa',
395
+ 'https://www.google.com.sb',
396
+ 'https://www.google.sc',
397
+ 'https://www.google.se',
398
+ 'https://www.google.com.sg',
399
+ 'https://www.google.sh',
400
+ 'https://www.google.si',
401
+ 'https://www.google.sk',
402
+ 'https://www.google.com.sl',
403
+ 'https://www.google.sn',
404
+ 'https://www.google.so',
405
+ 'https://www.google.sm',
406
+ 'https://www.google.sr',
407
+ 'https://www.google.st',
408
+ 'https://www.google.com.sv',
409
+ 'https://www.google.td',
410
+ 'https://www.google.tg',
411
+ 'https://www.google.co.th',
412
+ 'https://www.google.com.tj',
413
+ 'https://www.google.tl',
414
+ 'https://www.google.tm',
415
+ 'https://www.google.tn',
416
+ 'https://www.google.to',
417
+ 'https://www.google.com.tr',
418
+ 'https://www.google.tt',
419
+ 'https://www.google.com.tw',
420
+ 'https://www.google.co.tz',
421
+ 'https://www.google.com.ua',
422
+ 'https://www.google.co.ug',
423
+ 'https://www.google.co.uk',
424
+ 'https://www.google.com.uy',
425
+ 'https://www.google.co.uz',
426
+ 'https://www.google.com.vc',
427
+ 'https://www.google.co.ve',
428
+ 'https://www.google.co.vi',
429
+ 'https://www.google.com.vn',
430
+ 'https://www.google.vu',
431
+ 'https://www.google.ws',
432
+ 'https://www.google.rs',
433
+ 'https://www.google.co.za',
434
+ 'https://www.google.co.zm',
435
+ 'https://www.google.co.zw',
436
+ 'https://www.google.cat',
437
+ ],
438
+ 'style-src': [
439
+ 'https://googletagmanager.com',
440
+ 'https://tagmanager.google.com',
441
+ 'https://fonts.googleapis.com',
442
+ ],
443
+ 'font-src': ['https://fonts.gstatic.com'],
444
+ });
445
+ export const facebookPixelCspConfig = () => ({
446
+ 'script-src': ['https://connect.facebook.net'],
447
+ 'img-src': ['https://www.facebook.com'],
448
+ 'connect-src': ['https://www.facebook.com'],
449
+ });
450
+ export const typekitCspConfig = () => ({
451
+ 'script-src': ['use.typekit.net'],
452
+ 'style-src': ['use.typekit.net'],
453
+ 'font-src': ['use.typekit.net'],
454
+ 'img-src': ['p.typekit.net'],
455
+ 'connect-src': ['performance.typekit.net'],
456
+ });
457
+ export const cloudflareCspConfig = () => ({
458
+ 'script-src': [
459
+ SELF,
460
+ INLINE,
461
+ 'ajax.cloudflare.com',
462
+ 'static.cloudflareinsights.com',
463
+ 'https://challenges.cloudflare.com',
464
+ ],
465
+ 'connect-src': ['cloudflareinsights.com'],
466
+ 'frame-src': ['https://challenges.cloudflare.com'],
467
+ });