@flipdish/portal-library 1.0.75 → 1.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/components/{custom-hooks → components/custom-hooks}/useMicroFrontendAttributes.d.ts +2 -1
  2. package/dist/components/components/custom-hooks/useRenderValidText.d.ts +14 -0
  3. package/dist/components/components/custom-hooks/useToasts.d.ts +59 -0
  4. package/dist/components/{index.d.ts → components/index.d.ts} +2 -0
  5. package/dist/components/{ui/GenericDatePickerField/GenericDatePickerField.d.ts → components/ui/GenericDatePickerField/GenericDateFieldBase.d.ts} +5 -4
  6. package/dist/components/components/ui/GenericDatePickerField/GenericDatePickerField.d.ts +7 -0
  7. package/dist/components/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.d.ts +7 -0
  8. package/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js +1 -1
  9. package/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js.map +1 -1
  10. package/dist/components/custom-hooks/useMicroFrontendAttributes.js +1 -1
  11. package/dist/components/custom-hooks/useMicroFrontendAttributes.js.map +1 -1
  12. package/dist/components/custom-hooks/useRenderValidText.cjs.js +1 -1
  13. package/dist/components/custom-hooks/useRenderValidText.cjs.js.map +1 -1
  14. package/dist/components/custom-hooks/useRenderValidText.js +1 -1
  15. package/dist/components/custom-hooks/useRenderValidText.js.map +1 -1
  16. package/dist/components/custom-hooks/useToasts.cjs.js +2 -0
  17. package/dist/components/custom-hooks/useToasts.cjs.js.map +1 -0
  18. package/dist/components/custom-hooks/useToasts.js +2 -0
  19. package/dist/components/custom-hooks/useToasts.js.map +1 -0
  20. package/dist/components/index.cjs.js +1 -1
  21. package/dist/components/index.js +1 -1
  22. package/dist/components/providers/ToastProvider.d.ts +26 -0
  23. package/dist/components/renderUtilities/renderUtilities.cjs.js +1 -1
  24. package/dist/components/renderUtilities/renderUtilities.cjs.js.map +1 -1
  25. package/dist/components/renderUtilities/renderUtilities.js +1 -1
  26. package/dist/components/renderUtilities/renderUtilities.js.map +1 -1
  27. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.cjs.js +1 -1
  28. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.cjs.js.map +1 -1
  29. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.js +1 -1
  30. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.js.map +1 -1
  31. package/dist/components/ui/Form/FormItemLayout.cjs.js.map +1 -1
  32. package/dist/components/ui/Form/FormItemLayout.js.map +1 -1
  33. package/dist/components/ui/Form/GenericAutocompleteField.cjs.js +1 -1
  34. package/dist/components/ui/Form/GenericAutocompleteField.cjs.js.map +1 -1
  35. package/dist/components/ui/Form/GenericAutocompleteField.js +1 -1
  36. package/dist/components/ui/Form/GenericAutocompleteField.js.map +1 -1
  37. package/dist/components/ui/Form/GenericFormContainer.cjs.js +1 -1
  38. package/dist/components/ui/Form/GenericFormContainer.cjs.js.map +1 -1
  39. package/dist/components/ui/Form/GenericFormContainer.js +1 -1
  40. package/dist/components/ui/Form/GenericFormContainer.js.map +1 -1
  41. package/dist/components/ui/Form/GenericTextField.cjs.js +1 -1
  42. package/dist/components/ui/Form/GenericTextField.cjs.js.map +1 -1
  43. package/dist/components/ui/Form/GenericTextField.js +1 -1
  44. package/dist/components/ui/Form/GenericTextField.js.map +1 -1
  45. package/dist/components/ui/Form/utilities/formValidation.cjs.js.map +1 -1
  46. package/dist/components/ui/Form/utilities/formValidation.js.map +1 -1
  47. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.cjs.js +2 -0
  48. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.cjs.js.map +1 -0
  49. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.js +2 -0
  50. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.js.map +1 -0
  51. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.cjs.js +1 -1
  52. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.cjs.js.map +1 -1
  53. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.js +1 -1
  54. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.js.map +1 -1
  55. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js +1 -1
  56. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js.map +1 -1
  57. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js +1 -1
  58. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js.map +1 -1
  59. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js +1 -1
  60. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js.map +1 -1
  61. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js +1 -1
  62. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js.map +1 -1
  63. package/dist/components/ui/GenericTableBody/GenericTableBody.cjs.js +1 -1
  64. package/dist/components/ui/GenericTableBody/GenericTableBody.cjs.js.map +1 -1
  65. package/dist/components/ui/GenericTableBody/GenericTableBody.js +1 -1
  66. package/dist/components/ui/GenericTableBody/GenericTableBody.js.map +1 -1
  67. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js +1 -1
  68. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js.map +1 -1
  69. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.js +1 -1
  70. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.js.map +1 -1
  71. package/dist/components/ui/PageLayout/PageLayout.cjs.js +1 -1
  72. package/dist/components/ui/PageLayout/PageLayout.cjs.js.map +1 -1
  73. package/dist/components/ui/PageLayout/PageLayout.js +1 -1
  74. package/dist/components/ui/PageLayout/PageLayout.js.map +1 -1
  75. package/dist/components/ui/Spacer/Spacer.cjs.js.map +1 -1
  76. package/dist/components/ui/Spacer/Spacer.js.map +1 -1
  77. package/dist/providers/ToastProvider.cjs.js +2 -0
  78. package/dist/providers/ToastProvider.cjs.js.map +1 -0
  79. package/dist/providers/ToastProvider.js +2 -0
  80. package/dist/providers/ToastProvider.js.map +1 -0
  81. package/dist/providers/TranslationProvider.cjs.js.map +1 -1
  82. package/dist/providers/TranslationProvider.js.map +1 -1
  83. package/package.json +17 -12
  84. package/dist/components/custom-hooks/useRenderValidText.d.ts +0 -13
  85. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.d.ts +0 -21
  86. /package/dist/components/{genericUtilities → components/genericUtilities}/index.d.ts +0 -0
  87. /package/dist/components/{renderUtilities → components/renderUtilities}/renderUtilities.d.ts +0 -0
  88. /package/dist/components/{themes → components/themes}/flipdishPublicTheme.d.ts +0 -0
  89. /package/dist/components/{ui → components/ui}/Chip/Chip.d.ts +0 -0
  90. /package/dist/components/{ui → components/ui}/DateTimeLocalizationProvider/DateTimeLocalizationProvider.d.ts +0 -0
  91. /package/dist/components/{ui → components/ui}/FlipdishLogoLoader/FlipdishLogoLoader.d.ts +0 -0
  92. /package/dist/components/{ui → components/ui}/FlipdishStaffContainer/FlipdishStaffContainer.d.ts +0 -0
  93. /package/dist/components/{ui → components/ui}/Form/GenericAutocompleteField.d.ts +0 -0
  94. /package/dist/components/{ui → components/ui}/Form/GenericFormContainer.d.ts +0 -0
  95. /package/dist/components/{ui → components/ui}/Form/GenericTextField.d.ts +0 -0
  96. /package/dist/components/{ui → components/ui}/Form/PaginatedAutocompleteField.d.ts +0 -0
  97. /package/dist/components/{ui → components/ui}/Form/utilities/formValidation.d.ts +0 -0
  98. /package/dist/components/{ui → components/ui}/GenericRadioButtons/GenericRadioButtons.d.ts +0 -0
  99. /package/dist/components/{ui → components/ui}/GenericTable/GenericTable.d.ts +0 -0
  100. /package/dist/components/{ui → components/ui}/GenericTable/types.d.ts +0 -0
  101. /package/dist/components/{ui → components/ui}/GenericTableBody/GenericTableBody.d.ts +0 -0
  102. /package/dist/components/{ui → components/ui}/GenericTableBodyRow/GenericTableBodyRow.d.ts +0 -0
  103. /package/dist/components/{ui → components/ui}/GenericTableTitle/GenericTableTitle.d.ts +0 -0
  104. /package/dist/components/{ui → components/ui}/LazyComponent/LazyComponent.d.ts +0 -0
  105. /package/dist/components/{ui → components/ui}/ListItemLink/ListItemLink.d.ts +0 -0
  106. /package/dist/components/{ui → components/ui}/ListItemLinkButton/ListItemLinkButton.d.ts +0 -0
  107. /package/dist/components/{ui → components/ui}/NoResults/NoResults.d.ts +0 -0
  108. /package/dist/components/{ui → components/ui}/NotFoundPage/NotFoundPage.d.ts +0 -0
  109. /package/dist/components/{ui → components/ui}/PageLayout/PageLayout.d.ts +0 -0
  110. /package/dist/components/{ui → components/ui}/PortalMock/PortalMock.d.ts +0 -0
  111. /package/dist/components/{ui → components/ui}/Spacer/Spacer.d.ts +0 -0
  112. /package/dist/components/{ui → components/ui}/Switch/Switch.d.ts +0 -0
  113. /package/dist/components/{ui → components/ui}/Tooltip/Tooltip.d.ts +0 -0
