@flipdish/portal-library 1.0.75 → 1.0.76

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 (70) hide show
  1. package/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js +1 -1
  2. package/dist/components/custom-hooks/useMicroFrontendAttributes.cjs.js.map +1 -1
  3. package/dist/components/custom-hooks/useMicroFrontendAttributes.d.ts +2 -1
  4. package/dist/components/custom-hooks/useMicroFrontendAttributes.js +1 -1
  5. package/dist/components/custom-hooks/useMicroFrontendAttributes.js.map +1 -1
  6. package/dist/components/custom-hooks/useRenderValidText.cjs.js +1 -1
  7. package/dist/components/custom-hooks/useRenderValidText.cjs.js.map +1 -1
  8. package/dist/components/custom-hooks/useRenderValidText.d.ts +5 -4
  9. package/dist/components/custom-hooks/useRenderValidText.js +1 -1
  10. package/dist/components/custom-hooks/useRenderValidText.js.map +1 -1
  11. package/dist/components/renderUtilities/renderUtilities.cjs.js +1 -1
  12. package/dist/components/renderUtilities/renderUtilities.cjs.js.map +1 -1
  13. package/dist/components/renderUtilities/renderUtilities.js +1 -1
  14. package/dist/components/renderUtilities/renderUtilities.js.map +1 -1
  15. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.cjs.js +1 -1
  16. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.cjs.js.map +1 -1
  17. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.js +1 -1
  18. package/dist/components/ui/FDErrorBoundary/FDErrorBoundary.js.map +1 -1
  19. package/dist/components/ui/Form/FormItemLayout.cjs.js.map +1 -1
  20. package/dist/components/ui/Form/FormItemLayout.js.map +1 -1
  21. package/dist/components/ui/Form/GenericAutocompleteField.cjs.js +1 -1
  22. package/dist/components/ui/Form/GenericAutocompleteField.cjs.js.map +1 -1
  23. package/dist/components/ui/Form/GenericAutocompleteField.js +1 -1
  24. package/dist/components/ui/Form/GenericAutocompleteField.js.map +1 -1
  25. package/dist/components/ui/Form/GenericFormContainer.cjs.js +1 -1
  26. package/dist/components/ui/Form/GenericFormContainer.cjs.js.map +1 -1
  27. package/dist/components/ui/Form/GenericFormContainer.js +1 -1
  28. package/dist/components/ui/Form/GenericFormContainer.js.map +1 -1
  29. package/dist/components/ui/Form/GenericTextField.cjs.js +1 -1
  30. package/dist/components/ui/Form/GenericTextField.cjs.js.map +1 -1
  31. package/dist/components/ui/Form/GenericTextField.js +1 -1
  32. package/dist/components/ui/Form/GenericTextField.js.map +1 -1
  33. package/dist/components/ui/Form/utilities/formValidation.cjs.js.map +1 -1
  34. package/dist/components/ui/Form/utilities/formValidation.js.map +1 -1
  35. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.cjs.js +2 -0
  36. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.cjs.js.map +1 -0
  37. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.d.ts +22 -0
  38. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.js +2 -0
  39. package/dist/components/ui/GenericDatePickerField/GenericDateFieldBase.js.map +1 -0
  40. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.cjs.js +1 -1
  41. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.cjs.js.map +1 -1
  42. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.d.ts +3 -17
  43. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.js +1 -1
  44. package/dist/components/ui/GenericDatePickerField/GenericDatePickerField.js.map +1 -1
  45. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js +1 -1
  46. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js.map +1 -1
  47. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.d.ts +3 -17
  48. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js +1 -1
  49. package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js.map +1 -1
  50. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js +1 -1
  51. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js.map +1 -1
  52. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js +1 -1
  53. package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js.map +1 -1
  54. package/dist/components/ui/GenericTableBody/GenericTableBody.cjs.js +1 -1
  55. package/dist/components/ui/GenericTableBody/GenericTableBody.cjs.js.map +1 -1
  56. package/dist/components/ui/GenericTableBody/GenericTableBody.js +1 -1
  57. package/dist/components/ui/GenericTableBody/GenericTableBody.js.map +1 -1
  58. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js +1 -1
  59. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js.map +1 -1
  60. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.js +1 -1
  61. package/dist/components/ui/GenericTableBodyRow/GenericTableBodyRow.js.map +1 -1
  62. package/dist/components/ui/PageLayout/PageLayout.cjs.js +1 -1
  63. package/dist/components/ui/PageLayout/PageLayout.cjs.js.map +1 -1
  64. package/dist/components/ui/PageLayout/PageLayout.js +1 -1
  65. package/dist/components/ui/PageLayout/PageLayout.js.map +1 -1
  66. package/dist/components/ui/Spacer/Spacer.cjs.js.map +1 -1
  67. package/dist/components/ui/Spacer/Spacer.js.map +1 -1
  68. package/dist/providers/TranslationProvider.cjs.js.map +1 -1
  69. package/dist/providers/TranslationProvider.js.map +1 -1
  70. package/package.json +1 -1
