@flipdish/portal-library 1.0.47 → 1.0.49
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/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js +2 -0
- package/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js.map +1 -0
- package/dist/components/custom-hooks/useMicroFrontendAttributes.d.ts +28 -0
- package/dist/components/custom-hooks/useMicroFrontendAttributes.js +2 -0
- package/dist/components/custom-hooks/useMicroFrontendAttributes.js.map +1 -0
- package/dist/components/custom-hooks/useRenderValidText.d.ts +13 -0
- package/dist/components/index.cjs.js +1 -1
- package/dist/components/{components/index.d.ts → index.d.ts} +3 -1
- package/dist/components/index.js +1 -1
- package/dist/components/renderUtilities/renderUtilities.cjs.js.map +1 -0
- package/dist/components/renderUtilities/renderUtilities.d.ts +33 -0
- package/dist/components/renderUtilities/renderUtilities.js.map +1 -0
- package/dist/components/ui/PageLayout/PageLayout.cjs.js +1 -1
- package/dist/components/ui/PageLayout/PageLayout.cjs.js.map +1 -1
- package/dist/components/ui/PageLayout/PageLayout.js +1 -1
- package/dist/components/ui/PageLayout/PageLayout.js.map +1 -1
- package/dist/providers/TranslationProvider.cjs.js.map +1 -1
- package/dist/providers/TranslationProvider.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/utilities/renderUtilities.d.ts +0 -9
- package/dist/utilities/renderUtilities.cjs.js.map +0 -1
- package/dist/utilities/renderUtilities.js.map +0 -1
- /package/dist/{utilities → components/renderUtilities}/renderUtilities.cjs.js +0 -0
- /package/dist/{utilities → components/renderUtilities}/renderUtilities.js +0 -0
- /package/dist/components/{components/themes → themes}/flipdishPublicTheme.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Chip/Chip.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/DateTimeLocalizationProvider/DateTimeLocalizationProvider.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/FlipdishStaffContainer/FlipdishStaffContainer.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Form/GenericAutocompleteField.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Form/GenericFormContainer.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Form/GenericTextField.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Form/PaginatedAutocompleteField.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Form/utilities/formValidation.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericDateTimePickerField/GenericDateTimePickerField.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericRadioButtons/GenericRadioButtons.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericTable/GenericTable.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericTable/types.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericTableBody/GenericTableBody.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericTableBodyRow/GenericTableBodyRow.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/GenericTableTitle/GenericTableTitle.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/LazyComponent/LazyComponent.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/NotFoundPage/NotFoundPage.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/PageLayout/PageLayout.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/PortalMock/PortalMock.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Spacer/Spacer.d.ts +0 -0
- /package/dist/components/{components/ui → ui}/Switch/Switch.d.ts +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("react");const e=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}];module.exports=(n=[])=>{const[r,o]=t.useState((()=>{const t=[...e.map((t=>"string"==typeof t?t:t.key)),...n.map((t=>"string"==typeof t?t:t.key))],r={};return t.forEach((t=>{r[t]=null})),r}));return t.useEffect((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const r=[...e.map((t=>"string"==typeof t?t:t.key)),...n.map((t=>"string"==typeof t?t:t.key))],s=()=>{o((o=>{const s={...o};let i=!1;return r.forEach((r=>{const o=[...e,...n].find((t=>"string"==typeof t?t===r:t.key===r)),u=o&&"string"!=typeof o&&"type"in o?o.type:"string",p=(void 0)[`VITE_${("string"==typeof r?r:r.key).toUpperCase()}_OVERRIDE`];let f=null;if(p)f="boolean"===u?"true"===p.toString():"number"===u?Number(p):p;else{const e=`data-${"string"==typeof r?r:r.key}`,n=t.getAttribute(e);f="boolean"===u?"true"===n:"number"===u?n?Number(n):null:n}s[r]!==f&&(s[r]=f,i=!0)})),i?s:o}))};s();const i=new MutationObserver((()=>{s()}));return i.observe(t,{attributes:!0}),()=>i.disconnect()}),[n]),r};
|
|
2
|
+
//# sourceMappingURL=useMicroFrontendAttributes.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMicroFrontendAttributes.cjs.js","sources":["../../../src/components/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'string' | 'boolean' | 'number';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (string | KeyConfig)[] = ['orgId', 'appId', { key: 'isFlipdishStaff', type: 'boolean' }] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends string | KeyConfig>(\n customKeys: (T | KeyConfig)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> => {\n const [attributes, setAttributes] = useState(() => {\n // Create a union of all keys (ALWAYS_RETURN_KEYS and customKeys) and ensure they are all strings\n const allKeys: ExtractKey<AlwaysReturnKeys | T>[] = [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n\n // Initialize the state with null values for each of the keys\n const initialState: Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> = {} as Record<\n ExtractKey<AlwaysReturnKeys | T>,\n string | boolean | number | null\n >;\n\n allKeys.forEach((key) => {\n initialState[key] = null; // Set the value to null initially\n });\n\n return initialState;\n });\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys: (string | T | AlwaysReturnKeys)[] = [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes: Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> = { ...prev };\n\n let isChanged = false; // To track if any attribute is changed\n\n allKeys.forEach((key) => {\n // Find the config for the current key (either in ALWAYS_RETURN_KEYS or customKeys)\n const keyConfig = [...ALWAYS_RETURN_KEYS, ...customKeys].find((config) =>\n typeof config === 'string' ? config === key : config.key === key,\n );\n const type = keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig ? keyConfig.type : 'string';\n\n // Fetch value from environment variable or DOM attribute\n const envVar = import.meta.env[`VITE_${(typeof key === 'string' ? key : key.key).toUpperCase()}_OVERRIDE`];\n let newValue: string | boolean | number | null = null;\n\n if (envVar) {\n if (type === 'boolean') {\n newValue = envVar.toString() === 'true';\n } else if (type === 'number') {\n newValue = Number(envVar);\n } else {\n newValue = envVar;\n }\n } else {\n const attributeKey = `data-${typeof key === 'string' ? key : key.key}`;\n const value = microFrontendDiv.getAttribute(attributeKey);\n\n if (type === 'boolean') {\n newValue = value === 'true';\n } else if (type === 'number') {\n newValue = value ? Number(value) : null;\n } else {\n newValue = value;\n }\n }\n\n // Check if the value has actually changed\n if (newAttributes[key as ExtractKey<AlwaysReturnKeys | T>] !== newValue) {\n newAttributes[key as ExtractKey<AlwaysReturnKeys | T>] = newValue;\n isChanged = true; // Mark that at least one value has changed\n }\n });\n\n return isChanged ? newAttributes : prev; // Only update if something has changed\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(() => {\n updateValues();\n });\n\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","customKeys","attributes","setAttributes","useState","allKeys","map","initialState","forEach","useEffect","microFrontendDiv","document","getElementById","console","warn","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","envVar","undefined","toUpperCase","newValue","toString","Number","attributeKey","value","getAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"oCASA,MAAMA,EAA6C,CAAC,QAAS,QAAS,CAAEC,IAAK,kBAAmBC,KAAM,2BAyBnE,CAC/BC,EAAgC,MAEhC,MAAOC,EAAYC,GAAiBC,EAAQA,UAAC,KAEzC,MAAMC,EAA8C,IAC7CP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEE,EAAW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kB,CAAER,YAAY,IAE1C,IAAM6B,EAASG,YAAY,GACnC,CAACjC,IAEGC,CAAU"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type KeyType = 'string' | 'boolean' | 'number';
|
|
2
|
+
interface KeyConfig {
|
|
3
|
+
key: string;
|
|
4
|
+
type?: KeyType;
|
|
5
|
+
}
|
|
6
|
+
declare const ALWAYS_RETURN_KEYS: (string | KeyConfig)[];
|
|
7
|
+
type AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig ? (typeof ALWAYS_RETURN_KEYS)[number]['key'] : (typeof ALWAYS_RETURN_KEYS)[number];
|
|
8
|
+
type ExtractKey<T> = T extends KeyConfig ? T['key'] : T;
|
|
9
|
+
/**
|
|
10
|
+
* Custom hook to manage micro-frontend attributes.
|
|
11
|
+
*
|
|
12
|
+
* This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)
|
|
13
|
+
* and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes
|
|
14
|
+
* and are updated dynamically using a MutationObserver.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The type of custom keys, which can be either a string or a KeyConfig object.
|
|
17
|
+
*
|
|
18
|
+
* @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);
|
|
24
|
+
* console.log(attributes);
|
|
25
|
+
*/
|
|
26
|
+
declare const useMicroFrontendAttributes: <T extends string | KeyConfig>(customKeys?: (T | KeyConfig)[]) => Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>;
|
|
27
|
+
|
|
28
|
+
export { useMicroFrontendAttributes as default };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as t,useEffect as e}from"react";const n=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}],o=(o=[])=>{const[r,i]=t((()=>{const t=[...n.map((t=>"string"==typeof t?t:t.key)),...o.map((t=>"string"==typeof t?t:t.key))],e={};return t.forEach((t=>{e[t]=null})),e}));return e((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const e=[...n.map((t=>"string"==typeof t?t:t.key)),...o.map((t=>"string"==typeof t?t:t.key))],r=()=>{i((r=>{const i={...r};let s=!1;return e.forEach((e=>{const r=[...n,...o].find((t=>"string"==typeof t?t===e:t.key===e)),p=r&&"string"!=typeof r&&"type"in r?r.type:"string",a=import.meta.env[`VITE_${("string"==typeof e?e:e.key).toUpperCase()}_OVERRIDE`];let f=null;if(a)f="boolean"===p?"true"===a.toString():"number"===p?Number(a):a;else{const n=`data-${"string"==typeof e?e:e.key}`,o=t.getAttribute(n);f="boolean"===p?"true"===o:"number"===p?o?Number(o):null:o}i[e]!==f&&(i[e]=f,s=!0)})),s?i:r}))};r();const s=new MutationObserver((()=>{r()}));return s.observe(t,{attributes:!0}),()=>s.disconnect()}),[o]),r};export{o as default};
|
|
2
|
+
//# sourceMappingURL=useMicroFrontendAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMicroFrontendAttributes.js","sources":["../../../src/components/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'string' | 'boolean' | 'number';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (string | KeyConfig)[] = ['orgId', 'appId', { key: 'isFlipdishStaff', type: 'boolean' }] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends string | KeyConfig>(\n customKeys: (T | KeyConfig)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> => {\n const [attributes, setAttributes] = useState(() => {\n // Create a union of all keys (ALWAYS_RETURN_KEYS and customKeys) and ensure they are all strings\n const allKeys: ExtractKey<AlwaysReturnKeys | T>[] = [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n\n // Initialize the state with null values for each of the keys\n const initialState: Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> = {} as Record<\n ExtractKey<AlwaysReturnKeys | T>,\n string | boolean | number | null\n >;\n\n allKeys.forEach((key) => {\n initialState[key] = null; // Set the value to null initially\n });\n\n return initialState;\n });\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys: (string | T | AlwaysReturnKeys)[] = [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes: Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null> = { ...prev };\n\n let isChanged = false; // To track if any attribute is changed\n\n allKeys.forEach((key) => {\n // Find the config for the current key (either in ALWAYS_RETURN_KEYS or customKeys)\n const keyConfig = [...ALWAYS_RETURN_KEYS, ...customKeys].find((config) =>\n typeof config === 'string' ? config === key : config.key === key,\n );\n const type = keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig ? keyConfig.type : 'string';\n\n // Fetch value from environment variable or DOM attribute\n const envVar = import.meta.env[`VITE_${(typeof key === 'string' ? key : key.key).toUpperCase()}_OVERRIDE`];\n let newValue: string | boolean | number | null = null;\n\n if (envVar) {\n if (type === 'boolean') {\n newValue = envVar.toString() === 'true';\n } else if (type === 'number') {\n newValue = Number(envVar);\n } else {\n newValue = envVar;\n }\n } else {\n const attributeKey = `data-${typeof key === 'string' ? key : key.key}`;\n const value = microFrontendDiv.getAttribute(attributeKey);\n\n if (type === 'boolean') {\n newValue = value === 'true';\n } else if (type === 'number') {\n newValue = value ? Number(value) : null;\n } else {\n newValue = value;\n }\n }\n\n // Check if the value has actually changed\n if (newAttributes[key as ExtractKey<AlwaysReturnKeys | T>] !== newValue) {\n newAttributes[key as ExtractKey<AlwaysReturnKeys | T>] = newValue;\n isChanged = true; // Mark that at least one value has changed\n }\n });\n\n return isChanged ? newAttributes : prev; // Only update if something has changed\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(() => {\n updateValues();\n });\n\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","useMicroFrontendAttributes","customKeys","attributes","setAttributes","useState","allKeys","map","initialState","forEach","useEffect","microFrontendDiv","document","getElementById","console","warn","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","envVar","env","toUpperCase","newValue","toString","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YAAT1B,EACqB,SAAV8B,EACK,WAAT9B,EACI8B,EAAQF,OAAOE,GAAS,KAExBA,CAElB,CAGGZ,EAAcnB,KAA6C2B,IAC3DR,EAAcnB,GAA2C2B,EACzDP,GAAY,EACf,IAGEA,EAAYD,EAAgBD,CAAI,GACzC,EAGND,IAEA,MAAMgB,EAAW,IAAIC,kBAAiB,KAClCjB,GAAc,IAKlB,OAFAgB,EAASE,QAAQvB,EAAkB,CAAER,YAAY,IAE1C,IAAM6B,EAASG,YAAY,GACnC,CAACjC,IAEGC,CAAU"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
fieldError?: string;
|
|
3
|
+
showError?: boolean;
|
|
4
|
+
touched: boolean;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @description Use this with Formik - the touched field state is not available immediately because ```form.setFieldValue``` is async
|
|
9
|
+
* @description https://github.com/formium/formik/issues/529#issuecomment-571294217
|
|
10
|
+
*/
|
|
11
|
+
declare const useRenderValidText: ({ fieldError, showError, touched, value }: Props) => string | JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { useRenderValidText as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),i=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),r=require("./ui/FlipdishStaffContainer/FlipdishStaffContainer.cjs.js"),t=require("./ui/PageLayout/PageLayout.cjs.js"),o=require("./ui/PortalMock/PortalMock.cjs.js"),s=require("./ui/LazyComponent/LazyComponent.cjs.js"),
|
|
1
|
+
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),i=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),r=require("./ui/FlipdishStaffContainer/FlipdishStaffContainer.cjs.js"),t=require("./ui/PageLayout/PageLayout.cjs.js"),o=require("./ui/PortalMock/PortalMock.cjs.js"),s=require("./ui/LazyComponent/LazyComponent.cjs.js"),c=require("./ui/Spacer/Spacer.cjs.js"),u=require("./ui/Chip/Chip.cjs.js"),a=require("./ui/Switch/Switch.cjs.js"),n=require("./ui/Form/utilities/formValidation.cjs.js"),l=require("./ui/Form/GenericAutocompleteField.cjs.js"),p=require("./ui/Form/GenericFormContainer.cjs.js"),d=require("./ui/Form/GenericTextField.cjs.js"),j=require("./ui/Form/PaginatedAutocompleteField.cjs.js"),x=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),F=require("./ui/GenericRadioButtons/GenericRadioButtons.cjs.js"),m=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),T=require("./ui/GenericTable/GenericTable.cjs.js"),q=require("./ui/GenericTableBody/GenericTableBody.cjs.js"),G=require("./ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js"),h=require("./ui/GenericTableTitle/GenericTableTitle.cjs.js"),P=require("./custom-hooks/useRenderValidText.cjs.js"),b=require("./custom-hooks/useMicroFrontendAttributes.cjs.js"),g=require("./renderUtilities/renderUtilities.cjs.js");exports.flipdishPublicTheme=e,exports.NotFoundPage=i,exports.FlipdishStaffContainer=r,exports.PageLayout=t.default,exports.PortalMock=o,exports.LazyComponent=s,exports.Spacer=c,exports.Chip=u,exports.Switch=a,exports.formikValidate=n.formikValidate,exports.GenericAutocompleteField=l,exports.GenericFormContainer=p,exports.GenericTextField=d,exports.PaginatedAutocompleteField=j,exports.GenericDatePickerField=x,exports.GenericRadioButtons=F,exports.DateTimeLocalizationProvider=m,exports.GenericTable=T,exports.GenericTableBody=q,exports.GenericTableBodyRow=G,exports.GenericTableTitle=h,exports.useRenderValidText=P,exports.useMicroFrontendAttributes=b,exports.getAppId=g.getAppId,exports.getIsFlipdishStaff=g.getIsFlipdishStaff,exports.getMicroFrontendAttribute=g.getMicroFrontendAttribute,exports.getOrgId=g.getOrgId,exports.lazyWithRetry=g.lazyWithRetry;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -20,4 +20,6 @@ export { default as GenericTable } from './ui/GenericTable/GenericTable.js';
|
|
|
20
20
|
export { default as GenericTableBody } from './ui/GenericTableBody/GenericTableBody.js';
|
|
21
21
|
export { default as GenericTableBodyRow } from './ui/GenericTableBodyRow/GenericTableBodyRow.js';
|
|
22
22
|
export { default as GenericTableTitle } from './ui/GenericTableTitle/GenericTableTitle.js';
|
|
23
|
-
export {
|
|
23
|
+
export { default as useRenderValidText } from './custom-hooks/useRenderValidText.js';
|
|
24
|
+
export { default as useMicroFrontendAttributes } from './custom-hooks/useMicroFrontendAttributes.js';
|
|
25
|
+
export { getAppId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry } from './renderUtilities/renderUtilities.js';
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{default as flipdishPublicTheme}from"./themes/flipdishPublicTheme.js";export{default as NotFoundPage}from"./ui/NotFoundPage/NotFoundPage.js";export{default as FlipdishStaffContainer}from"./ui/FlipdishStaffContainer/FlipdishStaffContainer.js";export{default as PageLayout}from"./ui/PageLayout/PageLayout.js";export{default as PortalMock}from"./ui/PortalMock/PortalMock.js";export{default as LazyComponent}from"./ui/LazyComponent/LazyComponent.js";export{default as Spacer}from"./ui/Spacer/Spacer.js";export{default as Chip}from"./ui/Chip/Chip.js";export{default as Switch}from"./ui/Switch/Switch.js";export{formikValidate}from"./ui/Form/utilities/formValidation.js";export{default as GenericAutocompleteField}from"./ui/Form/GenericAutocompleteField.js";export{default as GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.js";export{default as PaginatedAutocompleteField}from"./ui/Form/PaginatedAutocompleteField.js";export{default as GenericDatePickerField}from"./ui/GenericDateTimePickerField/GenericDateTimePickerField.js";export{default as GenericRadioButtons}from"./ui/GenericRadioButtons/GenericRadioButtons.js";export{default as DateTimeLocalizationProvider}from"./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.js";export{default as GenericTable}from"./ui/GenericTable/GenericTable.js";export{default as GenericTableBody}from"./ui/GenericTableBody/GenericTableBody.js";export{default as GenericTableBodyRow}from"./ui/GenericTableBodyRow/GenericTableBodyRow.js";export{default as GenericTableTitle}from"./ui/GenericTableTitle/GenericTableTitle.js";
|
|
1
|
+
export{default as flipdishPublicTheme}from"./themes/flipdishPublicTheme.js";export{default as NotFoundPage}from"./ui/NotFoundPage/NotFoundPage.js";export{default as FlipdishStaffContainer}from"./ui/FlipdishStaffContainer/FlipdishStaffContainer.js";export{default as PageLayout}from"./ui/PageLayout/PageLayout.js";export{default as PortalMock}from"./ui/PortalMock/PortalMock.js";export{default as LazyComponent}from"./ui/LazyComponent/LazyComponent.js";export{default as Spacer}from"./ui/Spacer/Spacer.js";export{default as Chip}from"./ui/Chip/Chip.js";export{default as Switch}from"./ui/Switch/Switch.js";export{formikValidate}from"./ui/Form/utilities/formValidation.js";export{default as GenericAutocompleteField}from"./ui/Form/GenericAutocompleteField.js";export{default as GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.js";export{default as PaginatedAutocompleteField}from"./ui/Form/PaginatedAutocompleteField.js";export{default as GenericDatePickerField}from"./ui/GenericDateTimePickerField/GenericDateTimePickerField.js";export{default as GenericRadioButtons}from"./ui/GenericRadioButtons/GenericRadioButtons.js";export{default as DateTimeLocalizationProvider}from"./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.js";export{default as GenericTable}from"./ui/GenericTable/GenericTable.js";export{default as GenericTableBody}from"./ui/GenericTableBody/GenericTableBody.js";export{default as GenericTableBodyRow}from"./ui/GenericTableBodyRow/GenericTableBodyRow.js";export{default as GenericTableTitle}from"./ui/GenericTableTitle/GenericTableTitle.js";export{default as useRenderValidText}from"./custom-hooks/useRenderValidText.js";export{default as useMicroFrontendAttributes}from"./custom-hooks/useMicroFrontendAttributes.js";export{getAppId,getIsFlipdishStaff,getMicroFrontendAttribute,getOrgId,lazyWithRetry}from"./renderUtilities/renderUtilities.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderUtilities.cjs.js","sources":["../../../src/components/renderUtilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string | null => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv && microFrontendDiv.getAttribute(key);\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string | null => {\n return import.meta.env.VITE_APPID_OVERRIDE || getMicroFrontendAttribute('data-appId');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string | null => {\n return import.meta.env.VITE_ORGID_OVERRIDE || getMicroFrontendAttribute('data-orgId');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n const stringValue = import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE || getMicroFrontendAttribute('data-isFlipdishStaff');\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');\n\n try {\n const component = await componentImport();\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","undefined","VITE_APPID_OVERRIDE","stringValue","VITE_ISFLIPDISHSTAFFOVERRIDE","toString","VITE_ORGID_OVERRIDE","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"oCAEa,MAAAA,EAA6BC,IACtC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAoBA,EAAiBG,aAAaJ,EAAI,mBAWzC,UACbK,GAAgBC,qBAAuBP,EAA0B,yCAuB1C,KAC9B,MAAMQ,QAAcF,GAAgBG,8BAAgCT,EAA0B,wBAC9F,MAAmC,SAA5BQ,GAAaE,UAAqB,uDAdrB,UACbJ,GAAgBK,qBAAuBX,EAA0B,oCAiB9CY,GAC1BC,EAAAA,MAAKC,UACD,MAAMC,EAAmCC,KAAKC,MAAMC,OAAOC,eAAeC,QAAQ,kCAAoC,SAEtH,IACI,MAAMC,QAAkBT,IAGxB,OAFAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAExDD,CACV,CAAC,MAAOE,GACL,IAAKR,EAID,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAM3B,MAAMF,CACT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare const getMicroFrontendAttribute: (key: string) => string | null;
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the AppId.
|
|
6
|
+
*
|
|
7
|
+
* Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.
|
|
8
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.
|
|
9
|
+
*
|
|
10
|
+
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
11
|
+
*/
|
|
12
|
+
declare const getAppId: () => string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves the OrgId.
|
|
15
|
+
*
|
|
16
|
+
* Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.
|
|
17
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.
|
|
18
|
+
*
|
|
19
|
+
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
20
|
+
*/
|
|
21
|
+
declare const getOrgId: () => string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the isFlipdishStaff attribute.
|
|
24
|
+
*
|
|
25
|
+
* Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.
|
|
26
|
+
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.
|
|
27
|
+
*
|
|
28
|
+
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
29
|
+
*/
|
|
30
|
+
declare const getIsFlipdishStaff: () => boolean;
|
|
31
|
+
declare const lazyWithRetry: (componentImport: () => any) => React.LazyExoticComponent<React.ComponentType<any>>;
|
|
32
|
+
|
|
33
|
+
export { getAppId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderUtilities.js","sources":["../../../src/components/renderUtilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string | null => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv && microFrontendDiv.getAttribute(key);\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string | null => {\n return import.meta.env.VITE_APPID_OVERRIDE || getMicroFrontendAttribute('data-appId');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string | null => {\n return import.meta.env.VITE_ORGID_OVERRIDE || getMicroFrontendAttribute('data-orgId');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n const stringValue = import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE || getMicroFrontendAttribute('data-isFlipdishStaff');\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');\n\n try {\n const component = await componentImport();\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","getAppId","env","VITE_APPID_OVERRIDE","getOrgId","VITE_ORGID_OVERRIDE","getIsFlipdishStaff","stringValue","VITE_ISFLIPDISHSTAFFOVERRIDE","toString","lazyWithRetry","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"6BAEa,MAAAA,EAA6BC,IACtC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAoBA,EAAiBG,aAAaJ,EAAI,EAWpDK,EAAW,gBACDC,IAAIC,qBAAuBR,EAA0B,cAW/DS,EAAW,gBACDF,IAAIG,qBAAuBV,EAA0B,cAW/DW,EAAqB,KAC9B,MAAMC,cAA0BL,IAAIM,8BAAgCb,EAA0B,wBAC9F,MAAmC,SAA5BY,GAAaE,UAAqB,EAIhCC,EAAiBC,GAC1BC,GAAKC,UACD,MAAMC,EAAmCC,KAAKC,MAAMC,OAAOC,eAAeC,QAAQ,kCAAoC,SAEtH,IACI,MAAMC,QAAkBT,IAGxB,OAFAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAExDD,CACV,CAAC,MAAOE,GACL,IAAKR,EAID,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAM3B,MAAMF,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/icons-material/Add"),t=require("@mui/icons-material/ArrowBack"),n=require("@mui/material/Grid"),r=require("@mui/material/IconButton"),a=require("@mui/material/styles"),s=require("@mui/material/Typography"),o=require("@mui/material/useMediaQuery"),d=require("./DocumentTitle.cjs.js"),l=require("./FullWidthContainer.cjs.js"),c=require("../FDErrorBoundary/FDErrorBoundary.cjs.js"),m=require("@mui/material/Button"),p=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/icons-material/Add"),t=require("@mui/icons-material/ArrowBack"),n=require("@mui/material/Grid"),r=require("@mui/material/IconButton"),a=require("@mui/material/styles"),s=require("@mui/material/Typography"),o=require("@mui/material/useMediaQuery"),d=require("./DocumentTitle.cjs.js"),l=require("./FullWidthContainer.cjs.js"),c=require("../FDErrorBoundary/FDErrorBoundary.cjs.js"),m=require("@mui/material/Button"),p=require("../../renderUtilities/renderUtilities.cjs.js"),h=require("../../../utilities/validation.cjs.js"),g=require("../Spacer/Spacer.cjs.js"),u=require("@mui/material/Box"),x=require("@mui/material/Divider");const j=1112,y=a.styled("div")((({theme:e,fluid:i})=>({maxWidth:i?"none":j,[e.breakpoints.down("md")]:{maxWidth:"none"},margin:e.spacing(2,4)}))),f=a.styled(n)((({theme:e})=>({[e.breakpoints.down("sm")]:{width:"100%",paddingTop:e.spacing(2)}}))),v=a.styled(n)((({theme:e})=>({flexWrap:"nowrap",alignItems:"flex-start",paddingTop:e.spacing(3),paddingBottom:e.spacing(3),[e.breakpoints.down("md")]:{paddingTop:e.spacing(2),paddingBottom:e.spacing(3)}}))),b=a.styled(n)((({theme:e})=>({paddingTop:e.spacing(2)}))),k=a.styled(n)((()=>({flexGrow:1}))),B=a.styled("div")((({theme:e})=>({maxWidth:j,paddingBottom:e.spacing(3),[e.breakpoints.down("md")]:{paddingBottom:e.spacing(2),paddingLeft:e.spacing(2),paddingRight:e.spacing(2)}}))),q=a.styled(r,{shouldForwardProp:e=>"hasTitleComponent"!==e})((({theme:e,hasTitleComponent:i})=>({margin:i?e.spacing(-.75,2,-1.5,-1.5):e.spacing(-1.5,2,-1.5,-1.5),[e.breakpoints.only("sm")]:{marginLeft:e.spacing(-2)},[e.breakpoints.only("xs")]:{marginLeft:e.spacing(-2)}}))),w=a.styled("div")((({theme:e})=>({maxWidth:j,marginLeft:e.spacing(6),marginRight:e.spacing(4),paddingBottom:e.spacing(2),[e.breakpoints.only("md")]:{marginLeft:12,marginRight:e.spacing(3)},[e.breakpoints.only("sm")]:{marginLeft:e.spacing(3),marginRight:e.spacing(3),maxWidth:"none"},[e.breakpoints.only("xs")]:{marginLeft:e.spacing(2),marginRight:e.spacing(2),maxWidth:"none"}}))),T=a.styled(n)((()=>({display:"flex",flexGrow:1,justifyContent:"flex-end"}))),W=a.styled(s)((()=>({lineHeight:"26px"}))),C=a.styled(s)((()=>({fontWeight:"bold"}))),L=a.styled(x)((({theme:e})=>({marginBottom:e.spacing(4)}))),F=({title:i})=>e.jsx(C,{variant:"h5",component:"h2",children:i});exports.PageTitle=F,exports.default=r=>{const{actionBtnTitle:s,caption:x,children:j,contextButtons:C,documentTitle:A,fluid:P=!1,fullWidth:D,header:I,hideHeader:R,actionButtonLink:z,openLinkInNewTab:_=!1,pageHeader:G,showActionButton:H,showAddIcon:M,strictToParent:U,title:E,titleComponent:S,toParent:N,navigate:O,hideDivider:Q=!1,customActionButtons:$}=r,J=a.useTheme(),K=o(J.breakpoints.down("md")),V=p.getMicroFrontendAttribute("data-portal-base-url")||"/",X=z?.startsWith("https://"),Y=X?z:void 0!==z?h.joinUrlPaths(V,z):"";return e.jsxs(y,{fluid:P,children:[A&&e.jsx(d,{children:A}),G||null,e.jsxs(w,{children:[G&&e.jsx(g,{size:16,variant:"vertical"}),!R&&e.jsxs(e.Fragment,{children:[e.jsxs(v,{container:!0,alignItems:"center",direction:"column",children:[e.jsx(n,{item:!0,container:!0,direction:"row",alignContent:"space-between",children:e.jsx(T,{item:!0,children:C&&C.map(((i,t)=>e.jsx("div",{children:i},t)))})}),e.jsxs(b,{item:!0,container:!0,children:[N&&e.jsx(u,{children:e.jsx(q,{"aria-label":"Back","data-testid":"back_button",hasTitleComponent:!!S,component:"button",onClick:()=>{N&&U||N&&history.length<3?O(N):O(-1)},children:e.jsx(t,{})})}),e.jsxs(k,{item:!0,children:[S?e.jsx(S,{}):e.jsx(F,{title:E}),x&&e.jsx(W,{variant:"caption",component:"h3",children:x})]}),H&&e.jsxs(e.Fragment,{children:[K&&e.jsx(g,{size:56,variant:"vertical"}),e.jsx(f,{item:!0,children:e.jsxs(m,{variant:"contained",fullWidth:!0,"data-testid":`Action-button-${s}`,href:_||X?Y:"",target:_?"_blank":void 0,rel:_?"noopener noreferrer":void 0,onClick:_||X?()=>{}:()=>O(z),children:[M&&e.jsx(i,{}),s]})})]}),$&&$.map(((i,t)=>e.jsxs("div",{children:[K&&e.jsx(g,{size:56,variant:"vertical"}),!K&&e.jsx(g,{size:16,variant:"vertical"}),e.jsx(f,{item:!0,children:i})]},t)))]})]}),!Q&&e.jsx(L,{})]}),e.jsxs(l,{fullWidth:D,children:[I?e.jsx(B,{children:I}):null,e.jsx(c,{identifier:A,children:e.jsx(e.Fragment,{children:j})})]})]})]})},exports.maxWidth=j;
|
|
2
2
|
//# sourceMappingURL=PageLayout.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLayout.cjs.js","sources":["../../../../src/components/ui/PageLayout/PageLayout.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode } from 'react';\n\nimport Add from '@mui/icons-material/Add';\nimport ArrowBackIcon from '@mui/icons-material/ArrowBack';\nimport Grid from '@mui/material/Grid';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport DocumentTitle from './DocumentTitle';\nimport FullWidthContainer from './FullWidthContainer';\nimport FDErrorBoundary from '../FDErrorBoundary/FDErrorBoundary';\nimport Button from '@mui/material/Button';\nimport { getMicroFrontendAttribute } from '../../../utilities/renderUtilities';\nimport { joinUrlPaths } from '../../../utilities/validation';\nimport Spacer from '../Spacer/Spacer';\nimport Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\n\nexport const HORIZONTAL_SPACE_CLASSNAME = 'horizontal-content-space';\nexport const LEFT_HORIZONTAL_SPACE_CLASSNAME = 'left-horizontal-content-space';\nexport const RIGHT_HORIZONTAL_SPACE_CLASSNAME = 'right-horizontal-content-space';\nexport const VERTICAL_SPACE_CLASSNAME = 'vertical-content-space';\nexport const maxWidth = 1112;\nconst historyMinLength = 3;\n\nconst StyledWrapper = styled('div')<{ fluid: boolean }>(({ theme, fluid }) => ({\n maxWidth: fluid ? 'none' : maxWidth,\n [theme.breakpoints.down('md')]: {\n maxWidth: 'none',\n },\n margin: theme.spacing(2, 4),\n}));\n\nconst StyledActionButtonGrid = styled(Grid)(({ theme }) => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n paddingTop: theme.spacing(2),\n },\n}));\n\nconst StyledHeader = styled(Grid)(({ theme }) => ({\n flexWrap: 'nowrap',\n alignItems: 'flex-start',\n paddingTop: theme.spacing(3),\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingTop: theme.spacing(2),\n paddingBottom: theme.spacing(3),\n },\n}));\n\nconst StyledTitleContainer = styled(Grid)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n}));\n\nconst StyledTitleSection = styled(Grid)(() => ({\n flexGrow: 1,\n}));\n\nconst StyledTopSection = styled('div')(({ theme }) => ({\n maxWidth,\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingBottom: theme.spacing(2),\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n },\n}));\n\nconst StyledBackButton = styled(IconButton, {\n shouldForwardProp: (prop) => prop !== 'hasTitleComponent',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n})<{ hasTitleComponent: boolean; component: any }>(({ theme, hasTitleComponent }) => ({\n margin: hasTitleComponent ? theme.spacing(-0.75, 2, -1.5, -1.5) : theme.spacing(-1.5, 2, -1.5, -1.5),\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(-2),\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(-2),\n },\n}));\n\nconst StyledInnerWrapper = styled('div')(({ theme }) => ({\n maxWidth,\n marginLeft: theme.spacing(6),\n marginRight: theme.spacing(4),\n paddingBottom: theme.spacing(2),\n\n [theme.breakpoints.only('md')]: {\n marginLeft: 12,\n marginRight: theme.spacing(3),\n },\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(3),\n marginRight: theme.spacing(3),\n maxWidth: 'none',\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(2),\n marginRight: theme.spacing(2),\n maxWidth: 'none',\n },\n}));\n\nconst StyledHeaderContainer = styled(Grid)(() => ({\n display: 'flex',\n flexGrow: 1,\n justifyContent: 'flex-end',\n}));\nconst StyledCaption = styled(Typography)<{ component: string }>(() => ({\n lineHeight: '26px',\n}));\n\nconst StyledPageTitle = styled(Typography)<{ component: string }>(() => ({\n fontWeight: 'bold',\n}));\n\nconst StyledPageDivider = styled(Divider)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport const PageTitle = ({ title }: { title: string | ReactNode }) => (\n <StyledPageTitle variant=\"h5\" component=\"h2\">\n {title}\n </StyledPageTitle>\n);\n\nexport type Props = {\n actionBtnTitle?: string;\n caption?: ReactNode;\n children: ReactNode;\n contextButtons?: ReactNode[];\n documentTitle: string;\n fluid?: boolean;\n fullWidth?: boolean;\n header?: ReactNode;\n hideHeader?: boolean;\n actionButtonLink?: string;\n pageHeader?: ReactNode;\n showActionButton?: boolean;\n showAddIcon?: boolean;\n strictToParent?: boolean;\n title: ReactNode;\n titleComponent?: ComponentType<React.PropsWithChildren<unknown>>;\n toParent?: string;\n openLinkInNewTab?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n navigate: (to: any) => void;\n hideDivider?: boolean;\n customActionButtons?: ReactNode[];\n};\n\nconst PageLayout = (props: Props) => {\n const {\n actionBtnTitle,\n caption,\n children,\n contextButtons,\n documentTitle,\n fluid = false,\n fullWidth,\n header,\n hideHeader,\n actionButtonLink,\n openLinkInNewTab = false,\n pageHeader,\n showActionButton,\n showAddIcon,\n strictToParent,\n title,\n titleComponent: TitleComponent,\n toParent,\n navigate,\n hideDivider = false,\n customActionButtons,\n } = props;\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('md'));\n const baseUrl = getMicroFrontendAttribute('data-portal-base-url') || '/';\n const actionButtonWithHttps = actionButtonLink?.startsWith('https://');\n const actionButtonLinkFinal = actionButtonWithHttps\n ? actionButtonLink\n : actionButtonLink !== undefined\n ? joinUrlPaths(baseUrl, actionButtonLink)\n : '';\n\n return (\n <StyledWrapper fluid={fluid}>\n {documentTitle && <DocumentTitle>{documentTitle}</DocumentTitle>}\n\n {pageHeader ? pageHeader : null}\n <StyledInnerWrapper>\n {pageHeader && <Spacer size={16} variant=\"vertical\" />}\n {!hideHeader && (\n <>\n <StyledHeader container alignItems=\"center\" direction=\"column\">\n <Grid item container direction=\"row\" alignContent=\"space-between\">\n <StyledHeaderContainer item>\n {contextButtons && contextButtons.map((button, index) => <div key={index}>{button}</div>)}\n </StyledHeaderContainer>\n </Grid>\n <StyledTitleContainer item container>\n {toParent && (\n <Box>\n <StyledBackButton\n aria-label=\"Back\"\n data-testid=\"back_button\"\n hasTitleComponent={!!TitleComponent}\n component={'button'}\n onClick={() => {\n if (toParent && strictToParent) {\n navigate(toParent);\n } else if (toParent && history.length < historyMinLength) {\n navigate(toParent);\n } else {\n navigate(-1);\n }\n }}\n >\n <ArrowBackIcon />\n </StyledBackButton>\n </Box>\n )}\n\n <StyledTitleSection item>\n {TitleComponent ? <TitleComponent /> : <PageTitle title={title} />}\n {caption && (\n <StyledCaption variant=\"caption\" component=\"h3\">\n {caption}\n </StyledCaption>\n )}\n </StyledTitleSection>\n\n {showActionButton && (\n <>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n <StyledActionButtonGrid item>\n <Button\n variant=\"contained\"\n fullWidth={true}\n data-testid={`Action-button-${actionBtnTitle}`}\n href={openLinkInNewTab || actionButtonWithHttps ? actionButtonLinkFinal : ''}\n target={openLinkInNewTab ? '_blank' : undefined}\n rel={openLinkInNewTab ? 'noopener noreferrer' : undefined}\n onClick={!openLinkInNewTab && !actionButtonWithHttps ? () => navigate(actionButtonLink) : () => {}}\n >\n {showAddIcon && <Add />}\n {actionBtnTitle}\n </Button>\n </StyledActionButtonGrid>\n </>\n )}\n {customActionButtons &&\n customActionButtons.map((button, index) => (\n <div key={index}>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n {!isMobile && <Spacer size={16} variant=\"vertical\" />}\n <StyledActionButtonGrid item>{button}</StyledActionButtonGrid>\n </div>\n ))}\n </StyledTitleContainer>\n </StyledHeader>\n {!hideDivider && <StyledPageDivider />}\n </>\n )}\n <FullWidthContainer fullWidth={fullWidth}>\n {header ? <StyledTopSection>{header}</StyledTopSection> : null}\n <FDErrorBoundary identifier={documentTitle}>\n <>{children}</>\n </FDErrorBoundary>\n </FullWidthContainer>\n </StyledInnerWrapper>\n </StyledWrapper>\n );\n};\n\nexport default PageLayout;\n"],"names":["maxWidth","StyledWrapper","styled","theme","fluid","breakpoints","down","margin","spacing","StyledActionButtonGrid","Grid","width","paddingTop","StyledHeader","flexWrap","alignItems","paddingBottom","StyledTitleContainer","StyledTitleSection","flexGrow","StyledTopSection","paddingLeft","paddingRight","StyledBackButton","IconButton","shouldForwardProp","prop","hasTitleComponent","only","marginLeft","StyledInnerWrapper","marginRight","StyledHeaderContainer","display","justifyContent","StyledCaption","Typography","lineHeight","StyledPageTitle","fontWeight","StyledPageDivider","Divider","marginBottom","PageTitle","title","_jsx","variant","component","children","props","actionBtnTitle","caption","contextButtons","documentTitle","fullWidth","header","hideHeader","actionButtonLink","openLinkInNewTab","pageHeader","showActionButton","showAddIcon","strictToParent","titleComponent","TitleComponent","toParent","navigate","hideDivider","customActionButtons","useTheme","isMobile","useMediaQuery","baseUrl","getMicroFrontendAttribute","actionButtonWithHttps","startsWith","actionButtonLinkFinal","undefined","joinUrlPaths","_jsxs","DocumentTitle","jsxs","Spacer","size","container","direction","jsx","item","alignContent","map","button","index","Box","onClick","history","length","ArrowBackIcon","_Fragment","Button","href","target","rel","Add","FullWidthContainer","FDErrorBoundary","identifier"],"mappings":"ouBAwBO,MAAMA,EAAW,KAGlBC,EAAgBC,EAAMA,OAAC,MAAPA,EAAkC,EAAGC,QAAOC,YAAa,CAC3EJ,SAAUI,EAAQ,OAASJ,EAC3B,CAACG,EAAME,YAAYC,KAAK,OAAQ,CAC5BN,SAAU,QAEdO,OAAQJ,EAAMK,QAAQ,EAAG,OAGvBC,EAAyBP,EAAAA,OAAOQ,EAAPR,EAAa,EAAGC,YAAa,CACxD,CAACA,EAAME,YAAYC,KAAK,OAAQ,CAC5BK,MAAO,OACPC,WAAYT,EAAMK,QAAQ,QAI5BK,EAAeX,EAAAA,OAAOQ,EAAPR,EAAa,EAAGC,YAAa,CAC9CW,SAAU,SACVC,WAAY,aACZH,WAAYT,EAAMK,QAAQ,GAC1BQ,cAAeb,EAAMK,QAAQ,GAE7B,CAACL,EAAME,YAAYC,KAAK,OAAQ,CAC5BM,WAAYT,EAAMK,QAAQ,GAC1BQ,cAAeb,EAAMK,QAAQ,QAI/BS,EAAuBf,EAAAA,OAAOQ,EAAPR,EAAa,EAAGC,YAAa,CACtDS,WAAYT,EAAMK,QAAQ,OAGxBU,EAAqBhB,EAAAA,OAAOQ,EAAPR,EAAa,KAAO,CAC3CiB,SAAU,MAGRC,EAAmBlB,EAAAA,OAAO,MAAPA,EAAc,EAAGC,YAAa,CACnDH,WACAgB,cAAeb,EAAMK,QAAQ,GAE7B,CAACL,EAAME,YAAYC,KAAK,OAAQ,CAC5BU,cAAeb,EAAMK,QAAQ,GAC7Ba,YAAalB,EAAMK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gB,CAAA4B,SAAEO,IAA6B,KAC1DV,EAAAA,IAAC2D,EAAe,CAACC,WAAYpD,EACzBL,SAAAH,MAAAoD,EAAAA,SAAA,CAAAjD,SAAGA,cAKrB"}
|
|
1
|
+
{"version":3,"file":"PageLayout.cjs.js","sources":["../../../../src/components/ui/PageLayout/PageLayout.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode } from 'react';\n\nimport Add from '@mui/icons-material/Add';\nimport ArrowBackIcon from '@mui/icons-material/ArrowBack';\nimport Grid from '@mui/material/Grid';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport DocumentTitle from './DocumentTitle';\nimport FullWidthContainer from './FullWidthContainer';\nimport FDErrorBoundary from '../FDErrorBoundary/FDErrorBoundary';\nimport Button from '@mui/material/Button';\nimport { getMicroFrontendAttribute } from '../../renderUtilities';\nimport { joinUrlPaths } from '../../../utilities/validation';\nimport Spacer from '../Spacer/Spacer';\nimport Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\n\nexport const HORIZONTAL_SPACE_CLASSNAME = 'horizontal-content-space';\nexport const LEFT_HORIZONTAL_SPACE_CLASSNAME = 'left-horizontal-content-space';\nexport const RIGHT_HORIZONTAL_SPACE_CLASSNAME = 'right-horizontal-content-space';\nexport const VERTICAL_SPACE_CLASSNAME = 'vertical-content-space';\nexport const maxWidth = 1112;\nconst historyMinLength = 3;\n\nconst StyledWrapper = styled('div')<{ fluid: boolean }>(({ theme, fluid }) => ({\n maxWidth: fluid ? 'none' : maxWidth,\n [theme.breakpoints.down('md')]: {\n maxWidth: 'none',\n },\n margin: theme.spacing(2, 4),\n}));\n\nconst StyledActionButtonGrid = styled(Grid)(({ theme }) => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n paddingTop: theme.spacing(2),\n },\n}));\n\nconst StyledHeader = styled(Grid)(({ theme }) => ({\n flexWrap: 'nowrap',\n alignItems: 'flex-start',\n paddingTop: theme.spacing(3),\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingTop: theme.spacing(2),\n paddingBottom: theme.spacing(3),\n },\n}));\n\nconst StyledTitleContainer = styled(Grid)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n}));\n\nconst StyledTitleSection = styled(Grid)(() => ({\n flexGrow: 1,\n}));\n\nconst StyledTopSection = styled('div')(({ theme }) => ({\n maxWidth,\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingBottom: theme.spacing(2),\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n },\n}));\n\nconst StyledBackButton = styled(IconButton, {\n shouldForwardProp: (prop) => prop !== 'hasTitleComponent',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n})<{ hasTitleComponent: boolean; component: any }>(({ theme, hasTitleComponent }) => ({\n margin: hasTitleComponent ? theme.spacing(-0.75, 2, -1.5, -1.5) : theme.spacing(-1.5, 2, -1.5, -1.5),\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(-2),\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(-2),\n },\n}));\n\nconst StyledInnerWrapper = styled('div')(({ theme }) => ({\n maxWidth,\n marginLeft: theme.spacing(6),\n marginRight: theme.spacing(4),\n paddingBottom: theme.spacing(2),\n\n [theme.breakpoints.only('md')]: {\n marginLeft: 12,\n marginRight: theme.spacing(3),\n },\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(3),\n marginRight: theme.spacing(3),\n maxWidth: 'none',\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(2),\n marginRight: theme.spacing(2),\n maxWidth: 'none',\n },\n}));\n\nconst StyledHeaderContainer = styled(Grid)(() => ({\n display: 'flex',\n flexGrow: 1,\n justifyContent: 'flex-end',\n}));\nconst StyledCaption = styled(Typography)<{ component: string }>(() => ({\n lineHeight: '26px',\n}));\n\nconst StyledPageTitle = styled(Typography)<{ component: string }>(() => ({\n fontWeight: 'bold',\n}));\n\nconst StyledPageDivider = styled(Divider)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport const PageTitle = ({ title }: { title: string | ReactNode }) => (\n <StyledPageTitle variant=\"h5\" component=\"h2\">\n {title}\n </StyledPageTitle>\n);\n\nexport type Props = {\n actionBtnTitle?: string;\n caption?: ReactNode;\n children: ReactNode;\n contextButtons?: ReactNode[];\n documentTitle: string;\n fluid?: boolean;\n fullWidth?: boolean;\n header?: ReactNode;\n hideHeader?: boolean;\n actionButtonLink?: string;\n pageHeader?: ReactNode;\n showActionButton?: boolean;\n showAddIcon?: boolean;\n strictToParent?: boolean;\n title: ReactNode;\n titleComponent?: ComponentType<React.PropsWithChildren<unknown>>;\n toParent?: string;\n openLinkInNewTab?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n navigate: (to: any) => void;\n hideDivider?: boolean;\n customActionButtons?: ReactNode[];\n};\n\nconst PageLayout = (props: Props) => {\n const {\n actionBtnTitle,\n caption,\n children,\n contextButtons,\n documentTitle,\n fluid = false,\n fullWidth,\n header,\n hideHeader,\n actionButtonLink,\n openLinkInNewTab = false,\n pageHeader,\n showActionButton,\n showAddIcon,\n strictToParent,\n title,\n titleComponent: TitleComponent,\n toParent,\n navigate,\n hideDivider = false,\n customActionButtons,\n } = props;\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('md'));\n const baseUrl = getMicroFrontendAttribute('data-portal-base-url') || '/';\n const actionButtonWithHttps = actionButtonLink?.startsWith('https://');\n const actionButtonLinkFinal = actionButtonWithHttps\n ? actionButtonLink\n : actionButtonLink !== undefined\n ? joinUrlPaths(baseUrl, actionButtonLink)\n : '';\n\n return (\n <StyledWrapper fluid={fluid}>\n {documentTitle && <DocumentTitle>{documentTitle}</DocumentTitle>}\n\n {pageHeader ? pageHeader : null}\n <StyledInnerWrapper>\n {pageHeader && <Spacer size={16} variant=\"vertical\" />}\n {!hideHeader && (\n <>\n <StyledHeader container alignItems=\"center\" direction=\"column\">\n <Grid item container direction=\"row\" alignContent=\"space-between\">\n <StyledHeaderContainer item>\n {contextButtons && contextButtons.map((button, index) => <div key={index}>{button}</div>)}\n </StyledHeaderContainer>\n </Grid>\n <StyledTitleContainer item container>\n {toParent && (\n <Box>\n <StyledBackButton\n aria-label=\"Back\"\n data-testid=\"back_button\"\n hasTitleComponent={!!TitleComponent}\n component={'button'}\n onClick={() => {\n if (toParent && strictToParent) {\n navigate(toParent);\n } else if (toParent && history.length < historyMinLength) {\n navigate(toParent);\n } else {\n navigate(-1);\n }\n }}\n >\n <ArrowBackIcon />\n </StyledBackButton>\n </Box>\n )}\n\n <StyledTitleSection item>\n {TitleComponent ? <TitleComponent /> : <PageTitle title={title} />}\n {caption && (\n <StyledCaption variant=\"caption\" component=\"h3\">\n {caption}\n </StyledCaption>\n )}\n </StyledTitleSection>\n\n {showActionButton && (\n <>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n <StyledActionButtonGrid item>\n <Button\n variant=\"contained\"\n fullWidth={true}\n data-testid={`Action-button-${actionBtnTitle}`}\n href={openLinkInNewTab || actionButtonWithHttps ? actionButtonLinkFinal : ''}\n target={openLinkInNewTab ? '_blank' : undefined}\n rel={openLinkInNewTab ? 'noopener noreferrer' : undefined}\n onClick={!openLinkInNewTab && !actionButtonWithHttps ? () => navigate(actionButtonLink) : () => {}}\n >\n {showAddIcon && <Add />}\n {actionBtnTitle}\n </Button>\n </StyledActionButtonGrid>\n </>\n )}\n {customActionButtons &&\n customActionButtons.map((button, index) => (\n <div key={index}>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n {!isMobile && <Spacer size={16} variant=\"vertical\" />}\n <StyledActionButtonGrid item>{button}</StyledActionButtonGrid>\n </div>\n ))}\n </StyledTitleContainer>\n </StyledHeader>\n {!hideDivider && <StyledPageDivider />}\n </>\n )}\n <FullWidthContainer fullWidth={fullWidth}>\n {header ? <StyledTopSection>{header}</StyledTopSection> : null}\n <FDErrorBoundary identifier={documentTitle}>\n <>{children}</>\n </FDErrorBoundary>\n </FullWidthContainer>\n </StyledInnerWrapper>\n </StyledWrapper>\n );\n};\n\nexport default PageLayout;\n"],"names":["maxWidth","StyledWrapper","styled","theme","fluid","breakpoints","down","margin","spacing","StyledActionButtonGrid","Grid","width","paddingTop","StyledHeader","flexWrap","alignItems","paddingBottom","StyledTitleContainer","StyledTitleSection","flexGrow","StyledTopSection","paddingLeft","paddingRight","StyledBackButton","IconButton","shouldForwardProp","prop","hasTitleComponent","only","marginLeft","StyledInnerWrapper","marginRight","StyledHeaderContainer","display","justifyContent","StyledCaption","Typography","lineHeight","StyledPageTitle","fontWeight","StyledPageDivider","Divider","marginBottom","PageTitle","title","_jsx","variant","component","children","props","actionBtnTitle","caption","contextButtons","documentTitle","fullWidth","header","hideHeader","actionButtonLink","openLinkInNewTab","pageHeader","showActionButton","showAddIcon","strictToParent","titleComponent","TitleComponent","toParent","navigate","hideDivider","customActionButtons","useTheme","isMobile","useMediaQuery","baseUrl","getMicroFrontendAttribute","actionButtonWithHttps","startsWith","actionButtonLinkFinal","undefined","joinUrlPaths","_jsxs","DocumentTitle","jsxs","Spacer","size","container","direction","jsx","item","alignContent","map","button","index","Box","onClick","history","length","ArrowBackIcon","_Fragment","Button","href","target","rel","Add","FullWidthContainer","FDErrorBoundary","identifier"],"mappings":"uuBAwBO,MAAMA,EAAW,KAGlBC,EAAgBC,EAAMA,OAAC,MAAPA,EAAkC,EAAGC,QAAOC,YAAa,CAC3EJ,SAAUI,EAAQ,OAASJ,EAC3B,CAACG,EAAME,YAAYC,KAAK,OAAQ,CAC5BN,SAAU,QAEdO,OAAQJ,EAAMK,QAAQ,EAAG,OAGvBC,EAAyBP,EAAAA,OAAOQ,EAAPR,EAAa,EAAGC,YAAa,CACxD,CAACA,EAAME,YAAYC,KAAK,OAAQ,CAC5BK,MAAO,OACPC,WAAYT,EAAMK,QAAQ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IAC9BiD,KAAMzC,GAAoBgB,EAAwBE,EAAwB,GAC1EwB,OAAQ1C,EAAmB,cAAWmB,EACtCwB,IAAK3C,EAAmB,2BAAwBmB,EAChDgB,QAAUnC,GAAqBgB,EAA2D,OAAnC,IAAMR,EAAST,GAA4BT,SAAA,CAEjGa,GAAehB,MAACyD,EAAG,CAAA,GACnBpD,UAKhBkB,GACGA,EAAoBqB,KAAI,CAACC,EAAQC,IAC7BZ,wBACKT,GAAYzB,MAACqC,EAAM,CAACC,KAAM,GAAIrC,QAAQ,cACrCwB,GAAYzB,EAAAyC,IAACJ,EAAO,CAAAC,KAAM,GAAIrC,QAAQ,aACxCD,EAAAA,IAACpC,GAAuB8E,MAAI,EAAAvC,SAAE0C,MAHxBC,YAQxBxB,GAAetB,EAACyC,IAAA9C,EAAoB,OAG9CuC,EAAAA,KAACwB,EAAmB,CAAAjD,UAAWA,EAASN,SAAA,CACnCO,EAASV,MAACzB,EAAgB,CAAA4B,SAAEO,IAA6B,KAC1DV,EAAAA,IAAC2D,EAAe,CAACC,WAAYpD,EACzBL,SAAAH,MAAAoD,EAAAA,SAAA,CAAAjD,SAAGA,cAKrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as i,jsx as t,Fragment as n}from"react/jsx-runtime";import e from"@mui/icons-material/Add";import
|
|
1
|
+
import{jsxs as i,jsx as t,Fragment as n}from"react/jsx-runtime";import e from"@mui/icons-material/Add";import r from"@mui/icons-material/ArrowBack";import a from"@mui/material/Grid";import o from"@mui/material/IconButton";import{styled as m,useTheme as d}from"@mui/material/styles";import l from"@mui/material/Typography";import p from"@mui/material/useMediaQuery";import c from"./DocumentTitle.js";import s from"./FullWidthContainer.js";import h from"../FDErrorBoundary/FDErrorBoundary.js";import g from"@mui/material/Button";import{getMicroFrontendAttribute as u}from"../../renderUtilities/renderUtilities.js";import{joinUrlPaths as f}from"../../../utilities/validation.js";import v from"../Spacer/Spacer.js";import b from"@mui/material/Box";import x from"@mui/material/Divider";const k=1112,B=m("div")((({theme:i,fluid:t})=>({maxWidth:t?"none":k,[i.breakpoints.down("md")]:{maxWidth:"none"},margin:i.spacing(2,4)}))),w=m(a)((({theme:i})=>({[i.breakpoints.down("sm")]:{width:"100%",paddingTop:i.spacing(2)}}))),y=m(a)((({theme:i})=>({flexWrap:"nowrap",alignItems:"flex-start",paddingTop:i.spacing(3),paddingBottom:i.spacing(3),[i.breakpoints.down("md")]:{paddingTop:i.spacing(2),paddingBottom:i.spacing(3)}}))),T=m(a)((({theme:i})=>({paddingTop:i.spacing(2)}))),W=m(a)((()=>({flexGrow:1}))),C=m("div")((({theme:i})=>({maxWidth:k,paddingBottom:i.spacing(3),[i.breakpoints.down("md")]:{paddingBottom:i.spacing(2),paddingLeft:i.spacing(2),paddingRight:i.spacing(2)}}))),L=m(o,{shouldForwardProp:i=>"hasTitleComponent"!==i})((({theme:i,hasTitleComponent:t})=>({margin:t?i.spacing(-.75,2,-1.5,-1.5):i.spacing(-1.5,2,-1.5,-1.5),[i.breakpoints.only("sm")]:{marginLeft:i.spacing(-2)},[i.breakpoints.only("xs")]:{marginLeft:i.spacing(-2)}}))),j=m("div")((({theme:i})=>({maxWidth:k,marginLeft:i.spacing(6),marginRight:i.spacing(4),paddingBottom:i.spacing(2),[i.breakpoints.only("md")]:{marginLeft:12,marginRight:i.spacing(3)},[i.breakpoints.only("sm")]:{marginLeft:i.spacing(3),marginRight:i.spacing(3),maxWidth:"none"},[i.breakpoints.only("xs")]:{marginLeft:i.spacing(2),marginRight:i.spacing(2),maxWidth:"none"}}))),A=m(a)((()=>({display:"flex",flexGrow:1,justifyContent:"flex-end"}))),D=m(l)((()=>({lineHeight:"26px"}))),I=m(l)((()=>({fontWeight:"bold"}))),R=m(x)((({theme:i})=>({marginBottom:i.spacing(4)}))),z=({title:i})=>t(I,{variant:"h5",component:"h2",children:i}),F=o=>{const{actionBtnTitle:m,caption:l,children:x,contextButtons:k,documentTitle:I,fluid:F=!1,fullWidth:G,header:H,hideHeader:P,actionButtonLink:E,openLinkInNewTab:S=!1,pageHeader:U,showActionButton:_,showAddIcon:M,strictToParent:N,title:Q,titleComponent:$,toParent:q,navigate:J,hideDivider:K=!1,customActionButtons:O}=o,V=d(),X=p(V.breakpoints.down("md")),Y=u("data-portal-base-url")||"/",Z=E?.startsWith("https://"),ii=Z?E:void 0!==E?f(Y,E):"";return i(B,{fluid:F,children:[I&&t(c,{children:I}),U||null,i(j,{children:[U&&t(v,{size:16,variant:"vertical"}),!P&&i(n,{children:[i(y,{container:!0,alignItems:"center",direction:"column",children:[t(a,{item:!0,container:!0,direction:"row",alignContent:"space-between",children:t(A,{item:!0,children:k&&k.map(((i,n)=>t("div",{children:i},n)))})}),i(T,{item:!0,container:!0,children:[q&&t(b,{children:t(L,{"aria-label":"Back","data-testid":"back_button",hasTitleComponent:!!$,component:"button",onClick:()=>{q&&N||q&&history.length<3?J(q):J(-1)},children:t(r,{})})}),i(W,{item:!0,children:[$?t($,{}):t(z,{title:Q}),l&&t(D,{variant:"caption",component:"h3",children:l})]}),_&&i(n,{children:[X&&t(v,{size:56,variant:"vertical"}),t(w,{item:!0,children:i(g,{variant:"contained",fullWidth:!0,"data-testid":`Action-button-${m}`,href:S||Z?ii:"",target:S?"_blank":void 0,rel:S?"noopener noreferrer":void 0,onClick:S||Z?()=>{}:()=>J(E),children:[M&&t(e,{}),m]})})]}),O&&O.map(((n,e)=>i("div",{children:[X&&t(v,{size:56,variant:"vertical"}),!X&&t(v,{size:16,variant:"vertical"}),t(w,{item:!0,children:n})]},e)))]})]}),!K&&t(R,{})]}),i(s,{fullWidth:G,children:[H?t(C,{children:H}):null,t(h,{identifier:I,children:t(n,{children:x})})]})]})]})};export{z as PageTitle,F as default,k as maxWidth};
|
|
2
2
|
//# sourceMappingURL=PageLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLayout.js","sources":["../../../../src/components/ui/PageLayout/PageLayout.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode } from 'react';\n\nimport Add from '@mui/icons-material/Add';\nimport ArrowBackIcon from '@mui/icons-material/ArrowBack';\nimport Grid from '@mui/material/Grid';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport DocumentTitle from './DocumentTitle';\nimport FullWidthContainer from './FullWidthContainer';\nimport FDErrorBoundary from '../FDErrorBoundary/FDErrorBoundary';\nimport Button from '@mui/material/Button';\nimport { getMicroFrontendAttribute } from '../../../utilities/renderUtilities';\nimport { joinUrlPaths } from '../../../utilities/validation';\nimport Spacer from '../Spacer/Spacer';\nimport Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\n\nexport const HORIZONTAL_SPACE_CLASSNAME = 'horizontal-content-space';\nexport const LEFT_HORIZONTAL_SPACE_CLASSNAME = 'left-horizontal-content-space';\nexport const RIGHT_HORIZONTAL_SPACE_CLASSNAME = 'right-horizontal-content-space';\nexport const VERTICAL_SPACE_CLASSNAME = 'vertical-content-space';\nexport const maxWidth = 1112;\nconst historyMinLength = 3;\n\nconst StyledWrapper = styled('div')<{ fluid: boolean }>(({ theme, fluid }) => ({\n maxWidth: fluid ? 'none' : maxWidth,\n [theme.breakpoints.down('md')]: {\n maxWidth: 'none',\n },\n margin: theme.spacing(2, 4),\n}));\n\nconst StyledActionButtonGrid = styled(Grid)(({ theme }) => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n paddingTop: theme.spacing(2),\n },\n}));\n\nconst StyledHeader = styled(Grid)(({ theme }) => ({\n flexWrap: 'nowrap',\n alignItems: 'flex-start',\n paddingTop: theme.spacing(3),\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingTop: theme.spacing(2),\n paddingBottom: theme.spacing(3),\n },\n}));\n\nconst StyledTitleContainer = styled(Grid)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n}));\n\nconst StyledTitleSection = styled(Grid)(() => ({\n flexGrow: 1,\n}));\n\nconst StyledTopSection = styled('div')(({ theme }) => ({\n maxWidth,\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingBottom: theme.spacing(2),\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n },\n}));\n\nconst StyledBackButton = styled(IconButton, {\n shouldForwardProp: (prop) => prop !== 'hasTitleComponent',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n})<{ hasTitleComponent: boolean; component: any }>(({ theme, hasTitleComponent }) => ({\n margin: hasTitleComponent ? theme.spacing(-0.75, 2, -1.5, -1.5) : theme.spacing(-1.5, 2, -1.5, -1.5),\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(-2),\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(-2),\n },\n}));\n\nconst StyledInnerWrapper = styled('div')(({ theme }) => ({\n maxWidth,\n marginLeft: theme.spacing(6),\n marginRight: theme.spacing(4),\n paddingBottom: theme.spacing(2),\n\n [theme.breakpoints.only('md')]: {\n marginLeft: 12,\n marginRight: theme.spacing(3),\n },\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(3),\n marginRight: theme.spacing(3),\n maxWidth: 'none',\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(2),\n marginRight: theme.spacing(2),\n maxWidth: 'none',\n },\n}));\n\nconst StyledHeaderContainer = styled(Grid)(() => ({\n display: 'flex',\n flexGrow: 1,\n justifyContent: 'flex-end',\n}));\nconst StyledCaption = styled(Typography)<{ component: string }>(() => ({\n lineHeight: '26px',\n}));\n\nconst StyledPageTitle = styled(Typography)<{ component: string }>(() => ({\n fontWeight: 'bold',\n}));\n\nconst StyledPageDivider = styled(Divider)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport const PageTitle = ({ title }: { title: string | ReactNode }) => (\n <StyledPageTitle variant=\"h5\" component=\"h2\">\n {title}\n </StyledPageTitle>\n);\n\nexport type Props = {\n actionBtnTitle?: string;\n caption?: ReactNode;\n children: ReactNode;\n contextButtons?: ReactNode[];\n documentTitle: string;\n fluid?: boolean;\n fullWidth?: boolean;\n header?: ReactNode;\n hideHeader?: boolean;\n actionButtonLink?: string;\n pageHeader?: ReactNode;\n showActionButton?: boolean;\n showAddIcon?: boolean;\n strictToParent?: boolean;\n title: ReactNode;\n titleComponent?: ComponentType<React.PropsWithChildren<unknown>>;\n toParent?: string;\n openLinkInNewTab?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n navigate: (to: any) => void;\n hideDivider?: boolean;\n customActionButtons?: ReactNode[];\n};\n\nconst PageLayout = (props: Props) => {\n const {\n actionBtnTitle,\n caption,\n children,\n contextButtons,\n documentTitle,\n fluid = false,\n fullWidth,\n header,\n hideHeader,\n actionButtonLink,\n openLinkInNewTab = false,\n pageHeader,\n showActionButton,\n showAddIcon,\n strictToParent,\n title,\n titleComponent: TitleComponent,\n toParent,\n navigate,\n hideDivider = false,\n customActionButtons,\n } = props;\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('md'));\n const baseUrl = getMicroFrontendAttribute('data-portal-base-url') || '/';\n const actionButtonWithHttps = actionButtonLink?.startsWith('https://');\n const actionButtonLinkFinal = actionButtonWithHttps\n ? actionButtonLink\n : actionButtonLink !== undefined\n ? joinUrlPaths(baseUrl, actionButtonLink)\n : '';\n\n return (\n <StyledWrapper fluid={fluid}>\n {documentTitle && <DocumentTitle>{documentTitle}</DocumentTitle>}\n\n {pageHeader ? pageHeader : null}\n <StyledInnerWrapper>\n {pageHeader && <Spacer size={16} variant=\"vertical\" />}\n {!hideHeader && (\n <>\n <StyledHeader container alignItems=\"center\" direction=\"column\">\n <Grid item container direction=\"row\" alignContent=\"space-between\">\n <StyledHeaderContainer item>\n {contextButtons && contextButtons.map((button, index) => <div key={index}>{button}</div>)}\n </StyledHeaderContainer>\n </Grid>\n <StyledTitleContainer item container>\n {toParent && (\n <Box>\n <StyledBackButton\n aria-label=\"Back\"\n data-testid=\"back_button\"\n hasTitleComponent={!!TitleComponent}\n component={'button'}\n onClick={() => {\n if (toParent && strictToParent) {\n navigate(toParent);\n } else if (toParent && history.length < historyMinLength) {\n navigate(toParent);\n } else {\n navigate(-1);\n }\n }}\n >\n <ArrowBackIcon />\n </StyledBackButton>\n </Box>\n )}\n\n <StyledTitleSection item>\n {TitleComponent ? <TitleComponent /> : <PageTitle title={title} />}\n {caption && (\n <StyledCaption variant=\"caption\" component=\"h3\">\n {caption}\n </StyledCaption>\n )}\n </StyledTitleSection>\n\n {showActionButton && (\n <>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n <StyledActionButtonGrid item>\n <Button\n variant=\"contained\"\n fullWidth={true}\n data-testid={`Action-button-${actionBtnTitle}`}\n href={openLinkInNewTab || actionButtonWithHttps ? actionButtonLinkFinal : ''}\n target={openLinkInNewTab ? '_blank' : undefined}\n rel={openLinkInNewTab ? 'noopener noreferrer' : undefined}\n onClick={!openLinkInNewTab && !actionButtonWithHttps ? () => navigate(actionButtonLink) : () => {}}\n >\n {showAddIcon && <Add />}\n {actionBtnTitle}\n </Button>\n </StyledActionButtonGrid>\n </>\n )}\n {customActionButtons &&\n customActionButtons.map((button, index) => (\n <div key={index}>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n {!isMobile && <Spacer size={16} variant=\"vertical\" />}\n <StyledActionButtonGrid item>{button}</StyledActionButtonGrid>\n </div>\n ))}\n </StyledTitleContainer>\n </StyledHeader>\n {!hideDivider && <StyledPageDivider />}\n </>\n )}\n <FullWidthContainer fullWidth={fullWidth}>\n {header ? <StyledTopSection>{header}</StyledTopSection> : null}\n <FDErrorBoundary identifier={documentTitle}>\n <>{children}</>\n </FDErrorBoundary>\n </FullWidthContainer>\n </StyledInnerWrapper>\n </StyledWrapper>\n );\n};\n\nexport default PageLayout;\n"],"names":["maxWidth","StyledWrapper","styled","theme","fluid","breakpoints","down","margin","spacing","StyledActionButtonGrid","Grid","width","paddingTop","StyledHeader","flexWrap","alignItems","paddingBottom","StyledTitleContainer","StyledTitleSection","flexGrow","StyledTopSection","paddingLeft","paddingRight","StyledBackButton","IconButton","shouldForwardProp","prop","hasTitleComponent","only","marginLeft","StyledInnerWrapper","marginRight","StyledHeaderContainer","display","justifyContent","StyledCaption","Typography","lineHeight","StyledPageTitle","fontWeight","StyledPageDivider","Divider","marginBottom","PageTitle","title","_jsx","variant","component","children","PageLayout","props","actionBtnTitle","caption","contextButtons","documentTitle","fullWidth","header","hideHeader","actionButtonLink","openLinkInNewTab","pageHeader","showActionButton","showAddIcon","strictToParent","titleComponent","TitleComponent","toParent","navigate","hideDivider","customActionButtons","useTheme","isMobile","useMediaQuery","baseUrl","getMicroFrontendAttribute","actionButtonWithHttps","startsWith","actionButtonLinkFinal","undefined","joinUrlPaths","_jsxs","DocumentTitle","Spacer","size","container","direction","item","alignContent","map","button","index","Box","onClick","history","length","ArrowBackIcon","_Fragment","Button","href","target","rel","Add","FullWidthContainer","FDErrorBoundary","identifier"],"mappings":"0wBAwBO,MAAMA,EAAW,KAGlBC,EAAgBC,EAAO,MAAPA,EAAkC,EAAGC,QAAOC,YAAa,CAC3EJ,SAAUI,EAAQ,OAASJ,EAC3B,CAACG,EAAME,YAAYC,KAAK,OAAQ,CAC5BN,SAAU,QAEdO,OAAQJ,EAAMK,QAAQ,EAAG,OAGvBC,EAAyBP,EAAOQ,EAAPR,EAAa,EAAGC,YAAa,CACxD,CAACA,EAAME,YAAYC,KAAK,OAAQ,CAC5BK,MAAO,OACPC,WAAYT,EAAMK,QAAQ,QAI5BK,EAAeX,EAAOQ,EAAPR,EAAa,EAAGC,YAAa,CAC9CW,SAAU,SACVC,WAAY,aACZH,WAAYT,EAAMK,QAAQ,GAC1BQ,cAAeb,EAAMK,QAAQ,GAE7B,CAACL,EAAME,YAAYC,KAAK,OAAQ,CAC5BM,WAAYT,EAAMK,QAAQ,GAC1BQ,cAAeb,EAAMK,QAAQ,QA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evB,EAACL,EAAoB,OAG9CwC,EAACsB,EAAmB,CAAA/C,UAAWA,EAASP,SAAA,CACnCQ,EAASX,EAACzB,EAAgB,CAAA4B,SAAEQ,IAA6B,KAC1DX,EAAC0D,EAAe,CAACC,WAAYlD,EACzBN,SAAAH,EAAAmD,EAAA,CAAAhD,SAAGA,cAKrB"}
|
|
1
|
+
{"version":3,"file":"PageLayout.js","sources":["../../../../src/components/ui/PageLayout/PageLayout.tsx"],"sourcesContent":["import React, { ComponentType, ReactNode } from 'react';\n\nimport Add from '@mui/icons-material/Add';\nimport ArrowBackIcon from '@mui/icons-material/ArrowBack';\nimport Grid from '@mui/material/Grid';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport DocumentTitle from './DocumentTitle';\nimport FullWidthContainer from './FullWidthContainer';\nimport FDErrorBoundary from '../FDErrorBoundary/FDErrorBoundary';\nimport Button from '@mui/material/Button';\nimport { getMicroFrontendAttribute } from '../../renderUtilities';\nimport { joinUrlPaths } from '../../../utilities/validation';\nimport Spacer from '../Spacer/Spacer';\nimport Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\n\nexport const HORIZONTAL_SPACE_CLASSNAME = 'horizontal-content-space';\nexport const LEFT_HORIZONTAL_SPACE_CLASSNAME = 'left-horizontal-content-space';\nexport const RIGHT_HORIZONTAL_SPACE_CLASSNAME = 'right-horizontal-content-space';\nexport const VERTICAL_SPACE_CLASSNAME = 'vertical-content-space';\nexport const maxWidth = 1112;\nconst historyMinLength = 3;\n\nconst StyledWrapper = styled('div')<{ fluid: boolean }>(({ theme, fluid }) => ({\n maxWidth: fluid ? 'none' : maxWidth,\n [theme.breakpoints.down('md')]: {\n maxWidth: 'none',\n },\n margin: theme.spacing(2, 4),\n}));\n\nconst StyledActionButtonGrid = styled(Grid)(({ theme }) => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n paddingTop: theme.spacing(2),\n },\n}));\n\nconst StyledHeader = styled(Grid)(({ theme }) => ({\n flexWrap: 'nowrap',\n alignItems: 'flex-start',\n paddingTop: theme.spacing(3),\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingTop: theme.spacing(2),\n paddingBottom: theme.spacing(3),\n },\n}));\n\nconst StyledTitleContainer = styled(Grid)(({ theme }) => ({\n paddingTop: theme.spacing(2),\n}));\n\nconst StyledTitleSection = styled(Grid)(() => ({\n flexGrow: 1,\n}));\n\nconst StyledTopSection = styled('div')(({ theme }) => ({\n maxWidth,\n paddingBottom: theme.spacing(3),\n\n [theme.breakpoints.down('md')]: {\n paddingBottom: theme.spacing(2),\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n },\n}));\n\nconst StyledBackButton = styled(IconButton, {\n shouldForwardProp: (prop) => prop !== 'hasTitleComponent',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n})<{ hasTitleComponent: boolean; component: any }>(({ theme, hasTitleComponent }) => ({\n margin: hasTitleComponent ? theme.spacing(-0.75, 2, -1.5, -1.5) : theme.spacing(-1.5, 2, -1.5, -1.5),\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(-2),\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(-2),\n },\n}));\n\nconst StyledInnerWrapper = styled('div')(({ theme }) => ({\n maxWidth,\n marginLeft: theme.spacing(6),\n marginRight: theme.spacing(4),\n paddingBottom: theme.spacing(2),\n\n [theme.breakpoints.only('md')]: {\n marginLeft: 12,\n marginRight: theme.spacing(3),\n },\n\n [theme.breakpoints.only('sm')]: {\n marginLeft: theme.spacing(3),\n marginRight: theme.spacing(3),\n maxWidth: 'none',\n },\n\n [theme.breakpoints.only('xs')]: {\n marginLeft: theme.spacing(2),\n marginRight: theme.spacing(2),\n maxWidth: 'none',\n },\n}));\n\nconst StyledHeaderContainer = styled(Grid)(() => ({\n display: 'flex',\n flexGrow: 1,\n justifyContent: 'flex-end',\n}));\nconst StyledCaption = styled(Typography)<{ component: string }>(() => ({\n lineHeight: '26px',\n}));\n\nconst StyledPageTitle = styled(Typography)<{ component: string }>(() => ({\n fontWeight: 'bold',\n}));\n\nconst StyledPageDivider = styled(Divider)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport const PageTitle = ({ title }: { title: string | ReactNode }) => (\n <StyledPageTitle variant=\"h5\" component=\"h2\">\n {title}\n </StyledPageTitle>\n);\n\nexport type Props = {\n actionBtnTitle?: string;\n caption?: ReactNode;\n children: ReactNode;\n contextButtons?: ReactNode[];\n documentTitle: string;\n fluid?: boolean;\n fullWidth?: boolean;\n header?: ReactNode;\n hideHeader?: boolean;\n actionButtonLink?: string;\n pageHeader?: ReactNode;\n showActionButton?: boolean;\n showAddIcon?: boolean;\n strictToParent?: boolean;\n title: ReactNode;\n titleComponent?: ComponentType<React.PropsWithChildren<unknown>>;\n toParent?: string;\n openLinkInNewTab?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n navigate: (to: any) => void;\n hideDivider?: boolean;\n customActionButtons?: ReactNode[];\n};\n\nconst PageLayout = (props: Props) => {\n const {\n actionBtnTitle,\n caption,\n children,\n contextButtons,\n documentTitle,\n fluid = false,\n fullWidth,\n header,\n hideHeader,\n actionButtonLink,\n openLinkInNewTab = false,\n pageHeader,\n showActionButton,\n showAddIcon,\n strictToParent,\n title,\n titleComponent: TitleComponent,\n toParent,\n navigate,\n hideDivider = false,\n customActionButtons,\n } = props;\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('md'));\n const baseUrl = getMicroFrontendAttribute('data-portal-base-url') || '/';\n const actionButtonWithHttps = actionButtonLink?.startsWith('https://');\n const actionButtonLinkFinal = actionButtonWithHttps\n ? actionButtonLink\n : actionButtonLink !== undefined\n ? joinUrlPaths(baseUrl, actionButtonLink)\n : '';\n\n return (\n <StyledWrapper fluid={fluid}>\n {documentTitle && <DocumentTitle>{documentTitle}</DocumentTitle>}\n\n {pageHeader ? pageHeader : null}\n <StyledInnerWrapper>\n {pageHeader && <Spacer size={16} variant=\"vertical\" />}\n {!hideHeader && (\n <>\n <StyledHeader container alignItems=\"center\" direction=\"column\">\n <Grid item container direction=\"row\" alignContent=\"space-between\">\n <StyledHeaderContainer item>\n {contextButtons && contextButtons.map((button, index) => <div key={index}>{button}</div>)}\n </StyledHeaderContainer>\n </Grid>\n <StyledTitleContainer item container>\n {toParent && (\n <Box>\n <StyledBackButton\n aria-label=\"Back\"\n data-testid=\"back_button\"\n hasTitleComponent={!!TitleComponent}\n component={'button'}\n onClick={() => {\n if (toParent && strictToParent) {\n navigate(toParent);\n } else if (toParent && history.length < historyMinLength) {\n navigate(toParent);\n } else {\n navigate(-1);\n }\n }}\n >\n <ArrowBackIcon />\n </StyledBackButton>\n </Box>\n )}\n\n <StyledTitleSection item>\n {TitleComponent ? <TitleComponent /> : <PageTitle title={title} />}\n {caption && (\n <StyledCaption variant=\"caption\" component=\"h3\">\n {caption}\n </StyledCaption>\n )}\n </StyledTitleSection>\n\n {showActionButton && (\n <>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n <StyledActionButtonGrid item>\n <Button\n variant=\"contained\"\n fullWidth={true}\n data-testid={`Action-button-${actionBtnTitle}`}\n href={openLinkInNewTab || actionButtonWithHttps ? actionButtonLinkFinal : ''}\n target={openLinkInNewTab ? '_blank' : undefined}\n rel={openLinkInNewTab ? 'noopener noreferrer' : undefined}\n onClick={!openLinkInNewTab && !actionButtonWithHttps ? () => navigate(actionButtonLink) : () => {}}\n >\n {showAddIcon && <Add />}\n {actionBtnTitle}\n </Button>\n </StyledActionButtonGrid>\n </>\n )}\n {customActionButtons &&\n customActionButtons.map((button, index) => (\n <div key={index}>\n {isMobile && <Spacer size={56} variant=\"vertical\" />}\n {!isMobile && <Spacer size={16} variant=\"vertical\" />}\n <StyledActionButtonGrid item>{button}</StyledActionButtonGrid>\n </div>\n ))}\n </StyledTitleContainer>\n </StyledHeader>\n {!hideDivider && <StyledPageDivider />}\n </>\n )}\n <FullWidthContainer fullWidth={fullWidth}>\n {header ? <StyledTopSection>{header}</StyledTopSection> : null}\n <FDErrorBoundary identifier={documentTitle}>\n <>{children}</>\n </FDErrorBoundary>\n </FullWidthContainer>\n </StyledInnerWrapper>\n </StyledWrapper>\n );\n};\n\nexport default PageLayout;\n"],"names":["maxWidth","StyledWrapper","styled","theme","fluid","breakpoints","down","margin","spacing","StyledActionButtonGrid","Grid","width","paddingTop","StyledHeader","flexWrap","alignItems","paddingBottom","StyledTitleContainer","StyledTitleSection","flexGrow","StyledTopSection","paddingLeft","paddingRight","StyledBackButton","IconButton","shouldForwardProp","prop","hasTitleComponent","only","marginLeft","StyledInnerWrapper","marginRight","StyledHeaderContainer","display","justifyContent","StyledCaption","Typography","lineHeight","StyledPageTitle","fontWeight","StyledPageDivider","Divider","marginBottom","PageTitle","title","_jsx","variant","component","children","PageLayout","props","actionBtnTitle","caption","contextButtons","documentTitle","fullWidth","header","hideHeader","actionButtonLink","openLinkInNewTab","pageHeader","showActionButton","showAddIcon","strictToParent","titleComponent","TitleComponent","toParent","navigate","hideDivider","customActionButtons","useTheme","isMobile","useMediaQuery","baseUrl","getMicroFrontendAttribute","actionButtonWithHttps","startsWith","actionButtonLinkFinal","undefined","joinUrlPaths","_jsxs","DocumentTitle","Spacer","size","container","direction","item","alignContent","map","button","index","Box","onClick","history","length","ArrowBackIcon","_Fragment","Button","href","target","rel","Add","FullWidthContainer","FDErrorBoundary","identifier"],"mappings":"6wBAwBO,MAAMA,EAAW,KAGlBC,EAAgBC,EAAO,MAAPA,EAAkC,EAAGC,QAAOC,YAAa,CAC3EJ,SAAUI,EAAQ,OAASJ,EAC3B,CAACG,EAAME,YAAYC,KAAK,OAAQ,CAC5BN,SAAU,QAEdO,OAAQJ,EAAMK,QAAQ,EAAG,OAGvBC,EAAyBP,EAAOQ,EAAPR,EAAa,EAAGC,YAAa,CACxD,CAACA,EAAME,YA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AAST,GAA4BV,SAAA,CAEjGc,GAAejB,EAACwD,EAAG,CAAA,GACnBlD,UAKhBkB,GACGA,EAAoBmB,KAAI,CAACC,EAAQC,IAC7BV,mBACKT,GAAY1B,EAACqC,EAAM,CAACC,KAAM,GAAIrC,QAAQ,cACrCyB,GAAY1B,EAACqC,EAAO,CAAAC,KAAM,GAAIrC,QAAQ,aACxCD,EAACpC,GAAuB6E,MAAI,EAAAtC,SAAEyC,MAHxBC,YAQxBtB,GAAevB,EAACL,EAAoB,OAG9CwC,EAACsB,EAAmB,CAAA/C,UAAWA,EAASP,SAAA,CACnCQ,EAASX,EAACzB,EAAgB,CAAA4B,SAAEQ,IAA6B,KAC1DX,EAAC0D,EAAe,CAACC,WAAYlD,EACzBN,SAAAH,EAAAmD,EAAA,CAAAhD,SAAGA,cAKrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationProvider.cjs.js","sources":["../../src/providers/TranslationProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport en from '../../../../localization/en.json';\nimport { getMicroFrontendAttribute } from '../
|
|
1
|
+
{"version":3,"file":"TranslationProvider.cjs.js","sources":["../../src/providers/TranslationProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport en from '../../../../localization/en.json';\nimport { getMicroFrontendAttribute } from '../components/renderUtilities';\n\ndeclare global {\n type TranslationId = keyof typeof en;\n}\n\ntype Translation = { value: string };\n\ninterface TranslationBase {\n translations: Record<string, Translation>;\n}\n\nconst TranslationContext = createContext<TranslationBase>({} as unknown as TranslationBase);\n\ntype TranslationProp = {\n children: JSX.Element;\n} & TranslationBase;\n\nexport const TranslationProvider = ({ children, translations }: TranslationProp): JSX.Element => {\n const value = { translations };\n return <TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>;\n};\n\nexport const useTranslation = (): {\n translate: (key: TranslationId, data?: Record<string, string | number>) => string;\n translations: Record<string, Translation>;\n} => {\n const { translations } = useContext(TranslationContext);\n\n const translate = useCallback(\n (key: TranslationId, data?: Record<string, string | number>): string => {\n let translation = translations?.[key]?.value || en[key]?.value || key;\n if (data && translation) {\n Object.keys(data)?.forEach((key) => {\n translation = translation.replace(new RegExp(`{${key}}`, 'g'), `${data[key]}`);\n });\n }\n return translation;\n },\n [translations],\n );\n return { translate, translations };\n};\n\nconst languagesToLoad = ['nl', 'en-US', 'de', 'fr', 'it', 'es', 'pt', 'es-MX', 'dev-lang'];\n\nexport const useLoadTranslations = () => {\n const [translations, setTranslations] = useState<{\n loading: boolean;\n translations?: Record<string, { value: string }>;\n }>({ loading: true, translations: {} });\n const languageFromParentDiv = getMicroFrontendAttribute('data-language') || '';\n\n useEffect(() => {\n const fetchJSONData = async () => {\n // en loaded as default fallback already\n const shouldLoadLanguage = languagesToLoad.includes(languageFromParentDiv);\n if (shouldLoadLanguage) {\n import(`../../../../localization/${languageFromParentDiv}.json`)\n .then((response) => response.default) // Access the default export of the module\n .then((text) => {\n setTranslations({ loading: false, translations: text });\n })\n .catch((error) => {\n setTranslations({ loading: false });\n window.fdlogger?.error(`Error while fetching ${languageFromParentDiv || 'en'} language JSON data: ${error.message}`);\n });\n } else {\n setTranslations({ loading: false });\n }\n };\n\n void fetchJSONData();\n }, [languageFromParentDiv]);\n\n return {\n translations: translations.translations || {},\n loading: translations.loading,\n };\n};\n"],"names":["TranslationContext","createContext","translations","useContext","translate","useCallback","key","data","translation","value","en","Object","keys","forEach","replace","RegExp"],"mappings":"6GAcA,MAAMA,EAAqBC,EAAAA,cAA+B,CAAA,0BAW5B,KAI1B,MAAMC,aAAEA,GAAiBC,EAAUA,WAACH,GAcpC,MAAO,CAAEI,UAZSC,EAAAA,aACd,CAACC,EAAoBC,KACjB,IAAIC,EAAcN,IAAeI,IAAMG,OAASC,EAAAA,QAAGJ,IAAMG,OAASH,EAMlE,OALIC,GAAQC,GACRG,OAAOC,KAAKL,IAAOM,SAASP,IACxBE,EAAcA,EAAYM,QAAQ,IAAIC,OAAO,IAAIT,KAAQ,KAAM,GAAGC,EAAKD,KAAO,IAG/EE,CAAW,GAEtB,CAACN,IAEeA,eAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationProvider.js","sources":["../../src/providers/TranslationProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport en from '../../../../localization/en.json';\nimport { getMicroFrontendAttribute } from '../
|
|
1
|
+
{"version":3,"file":"TranslationProvider.js","sources":["../../src/providers/TranslationProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport en from '../../../../localization/en.json';\nimport { getMicroFrontendAttribute } from '../components/renderUtilities';\n\ndeclare global {\n type TranslationId = keyof typeof en;\n}\n\ntype Translation = { value: string };\n\ninterface TranslationBase {\n translations: Record<string, Translation>;\n}\n\nconst TranslationContext = createContext<TranslationBase>({} as unknown as TranslationBase);\n\ntype TranslationProp = {\n children: JSX.Element;\n} & TranslationBase;\n\nexport const TranslationProvider = ({ children, translations }: TranslationProp): JSX.Element => {\n const value = { translations };\n return <TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>;\n};\n\nexport const useTranslation = (): {\n translate: (key: TranslationId, data?: Record<string, string | number>) => string;\n translations: Record<string, Translation>;\n} => {\n const { translations } = useContext(TranslationContext);\n\n const translate = useCallback(\n (key: TranslationId, data?: Record<string, string | number>): string => {\n let translation = translations?.[key]?.value || en[key]?.value || key;\n if (data && translation) {\n Object.keys(data)?.forEach((key) => {\n translation = translation.replace(new RegExp(`{${key}}`, 'g'), `${data[key]}`);\n });\n }\n return translation;\n },\n [translations],\n );\n return { translate, translations };\n};\n\nconst languagesToLoad = ['nl', 'en-US', 'de', 'fr', 'it', 'es', 'pt', 'es-MX', 'dev-lang'];\n\nexport const useLoadTranslations = () => {\n const [translations, setTranslations] = useState<{\n loading: boolean;\n translations?: Record<string, { value: string }>;\n }>({ loading: true, translations: {} });\n const languageFromParentDiv = getMicroFrontendAttribute('data-language') || '';\n\n useEffect(() => {\n const fetchJSONData = async () => {\n // en loaded as default fallback already\n const shouldLoadLanguage = languagesToLoad.includes(languageFromParentDiv);\n if (shouldLoadLanguage) {\n import(`../../../../localization/${languageFromParentDiv}.json`)\n .then((response) => response.default) // Access the default export of the module\n .then((text) => {\n setTranslations({ loading: false, translations: text });\n })\n .catch((error) => {\n setTranslations({ loading: false });\n window.fdlogger?.error(`Error while fetching ${languageFromParentDiv || 'en'} language JSON data: ${error.message}`);\n });\n } else {\n setTranslations({ loading: false });\n }\n };\n\n void fetchJSONData();\n }, [languageFromParentDiv]);\n\n return {\n translations: translations.translations || {},\n loading: translations.loading,\n };\n};\n"],"names":["TranslationContext","createContext","useTranslation","translations","useContext","translate","useCallback","key","data","translation","value","en","Object","keys","forEach","replace","RegExp"],"mappings":"2IAcA,MAAMA,EAAqBC,EAA+B,CAAA,GAW7CC,EAAiB,KAI1B,MAAMC,aAAEA,GAAiBC,EAAWJ,GAcpC,MAAO,CAAEK,UAZSC,GACd,CAACC,EAAoBC,KACjB,IAAIC,EAAcN,IAAeI,IAAMG,OAASC,EAAGJ,IAAMG,OAASH,EAMlE,OALIC,GAAQC,GACRG,OAAOC,KAAKL,IAAOM,SAASP,IACxBE,EAAcA,EAAYM,QAAQ,IAAIC,OAAO,IAAIT,KAAQ,KAAM,GAAGC,EAAKD,KAAO,IAG/EE,CAAW,GAEtB,CAACN,IAEeA,eAAc"}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
declare const getMicroFrontendAttribute: (key: string) => string | null;
|
|
4
|
-
declare const getAppId: () => string | null;
|
|
5
|
-
declare const getOrgId: () => string | null;
|
|
6
|
-
declare const getIsFlipdishStaff: () => boolean;
|
|
7
|
-
declare const lazyWithRetry: (componentImport: () => any) => React.LazyExoticComponent<React.ComponentType<any>>;
|
|
8
|
-
|
|
9
|
-
export { getAppId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderUtilities.cjs.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string | null => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv && microFrontendDiv.getAttribute(key);\n};\n\nexport const getAppId = (): string | null => {\n return import.meta.env.VITE_APPID_OVERRIDE || getMicroFrontendAttribute('data-appId');\n};\n\nexport const getOrgId = (): string | null => {\n return import.meta.env.VITE_ORGID_OVERRIDE || getMicroFrontendAttribute('data-orgId');\n};\n\nexport const getIsFlipdishStaff = (): boolean => {\n const stringValue = import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE || getMicroFrontendAttribute('data-isFlipdishStaff');\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');\n\n try {\n const component = await componentImport();\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","undefined","VITE_APPID_OVERRIDE","stringValue","VITE_ISFLIPDISHSTAFFOVERRIDE","toString","VITE_ORGID_OVERRIDE","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"oCAEa,MAAAA,EAA6BC,IACtC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAoBA,EAAiBG,aAAaJ,EAAI,mBAGzC,UACbK,GAAgBC,qBAAuBP,EAA0B,yCAO1C,KAC9B,MAAMQ,QAAcF,GAAgBG,8BAAgCT,EAA0B,wBAC9F,MAAmC,SAA5BQ,GAAaE,UAAqB,uDANrB,UACbJ,GAAgBK,qBAAuBX,EAA0B,oCAS9CY,GAC1BC,EAAAA,MAAKC,UACD,MAAMC,EAAmCC,KAAKC,MAAMC,OAAOC,eAAeC,QAAQ,kCAAoC,SAEtH,IACI,MAAMC,QAAkBT,IAGxB,OAFAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAExDD,CACV,CAAC,MAAOE,GACL,IAAKR,EAID,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAM3B,MAAMF,CACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderUtilities.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string | null => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv && microFrontendDiv.getAttribute(key);\n};\n\nexport const getAppId = (): string | null => {\n return import.meta.env.VITE_APPID_OVERRIDE || getMicroFrontendAttribute('data-appId');\n};\n\nexport const getOrgId = (): string | null => {\n return import.meta.env.VITE_ORGID_OVERRIDE || getMicroFrontendAttribute('data-orgId');\n};\n\nexport const getIsFlipdishStaff = (): boolean => {\n const stringValue = import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE || getMicroFrontendAttribute('data-isFlipdishStaff');\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false');\n\n try {\n const component = await componentImport();\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","getAppId","env","VITE_APPID_OVERRIDE","getOrgId","VITE_ORGID_OVERRIDE","getIsFlipdishStaff","stringValue","VITE_ISFLIPDISHSTAFFOVERRIDE","toString","lazyWithRetry","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"6BAEa,MAAAA,EAA6BC,IACtC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAoBA,EAAiBG,aAAaJ,EAAI,EAGpDK,EAAW,gBACDC,IAAIC,qBAAuBR,EAA0B,cAG/DS,EAAW,gBACDF,IAAIG,qBAAuBV,EAA0B,cAG/DW,EAAqB,KAC9B,MAAMC,cAA0BL,IAAIM,8BAAgCb,EAA0B,wBAC9F,MAAmC,SAA5BY,GAAaE,UAAqB,EAIhCC,EAAiBC,GAC1BC,GAAKC,UACD,MAAMC,EAAmCC,KAAKC,MAAMC,OAAOC,eAAeC,QAAQ,kCAAoC,SAEtH,IACI,MAAMC,QAAkBT,IAGxB,OAFAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAExDD,CACV,CAAC,MAAOE,GACL,IAAKR,EAID,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAM3B,MAAMF,CACT"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/components/{components/ui → ui}/FlipdishStaffContainer/FlipdishStaffContainer.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|