@@ -6,6 +6,7 @@ interface KeyConfig {
6
6
  declare const ALWAYS_RETURN_KEYS: (string | KeyConfig)[];
7
7
  type AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig ? (typeof ALWAYS_RETURN_KEYS)[number]['key'] : (typeof ALWAYS_RETURN_KEYS)[number];
8
8
  type ExtractKey<T> = T extends KeyConfig ? T['key'] : T;
9
+ type AttributeValue = string | boolean | number | null;
9
10
  /**
10
11
  * Custom hook to manage micro-frontend attributes.
11
12
  *
@@ -23,6 +24,6 @@ type ExtractKey<T> = T extends KeyConfig ? T['key'] : T;
23
24
  * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);
24
25
  * console.log(attributes);
25
26
  */
26
- declare const useMicroFrontendAttributes: <T extends string | KeyConfig>(customKeys?: (T | KeyConfig)[]) => Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>;
27
+ declare const useMicroFrontendAttributes: <T extends string | KeyConfig>(customKeys?: (T | KeyConfig)[]) => Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;
27
28
 
28
29
  export { useMicroFrontendAttributes as default };
@@ -0,0 +1,14 @@
1
+ type ValidationState = {
2
+ fieldError?: string;
3
+ showError?: boolean;
4
+ touched: boolean;
5
+ value: string;
6
+ };
7
+ type ValidationElement = JSX.Element | string | undefined;
8
+ /**
9
+ * @description Custom hook for rendering validation text in form fields
10
+ * @description Handles different validation states with separate methods for better clarity
11
+ */
12
+ declare const useRenderValidText: ({ fieldError, showError, touched, value }: ValidationState) => ValidationElement;
13
+
14
+ export { useRenderValidText as default };
@@ -0,0 +1,59 @@
1
+ import { SnackbarKey } from 'notistack';
2
+
3
+ /**
4
+ * Configuration options for toast notifications
5
+ * @interface ToastOptions
6
+ * @property {boolean} [persist] - If true, the toast will not auto-dismiss
7
+ * @property {number} [durationMs] - Duration in milliseconds before the toast auto-dismisses
8
+ */
9
+ interface ToastOptions {
10
+ /** If true, the toast will not auto-dismiss */
11
+ persist?: boolean;
12
+ /** Duration in milliseconds before the toast auto-dismisses */
13
+ durationMs?: number;
14
+ }
15
+ /**
16
+ * Type alias for toast notification keys
17
+ * Used to uniquely identify toast notifications for dismissal
18
+ */
19
+ type ToastKey = SnackbarKey;
20
+ /**
21
+ * Interface defining the return value of the useToasts hook
22
+ */
23
+ interface UseToastsReturn {
24
+ /** Dismisses all active toast notifications */
25
+ dismissAllToasts: () => void;
26
+ /** Dismisses a specific toast by its key */
27
+ dismissToast: (key: string) => void;
28
+ /** Shows a default toast notification */
29
+ showDefaultToast: (message: string, options?: ToastOptions) => ToastKey;
30
+ /** Shows a success toast notification */
31
+ showSuccessToast: (message: string, options?: ToastOptions) => ToastKey;
32
+ /** Shows an error toast notification */
33
+ showErrorToast: (message: string, options?: ToastOptions) => ToastKey;
34
+ }
35
+ /**
36
+ * Custom hook for managing toast notifications
37
+ * Provides methods to show different types of toasts (default, success, error)
38
+ * and dismiss them individually or all at once
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * const { showSuccessToast, showErrorToast, dismissAllToasts } = useToasts();
43
+ *
44
+ * // Show a success toast that auto-dismisses after 3 seconds
45
+ * const toastKey = showSuccessToast('Operation successful', { durationMs: 3000 });
46
+ *
47
+ * // Show a persistent error toast
48
+ * const errorToastKey = showErrorToast('Error occurred', { persist: true });
49
+ *
50
+ * // Later, dismiss a specific toast using its key
51
+ * dismissToast(toastKey);
52
+ *
53
+ * // Or dismiss all toasts
54
+ * dismissAllToasts();
55
+ * ```
56
+ */
57
+ declare const useToasts: () => UseToastsReturn;
58
+
59
+ export { type ToastKey, type ToastOptions, type UseToastsReturn, useToasts as default };
@@ -32,5 +32,7 @@ export { default as AccessTimeIcon } from '@mui/icons-material/AccessTime';
32
32
  export { default as DoneIcon } from '@mui/icons-material/Done';
33
33
  export { default as useRenderValidText } from './custom-hooks/useRenderValidText.js';
34
34
  export { default as useMicroFrontendAttributes } from './custom-hooks/useMicroFrontendAttributes.js';
35
+ export { default as useToasts } from './custom-hooks/useToasts.js';
35
36
  export { getAppId, getBrandId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry } from './renderUtilities/renderUtilities.js';
36
37
  export { debounce } from './genericUtilities/index.js';
38
+ export { default as ToastProvider } from '../providers/ToastProvider.js';
@@ -1,8 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import { TextFieldVariants } from '@mui/material/TextField';
3
2
  import moment from 'moment';
3
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
4
+ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
4
5
 
5
- type Props = {
6
+ type GenericDateFieldBaseProps = {
6
7
  label: string;
7
8
  placeholder?: string;
8
9
  fieldName: string;
@@ -15,7 +16,7 @@ type Props = {
15
16
  disablefuture?: boolean;
16
17
  onChange?: (dateTime: moment.Moment) => void;
17
18
  showHelperTextWhenValid?: boolean;
19
+ pickerComponent: typeof DatePicker | typeof DateTimePicker;
18
20
  };
19
- declare const GenericDatePickerField: ({ label, fieldName, description, validation, variant, layout, onChange, disabled, disablePast, disablefuture, placeholder, showHelperTextWhenValid, }: Props) => react_jsx_runtime.JSX.Element;
20
21
 
21
- export { GenericDatePickerField as default };
22
+ export type { GenericDateFieldBaseProps };
@@ -0,0 +1,7 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { GenericDateFieldBaseProps } from './GenericDateFieldBase.js';
3
+
4
+ type Props = Omit<GenericDateFieldBaseProps, 'pickerComponent'>;
5
+ declare const GenericDatePickerField: (props: Props) => react_jsx_runtime.JSX.Element;
6
+
7
+ export { GenericDatePickerField as default };
@@ -0,0 +1,7 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { GenericDateFieldBaseProps } from '../GenericDatePickerField/GenericDateFieldBase.js';
3
+
4
+ type Props = Omit<GenericDateFieldBaseProps, 'pickerComponent'>;
5
+ declare const GenericDateTimePickerField: (props: Props) => react_jsx_runtime.JSX.Element;
6
+
7
+ export { GenericDateTimePickerField as default };
@@ -1,2 +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};
1
+ "use strict";var t=require("react");const e=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}],n=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,o=t=>[...e.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))];module.exports=(r=[])=>{const[s,i]=t.useState((()=>(t=>{const e=o(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(r)));return t.useEffect((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const s=o(r),u=[...e,...r],c=()=>{i((e=>{const o={...e};let r=!1;return s.forEach((e=>{const{value:s,key:i}=((t,e,o)=>{const r=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,o),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type:"string")(r),i="string"==typeof t?t:t.key,u=(void 0)[`VITE_${i.toUpperCase()}_OVERRIDE`],c=`data-${i}`,a=e.getAttribute(c);return{value:n(u?u.toString():a,s),key:i}})(e,t,u);o[i]!==s&&(o[i]=s,r=!0)})),r?o:e}))};c();const a=new MutationObserver(c);return a.observe(t,{attributes:!0}),()=>a.disconnect()}),[r]),s};
2
2
  //# sourceMappingURL=useMicroFrontendAttributes.cjs.js.map