@@ -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"}
@@ -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 };
@@ -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,13 +1,14 @@
1
- type Props = {
1
+ type ValidationState = {
2
2
  fieldError?: string;
3
3
  showError?: boolean;
4
4
  touched: boolean;
5
5
  value: string;
6
6
  };
7
+ type ValidationElement = JSX.Element | string | undefined;
7
8
  /**
8
- * @description Use this with Formik - the touched field state is not available immediately because ```form.setFieldValue``` is async
9
- * @description https://github.com/formium/formik/issues/529#issuecomment-571294217
9
+ * @description Custom hook for rendering validation text in form fields
10
+ * @description Handles different validation states with separate methods for better clarity
10
11
  */
11
- declare const useRenderValidText: ({ fieldError, showError, touched, value }: Props) => string | JSX.Element;
12
+ declare const useRenderValidText: ({ fieldError, showError, touched, value }: ValidationState) => ValidationElement;
12
13
 
13
14
  export { useRenderValidText as default };
@@ -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"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"FDErrorBoundary.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","FDErrorBoundary","identifier","children","translate","useTranslation","_jsx","ErrorBoundary","FallbackComponent","onError","error","info","window","fdlogger","toString","message","stack"],"mappings":"oOAKA,MAAMA,EAAsBC,EAAO,MAAPA,EAAc,EAAGC,YAAa,CACtDC,UAAWD,EAAME,QAAQ,GACzBC,QAAS,OACTC,eAAgB,SAChBC,WAAY,aAEVC,EAAkB,EAAGC,aAAYC,eACnC,MAAMC,UAAEA,GAAcC,IACtB,OACIC,EAACC,EACG,CAAAC,kBAAmB,IAAMF,EAACb,EAAmB,CAAAU,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.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","FDErrorBoundary","identifier","ErrorBoundary","onError","error","info","window","fdlogger","toString","message","stack"],"mappings":"oOAKA,MAAMA,EAAsBC,EAAO,MAAPA,EAAc,EAAGC,YAAa,CACtDC,UAAWD,EAAME,QAAQ,GACzBC,QAAS,OACTC,eAAgB,SAChBC,WAAY,aAGVC,EAAoB,KACtB,MAAMC,UAAEA,GAAcC,IACtB,OAAOC,EAACX,EAAqB,CAAAY,SAAAH,EAAU,iDAAsE,EAG3GI,EAAkB,EAAGC,aAAYF,cAE/BD,EAACI,EAAa,CACVP,kBAAmBA,EACnBQ,QAAS,CAACC,EAAOC,KACbC,OAAOC,UAAUH,MAAM,GAAGH,GAAYO,4BAA6B,CAC/DC,QAASL,GAAOK,QAChBC,MAAOL,GACT,EAGLN,SAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FormItemLayout.cjs.js","sources":["../../../../src/components/ui/Form/FormItemLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport Grid, { type GridSize } from '@mui/material/Grid';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nconst StyledGrid = styled(Grid)(({ theme }) => ({\n padding: theme.spacing(4.75, 0, 2.5, 0),\n alignItems: 'flex-start',\n flexWrap: 'wrap',\n borderBottom: '1px solid rgba(0,0,0,0.2)',\n}));\n\nconst StyledDescription = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n paddingRight: theme.spacing(1.75),\n}));\n\nexport interface FormItemLayoutProps {\n alignItems?: 'stretch' | 'center' | 'flex-end' | 'flex-start' | 'baseline';\n children: React.ReactNode;\n description?: React.ReactNode;\n descriptionTranslated?: string;\n label?: React.ReactNode;\n labelTranslated?: string;\n mdProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n noWrap?: boolean;\n removeRootPaddings?: boolean;\n smProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n}\n\ntype Props = FormItemLayoutProps;\nconst FormItemLayout = (props: Props) => {\n const { children, description, descriptionTranslated, label, labelTranslated, mdProportion, smProportion } = props;\n\n const [titleProportion, dataProportion] = mdProportion ? mdProportion.split('x').map((m) => parseInt(m, 10)) : [4, 8];\n const [titleProportionSm, dataProportionSm] = smProportion ? smProportion.split('x').map((m) => parseInt(m, 10)) : [];\n const castToGridSize = (data: unknown) => data as GridSize;\n\n return (\n <StyledGrid container>\n <Grid item xs={12} sm={castToGridSize(titleProportionSm)} md={castToGridSize(titleProportion)}>\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {labelTranslated || label || null}\n </Typography>\n\n {descriptionTranslated || description ? (\n <StyledDescription>\n <Typography variant=\"caption\" color=\"textSecondary\">\n {descriptionTranslated || description || null}\n </Typography>\n </StyledDescription>\n ) : null}\n </Grid>\n <Grid item xs={12} sm={castToGridSize(dataProportionSm)} md={castToGridSize(dataProportion)}>\n {children}\n </Grid>\n </StyledGrid>\n );\n};\n\nexport default FormItemLayout;\n"],"names":["StyledGrid","styled","Grid","theme","padding","spacing","alignItems","flexWrap","borderBottom","StyledDescription","paddingBottom","paddingRight","props","children","description","descriptionTranslated","label","labelTranslated","mdProportion","smProportion","titleProportion","dataProportion","split","map","m","parseInt","titleProportionSm","dataProportionSm","_jsxs","container","item","xs","sm","md","_jsx","Typography","variant","component","color"],"mappings":"6KAMA,MAAMA,EAAaC,EAAAA,OAAOC,EAAPD,EAAa,EAAGE,YAAa,CAC5CC,QAASD,EAAME,QAAQ,KAAM,EAAG,IAAK,GACrCC,WAAY,aACZC,SAAU,OACVC,aAAc,gCAGZC,EAAoBR,EAAAA,OAAO,MAAPA,EAAc,EAAGE,YAAa,CACpDO,cAAeP,EAAME,QAAQ,GAC7BM,aAAcR,EAAME,QAAQ,yBAiBRO,IACpB,MAAMC,SAAEA,EAAQC,YAAEA,EAAWC,sBAAEA,EAAqBC,MAAEA,EAAKC,gBAAEA,EAAeC,aAAEA,EAAYC,aAAEA,GAAiBP,GAEtGQ,EAAiBC,GAAkBH,EAAeA,EAAaI,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,CAAC,EAAG,IAC5GE,EAAmBC,GAAoBR,EAAeA,EAAaG,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,GAGnH,OACII,EAAAA,KAAC5B,EAAW,CAAA6B,uBACRD,OAAC1B,EAAK,CAAA4B,MAAK,EAAAC,GAAI,GAAIC,GAAmBN,EAAoBO,GAAmBb,EACzEP,SAAA,CAAAqB,EAAAA,IAACC,EAAU,CAACC,QAAQ,YAAYC,UAAU,KAAKC,MAAM,cAAazB,SAC7DI,GAAmBD,GAAS,OAGhCD,GAAyBD,EACtBoB,EAAAA,IAACzB,EAAiB,CAAAI,SACdqB,EAAAA,IAACC,GAAWC,QAAQ,UAAUE,MAAM,gBAC/BzB,SAAAE,GAAyBD,GAAe,SAGjD,QAERoB,EAAAA,IAAChC,EAAK,CAAA4B,MAAK,EAAAC,GAAI,GAAIC,GAAmBL,EAAmBM,GAAmBZ,EAAeR,SACtFA,MAGX"}
1
+ {"version":3,"file":"FormItemLayout.cjs.js","sources":["../../../../src/components/ui/Form/FormItemLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport Grid, { type GridSize } from '@mui/material/Grid';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nconst StyledGrid = styled(Grid)(({ theme }) => ({\n padding: theme.spacing(4.75, 0, 2.5, 0),\n alignItems: 'flex-start',\n flexWrap: 'wrap',\n borderBottom: '1px solid rgba(0,0,0,0.2)',\n}));\n\nconst StyledDescription = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n paddingRight: theme.spacing(1.75),\n}));\n\nexport interface FormItemLayoutProps {\n children: React.ReactNode;\n description?: React.ReactNode;\n descriptionTranslated?: string;\n label?: React.ReactNode;\n labelTranslated?: string;\n mdProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n smProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n}\n\ntype Props = FormItemLayoutProps;\nconst FormItemLayout = (props: Props) => {\n const { children, description, descriptionTranslated, label, labelTranslated, mdProportion, smProportion } = props;\n\n const [titleProportion, dataProportion] = mdProportion ? mdProportion.split('x').map((m) => parseInt(m, 10)) : [4, 8];\n const [titleProportionSm, dataProportionSm] = smProportion ? smProportion.split('x').map((m) => parseInt(m, 10)) : [];\n const castToGridSize = (data: unknown) => data as GridSize;\n\n return (\n <StyledGrid container>\n <Grid item xs={12} sm={castToGridSize(titleProportionSm)} md={castToGridSize(titleProportion)}>\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {labelTranslated || label || null}\n </Typography>\n\n {descriptionTranslated || description ? (\n <StyledDescription>\n <Typography variant=\"caption\" color=\"textSecondary\">\n {descriptionTranslated || description || null}\n </Typography>\n </StyledDescription>\n ) : null}\n </Grid>\n <Grid item xs={12} sm={castToGridSize(dataProportionSm)} md={castToGridSize(dataProportion)}>\n {children}\n </Grid>\n </StyledGrid>\n );\n};\n\nexport default FormItemLayout;\n"],"names":["StyledGrid","styled","Grid","theme","padding","spacing","alignItems","flexWrap","borderBottom","StyledDescription","paddingBottom","paddingRight","props","children","description","descriptionTranslated","label","labelTranslated","mdProportion","smProportion","titleProportion","dataProportion","split","map","m","parseInt","titleProportionSm","dataProportionSm","_jsxs","container","item","xs","sm","md","_jsx","Typography","variant","component","color"],"mappings":"6KAMA,MAAMA,EAAaC,EAAAA,OAAOC,EAAPD,EAAa,EAAGE,YAAa,CAC5CC,QAASD,EAAME,QAAQ,KAAM,EAAG,IAAK,GACrCC,WAAY,aACZC,SAAU,OACVC,aAAc,gCAGZC,EAAoBR,EAAAA,OAAO,MAAPA,EAAc,EAAGE,YAAa,CACpDO,cAAeP,EAAME,QAAQ,GAC7BM,aAAcR,EAAME,QAAQ,yBAcRO,IACpB,MAAMC,SAAEA,EAAQC,YAAEA,EAAWC,sBAAEA,EAAqBC,MAAEA,EAAKC,gBAAEA,EAAeC,aAAEA,EAAYC,aAAEA,GAAiBP,GAEtGQ,EAAiBC,GAAkBH,EAAeA,EAAaI,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,CAAC,EAAG,IAC5GE,EAAmBC,GAAoBR,EAAeA,EAAaG,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,GAGnH,OACII,EAAAA,KAAC5B,EAAW,CAAA6B,uBACRD,OAAC1B,EAAK,CAAA4B,MAAK,EAAAC,GAAI,GAAIC,GAAmBN,EAAoBO,GAAmBb,EACzEP,SAAA,CAAAqB,EAAAA,IAACC,EAAU,CAACC,QAAQ,YAAYC,UAAU,KAAKC,MAAM,cAAazB,SAC7DI,GAAmBD,GAAS,OAGhCD,GAAyBD,EACtBoB,EAAAA,IAACzB,EAAiB,CAAAI,SACdqB,EAAAA,IAACC,GAAWC,QAAQ,UAAUE,MAAM,gBAC/BzB,SAAAE,GAAyBD,GAAe,SAGjD,QAERoB,EAAAA,IAAChC,EAAK,CAAA4B,MAAK,EAAAC,GAAI,GAAIC,GAAmBL,EAAmBM,GAAmBZ,EAAeR,SACtFA,MAGX"}
@@ -1 +1 @@
1
- {"version":3,"file":"FormItemLayout.js","sources":["../../../../src/components/ui/Form/FormItemLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport Grid, { type GridSize } from '@mui/material/Grid';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nconst StyledGrid = styled(Grid)(({ theme }) => ({\n padding: theme.spacing(4.75, 0, 2.5, 0),\n alignItems: 'flex-start',\n flexWrap: 'wrap',\n borderBottom: '1px solid rgba(0,0,0,0.2)',\n}));\n\nconst StyledDescription = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n paddingRight: theme.spacing(1.75),\n}));\n\nexport interface FormItemLayoutProps {\n alignItems?: 'stretch' | 'center' | 'flex-end' | 'flex-start' | 'baseline';\n children: React.ReactNode;\n description?: React.ReactNode;\n descriptionTranslated?: string;\n label?: React.ReactNode;\n labelTranslated?: string;\n mdProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n noWrap?: boolean;\n removeRootPaddings?: boolean;\n smProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n}\n\ntype Props = FormItemLayoutProps;\nconst FormItemLayout = (props: Props) => {\n const { children, description, descriptionTranslated, label, labelTranslated, mdProportion, smProportion } = props;\n\n const [titleProportion, dataProportion] = mdProportion ? mdProportion.split('x').map((m) => parseInt(m, 10)) : [4, 8];\n const [titleProportionSm, dataProportionSm] = smProportion ? smProportion.split('x').map((m) => parseInt(m, 10)) : [];\n const castToGridSize = (data: unknown) => data as GridSize;\n\n return (\n <StyledGrid container>\n <Grid item xs={12} sm={castToGridSize(titleProportionSm)} md={castToGridSize(titleProportion)}>\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {labelTranslated || label || null}\n </Typography>\n\n {descriptionTranslated || description ? (\n <StyledDescription>\n <Typography variant=\"caption\" color=\"textSecondary\">\n {descriptionTranslated || description || null}\n </Typography>\n </StyledDescription>\n ) : null}\n </Grid>\n <Grid item xs={12} sm={castToGridSize(dataProportionSm)} md={castToGridSize(dataProportion)}>\n {children}\n </Grid>\n </StyledGrid>\n );\n};\n\nexport default FormItemLayout;\n"],"names":["StyledGrid","styled","Grid","theme","padding","spacing","alignItems","flexWrap","borderBottom","StyledDescription","paddingBottom","paddingRight","FormItemLayout","props","children","description","descriptionTranslated","label","labelTranslated","mdProportion","smProportion","titleProportion","dataProportion","split","map","m","parseInt","titleProportionSm","dataProportionSm","_jsxs","container","item","xs","sm","md","_jsx","Typography","variant","component","color"],"mappings":"wLAMA,MAAMA,EAAaC,EAAOC,EAAPD,EAAa,EAAGE,YAAa,CAC5CC,QAASD,EAAME,QAAQ,KAAM,EAAG,IAAK,GACrCC,WAAY,aACZC,SAAU,OACVC,aAAc,gCAGZC,EAAoBR,EAAO,MAAPA,EAAc,EAAGE,YAAa,CACpDO,cAAeP,EAAME,QAAQ,GAC7BM,aAAcR,EAAME,QAAQ,UAiB1BO,EAAkBC,IACpB,MAAMC,SAAEA,EAAQC,YAAEA,EAAWC,sBAAEA,EAAqBC,MAAEA,EAAKC,gBAAEA,EAAeC,aAAEA,EAAYC,aAAEA,GAAiBP,GAEtGQ,EAAiBC,GAAkBH,EAAeA,EAAaI,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,CAAC,EAAG,IAC5GE,EAAmBC,GAAoBR,EAAeA,EAAaG,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,GAGnH,OACII,EAAC7B,EAAW,CAAA8B,uBACRD,EAAC3B,EAAK,CAAA6B,MAAK,EAAAC,GAAI,GAAIC,GAAmBN,EAAoBO,GAAmBb,EACzEP,SAAA,CAAAqB,EAACC,EAAU,CAACC,QAAQ,YAAYC,UAAU,KAAKC,MAAM,cAAazB,SAC7DI,GAAmBD,GAAS,OAGhCD,GAAyBD,EACtBoB,EAAC1B,EAAiB,CAAAK,SACdqB,EAACC,GAAWC,QAAQ,UAAUE,MAAM,gBAC/BzB,SAAAE,GAAyBD,GAAe,SAGjD,QAERoB,EAACjC,EAAK,CAAA6B,MAAK,EAAAC,GAAI,GAAIC,GAAmBL,EAAmBM,GAAmBZ,EAAeR,SACtFA,MAGX"}
1
+ {"version":3,"file":"FormItemLayout.js","sources":["../../../../src/components/ui/Form/FormItemLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport Grid, { type GridSize } from '@mui/material/Grid';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nconst StyledGrid = styled(Grid)(({ theme }) => ({\n padding: theme.spacing(4.75, 0, 2.5, 0),\n alignItems: 'flex-start',\n flexWrap: 'wrap',\n borderBottom: '1px solid rgba(0,0,0,0.2)',\n}));\n\nconst StyledDescription = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n paddingRight: theme.spacing(1.75),\n}));\n\nexport interface FormItemLayoutProps {\n children: React.ReactNode;\n description?: React.ReactNode;\n descriptionTranslated?: string;\n label?: React.ReactNode;\n labelTranslated?: string;\n mdProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n smProportion?: '4x8' | '8x4' | '10x2' | '12x12';\n}\n\ntype Props = FormItemLayoutProps;\nconst FormItemLayout = (props: Props) => {\n const { children, description, descriptionTranslated, label, labelTranslated, mdProportion, smProportion } = props;\n\n const [titleProportion, dataProportion] = mdProportion ? mdProportion.split('x').map((m) => parseInt(m, 10)) : [4, 8];\n const [titleProportionSm, dataProportionSm] = smProportion ? smProportion.split('x').map((m) => parseInt(m, 10)) : [];\n const castToGridSize = (data: unknown) => data as GridSize;\n\n return (\n <StyledGrid container>\n <Grid item xs={12} sm={castToGridSize(titleProportionSm)} md={castToGridSize(titleProportion)}>\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {labelTranslated || label || null}\n </Typography>\n\n {descriptionTranslated || description ? (\n <StyledDescription>\n <Typography variant=\"caption\" color=\"textSecondary\">\n {descriptionTranslated || description || null}\n </Typography>\n </StyledDescription>\n ) : null}\n </Grid>\n <Grid item xs={12} sm={castToGridSize(dataProportionSm)} md={castToGridSize(dataProportion)}>\n {children}\n </Grid>\n </StyledGrid>\n );\n};\n\nexport default FormItemLayout;\n"],"names":["StyledGrid","styled","Grid","theme","padding","spacing","alignItems","flexWrap","borderBottom","StyledDescription","paddingBottom","paddingRight","FormItemLayout","props","children","description","descriptionTranslated","label","labelTranslated","mdProportion","smProportion","titleProportion","dataProportion","split","map","m","parseInt","titleProportionSm","dataProportionSm","_jsxs","container","item","xs","sm","md","_jsx","Typography","variant","component","color"],"mappings":"wLAMA,MAAMA,EAAaC,EAAOC,EAAPD,EAAa,EAAGE,YAAa,CAC5CC,QAASD,EAAME,QAAQ,KAAM,EAAG,IAAK,GACrCC,WAAY,aACZC,SAAU,OACVC,aAAc,gCAGZC,EAAoBR,EAAO,MAAPA,EAAc,EAAGE,YAAa,CACpDO,cAAeP,EAAME,QAAQ,GAC7BM,aAAcR,EAAME,QAAQ,UAc1BO,EAAkBC,IACpB,MAAMC,SAAEA,EAAQC,YAAEA,EAAWC,sBAAEA,EAAqBC,MAAEA,EAAKC,gBAAEA,EAAeC,aAAEA,EAAYC,aAAEA,GAAiBP,GAEtGQ,EAAiBC,GAAkBH,EAAeA,EAAaI,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,CAAC,EAAG,IAC5GE,EAAmBC,GAAoBR,EAAeA,EAAaG,MAAM,KAAKC,KAAKC,GAAMC,SAASD,EAAG,MAAO,GAGnH,OACII,EAAC7B,EAAW,CAAA8B,uBACRD,EAAC3B,EAAK,CAAA6B,MAAK,EAAAC,GAAI,GAAIC,GAAmBN,EAAoBO,GAAmBb,EACzEP,SAAA,CAAAqB,EAACC,EAAU,CAACC,QAAQ,YAAYC,UAAU,KAAKC,MAAM,cAAazB,SAC7DI,GAAmBD,GAAS,OAGhCD,GAAyBD,EACtBoB,EAAC1B,EAAiB,CAAAK,SACdqB,EAACC,GAAWC,QAAQ,UAAUE,MAAM,gBAC/BzB,SAAAE,GAAyBD,GAAe,SAGjD,QAERoB,EAACjC,EAAK,CAAA6B,MAAK,EAAAC,GAAI,GAAIC,GAAmBL,EAAmBM,GAAmBZ,EAAeR,SACtFA,MAGX"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Autocomplete"),i=require("@mui/material/CircularProgress"),t=require("@mui/material/TextField"),l=require("@mui/material/Typography"),a=require("formik");require("react");var o=require("../../custom-hooks/useRenderValidText.cjs.js"),n=require("./FormItemLayout.cjs.js");module.exports=({label:s,fieldName:u,options:d,placeholder:m,getOptionLabel:p,validation:c,onChange:h,onInputChange:g,isOptionEqualToValue:x,onScroll:v,layout:j="horizontal",variant:q="outlined",disabled:b=!1,loading:f=!1,required:T=!1,multiple:y=!1,limitTags:F})=>{const I=()=>e.jsx(a.Field,{name:u,validate:c,children:({field:l,form:a})=>{const{errors:n,touched:c,isSubmitting:I}=a,P=n[l.name],C=!!P&&c[l.name],A=o({fieldError:P,showError:C,touched:!!c[l.name],value:l.value});return e.jsx(r,{options:d,getOptionLabel:p,isOptionEqualToValue:x,onChange:(e,r)=>{a.setFieldValue(u,r),h&&h(e,r)},onInputChange:g,disabled:I||b,fullWidth:!0,value:l.value||(y?[]:null),loading:f,renderInput:r=>e.jsx(t,{...r,label:"standard"===q?void 0:s,variant:q,"data-testid":`text-field-${u}`,fullWidth:!0,style:{paddingRight:"horizontal"===j?16:0},placeholder:m||void 0,required:T,error:C,helperText:A,slotProps:{input:{...r.InputProps,endAdornment:e.jsxs(e.Fragment,{children:[f&&e.jsx(i,{color:"inherit",size:25}),r.InputProps.endAdornment]})},formHelperText:{children:" ",style:{textAlign:"right"}}}}),multiple:y,limitTags:y?F??2:void 0,slotProps:{listbox:{onScroll:v}}})}});return"vertical"===j?e.jsxs(e.Fragment,{children:["standard"===q&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:s}),I()]}):e.jsx(n,{label:s,children:I()})};
1
+ "use strict";var e=require("react/jsx-runtime"),l=require("@mui/material/Autocomplete"),i=require("@mui/material/CircularProgress"),r=require("@mui/material/TextField"),t=require("@mui/material/Typography"),a=require("formik");require("react");var o=require("../../custom-hooks/useRenderValidText.cjs.js"),n=require("./FormItemLayout.cjs.js");const u=({field:t,form:a,fieldName:n,options:u,label:d,variant:s,placeholder:p,getOptionLabel:m,isOptionEqualToValue:h,onChange:c,onInputChange:g,onScroll:x,layout:q="horizontal",disabled:v=!1,loading:b=!1,required:j=!1,multiple:T=!1,limitTags:f})=>{const{errors:y,touched:C,isSubmitting:I}=a,O=y[t.name],E=!!O&&C[t.name],F=o({fieldError:O,showError:E,touched:!!C[t.name],value:t.value});return e.jsx(l,{options:u,getOptionLabel:m,isOptionEqualToValue:h,onChange:(e,l)=>{a.setFieldValue(n,l),c&&c(e,l)},onInputChange:g,disabled:I||v,fullWidth:!0,value:t.value||(T?[]:null),loading:b,renderInput:l=>e.jsx(r,{...l,label:"standard"===s?void 0:d,variant:s,"data-testid":`text-field-${n}`,fullWidth:!0,style:{paddingRight:"horizontal"===q?16:0},placeholder:p||void 0,required:j,error:E,helperText:F,slotProps:{input:{...l.InputProps,endAdornment:e.jsxs(e.Fragment,{children:[b&&e.jsx(i,{color:"inherit",size:25}),l.InputProps.endAdornment]})},formHelperText:{children:" ",style:{textAlign:"right"}}}}),multiple:T,limitTags:T?f??2:void 0,slotProps:{listbox:{onScroll:x}}})};module.exports=({label:l,fieldName:i,options:r,placeholder:o,getOptionLabel:d,validation:s,onChange:p,onInputChange:m,isOptionEqualToValue:h,onScroll:c,layout:g="horizontal",variant:x="outlined",disabled:q=!1,loading:v=!1,required:b=!1,multiple:j=!1,limitTags:T})=>{const f=()=>e.jsx(a.Field,{name:i,validate:s,children:t=>e.jsx(u,{...t,fieldName:i,options:r,label:l,variant:x,placeholder:o,getOptionLabel:d,isOptionEqualToValue:h,onChange:p,onInputChange:m,onScroll:c,layout:g,disabled:q,loading:v,required:b,multiple:j,limitTags:T})});return"vertical"===g?e.jsxs(e.Fragment,{children:["standard"===x&&e.jsx(t,{variant:"subtitle1",component:"h3",color:"textPrimary",children:l}),f()]}):e.jsx(n,{label:l,children:f()})};
2
2
  //# sourceMappingURL=GenericAutocompleteField.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericAutocompleteField.cjs.js","sources":["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Autocomplete from '@mui/material/Autocomplete';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField, { type TextFieldProps } from '@mui/material/TextField';\nimport Typography from '@mui/material/Typography';\nimport { Field, type FieldProps } from 'formik';\nimport { type SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\nexport type Props<T> = {\n label: string;\n fieldName: string;\n options: T[];\n placeholder?: string;\n getOptionLabel?: (option: T) => string;\n validation?: (value: T | T[]) => string | undefined;\n onChange?: (e: SyntheticEvent, value: T | T[]) => void;\n onInputChange?: (e: SyntheticEvent, value: string) => void;\n isOptionEqualToValue?: (option: T, value: T) => boolean;\n onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n loading?: boolean;\n required?: boolean;\n multiple?: boolean;\n limitTags?: number;\n};\n\nconst GenericAutocompleteField = <T,>({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n onInputChange,\n isOptionEqualToValue,\n onScroll,\n layout = 'horizontal',\n variant = 'outlined',\n disabled = false,\n loading = false,\n required = false,\n multiple = false,\n limitTags = undefined,\n}: Props<T>) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {({ field, form }: FieldProps) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel}\n isOptionEqualToValue={isOptionEqualToValue}\n onChange={(e: SyntheticEvent, value: T[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n onInputChange={onInputChange}\n disabled={isSubmitting || disabled}\n fullWidth\n value={field.value || (multiple ? [] : null)}\n loading={loading}\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\n required={required}\n error={showError}\n helperText={helperText}\n slotProps={{\n input: {\n ...params.InputProps,\n endAdornment: (\n <>\n {loading && <CircularProgress color=\"inherit\" size={25} />}\n {params.InputProps.endAdornment}\n </>\n ),\n },\n\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n }}\n />\n )}\n multiple={multiple}\n limitTags={multiple ? (limitTags ?? 2) : undefined}\n slotProps={{\n listbox: {\n onScroll,\n },\n }}\n />\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericAutocompleteField;\n"],"names":["label","fieldName","options","placeholder","getOptionLabel","validation","onChange","onInputChange","isOptionEqualToValue","onScroll","layout","variant","disabled","loading","required","multiple","limitTags","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","Autocomplete","e","setFieldValue","fullWidth","renderInput","params","jsx","TextField","undefined","style","paddingRight","error","slotProps","input","InputProps","endAdornment","_jsxs","jsxs","_Fragment","CircularProgress","color","size","formHelperText","textAlign","listbox","Typography","component","FormItemLayout"],"mappings":"sWA8BiC,EAC7BA,QACAC,YACAC,UACAC,cACAC,iBACAC,aACAC,WACAC,gBACAC,uBACAC,WACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,WAAU,EACVC,YAAW,EACXC,YAAW,EACXC,gBAEA,MAAMC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMnB,EAAWoB,SAAUhB,EAAUiB,SACvC,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMH,MAC1BS,IAAcD,GAAeF,EAAQH,EAAMH,MAC3CU,EAAaC,EAAmB,CAClCH,aACAC,YACAH,UAAWA,EAAQH,EAAMH,MACzBY,MAAOT,EAAMS,QAGjB,OACId,MAACe,EAAY,CACT/B,QAASA,EACTE,eAAgBA,EAChBI,qBAAsBA,EACtBF,SAAU,CAAC4B,EAAmBF,KAE1BR,EAAKW,cAAclC,EAAW+B,GAC1B1B,GACAA,EAAS4B,EAAGF,EACf,EAELzB,cAAeA,EACfK,SAAUe,GAAgBf,EAC1BwB,aACAJ,MAAOT,EAAMS,QAAUjB,EAAW,GAAK,MACvCF,QAASA,EACTwB,YAAcC,GACVpB,EAACqB,IAAAC,EACO,IAAAF,EACJtC,MAAmB,aAAZW,OAAyB8B,EAAYzC,EAC5CW,QAASA,EAAO,cACH,cAAcV,IAC3BmC,WAAS,EACTM,MAAO,CAAEC,aAAyB,eAAXjC,EAA0B,GAAK,GACtDP,YAAaA,QAA4BsC,EACzC3B,SAAUA,EACV8B,MAAOf,EACPC,WAAYA,EACZe,UAAW,CACPC,MAAO,IACAR,EAAOS,WACVC,aACIC,EACKC,KAAAC,WAAA,CAAA7B,SAAA,CAAAT,GAAWK,EAACqB,IAAAa,EAAiB,CAAAC,MAAM,UAAUC,KAAM,KACnDhB,EAAOS,WAAWC,iBAK/BO,eAAgB,CACZjC,SAAU,IACVoB,MAAO,CAAEc,UAAW,aAKpCzC,SAAUA,EACVC,UAAWD,EAAYC,GAAa,OAAKyB,EACzCI,UAAW,CACPY,QAAS,CACLhD,cAId,IAMlB,MAAe,aAAXC,EAEIuC,EAAAC,KAAAC,WAAA,CAAA7B,SAAA,CACiB,aAAZX,GACGO,EAAAqB,IAACmB,EAAU,CAAC/C,QAAQ,YAAYgD,UAAU,KAAKN,MAAM,cAChD/B,SAAAtB,IAGRiB,OAKNC,EAAAqB,IAACqB,EAAc,CAAC5D,MAAOA,EAAQsB,SAAAL,KAA+B"}
1
+ {"version":3,"file":"GenericAutocompleteField.cjs.js","sources":["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport Autocomplete from '@mui/material/Autocomplete';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField, { type TextFieldProps } from '@mui/material/TextField';\nimport Typography from '@mui/material/Typography';\nimport { Field, type FieldProps } from 'formik';\nimport { type SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\nexport type Props<T> = {\n label: string;\n fieldName: string;\n options: T[];\n placeholder?: string;\n getOptionLabel?: (option: T) => string;\n validation?: (value: T | T[]) => string | undefined;\n onChange?: (e: SyntheticEvent, value: T | T[]) => void;\n onInputChange?: (e: SyntheticEvent, value: string) => void;\n isOptionEqualToValue?: (option: T, value: T) => boolean;\n onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n loading?: boolean;\n required?: boolean;\n multiple?: boolean;\n limitTags?: number;\n};\n\ntype AutocompleteFieldProps<T> = {\n field: FieldProps['field'];\n form: FieldProps['form'];\n fieldName: string;\n options: T[];\n label: string;\n variant: TextFieldProps['variant'];\n placeholder?: string;\n getOptionLabel?: (option: T) => string;\n isOptionEqualToValue?: (option: T, value: T) => boolean;\n onChange?: (e: SyntheticEvent, value: T | T[]) => void;\n onInputChange?: (e: SyntheticEvent, value: string) => void;\n onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;\n layout?: 'horizontal' | 'vertical';\n disabled?: boolean;\n loading?: boolean;\n required?: boolean;\n multiple?: boolean;\n limitTags?: number;\n};\n\nconst AutocompleteFieldComponent = <T,>({\n field,\n form,\n fieldName,\n options,\n label,\n variant,\n placeholder,\n getOptionLabel,\n isOptionEqualToValue,\n onChange,\n onInputChange,\n onScroll,\n layout = 'horizontal',\n disabled = false,\n loading = false,\n required = false,\n multiple = false,\n limitTags,\n}: AutocompleteFieldProps<T>) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel}\n isOptionEqualToValue={isOptionEqualToValue}\n onChange={(e: SyntheticEvent, value: T[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n onInputChange={onInputChange}\n disabled={isSubmitting || disabled}\n fullWidth\n value={field.value || (multiple ? [] : null)}\n loading={loading}\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder || undefined}\n required={required}\n error={showError}\n helperText={helperText}\n slotProps={{\n input: {\n ...params.InputProps,\n endAdornment: (\n <>\n {loading && <CircularProgress color=\"inherit\" size={25} />}\n {params.InputProps.endAdornment}\n </>\n ),\n },\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n }}\n />\n )}\n multiple={multiple}\n limitTags={multiple ? (limitTags ?? 2) : undefined}\n slotProps={{\n listbox: {\n onScroll,\n },\n }}\n />\n );\n};\n\nconst GenericAutocompleteField = <T,>({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n onInputChange,\n isOptionEqualToValue,\n onScroll,\n layout = 'horizontal',\n variant = 'outlined',\n disabled = false,\n loading = false,\n required = false,\n multiple = false,\n limitTags = undefined,\n}: Props<T>) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {(fieldProps: FieldProps) => (\n <AutocompleteFieldComponent<T>\n {...fieldProps}\n fieldName={fieldName}\n options={options}\n label={label}\n variant={variant}\n placeholder={placeholder}\n getOptionLabel={getOptionLabel}\n isOptionEqualToValue={isOptionEqualToValue}\n onChange={onChange}\n onInputChange={onInputChange}\n onScroll={onScroll}\n layout={layout}\n disabled={disabled}\n loading={loading}\n required={required}\n multiple={multiple}\n limitTags={limitTags}\n />\n )}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericAutocompleteField;\n"],"names":["AutocompleteFieldComponent","field","form","fieldName","options","label","variant","placeholder","getOptionLabel","isOptionEqualToValue","onChange","onInputChange","onScroll","layout","disabled","loading","required","multiple","limitTags","errors","touched","isSubmitting","fieldError","name","showError","helperText","useRenderValidText","value","_jsx","Autocomplete","e","setFieldValue","fullWidth","renderInput","params","TextField","undefined","style","paddingRight","error","slotProps","input","InputProps","endAdornment","_jsxs","jsxs","_Fragment","children","jsx","CircularProgress","color","size","formHelperText","textAlign","listbox","validation","renderField","Field","validate","fieldProps","Typography","component","FormItemLayout"],"mappings":"uVAmDA,MAAMA,EAA6B,EAC/BC,QACAC,OACAC,YACAC,UACAC,QACAC,UACAC,cACAC,iBACAC,uBACAC,WACAC,gBACAC,WACAC,SAAS,aACTC,YAAW,EACXC,WAAU,EACVC,YAAW,EACXC,YAAW,EACXC,gBAEA,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBnB,EACpCoB,EAAaH,EAAOlB,EAAMsB,MAC1BC,IAAcF,GAAeF,EAAQnB,EAAMsB,MAC3CE,EAAaC,EAAmB,CAClCJ,aACAE,YACAJ,UAAWA,EAAQnB,EAAMsB,MACzBI,MAAO1B,EAAM0B,QAGjB,OACIC,MAACC,EAAY,CACTzB,QAASA,EACTI,eAAgBA,EAChBC,qBAAsBA,EACtBC,SAAU,CAACoB,EAAmBH,KAE1BzB,EAAK6B,cAAc5B,EAAWwB,GAC1BjB,GACAA,EAASoB,EAAGH,EACf,EAELhB,cAAeA,EACfG,SAAUO,GAAgBP,EAC1BkB,aACAL,MAAO1B,EAAM0B,QAAUV,EAAW,GAAK,MACvCF,QAASA,EACTkB,YAAcC,GACVN,EAAAA,IAACO,EACO,IAAAD,EACJ7B,MAAmB,aAAZC,OAAyB8B,EAAY/B,EAC5CC,QAASA,EAAO,cACH,cAAcH,IAC3B6B,WACA,EAAAK,MAAO,CAAEC,aAAyB,eAAXzB,EAA0B,GAAK,GACtDN,YAAaA,QAAe6B,EAC5BpB,SAAUA,EACVuB,MAAOf,EACPC,WAAYA,EACZe,UAAW,CACPC,MAAO,IACAP,EAAOQ,WACVC,aACIC,EACKC,KAAAC,WAAA,CAAAC,SAAA,CAAAhC,GAAWa,EAACoB,IAAAC,EAAiB,CAAAC,MAAM,UAAUC,KAAM,KACnDjB,EAAOQ,WAAWC,iBAI/BS,eAAgB,CACZL,SAAU,IACVV,MAAO,CAAEgB,UAAW,aAKpCpC,SAAUA,EACVC,UAAWD,EAAYC,GAAa,OAAKkB,EACzCI,UAAW,CACPc,QAAS,CACL1C,cAId,iBAG2B,EAC7BP,QACAF,YACAC,UACAG,cACAC,iBACA+C,aACA7C,WACAC,gBACAF,uBACAG,WACAC,SAAS,aACTP,UAAU,WACVQ,YAAW,EACXC,WAAU,EACVC,YAAW,EACXC,YAAW,EACXC,gBAEA,MAAMsC,EAAc,IAEZ5B,MAAC6B,EAAAA,OAAMlC,KAAMpB,EAAWuD,SAAUH,EAAUR,SACtCY,GACE/B,MAAC5B,EAA0B,IACnB2D,EACJxD,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,QAASA,EACTC,YAAaA,EACbC,eAAgBA,EAChBC,qBAAsBA,EACtBC,SAAUA,EACVC,cAAeA,EACfC,SAAUA,EACVC,OAAQA,EACRC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVC,SAAUA,EACVC,UAAWA,MAO/B,MAAe,aAAXL,EAEI+B,EAAAC,KAAAC,WAAA,CAAAC,SAAA,CACiB,aAAZzC,GACGsB,EAAAoB,IAACY,EAAU,CAACtD,QAAQ,YAAYuD,UAAU,KAAKX,MAAM,cAChDH,SAAA1C,IAGRmD,OAKN5B,EAAAoB,IAACc,EAAc,CAACzD,MAAOA,EAAQ0C,SAAAS,KAA+B"}
@@ -1,2 +1,2 @@
1
- import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import o from"@mui/material/Autocomplete";import i from"@mui/material/CircularProgress";import l from"@mui/material/TextField";import a from"@mui/material/Typography";import{Field as n}from"formik";import"react";import d from"../../custom-hooks/useRenderValidText.js";import m from"./FormItemLayout.js";const u=({label:u,fieldName:s,options:p,placeholder:h,getOptionLabel:c,validation:f,onChange:g,onInputChange:v,isOptionEqualToValue:b,onScroll:x,layout:T="horizontal",variant:y="outlined",disabled:I=!1,loading:P=!1,required:C=!1,multiple:q=!1,limitTags:A})=>{const E=()=>r(n,{name:s,validate:f,children:({field:a,form:n})=>{const{errors:m,touched:f,isSubmitting:E}=n,O=m[a.name],V=!!O&&f[a.name],j=d({fieldError:O,showError:V,touched:!!f[a.name],value:a.value});return r(o,{options:p,getOptionLabel:c,isOptionEqualToValue:b,onChange:(e,t)=>{n.setFieldValue(s,t),g&&g(e,t)},onInputChange:v,disabled:E||I,fullWidth:!0,value:a.value||(q?[]:null),loading:P,renderInput:o=>r(l,{...o,label:"standard"===y?void 0:u,variant:y,"data-testid":`text-field-${s}`,fullWidth:!0,style:{paddingRight:"horizontal"===T?16:0},placeholder:h||void 0,required:C,error:V,helperText:j,slotProps:{input:{...o.InputProps,endAdornment:e(t,{children:[P&&r(i,{color:"inherit",size:25}),o.InputProps.endAdornment]})},formHelperText:{children:" ",style:{textAlign:"right"}}}}),multiple:q,limitTags:q?A??2:void 0,slotProps:{listbox:{onScroll:x}}})}});return"vertical"===T?e(t,{children:["standard"===y&&r(a,{variant:"subtitle1",component:"h3",color:"textPrimary",children:u}),E()]}):r(m,{label:u,children:E()})};export{u as default};
1
+ import{jsxs as e,Fragment as o,jsx as l}from"react/jsx-runtime";import t from"@mui/material/Autocomplete";import i from"@mui/material/CircularProgress";import r from"@mui/material/TextField";import a from"@mui/material/Typography";import{Field as n}from"formik";import"react";import d from"../../custom-hooks/useRenderValidText.js";import m from"./FormItemLayout.js";const u=({field:a,form:n,fieldName:m,options:u,label:p,variant:s,placeholder:h,getOptionLabel:c,isOptionEqualToValue:g,onChange:f,onInputChange:b,onScroll:v,layout:T="horizontal",disabled:x=!1,loading:y=!1,required:C=!1,multiple:q=!1,limitTags:I})=>{const{errors:O,touched:E,isSubmitting:P}=n,V=O[a.name],L=!!V&&E[a.name],S=d({fieldError:V,showError:L,touched:!!E[a.name],value:a.value});return l(t,{options:u,getOptionLabel:c,isOptionEqualToValue:g,onChange:(e,o)=>{n.setFieldValue(m,o),f&&f(e,o)},onInputChange:b,disabled:P||x,fullWidth:!0,value:a.value||(q?[]:null),loading:y,renderInput:t=>l(r,{...t,label:"standard"===s?void 0:p,variant:s,"data-testid":`text-field-${m}`,fullWidth:!0,style:{paddingRight:"horizontal"===T?16:0},placeholder:h||void 0,required:C,error:L,helperText:S,slotProps:{input:{...t.InputProps,endAdornment:e(o,{children:[y&&l(i,{color:"inherit",size:25}),t.InputProps.endAdornment]})},formHelperText:{children:" ",style:{textAlign:"right"}}}}),multiple:q,limitTags:q?I??2:void 0,slotProps:{listbox:{onScroll:v}}})},p=({label:t,fieldName:i,options:r,placeholder:d,getOptionLabel:p,validation:s,onChange:h,onInputChange:c,isOptionEqualToValue:g,onScroll:f,layout:b="horizontal",variant:v="outlined",disabled:T=!1,loading:x=!1,required:y=!1,multiple:C=!1,limitTags:q})=>{const I=()=>l(n,{name:i,validate:s,children:e=>l(u,{...e,fieldName:i,options:r,label:t,variant:v,placeholder:d,getOptionLabel:p,isOptionEqualToValue:g,onChange:h,onInputChange:c,onScroll:f,layout:b,disabled:T,loading:x,required:y,multiple:C,limitTags:q})});return"vertical"===b?e(o,{children:["standard"===v&&l(a,{variant:"subtitle1",component:"h3",color:"textPrimary",children:t}),I()]}):l(m,{label:t,children:I()})};export{p as default};
2
2
  //# sourceMappingURL=GenericAutocompleteField.js.map