@@ -1 +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,EAAWK,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAI9DQ,EAA2F,CAAA,EASjG,OAJAF,EAAQG,SAAST,IACbQ,EAAaR,GAAO,IAAI,IAGrBQ,CAAY,IA2EvB,OAxEAE,EAAAA,WAAU,KACN,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAED,YADAG,QAAQC,KAAK,gCAIjB,MAAMT,EAA6C,IAC5CP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEE,EAAWK,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAG9DgB,EAAe,KACjBZ,GAAea,IACX,MAAMC,EAA4F,IAAKD,GAEvG,IAAIE,GAAY,EAyChB,OAvCAb,EAAQG,SAAST,IAEb,MAAMoB,EAAY,IAAIrB,KAAuBG,GAAYmB,MAAMC,GACzC,iBAAXA,EAAsBA,IAAWtB,EAAMsB,EAAOtB,MAAQA,IAE3DC,EAAOmB,GAAkC,iBAAdA,GAA0B,SAAUA,EAAYA,EAAUnB,KAAO,SAG5FsB,QAASC,GAAgB,SAAwB,iBAARxB,EAAmBA,EAAMA,EAAIA,KAAKyB,0BACjF,IAAIC,EAA6C,KAEjD,GAAIH,EAEIG,EADS,YAATzB,EACiC,SAAtBsB,EAAOI,WACF,WAAT1B,EACI2B,OAAOL,GAEPA,MAEZ,CACH,MAAMM,EAAe,QAAuB,iBAAR7B,EAAmBA,EAAMA,EAAIA,MAC3D8B,EAAQnB,EAAiBoB,aAAaF,GAGxCH,EADS,YAATzB,EACqB,SAAV6B,EACK,WAAT7B,EACI6B,EAAQF,OAAOE,GAAS,KAExBA,CAElB,CAGGZ,EAAclB,KAA6C0B,IAC3DR,EAAclB,GAA2C0B,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"}
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\ntype AttributeValue = string | boolean | number | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = string | T | AlwaysReturnKeys;\nconst getKeyConfig = <T extends string | KeyConfig>(key: KeyArg<T>, allConfigs: (string | KeyConfig)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig ? keyConfig.type : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends string | KeyConfig>(customKeys: (T | KeyConfig)[]): (string | T | AlwaysReturnKeys)[] => {\n return [\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\nconst getInitialState = <T extends string | KeyConfig>(customKeys: (T | KeyConfig)[]): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends string | KeyConfig>(\n key: string | T | AlwaysReturnKeys,\n microFrontendDiv: HTMLElement,\n allConfigs: (string | KeyConfig)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | undefined | null;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\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>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\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 = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\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","parseValue","value","Number","getAllKeys","customKeys","map","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","undefined","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"oCASA,MAAMA,EAA6C,CAAC,QAAS,QAAS,CAAEC,IAAK,kBAAmBC,KAAM,YAoBhGC,EAAa,CAACC,EAAsBF,IACjCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMvCE,EAA4CC,GACvC,IACAP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,sBAgDrC,CAC/BM,EAAgC,MAEhC,MAAOE,EAAYC,GAAiBC,EAAQA,UAAC,IA/CzB,CAA+BJ,IACnD,MAAMK,EAAUN,EAAWC,GACrBM,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASb,IACb,MAAMc,EAA2B,iBAARd,EAAmBA,EAAMA,EAAIA,IACtDY,EAAaE,GAAY,IAAI,IAE1BF,CAAY,EAwCgCG,CAAgBT,KAqCnE,OAnCAU,EAAAA,WAAU,KACN,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAED,YADAG,QAAQC,KAAK,gCAIjB,MAAMV,EAAUN,EAAWC,GACrBgB,EAAa,IAAIvB,KAAuBO,GAExCiB,EAAe,KACjBd,GAAee,IACX,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASb,IACb,MAAMG,MAAEA,EAAOH,IAAKc,GAvDf,EACrBd,EACAiB,EACAK,KAEA,MAAMK,EArCW,EAA+B3B,EAAgBsB,IACzDA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW7B,EAAM6B,EAAO7B,MAAQA,IAoC/E8B,CAAa9B,EAAKsB,GAC9BrB,EAlCW,CAAC0B,GACXA,GAAkC,iBAAdA,GAA0B,SAAUA,EAAYA,EAAU1B,KAAO,SAiC/E8B,CAAaJ,GACpBK,EAA2B,iBAARhC,EAAmBA,EAAMA,EAAIA,IAEhDiC,QAASC,GAAgB,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAEjC,MADcD,EAAT+B,EAAoBA,EAAOM,WAA+BF,EAAnBpC,GACrCD,IAAKgC,EAA+C,EAyCnBQ,CAAiBxC,EAAKiB,EAAkBK,GACrEG,EAAcX,KAAcX,IAC5BsB,EAAcX,GAAYX,EAC1BuB,GAAY,EACf,IAGEA,EAAYD,EAAgBD,CAAI,GACzC,EAGND,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,YAAY,GACnC,CAACtC,IAEGE,CAAU"}
@@ -1,2 +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};
1
+ import{useState as t,useEffect as e}from"react";const n=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}],o=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...n.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))],s=(s=[])=>{const[i,a]=t((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(s)));return e((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const e=r(s),i=[...n,...s],p=()=>{a((n=>{const r={...n};let s=!1;return e.forEach((e=>{const{value:n,key:a}=((t,e,n)=>{const r=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,n),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type:"string")(r),i="string"==typeof t?t:t.key,a=import.meta.env[`VITE_${i.toUpperCase()}_OVERRIDE`],p=`data-${i}`,c=e.getAttribute(p);return{value:o(a?a.toString():c,s),key:i}})(e,t,i);r[a]!==n&&(r[a]=n,s=!0)})),s?r:n}))};p();const c=new MutationObserver(p);return c.observe(t,{attributes:!0}),()=>c.disconnect()}),[s]),i};export{s as default};
2
2
  //# sourceMappingURL=useMicroFrontendAttributes.js.map
@@ -1 +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","Number","attributeKey","value","getAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"gDASA,MAAMA,EAA6C,CAAC,QAAS,QAAS,CAAEC,IAAK,kBAAmBC,KAAM,YAyBhGC,EAA6B,CAC/BC,EAAgC,MAEhC,MAAOC,EAAYC,GAAiBC,GAAS,KAEzC,MAAMC,EAA8C,IAC7CR,EAAmBS,KAAKR,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEG,EAAWK,KAAKR,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAI9DS,EAA2F,CAAA,EASjG,OAJAF,EAAQG,SAASV,IACbS,EAAaT,GAAO,IAAI,IAGrBS,CAAY,IA2EvB,OAxEAE,GAAU,KACN,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAED,YADAG,QAAQC,KAAK,gCAIjB,MAAMT,EAA6C,IAC5CR,EAAmBS,KAAKR,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEG,EAAWK,KAAKR,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAG9DiB,EAAe,KACjBZ,GAAea,IACX,MAAMC,EAA4F,IAAKD,GAEvG,IAAIE,GAAY,EAyChB,OAvCAb,EAAQG,SAASV,IAEb,MAAMqB,EAAY,IAAItB,KAAuBI,GAAYmB,MAAMC,GACzC,iBAAXA,EAAsBA,IAAWvB,EAAMuB,EAAOvB,MAAQA,IAE3DC,EAAOoB,GAAkC,iBAAdA,GAA0B,SAAUA,EAAYA,EAAUpB,KAAO,SAG5FuB,cAAqBC,IAAI,SAAwB,iBAARzB,EAAmBA,EAAMA,EAAIA,KAAK0B,0BACjF,IAAIC,EAA6C,KAEjD,GAAIH,EAEIG,EADS,YAAT1B,EACiC,SAAtBuB,EAAOI,WACF,WAAT3B,EACI4B,OAAOL,GAEPA,MAEZ,CACH,MAAMM,EAAe,QAAuB,iBAAR9B,EAAmBA,EAAMA,EAAIA,MAC3D+B,EAAQnB,EAAiBoB,aAAaF,GAGxCH,EADS,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"}
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\ntype AttributeValue = string | boolean | number | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = string | T | AlwaysReturnKeys;\nconst getKeyConfig = <T extends string | KeyConfig>(key: KeyArg<T>, allConfigs: (string | KeyConfig)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig ? keyConfig.type : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends string | KeyConfig>(customKeys: (T | KeyConfig)[]): (string | T | AlwaysReturnKeys)[] => {\n return [\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\nconst getInitialState = <T extends string | KeyConfig>(customKeys: (T | KeyConfig)[]): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends string | KeyConfig>(\n key: string | T | AlwaysReturnKeys,\n microFrontendDiv: HTMLElement,\n allConfigs: (string | KeyConfig)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | undefined | null;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\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>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\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 = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\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","parseValue","value","Number","getAllKeys","customKeys","map","useMicroFrontendAttributes","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","env","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"gDASA,MAAMA,EAA6C,CAAC,QAAS,QAAS,CAAEC,IAAK,kBAAmBC,KAAM,YAoBhGC,EAAa,CAACC,EAAsBF,IACjCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMvCE,EAA4CC,GACvC,IACAP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAgDlEQ,EAA6B,CAC/BF,EAAgC,MAEhC,MAAOG,EAAYC,GAAiBC,GAAS,IA/CzB,CAA+BL,IACnD,MAAMM,EAAUP,EAAWC,GACrBO,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASd,IACb,MAAMe,EAA2B,iBAARf,EAAmBA,EAAMA,EAAIA,IACtDa,EAAaE,GAAY,IAAI,IAE1BF,CAAY,EAwCgCG,CAAgBV,KAqCnE,OAnCAW,GAAU,KACN,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAED,YADAG,QAAQC,KAAK,gCAIjB,MAAMV,EAAUP,EAAWC,GACrBiB,EAAa,IAAIxB,KAAuBO,GAExCkB,EAAe,KACjBd,GAAee,IACX,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASd,IACb,MAAMG,MAAEA,EAAOH,IAAKe,GAvDf,EACrBf,EACAkB,EACAK,KAEA,MAAMK,EArCW,EAA+B5B,EAAgBuB,IACzDA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW9B,EAAM8B,EAAO9B,MAAQA,IAoC/E+B,CAAa/B,EAAKuB,GAC9BtB,EAlCW,CAAC2B,GACXA,GAAkC,iBAAdA,GAA0B,SAAUA,EAAYA,EAAU3B,KAAO,SAiC/E+B,CAAaJ,GACpBK,EAA2B,iBAARjC,EAAmBA,EAAMA,EAAIA,IAEhDkC,cAAqBC,IAAI,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAElC,MADcD,EAATgC,EAAoBA,EAAOM,WAA+BF,EAAnBrC,GACrCD,IAAKiC,EAA+C,EAyCnBQ,CAAiBzC,EAAKkB,EAAkBK,GACrEG,EAAcX,KAAcZ,IAC5BuB,EAAcX,GAAYZ,EAC1BwB,GAAY,EACf,IAGEA,EAAYD,EAAgBD,CAAI,GACzC,EAGND,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,YAAY,GACnC,CAACvC,IAEGG,CAAU"}
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("react/jsx-runtime"),e=require("react"),s=require("../../providers/TranslationProvider.cjs.js");module.exports=({fieldError:t,showError:a,touched:o,value:i})=>{const[u,c]=e.useState(""),{translate:l}=s.useTranslation();return e.useEffect((()=>{c(!a&&o&&i?r.jsx("span",{style:{color:"#1dc798"},children:l("Valid")}):a?t:"")}),[t,i,a,o]),u};
1
+ "use strict";var r=require("react/jsx-runtime"),e=require("react"),s=require("../../providers/TranslationProvider.cjs.js");module.exports=({fieldError:t,showError:a,touched:o,value:i})=>{const[u,c]=e.useState(""),{translate:l}=s.useTranslation(),n=()=>!a&&o&&i?r.jsx("span",{style:{color:"#1dc798"},children:l("Valid")}):a?t:"";return e.useEffect((()=>{c(n())}),[t,i,a,o]),u};
2
2
  //# sourceMappingURL=useRenderValidText.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRenderValidText.cjs.js","sources":["../../../src/components/custom-hooks/useRenderValidText.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useTranslation } from '../../providers/TranslationProvider';\n\ntype Props = {\n fieldError?: string;\n showError?: boolean;\n touched: boolean;\n value: string;\n};\n/**\n * @description Use this with Formik - the touched field state is not available immediately because ```form.setFieldValue``` is async\n * @description https://github.com/formium/formik/issues/529#issuecomment-571294217\n */\nconst useRenderValidText = ({ fieldError, showError, touched, value }: Props) => {\n const [validTextElement, setvalidTextElement] = useState<JSX.Element | string | undefined>('');\n const { translate } = useTranslation();\n\n useEffect(() => {\n if (!showError && touched && value) {\n setvalidTextElement(<span style={{ color: '#1dc798' }}>{translate('Valid')}</span>);\n } else if (showError) {\n setvalidTextElement(fieldError);\n } else setvalidTextElement('');\n }, [fieldError, value, showError, touched]);\n\n return validTextElement;\n};\n\nexport default useRenderValidText;\n"],"names":["fieldError","showError","touched","value","validTextElement","setvalidTextElement","useState","translate","useTranslation","useEffect","_jsx","style","color","children"],"mappings":"0IAa2B,EAAGA,aAAYC,YAAWC,UAASC,YAC1D,MAAOC,EAAkBC,GAAuBC,EAAQA,SAAmC,KACrFC,UAAEA,GAAcC,EAAAA,iBAUtB,OARAC,EAAAA,WAAU,KAEFJ,GADCJ,GAAaC,GAAWC,EACLO,EAAAA,IAAM,OAAA,CAAAC,MAAO,CAAEC,MAAO,WAAWC,SAAGN,EAAU,WAC3DN,EACaD,EACG,GAAG,GAC/B,CAACA,EAAYG,EAAOF,EAAWC,IAE3BE,CAAgB"}
1
+ {"version":3,"file":"useRenderValidText.cjs.js","sources":["../../../src/components/custom-hooks/useRenderValidText.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useTranslation } from '../../providers/TranslationProvider';\n\ntype ValidationState = {\n fieldError?: string;\n showError?: boolean;\n touched: boolean;\n value: string;\n};\n\ntype ValidationElement = JSX.Element | string | undefined;\n\n/**\n * @description Custom hook for rendering validation text in form fields\n * @description Handles different validation states with separate methods for better clarity\n */\nconst useRenderValidText = ({ fieldError, showError, touched, value }: ValidationState) => {\n const [validTextElement, setValidTextElement] = useState<ValidationElement>('');\n const { translate } = useTranslation();\n\n const renderValidState = (): ValidationElement => {\n return <span style={{ color: '#1dc798' }}>{translate('Valid')}</span>;\n };\n\n const renderErrorState = (): ValidationElement => {\n return fieldError;\n };\n\n const renderEmptyState = (): ValidationElement => {\n return '';\n };\n\n const determineValidationState = (): ValidationElement => {\n if (!showError && touched && value) {\n return renderValidState();\n }\n\n if (showError) {\n return renderErrorState();\n }\n\n return renderEmptyState();\n };\n\n useEffect(() => {\n setValidTextElement(determineValidationState());\n }, [fieldError, value, showError, touched]);\n\n return validTextElement;\n};\n\nexport default useRenderValidText;\n"],"names":["fieldError","showError","touched","value","validTextElement","setValidTextElement","useState","translate","useTranslation","determineValidationState","_jsx","style","color","children","useEffect"],"mappings":"0IAgB2B,EAAGA,aAAYC,YAAWC,UAASC,YAC1D,MAAOC,EAAkBC,GAAuBC,EAAQA,SAAoB,KACtEC,UAAEA,GAAcC,EAAAA,iBAchBC,EAA2B,KACxBR,GAAaC,GAAWC,EAZtBO,MAAM,OAAA,CAAAC,MAAO,CAAEC,MAAO,WAAWC,SAAGN,EAAU,WAgBjDN,EAZGD,EAIA,GAmBX,OAJAc,EAAAA,WAAU,KACNT,EAAoBI,IAA2B,GAChD,CAACT,EAAYG,EAAOF,EAAWC,IAE3BE,CAAgB"}
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{useState as o,useEffect as t}from"react";import{useTranslation as e}from"../../providers/TranslationProvider.js";const a=({fieldError:a,showError:s,touched:i,value:l})=>{const[n,c]=o(""),{translate:d}=e();return t((()=>{c(!s&&i&&l?r("span",{style:{color:"#1dc798"},children:d("Valid")}):s?a:"")}),[a,l,s,i]),n};export{a as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{useState as o,useEffect as t}from"react";import{useTranslation as e}from"../../providers/TranslationProvider.js";const a=({fieldError:a,showError:s,touched:i,value:l})=>{const[n,c]=o(""),{translate:d}=e(),m=()=>!s&&i&&l?r("span",{style:{color:"#1dc798"},children:d("Valid")}):s?a:"";return t((()=>{c(m())}),[a,l,s,i]),n};export{a as default};
2
2
  //# sourceMappingURL=useRenderValidText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRenderValidText.js","sources":["../../../src/components/custom-hooks/useRenderValidText.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useTranslation } from '../../providers/TranslationProvider';\n\ntype Props = {\n fieldError?: string;\n showError?: boolean;\n touched: boolean;\n value: string;\n};\n/**\n * @description Use this with Formik - the touched field state is not available immediately because ```form.setFieldValue``` is async\n * @description https://github.com/formium/formik/issues/529#issuecomment-571294217\n */\nconst useRenderValidText = ({ fieldError, showError, touched, value }: Props) => {\n const [validTextElement, setvalidTextElement] = useState<JSX.Element | string | undefined>('');\n const { translate } = useTranslation();\n\n useEffect(() => {\n if (!showError && touched && value) {\n setvalidTextElement(<span style={{ color: '#1dc798' }}>{translate('Valid')}</span>);\n } else if (showError) {\n setvalidTextElement(fieldError);\n } else setvalidTextElement('');\n }, [fieldError, value, showError, touched]);\n\n return validTextElement;\n};\n\nexport default useRenderValidText;\n"],"names":["useRenderValidText","fieldError","showError","touched","value","validTextElement","setvalidTextElement","useState","translate","useTranslation","useEffect","_jsx","style","color","children"],"mappings":"gKAaA,MAAMA,EAAqB,EAAGC,aAAYC,YAAWC,UAASC,YAC1D,MAAOC,EAAkBC,GAAuBC,EAA2C,KACrFC,UAAEA,GAAcC,IAUtB,OARAC,GAAU,KAEFJ,GADCJ,GAAaC,GAAWC,EACLO,EAAM,OAAA,CAAAC,MAAO,CAAEC,MAAO,WAAWC,SAAGN,EAAU,WAC3DN,EACaD,EACG,GAAG,GAC/B,CAACA,EAAYG,EAAOF,EAAWC,IAE3BE,CAAgB"}
1
+ {"version":3,"file":"useRenderValidText.js","sources":["../../../src/components/custom-hooks/useRenderValidText.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useTranslation } from '../../providers/TranslationProvider';\n\ntype ValidationState = {\n fieldError?: string;\n showError?: boolean;\n touched: boolean;\n value: string;\n};\n\ntype ValidationElement = JSX.Element | string | undefined;\n\n/**\n * @description Custom hook for rendering validation text in form fields\n * @description Handles different validation states with separate methods for better clarity\n */\nconst useRenderValidText = ({ fieldError, showError, touched, value }: ValidationState) => {\n const [validTextElement, setValidTextElement] = useState<ValidationElement>('');\n const { translate } = useTranslation();\n\n const renderValidState = (): ValidationElement => {\n return <span style={{ color: '#1dc798' }}>{translate('Valid')}</span>;\n };\n\n const renderErrorState = (): ValidationElement => {\n return fieldError;\n };\n\n const renderEmptyState = (): ValidationElement => {\n return '';\n };\n\n const determineValidationState = (): ValidationElement => {\n if (!showError && touched && value) {\n return renderValidState();\n }\n\n if (showError) {\n return renderErrorState();\n }\n\n return renderEmptyState();\n };\n\n useEffect(() => {\n setValidTextElement(determineValidationState());\n }, [fieldError, value, showError, touched]);\n\n return validTextElement;\n};\n\nexport default useRenderValidText;\n"],"names":["useRenderValidText","fieldError","showError","touched","value","validTextElement","setValidTextElement","useState","translate","useTranslation","determineValidationState","_jsx","style","color","children","useEffect"],"mappings":"gKAgBA,MAAMA,EAAqB,EAAGC,aAAYC,YAAWC,UAASC,YAC1D,MAAOC,EAAkBC,GAAuBC,EAA4B,KACtEC,UAAEA,GAAcC,IAchBC,EAA2B,KACxBR,GAAaC,GAAWC,EAZtBO,EAAM,OAAA,CAAAC,MAAO,CAAEC,MAAO,WAAWC,SAAGN,EAAU,WAgBjDN,EAZGD,EAIA,GAmBX,OAJAc,GAAU,KACNT,EAAoBI,IAA2B,GAChD,CAACT,EAAYG,EAAOF,EAAWC,IAE3BE,CAAgB"}
@@ -0,0 +1,2 @@
1
+ "use strict";var s=require("notistack");module.exports=()=>{const{enqueueSnackbar:o,closeSnackbar:r}=s.useSnackbar(),a=(s,r,a=void 0)=>o(s,{autoHideDuration:a?.durationMs,persist:a?.persist,variant:r});return{dismissAllToasts:()=>{r()},dismissToast:s=>{r(s)},showDefaultToast:(s,o=void 0)=>a(s,"default",o),showSuccessToast:(s,o=void 0)=>a(s,"success",o),showErrorToast:(s,o=void 0)=>a(s,"error",o)}};
2
+ //# sourceMappingURL=useToasts.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToasts.cjs.js","sources":["../../../src/components/custom-hooks/useToasts.tsx"],"sourcesContent":["import { useSnackbar, type SnackbarKey, type VariantType } from 'notistack';\n\n/**\n * Configuration options for toast notifications\n * @interface ToastOptions\n * @property {boolean} [persist] - If true, the toast will not auto-dismiss\n * @property {number} [durationMs] - Duration in milliseconds before the toast auto-dismisses\n */\nexport interface ToastOptions {\n /** If true, the toast will not auto-dismiss */\n persist?: boolean;\n /** Duration in milliseconds before the toast auto-dismisses */\n durationMs?: number;\n}\n\n/**\n * Type alias for toast notification keys\n * Used to uniquely identify toast notifications for dismissal\n */\nexport type ToastKey = SnackbarKey;\n\n/**\n * Interface defining the return value of the useToasts hook\n */\nexport interface UseToastsReturn {\n /** Dismisses all active toast notifications */\n dismissAllToasts: () => void;\n /** Dismisses a specific toast by its key */\n dismissToast: (key: string) => void;\n /** Shows a default toast notification */\n showDefaultToast: (message: string, options?: ToastOptions) => ToastKey;\n /** Shows a success toast notification */\n showSuccessToast: (message: string, options?: ToastOptions) => ToastKey;\n /** Shows an error toast notification */\n showErrorToast: (message: string, options?: ToastOptions) => ToastKey;\n}\n\n/**\n * Custom hook for managing toast notifications\n * Provides methods to show different types of toasts (default, success, error)\n * and dismiss them individually or all at once\n *\n * @example\n * ```tsx\n * const { showSuccessToast, showErrorToast, dismissAllToasts } = useToasts();\n *\n * // Show a success toast that auto-dismisses after 3 seconds\n * const toastKey = showSuccessToast('Operation successful', { durationMs: 3000 });\n *\n * // Show a persistent error toast\n * const errorToastKey = showErrorToast('Error occurred', { persist: true });\n *\n * // Later, dismiss a specific toast using its key\n * dismissToast(toastKey);\n *\n * // Or dismiss all toasts\n * dismissAllToasts();\n * ```\n */\nconst useToasts = (): UseToastsReturn => {\n const { enqueueSnackbar, closeSnackbar } = useSnackbar();\n\n /**\n * Dismisses all currently active toast notifications\n */\n const dismissAllToasts = () => {\n closeSnackbar();\n };\n\n /**\n * Dismisses a specific toast notification by its key\n * @param {string} key - Unique identifier of the toast to dismiss\n */\n const dismissToast = (key: string) => {\n closeSnackbar(key);\n };\n\n /**\n * Internal method to show a toast notification with specified variant and options\n * @param {string} message - The message to display in the toast\n * @param {VariantType} variant - The type of toast (default, success, error)\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showToast = (message: string, variant: VariantType, options: ToastOptions | undefined = undefined): ToastKey => {\n return enqueueSnackbar(message, {\n autoHideDuration: options?.durationMs,\n persist: options?.persist,\n variant,\n });\n };\n\n /**\n * Shows a default toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showDefaultToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'default', options);\n };\n\n /**\n * Shows a success toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showSuccessToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'success', options);\n };\n\n /**\n * Shows an error toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showErrorToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'error', options);\n };\n\n return { dismissAllToasts, dismissToast, showDefaultToast, showSuccessToast, showErrorToast };\n};\n\nexport default useToasts;\n"],"names":["enqueueSnackbar","closeSnackbar","useSnackbar","showToast","message","variant","options","undefined","autoHideDuration","durationMs","persist","dismissAllToasts","dismissToast","key","showDefaultToast","showSuccessToast","showErrorToast"],"mappings":"uDA2DkB,KACd,MAAMA,gBAAEA,EAAeC,cAAEA,GAAkBC,EAAWA,cAwBhDC,EAAY,CAACC,EAAiBC,EAAsBC,OAAoCC,IACnFP,EAAgBI,EAAS,CAC5BI,iBAAkBF,GAASG,WAC3BC,QAASJ,GAASI,QAClBL,YAkCR,MAAO,CAAEM,iBAzDgB,KACrBV,GAAe,EAwDQW,aAjDLC,IAClBZ,EAAcY,EAAI,EAgDmBC,iBAxBhB,CAACV,EAAiBE,OAAoCC,IACpEJ,EAAUC,EAAS,UAAWE,GAuBkBS,iBAdlC,CAACX,EAAiBE,OAAoCC,IACpEJ,EAAUC,EAAS,UAAWE,GAaoCU,eAJtD,CAACZ,EAAiBE,OAAoCC,IAClEJ,EAAUC,EAAS,QAASE,GAGsD"}
@@ -0,0 +1,2 @@
1
+ import{useSnackbar as s}from"notistack";const o=()=>{const{enqueueSnackbar:o,closeSnackbar:t}=s(),a=(s,t,a=void 0)=>o(s,{autoHideDuration:a?.durationMs,persist:a?.persist,variant:t});return{dismissAllToasts:()=>{t()},dismissToast:s=>{t(s)},showDefaultToast:(s,o=void 0)=>a(s,"default",o),showSuccessToast:(s,o=void 0)=>a(s,"success",o),showErrorToast:(s,o=void 0)=>a(s,"error",o)}};export{o as default};
2
+ //# sourceMappingURL=useToasts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToasts.js","sources":["../../../src/components/custom-hooks/useToasts.tsx"],"sourcesContent":["import { useSnackbar, type SnackbarKey, type VariantType } from 'notistack';\n\n/**\n * Configuration options for toast notifications\n * @interface ToastOptions\n * @property {boolean} [persist] - If true, the toast will not auto-dismiss\n * @property {number} [durationMs] - Duration in milliseconds before the toast auto-dismisses\n */\nexport interface ToastOptions {\n /** If true, the toast will not auto-dismiss */\n persist?: boolean;\n /** Duration in milliseconds before the toast auto-dismisses */\n durationMs?: number;\n}\n\n/**\n * Type alias for toast notification keys\n * Used to uniquely identify toast notifications for dismissal\n */\nexport type ToastKey = SnackbarKey;\n\n/**\n * Interface defining the return value of the useToasts hook\n */\nexport interface UseToastsReturn {\n /** Dismisses all active toast notifications */\n dismissAllToasts: () => void;\n /** Dismisses a specific toast by its key */\n dismissToast: (key: string) => void;\n /** Shows a default toast notification */\n showDefaultToast: (message: string, options?: ToastOptions) => ToastKey;\n /** Shows a success toast notification */\n showSuccessToast: (message: string, options?: ToastOptions) => ToastKey;\n /** Shows an error toast notification */\n showErrorToast: (message: string, options?: ToastOptions) => ToastKey;\n}\n\n/**\n * Custom hook for managing toast notifications\n * Provides methods to show different types of toasts (default, success, error)\n * and dismiss them individually or all at once\n *\n * @example\n * ```tsx\n * const { showSuccessToast, showErrorToast, dismissAllToasts } = useToasts();\n *\n * // Show a success toast that auto-dismisses after 3 seconds\n * const toastKey = showSuccessToast('Operation successful', { durationMs: 3000 });\n *\n * // Show a persistent error toast\n * const errorToastKey = showErrorToast('Error occurred', { persist: true });\n *\n * // Later, dismiss a specific toast using its key\n * dismissToast(toastKey);\n *\n * // Or dismiss all toasts\n * dismissAllToasts();\n * ```\n */\nconst useToasts = (): UseToastsReturn => {\n const { enqueueSnackbar, closeSnackbar } = useSnackbar();\n\n /**\n * Dismisses all currently active toast notifications\n */\n const dismissAllToasts = () => {\n closeSnackbar();\n };\n\n /**\n * Dismisses a specific toast notification by its key\n * @param {string} key - Unique identifier of the toast to dismiss\n */\n const dismissToast = (key: string) => {\n closeSnackbar(key);\n };\n\n /**\n * Internal method to show a toast notification with specified variant and options\n * @param {string} message - The message to display in the toast\n * @param {VariantType} variant - The type of toast (default, success, error)\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showToast = (message: string, variant: VariantType, options: ToastOptions | undefined = undefined): ToastKey => {\n return enqueueSnackbar(message, {\n autoHideDuration: options?.durationMs,\n persist: options?.persist,\n variant,\n });\n };\n\n /**\n * Shows a default toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showDefaultToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'default', options);\n };\n\n /**\n * Shows a success toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showSuccessToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'success', options);\n };\n\n /**\n * Shows an error toast notification\n * @param {string} message - The message to display\n * @param {ToastOptions} [options] - Configuration options for the toast\n * @returns {ToastKey} A unique key that can be used to dismiss this toast later\n */\n const showErrorToast = (message: string, options: ToastOptions | undefined = undefined): ToastKey => {\n return showToast(message, 'error', options);\n };\n\n return { dismissAllToasts, dismissToast, showDefaultToast, showSuccessToast, showErrorToast };\n};\n\nexport default useToasts;\n"],"names":["useToasts","enqueueSnackbar","closeSnackbar","useSnackbar","showToast","message","variant","options","undefined","autoHideDuration","durationMs","persist","dismissAllToasts","dismissToast","key","showDefaultToast","showSuccessToast","showErrorToast"],"mappings":"wCA2DM,MAAAA,EAAY,KACd,MAAMC,gBAAEA,EAAeC,cAAEA,GAAkBC,IAwBrCC,EAAY,CAACC,EAAiBC,EAAsBC,OAAoCC,IACnFP,EAAgBI,EAAS,CAC5BI,iBAAkBF,GAASG,WAC3BC,QAASJ,GAASI,QAClBL,YAkCR,MAAO,CAAEM,iBAzDgB,KACrBV,GAAe,EAwDQW,aAjDLC,IAClBZ,EAAcY,EAAI,EAgDmBC,iBAxBhB,CAACV,EAAiBE,OAAoCC,IACpEJ,EAAUC,EAAS,UAAWE,GAuBkBS,iBAdlC,CAACX,EAAiBE,OAAoCC,IACpEJ,EAAUC,EAAS,UAAWE,GAaoCU,eAJtD,CAACZ,EAAiBE,OAAoCC,IAClEJ,EAAUC,EAAS,QAASE,GAGsD"}
@@ -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"),c=require("./ui/Spacer/Spacer.cjs.js"),u=require("./ui/Chip/Chip.cjs.js"),a=require("./ui/Switch/Switch.cjs.js"),n=require("./ui/Tooltip/Tooltip.cjs.js"),l=require("./ui/Form/utilities/formValidation.cjs.js"),d=require("./ui/Form/GenericAutocompleteField.cjs.js"),p=require("./ui/Form/GenericFormContainer.cjs.js"),j=require("./ui/Form/GenericTextField.cjs.js"),m=require("./ui/Form/PaginatedAutocompleteField.cjs.js"),x=require("./ui/FlipdishLogoLoader/FlipdishLogoLoader.cjs.js"),q=require("./ui/GenericDatePickerField/GenericDatePickerField.cjs.js"),F=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),T=require("./ui/GenericRadioButtons/GenericRadioButtons.cjs.js"),L=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),G=require("./ui/GenericTable/GenericTable.cjs.js"),h=require("./ui/GenericTableBody/GenericTableBody.cjs.js"),g=require("./ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js"),P=require("./ui/GenericTableTitle/GenericTableTitle.cjs.js"),b=require("./ui/ListItemLink/ListItemLink.cjs.js"),k=require("./ui/ListItemLinkButton/ListItemLinkButton.cjs.js"),I=require("./ui/NoResults/NoResults.cjs.js"),y=require("@mui/icons-material/Search"),f=require("@mui/icons-material/CalendarToday"),B=require("@mui/icons-material/AccessTime"),C=require("@mui/icons-material/Done"),R=require("./custom-hooks/useRenderValidText.cjs.js"),S=require("./custom-hooks/useMicroFrontendAttributes.cjs.js"),A=require("./renderUtilities/renderUtilities.cjs.js"),D=require("./genericUtilities/index.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.default,exports.Switch=a,exports.Tooltip=n,exports.formikValidate=l.formikValidate,exports.GenericAutocompleteField=d,exports.GenericFormContainer=p,exports.GenericTextField=j,exports.PaginatedAutocompleteField=m,exports.FlipdishLogoLoader=x,exports.GenericDatePickerField=q,exports.GenericDateTimePickerField=F,exports.GenericRadioButtons=T,exports.DateTimeLocalizationProvider=L,exports.GenericTable=G,exports.GenericTableBody=h,exports.GenericTableBodyRow=g,exports.GenericTableTitle=P,exports.ListItemLink=b,exports.ListItemLinkButton=k.ListItemLinkButton,exports.NoResults=I,exports.SearchIcon=y,exports.CalendarTodayIcon=f,exports.AccessTimeIcon=B,exports.DoneIcon=C,exports.useRenderValidText=R,exports.useMicroFrontendAttributes=S,exports.getAppId=A.getAppId,exports.getBrandId=A.getBrandId,exports.getIsFlipdishStaff=A.getIsFlipdishStaff,exports.getMicroFrontendAttribute=A.getMicroFrontendAttribute,exports.getOrgId=A.getOrgId,exports.lazyWithRetry=A.lazyWithRetry,exports.debounce=D.debounce;
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"),s=require("./ui/PortalMock/PortalMock.cjs.js"),o=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/Tooltip/Tooltip.cjs.js"),d=require("./ui/Form/utilities/formValidation.cjs.js"),l=require("./ui/Form/GenericAutocompleteField.cjs.js"),p=require("./ui/Form/GenericFormContainer.cjs.js"),j=require("./ui/Form/GenericTextField.cjs.js"),x=require("./ui/Form/PaginatedAutocompleteField.cjs.js"),m=require("./ui/FlipdishLogoLoader/FlipdishLogoLoader.cjs.js"),T=require("./ui/GenericDatePickerField/GenericDatePickerField.cjs.js"),q=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),F=require("./ui/GenericRadioButtons/GenericRadioButtons.cjs.js"),L=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),G=require("./ui/GenericTable/GenericTable.cjs.js"),h=require("./ui/GenericTableBody/GenericTableBody.cjs.js"),g=require("./ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js"),P=require("./ui/GenericTableTitle/GenericTableTitle.cjs.js"),k=require("./ui/ListItemLink/ListItemLink.cjs.js"),b=require("./ui/ListItemLinkButton/ListItemLinkButton.cjs.js"),I=require("./ui/NoResults/NoResults.cjs.js"),y=require("@mui/icons-material/Search"),f=require("@mui/icons-material/CalendarToday"),B=require("@mui/icons-material/AccessTime"),C=require("@mui/icons-material/Done"),R=require("./custom-hooks/useRenderValidText.cjs.js"),S=require("./custom-hooks/useMicroFrontendAttributes.cjs.js"),A=require("./custom-hooks/useToasts.cjs.js"),D=require("./renderUtilities/renderUtilities.cjs.js"),z=require("./genericUtilities/index.cjs.js"),v=require("../providers/ToastProvider.cjs.js");exports.flipdishPublicTheme=e,exports.NotFoundPage=i,exports.FlipdishStaffContainer=r,exports.PageLayout=t.default,exports.PortalMock=s,exports.LazyComponent=o,exports.Spacer=c,exports.Chip=u.default,exports.Switch=a,exports.Tooltip=n,exports.formikValidate=d.formikValidate,exports.GenericAutocompleteField=l,exports.GenericFormContainer=p,exports.GenericTextField=j,exports.PaginatedAutocompleteField=x,exports.FlipdishLogoLoader=m,exports.GenericDatePickerField=T,exports.GenericDateTimePickerField=q,exports.GenericRadioButtons=F,exports.DateTimeLocalizationProvider=L,exports.GenericTable=G,exports.GenericTableBody=h,exports.GenericTableBodyRow=g,exports.GenericTableTitle=P,exports.ListItemLink=k,exports.ListItemLinkButton=b.ListItemLinkButton,exports.NoResults=I,exports.SearchIcon=y,exports.CalendarTodayIcon=f,exports.AccessTimeIcon=B,exports.DoneIcon=C,exports.useRenderValidText=R,exports.useMicroFrontendAttributes=S,exports.useToasts=A,exports.getAppId=D.getAppId,exports.getBrandId=D.getBrandId,exports.getIsFlipdishStaff=D.getIsFlipdishStaff,exports.getMicroFrontendAttribute=D.getMicroFrontendAttribute,exports.getOrgId=D.getOrgId,exports.lazyWithRetry=D.lazyWithRetry,exports.debounce=z.debounce,exports.ToastProvider=v;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -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{default as Tooltip}from"./ui/Tooltip/Tooltip.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 FlipdishLogoLoader}from"./ui/FlipdishLogoLoader/FlipdishLogoLoader.js";export{default as GenericDatePickerField}from"./ui/GenericDatePickerField/GenericDatePickerField.js";export{default as GenericDateTimePickerField}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 ListItemLink}from"./ui/ListItemLink/ListItemLink.js";export{ListItemLinkButton}from"./ui/ListItemLinkButton/ListItemLinkButton.js";export{default as NoResults}from"./ui/NoResults/NoResults.js";export{default as SearchIcon}from"@mui/icons-material/Search";export{default as CalendarTodayIcon}from"@mui/icons-material/CalendarToday";export{default as AccessTimeIcon}from"@mui/icons-material/AccessTime";export{default as DoneIcon}from"@mui/icons-material/Done";export{default as useRenderValidText}from"./custom-hooks/useRenderValidText.js";export{default as useMicroFrontendAttributes}from"./custom-hooks/useMicroFrontendAttributes.js";export{getAppId,getBrandId,getIsFlipdishStaff,getMicroFrontendAttribute,getOrgId,lazyWithRetry}from"./renderUtilities/renderUtilities.js";export{debounce}from"./genericUtilities/index.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{default as Tooltip}from"./ui/Tooltip/Tooltip.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 FlipdishLogoLoader}from"./ui/FlipdishLogoLoader/FlipdishLogoLoader.js";export{default as GenericDatePickerField}from"./ui/GenericDatePickerField/GenericDatePickerField.js";export{default as GenericDateTimePickerField}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 ListItemLink}from"./ui/ListItemLink/ListItemLink.js";export{ListItemLinkButton}from"./ui/ListItemLinkButton/ListItemLinkButton.js";export{default as NoResults}from"./ui/NoResults/NoResults.js";export{default as SearchIcon}from"@mui/icons-material/Search";export{default as CalendarTodayIcon}from"@mui/icons-material/CalendarToday";export{default as AccessTimeIcon}from"@mui/icons-material/AccessTime";export{default as DoneIcon}from"@mui/icons-material/Done";export{default as useRenderValidText}from"./custom-hooks/useRenderValidText.js";export{default as useMicroFrontendAttributes}from"./custom-hooks/useMicroFrontendAttributes.js";export{default as useToasts}from"./custom-hooks/useToasts.js";export{getAppId,getBrandId,getIsFlipdishStaff,getMicroFrontendAttribute,getOrgId,lazyWithRetry}from"./renderUtilities/renderUtilities.js";export{debounce}from"./genericUtilities/index.js";export{default as ToastProvider}from"../providers/ToastProvider.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,26 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * ToastProvider component that wraps the application with notistack's SnackbarProvider.
5
+ * Provides a centralized toast notification system with custom styling.
6
+ *
7
+ * Features:
8
+ * - Maximum of 3 notifications displayed simultaneously
9
+ * - Notifications appear at the bottom center of the scree
10
+ *
11
+ * @param {Object} props - Component props
12
+ * @param {React.ReactNode} props.children - Child components to be wrapped by the provider
13
+ * @returns {JSX.Element} ToastProvider component
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <ToastProvider>
18
+ * <App />
19
+ * </ToastProvider>
20
+ * ```
21
+ */
22
+ declare const ToastProvider: ({ children }: {
23
+ children: React.ReactNode;
24
+ }) => react_jsx_runtime.JSX.Element;
25
+
26
+ export { ToastProvider as default };
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t&&t.getAttribute(e)};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-appId"),exports.getBrandId=()=>(void 0).VITE_BRANDID_OVERRIDE||t("data-brandId"),exports.getIsFlipdishStaff=()=>{const e=(void 0).VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},exports.getMicroFrontendAttribute=t,exports.getOrgId=()=>(void 0).VITE_ORGID_OVERRIDE||t("data-orgId"),exports.lazyWithRetry=t=>e.lazy((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));
1
+ "use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-appId"),exports.getBrandId=()=>(void 0).VITE_BRANDID_OVERRIDE||t("data-brandId"),exports.getIsFlipdishStaff=()=>{const e=(void 0).VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},exports.getMicroFrontendAttribute=t,exports.getOrgId=()=>(void 0).VITE_ORGID_OVERRIDE||t("data-orgId"),exports.lazyWithRetry=t=>e.lazy((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));
2
2
  //# sourceMappingURL=renderUtilities.cjs.js.map
@@ -1 +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 BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\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 getBrandId = (): string | null => {\n return import.meta.env.VITE_BRANDID_OVERRIDE || getMicroFrontendAttribute('data-brandId');\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","VITE_BRANDID_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,iCAuBlD,UACfM,GAAgBE,uBAAyBR,EAA0B,2CAW5C,KAC9B,MAAMS,QAAcH,GAAgBI,8BAAgCV,EAA0B,wBAC9F,MAAmC,SAA5BS,GAAaE,UAAqB,uDA1BrB,UACbL,GAAgBM,qBAAuBZ,EAA0B,oCA6B9Ca,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
+ {"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?.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 BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\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 getBrandId = (): string | null => {\n return import.meta.env.VITE_BRANDID_OVERRIDE || getMicroFrontendAttribute('data-brandId');\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","VITE_BRANDID_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,GAAkBG,aAAaJ,EAAI,mBAWtB,UACbK,GAAgBC,qBAAuBP,EAA0B,iCAuBlD,UACfM,GAAgBE,uBAAyBR,EAA0B,2CAW5C,KAC9B,MAAMS,QAAcH,GAAgBI,8BAAgCV,EAA0B,wBAC9F,MAAmC,SAA5BS,GAAaE,UAAqB,uDA1BrB,UACbL,GAAgBM,qBAAuBZ,EAA0B,oCA6B9Ca,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,2 +1,2 @@
1
- import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t&&t.getAttribute(e)},r=()=>import.meta.env.VITE_APPID_OVERRIDE||t("data-appId"),a=()=>import.meta.env.VITE_ORGID_OVERRIDE||t("data-orgId"),o=()=>import.meta.env.VITE_BRANDID_OVERRIDE||t("data-brandId"),n=()=>{const e=import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},s=t=>e((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));export{r as getAppId,o as getBrandId,n as getIsFlipdishStaff,t as getMicroFrontendAttribute,a as getOrgId,s as lazyWithRetry};
1
+ import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)},r=()=>import.meta.env.VITE_APPID_OVERRIDE||t("data-appId"),a=()=>import.meta.env.VITE_ORGID_OVERRIDE||t("data-orgId"),o=()=>import.meta.env.VITE_BRANDID_OVERRIDE||t("data-brandId"),n=()=>{const e=import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},s=t=>e((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));export{r as getAppId,o as getBrandId,n as getIsFlipdishStaff,t as getMicroFrontendAttribute,a as getOrgId,s as lazyWithRetry};
2
2
  //# sourceMappingURL=renderUtilities.js.map
@@ -1 +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 BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\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 getBrandId = (): string | null => {\n return import.meta.env.VITE_BRANDID_OVERRIDE || getMicroFrontendAttribute('data-brandId');\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","getBrandId","VITE_BRANDID_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,EAAa,gBACHJ,IAAIK,uBAAyBZ,EAA0B,gBAWjEa,EAAqB,KAC9B,MAAMC,cAA0BP,IAAIQ,8BAAgCf,EAA0B,wBAC9F,MAAmC,SAA5Bc,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
+ {"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?.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 BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\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 getBrandId = (): string | null => {\n return import.meta.env.VITE_BRANDID_OVERRIDE || getMicroFrontendAttribute('data-brandId');\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","getBrandId","VITE_BRANDID_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,GAAkBG,aAAaJ,EAAI,EAWjCK,EAAW,gBACDC,IAAIC,qBAAuBR,EAA0B,cAW/DS,EAAW,gBACDF,IAAIG,qBAAuBV,EAA0B,cAW/DW,EAAa,gBACHJ,IAAIK,uBAAyBZ,EAA0B,gBAWjEa,EAAqB,KAC9B,MAAMC,cAA0BP,IAAIQ,8BAAgCf,EAA0B,wBAC9F,MAAmC,SAA5Bc,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";var r=require("react/jsx-runtime"),e=require("react-error-boundary"),t=require("../../../providers/TranslationProvider.cjs.js");require("react");const n=require("@mui/material/styles").styled("div")((({theme:r})=>({marginTop:r.spacing(2),display:"flex",justifyContent:"center",alignItems:"center"})));module.exports=({identifier:s,children:i})=>{const{translate:a}=t.useTranslation();return r.jsx(e.ErrorBoundary,{FallbackComponent:()=>r.jsx(n,{children:a("Something_went_wrong_please_refresh_the_page")}),onError:(r,e)=>{window.fdlogger?.error(`${s?.toString()} Error Boundary`,{message:r?.message,stack:e})},children:i})};
1
+ "use strict";var r=require("react/jsx-runtime"),e=require("react-error-boundary"),t=require("../../../providers/TranslationProvider.cjs.js");require("react");const n=require("@mui/material/styles").styled("div")((({theme:r})=>({marginTop:r.spacing(2),display:"flex",justifyContent:"center",alignItems:"center"}))),s=()=>{const{translate:e}=t.useTranslation();return r.jsx(n,{children:e("Something_went_wrong_please_refresh_the_page")})};module.exports=({identifier:t,children:n})=>r.jsx(e.ErrorBoundary,{FallbackComponent:s,onError:(r,e)=>{window.fdlogger?.error(`${t?.toString()} Error Boundary`,{message:r?.message,stack:e})},children:n});
2
2
  //# sourceMappingURL=FDErrorBoundary.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FDErrorBoundary.cjs.js","sources":["../../../../src/components/ui/FDErrorBoundary/FDErrorBoundary.tsx"],"sourcesContent":["import { ErrorBoundary } from 'react-error-boundary';\nimport { useTranslation } from '../../../providers/TranslationProvider';\nimport { type ReactNode } from 'react';\nimport { styled } from '@mui/material/styles';\n\nconst StyledTextContainer = styled('div')(({ theme }) => ({\n marginTop: theme.spacing(2),\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n}));\nconst FDErrorBoundary = ({ identifier, children }: { identifier: string; children: ReactNode }) => {\n const { translate } = useTranslation();\n return (\n <ErrorBoundary\n FallbackComponent={() => <StyledTextContainer>{translate('Something_went_wrong_please_refresh_the_page')}</StyledTextContainer>}\n onError={(error, info) => {\n window.fdlogger?.error(`${identifier?.toString()} Error Boundary`, {\n message: error?.message,\n stack: info,\n });\n }}\n >\n {children}\n </ErrorBoundary>\n );\n};\n\nexport default FDErrorBoundary;\n"],"names":["StyledTextContainer","styled","theme","marginTop","spacing","display","justifyContent","alignItems","identifier","children","translate","useTranslation","_jsx","ErrorBoundary","FallbackComponent","onError","error","info","window","fdlogger","toString","message","stack"],"mappings":"8JAKA,MAAMA,kCAAsBC,OAAO,MAAPA,EAAc,EAAGC,YAAa,CACtDC,UAAWD,EAAME,QAAQ,GACzBC,QAAS,OACTC,eAAgB,SAChBC,WAAY,4BAEQ,EAAGC,aAAYC,eACnC,MAAMC,UAAEA,GAAcC,EAAAA,iBACtB,OACIC,EAAAA,IAACC,EAAAA,cACG,CAAAC,kBAAmB,IAAMF,EAAAA,IAACZ,EAAmB,CAAAS,SAAEC,EAAU,kDACzDK,QAAS,CAACC,EAAOC,KACbC,OAAOC,UAAUH,MAAM,GAAGR,GAAYY,4BAA6B,CAC/DC,QAASL,GAAOK,QAChBC,MAAOL,GACT,EAGLR,SAAAA,GAEP"}
1
+ {"version":3,"file":"FDErrorBoundary.cjs.js","sources":["../../../../src/components/ui/FDErrorBoundary/FDErrorBoundary.tsx"],"sourcesContent":["import { ErrorBoundary } from 'react-error-boundary';\nimport { useTranslation } from '../../../providers/TranslationProvider';\nimport { type ReactNode } from 'react';\nimport { styled } from '@mui/material/styles';\n\nconst StyledTextContainer = styled('div')(({ theme }) => ({\n marginTop: theme.spacing(2),\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n}));\n\nconst FallbackComponent = () => {\n const { translate } = useTranslation();\n return <StyledTextContainer>{translate('Something_went_wrong_please_refresh_the_page')}</StyledTextContainer>;\n};\n\nconst FDErrorBoundary = ({ identifier, children }: { identifier: string; children: ReactNode }) => {\n return (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onError={(error, info) => {\n window.fdlogger?.error(`${identifier?.toString()} Error Boundary`, {\n message: error?.message,\n stack: info,\n });\n }}\n >\n {children}\n </ErrorBoundary>\n );\n};\n\nexport default FDErrorBoundary;\n"],"names":["StyledTextContainer","styled","theme","marginTop","spacing","display","justifyContent","alignItems","FallbackComponent","translate","useTranslation","_jsx","children","identifier","jsx","ErrorBoundary","onError","error","info","window","fdlogger","toString","message","stack"],"mappings":"8JAKA,MAAMA,kCAAsBC,OAAO,MAAPA,EAAc,EAAGC,YAAa,CACtDC,UAAWD,EAAME,QAAQ,GACzBC,QAAS,OACTC,eAAgB,SAChBC,WAAY,aAGVC,EAAoB,KACtB,MAAMC,UAAEA,GAAcC,EAAAA,iBACtB,OAAOC,EAAAA,IAACX,EAAqB,CAAAY,SAAAH,EAAU,iDAAsE,iBAGzF,EAAGI,aAAYD,cAE/BD,EAAAG,IAACC,EAAaA,cAAA,CACVP,kBAAmBA,EACnBQ,QAAS,CAACC,EAAOC,KACbC,OAAOC,UAAUH,MAAM,GAAGJ,GAAYQ,4BAA6B,CAC/DC,QAASL,GAAOK,QAChBC,MAAOL,GACT,EAGLN,SAAAA"}
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{ErrorBoundary as e}from"react-error-boundary";import{useTranslation as t}from"../../../providers/TranslationProvider.js";import"react";import{styled as o}from"@mui/material/styles";const n=o("div")((({theme:r})=>({marginTop:r.spacing(2),display:"flex",justifyContent:"center",alignItems:"center"}))),i=({identifier:o,children:i})=>{const{translate:a}=t();return r(e,{FallbackComponent:()=>r(n,{children:a("Something_went_wrong_please_refresh_the_page")}),onError:(r,e)=>{window.fdlogger?.error(`${o?.toString()} Error Boundary`,{message:r?.message,stack:e})},children:i})};export{i as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{ErrorBoundary as e}from"react-error-boundary";import{useTranslation as t}from"../../../providers/TranslationProvider.js";import"react";import{styled as o}from"@mui/material/styles";const n=o("div")((({theme:r})=>({marginTop:r.spacing(2),display:"flex",justifyContent:"center",alignItems:"center"}))),i=()=>{const{translate:e}=t();return r(n,{children:e("Something_went_wrong_please_refresh_the_page")})},a=({identifier:t,children:o})=>r(e,{FallbackComponent:i,onError:(r,e)=>{window.fdlogger?.error(`${t?.toString()} Error Boundary`,{message:r?.message,stack:e})},children:o});export{a as default};
2
2
  //# sourceMappingURL=FDErrorBoundary.js.map