@beinformed/ui 1.20.0 → 1.20.1

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 (78) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/esm/hooks/useContent.js +2 -6
  3. package/esm/hooks/useContent.js.map +1 -1
  4. package/esm/hooks/useI18n.js +10 -11
  5. package/esm/hooks/useI18n.js.map +1 -1
  6. package/esm/hooks/useModularUI.js +2 -3
  7. package/esm/hooks/useModularUI.js.map +1 -1
  8. package/esm/hooks/useModularUIRequest.js +2 -5
  9. package/esm/hooks/useModularUIRequest.js.map +1 -1
  10. package/esm/i18n/Message.js.map +1 -1
  11. package/esm/i18n/withMessage.js +2 -10
  12. package/esm/i18n/withMessage.js.map +1 -1
  13. package/esm/redux/_modularui/connector.js +3 -4
  14. package/esm/redux/_modularui/connector.js.map +1 -1
  15. package/esm/redux/_modularui/selectors.js +22 -5
  16. package/esm/redux/_modularui/selectors.js.map +1 -1
  17. package/esm/redux/_modularui/withModularUI.js +2 -10
  18. package/esm/redux/_modularui/withModularUI.js.map +1 -1
  19. package/esm/redux/actions/Application.js +26 -7
  20. package/esm/redux/actions/Application.js.map +1 -1
  21. package/esm/redux/selectors/i18n.js +16 -0
  22. package/esm/redux/selectors/i18n.js.map +1 -0
  23. package/esm/utils/datetime/DateTimeUtil.js +3 -1
  24. package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
  25. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +0 -8
  26. package/lib/hooks/useContent.js +3 -7
  27. package/lib/hooks/useContent.js.flow +2 -2
  28. package/lib/hooks/useContent.js.map +1 -1
  29. package/lib/hooks/useI18n.js +12 -9
  30. package/lib/hooks/useI18n.js.flow +10 -11
  31. package/lib/hooks/useI18n.js.map +1 -1
  32. package/lib/hooks/useModularUI.js +3 -3
  33. package/lib/hooks/useModularUI.js.flow +3 -2
  34. package/lib/hooks/useModularUI.js.map +1 -1
  35. package/lib/hooks/useModularUIRequest.js +2 -4
  36. package/lib/hooks/useModularUIRequest.js.flow +8 -10
  37. package/lib/hooks/useModularUIRequest.js.map +1 -1
  38. package/lib/i18n/Message.js.flow +1 -1
  39. package/lib/i18n/Message.js.map +1 -1
  40. package/lib/i18n/withMessage.js +2 -8
  41. package/lib/i18n/withMessage.js.flow +3 -4
  42. package/lib/i18n/withMessage.js.map +1 -1
  43. package/lib/redux/_modularui/connector.js +3 -3
  44. package/lib/redux/_modularui/connector.js.flow +3 -2
  45. package/lib/redux/_modularui/connector.js.map +1 -1
  46. package/lib/redux/_modularui/selectors.js +26 -6
  47. package/lib/redux/_modularui/selectors.js.flow +19 -1
  48. package/lib/redux/_modularui/selectors.js.map +1 -1
  49. package/lib/redux/_modularui/withModularUI.js +3 -9
  50. package/lib/redux/_modularui/withModularUI.js.flow +3 -5
  51. package/lib/redux/_modularui/withModularUI.js.map +1 -1
  52. package/lib/redux/actions/Application.js +31 -8
  53. package/lib/redux/actions/Application.js.flow +6 -8
  54. package/lib/redux/actions/Application.js.map +1 -1
  55. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -5
  56. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +1 -1
  57. package/lib/redux/selectors/i18n.js +28 -0
  58. package/lib/redux/selectors/i18n.js.flow +15 -0
  59. package/lib/redux/selectors/i18n.js.map +1 -0
  60. package/lib/utils/datetime/DateTimeUtil.js +3 -1
  61. package/lib/utils/datetime/DateTimeUtil.js.flow +1 -1
  62. package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/hooks/__tests__/useAuthentication.spec.js +0 -8
  65. package/src/hooks/useContent.js +2 -2
  66. package/src/hooks/useI18n.js +10 -11
  67. package/src/hooks/useModularUI.js +3 -2
  68. package/src/hooks/useModularUIRequest.js +8 -10
  69. package/src/i18n/Message.js +1 -1
  70. package/src/i18n/withMessage.js +3 -4
  71. package/src/redux/_modularui/connector.js +3 -2
  72. package/src/redux/_modularui/selectors.js +19 -1
  73. package/src/redux/_modularui/withModularUI.js +3 -5
  74. package/src/redux/actions/Application.js +6 -8
  75. package/src/redux/actions/__tests__/Application.spec.js +1 -5
  76. package/src/redux/actions/__tests__/Authorization.spec.js +1 -1
  77. package/src/redux/selectors/i18n.js +15 -0
  78. package/src/utils/datetime/DateTimeUtil.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeUtil.js","names":["parse","format","isValid","isAfter","isBefore","isSameDay","addSeconds","addMinutes","addHours","addDays","addWeeks","addMonths","addYears","subSeconds","subMinutes","subHours","subDays","subWeeks","subMonths","subYears","startOfMonth","endOfMonth","startOfWeek","getHours","getMinutes","getDay","getWeek","setMilliseconds","setSeconds","setMinutes","setHours","setMonth","setYear","set","nl","enGB","getCookie","getSetting","ISO_DATE_FORMAT","ISO_DATETIME_FORMAT","ISO_TIME_FORMAT","ISO_TIMESTAMP_FORMAT","DEFAULT_WEEK_STARTS_ON","DEFAULT_FIRST_WEEK_CONTAINS_DATE","BaseDateTimeUtil","isoFormat","_isoFormat","locale","weekStartsOn","firstWeekContainsDate","date","inputFormat","getOptions","Date","targetFormat","parsedDate","toDate","getLocale","sourceFormat","toISO","realDate","formattedValue","isOutsideRange","replace","toUpperCase","inputDate","afterISODate","isSame","beforeISODate","compareDate","getTime","SATURDAY_NUMBER","SUNDAY_NUMBER","weekDay","amount","year","month","hour","minute","second","milliseconds","hours","minutes","seconds","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil"],"sources":["../../../src/utils/datetime/DateTimeUtil.js"],"sourcesContent":["// @flow\nimport {\n parse,\n format,\n isValid,\n isAfter,\n isBefore,\n isSameDay,\n addSeconds,\n addMinutes,\n addHours,\n addDays,\n addWeeks,\n addMonths,\n addYears,\n subSeconds,\n subMinutes,\n subHours,\n subDays,\n subWeeks,\n subMonths,\n subYears,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getHours,\n getMinutes,\n getDay,\n getWeek,\n setMilliseconds,\n setSeconds,\n setMinutes,\n setHours,\n setMonth,\n setYear,\n set,\n} from \"date-fns\";\nimport { nl, enGB } from \"date-fns/locale\";\n\nimport { getCookie } from \"../browser/Cookies\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport {\n ISO_DATE_FORMAT,\n ISO_DATETIME_FORMAT,\n ISO_TIME_FORMAT,\n ISO_TIMESTAMP_FORMAT,\n DEFAULT_WEEK_STARTS_ON,\n DEFAULT_FIRST_WEEK_CONTAINS_DATE,\n} from \"../../constants\";\n\n/**\n * @hideconstructor\n */\nclass BaseDateTimeUtil {\n _isoFormat: string;\n\n constructor(isoFormat: string) {\n this._isoFormat = isoFormat;\n }\n\n /**\n */\n getLocale(): typeof nl | typeof enGB {\n const locale = getCookie(\"locale\") || \"en\";\n\n if (locale === \"nl\") {\n return nl;\n }\n\n return enGB;\n }\n\n // returns the options defined in settings\n getOptions(): {\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6,\n firstWeekContainsDate: 1 | 2 | 3 | 4 | 5 | 6 | 7,\n } {\n // indicates on what day the week starts\n const weekStartsOn = getSetting(\n \"CALENDAR_WEEK_STARTS_ON\",\n DEFAULT_WEEK_STARTS_ON\n );\n\n // indicates which date indicates the first week of the year\n const firstWeekContainsDate = getSetting(\n \"CALENDAR_FIRST_WEEK_CONTAINS_DATE\",\n DEFAULT_FIRST_WEEK_CONTAINS_DATE\n );\n\n return { weekStartsOn, firstWeekContainsDate };\n }\n\n /**\n */\n toDate(date: string, inputFormat: string = this._isoFormat): Date {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return parse(date, inputFormat, new Date(), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n */\n toFormat(date: string | Date, targetFormat: string): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, targetFormat, {\n weekStartsOn,\n locale: this.getLocale(),\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n toISO(date: string | Date, sourceFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate =\n typeof date === \"string\" ? this.toDate(date, sourceFormat) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, this._isoFormat, {\n weekStartsOn,\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n now(): string {\n return this.toISO(new Date());\n }\n\n /**\n */\n convertFormat(sourceFormat: string): string {\n return sourceFormat ? sourceFormat : this._isoFormat;\n }\n\n /**\n * VALIDATION\n */\n hasFormat(date: string, sourceFormat: string): boolean {\n const { weekStartsOn } = this.getOptions();\n\n const realDate = this.toDate(date, sourceFormat);\n if (isValid(realDate)) {\n const formattedValue = format(realDate, sourceFormat, {\n weekStartsOn,\n });\n\n const isOutsideRange =\n isBefore(realDate, new Date(1000, 1, 1)) ||\n isAfter(realDate, new Date(9999, 11, 31));\n if (isOutsideRange) {\n return false;\n }\n\n return (\n formattedValue.replace(/0/gu, \"\").toUpperCase() ===\n date.replace(/0/gu, \"\").toUpperCase()\n );\n }\n\n return false;\n }\n\n /**\n */\n isValid(date: string, inputFormat: string = this._isoFormat): boolean {\n return isValid(this.toDate(date, inputFormat));\n }\n\n /**\n */\n isAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n isAfter(this.toDate(inputDate, inputFormat), this.toDate(afterISODate))\n );\n }\n\n /**\n */\n isSameOrAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n (this.isAfter(inputDate, afterISODate, inputFormat) ||\n this.isSame(inputDate, afterISODate, inputFormat))\n );\n }\n\n /**\n */\n isBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n isBefore(this.toDate(inputDate, inputFormat), this.toDate(beforeISODate))\n );\n }\n\n /**\n */\n isSameOrBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n (this.isBefore(inputDate, beforeISODate, inputFormat) ||\n this.isSame(inputDate, beforeISODate, inputFormat))\n );\n }\n\n /**\n */\n isSame(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n this.toDate(inputDate, inputFormat).getTime() ===\n this.toDate(compareDate).getTime()\n );\n }\n\n /**\n */\n isSameDay(\n inputDate: string,\n compareDate: string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n isSameDay(\n this.toDate(inputDate, inputFormat),\n this.toDate(compareDate, inputFormat)\n )\n );\n }\n\n /**\n */\n isOther(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return !this.isSame(inputDate, compareDate, inputFormat);\n }\n\n /**\n */\n isWeekend(inputDate: string): boolean {\n const SATURDAY_NUMBER = 6;\n const SUNDAY_NUMBER = 0;\n const weekDay = getDay(this.toDate(inputDate));\n\n return weekDay === SATURDAY_NUMBER || weekDay === SUNDAY_NUMBER;\n }\n\n /**\n * CALCULATIONS\n */\n addSeconds(date: string, amount: number): string {\n return this.toISO(addSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n addMinutes(date: string, amount: number): string {\n return this.toISO(addMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n addHours(date: string, amount: number): string {\n return this.toISO(addHours(this.toDate(date), amount));\n }\n\n /**\n */\n addDays(date: string, amount: number): string {\n return this.toISO(addDays(this.toDate(date), amount));\n }\n\n /**\n */\n addWeeks(date: string, amount: number): string {\n return this.toISO(addWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n addMonths(date: string, amount: number): string {\n return this.toISO(addMonths(this.toDate(date), amount));\n }\n\n /**\n */\n addYears(date: string, amount: number): string {\n return this.toISO(addYears(this.toDate(date), amount));\n }\n\n /**\n */\n subtractSeconds(date: string, amount: number): string {\n return this.toISO(subSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMinutes(date: string, amount: number): string {\n return this.toISO(subMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n subtractHours(date: string, amount: number): string {\n return this.toISO(subHours(this.toDate(date), amount));\n }\n\n /**\n */\n subtractDays(date: string, amount: number): string {\n return this.toISO(subDays(this.toDate(date), amount));\n }\n\n /**\n */\n subtractWeeks(date: string, amount: number): string {\n return this.toISO(subWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMonths(date: string, amount: number): string {\n return this.toISO(subMonths(this.toDate(date), amount));\n }\n\n /**\n */\n subtractYears(date: string, amount: number): string {\n return this.toISO(subYears(this.toDate(date), amount));\n }\n\n /**\n * GETTERS\n */\n startOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(startOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n endOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(endOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n startOfWeek(date: string, inputFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n return this.toISO(\n startOfWeek(this.toDate(date, inputFormat), {\n weekStartsOn,\n })\n );\n }\n\n /**\n */\n getHours(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getHours(parsedDate);\n }\n\n /**\n */\n getMinutes(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getMinutes(parsedDate);\n }\n\n /**\n */\n getWeek(date: string): number {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return getWeek(this.toDate(date), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n * SETTERS\n */\n setYear(date: string, year: number): string {\n return this.toISO(setYear(this.toDate(date), year));\n }\n\n /**\n */\n setMonth(date: string, month: number): string {\n return this.toISO(setMonth(this.toDate(date), month));\n }\n\n /**\n */\n setHour(date: string, hour: number): string {\n return this.toISO(setHours(this.toDate(date), hour));\n }\n\n /**\n */\n setMinute(date: string, minute: number): string {\n return this.toISO(setMinutes(this.toDate(date), minute));\n }\n\n /**\n */\n setSecond(date: string, second: number): string {\n return this.toISO(setSeconds(this.toDate(date), second));\n }\n\n /**\n */\n setMilliseconds(date: string, milliseconds: number): string {\n return this.toISO(setMilliseconds(this.toDate(date), milliseconds));\n }\n\n /**\n */\n setTime(\n date: string,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number\n ): string {\n return this.toISO(\n set(this.toDate(date), {\n hours,\n minutes,\n seconds,\n milliseconds,\n })\n );\n }\n}\n\n/**\n * DateUtil\n */\nconst DateUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_DATE_FORMAT);\n\n/**\n * DateTimeUtil\n */\nconst DateTimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_DATETIME_FORMAT\n);\n\n/**\n * TimeUtil\n */\nconst TimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_TIME_FORMAT);\n\n/**\n * TimestampUtil\n */\nconst TimestampUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_TIMESTAMP_FORMAT\n);\n\nexport { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil };\n"],"mappings":";;;AACA,SACEA,KADF,EAEEC,MAFF,EAGEC,OAAO,IAAPA,QAHF,EAIEC,OAAO,IAAPA,QAJF,EAKEC,QAAQ,IAARA,SALF,EAMEC,SAAS,IAATA,UANF,EAOEC,UAAU,IAAVA,WAPF,EAQEC,UAAU,IAAVA,WARF,EASEC,QAAQ,IAARA,SATF,EAUEC,OAAO,IAAPA,QAVF,EAWEC,QAAQ,IAARA,SAXF,EAYEC,SAAS,IAATA,UAZF,EAaEC,QAAQ,IAARA,SAbF,EAcEC,UAdF,EAeEC,UAfF,EAgBEC,QAhBF,EAiBEC,OAjBF,EAkBEC,QAlBF,EAmBEC,SAnBF,EAoBEC,QApBF,EAqBEC,YA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imeUtil.js","names":["parse","format","isValid","isAfter","isBefore","isSameDay","addSeconds","addMinutes","addHours","addDays","addWeeks","addMonths","addYears","subSeconds","subMinutes","subHours","subDays","subWeeks","subMonths","subYears","startOfMonth","endOfMonth","startOfWeek","getHours","getMinutes","getDay","getWeek","setMilliseconds","setSeconds","setMinutes","setHours","setMonth","setYear","set","nl","enGB","getCookie","getSetting","ISO_DATE_FORMAT","ISO_DATETIME_FORMAT","ISO_TIME_FORMAT","ISO_TIMESTAMP_FORMAT","DEFAULT_WEEK_STARTS_ON","DEFAULT_FIRST_WEEK_CONTAINS_DATE","BaseDateTimeUtil","isoFormat","_isoFormat","locale","weekStartsOn","firstWeekContainsDate","date","inputFormat","getOptions","Date","targetFormat","parsedDate","toDate","getLocale","sourceFormat","toISO","realDate","formattedValue","isOutsideRange","replace","toUpperCase","inputDate","afterISODate","isSame","beforeISODate","compareDate","getTime","SATURDAY_NUMBER","SUNDAY_NUMBER","weekDay","amount","year","month","hour","minute","second","milliseconds","hours","minutes","seconds","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil"],"sources":["../../../src/utils/datetime/DateTimeUtil.js"],"sourcesContent":["// @flow\nimport {\n parse,\n format,\n isValid,\n isAfter,\n isBefore,\n isSameDay,\n addSeconds,\n addMinutes,\n addHours,\n addDays,\n addWeeks,\n addMonths,\n addYears,\n subSeconds,\n subMinutes,\n subHours,\n subDays,\n subWeeks,\n subMonths,\n subYears,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getHours,\n getMinutes,\n getDay,\n getWeek,\n setMilliseconds,\n setSeconds,\n setMinutes,\n setHours,\n setMonth,\n setYear,\n set,\n} from \"date-fns\";\nimport { nl, enGB } from \"date-fns/locale\";\n\nimport { getCookie } from \"../browser/Cookies\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport {\n ISO_DATE_FORMAT,\n ISO_DATETIME_FORMAT,\n ISO_TIME_FORMAT,\n ISO_TIMESTAMP_FORMAT,\n DEFAULT_WEEK_STARTS_ON,\n DEFAULT_FIRST_WEEK_CONTAINS_DATE,\n} from \"../../constants\";\n\n/**\n * @hideconstructor\n */\nclass BaseDateTimeUtil {\n _isoFormat: string;\n\n constructor(isoFormat: string) {\n this._isoFormat = isoFormat;\n }\n\n /**\n */\n getLocale(): typeof nl | typeof enGB {\n const locale = getCookie(\"locale\") ?? \"en\";\n\n if (locale === \"nl\") {\n return nl;\n }\n\n return enGB;\n }\n\n // returns the options defined in settings\n getOptions(): {\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6,\n firstWeekContainsDate: 1 | 2 | 3 | 4 | 5 | 6 | 7,\n } {\n // indicates on what day the week starts\n const weekStartsOn = getSetting(\n \"CALENDAR_WEEK_STARTS_ON\",\n DEFAULT_WEEK_STARTS_ON\n );\n\n // indicates which date indicates the first week of the year\n const firstWeekContainsDate = getSetting(\n \"CALENDAR_FIRST_WEEK_CONTAINS_DATE\",\n DEFAULT_FIRST_WEEK_CONTAINS_DATE\n );\n\n return { weekStartsOn, firstWeekContainsDate };\n }\n\n /**\n */\n toDate(date: string, inputFormat: string = this._isoFormat): Date {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return parse(date, inputFormat, new Date(), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n */\n toFormat(date: string | Date, targetFormat: string): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, targetFormat, {\n weekStartsOn,\n locale: this.getLocale(),\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n toISO(date: string | Date, sourceFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate =\n typeof date === \"string\" ? this.toDate(date, sourceFormat) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, this._isoFormat, {\n weekStartsOn,\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n now(): string {\n return this.toISO(new Date());\n }\n\n /**\n */\n convertFormat(sourceFormat: string): string {\n return sourceFormat ? sourceFormat : this._isoFormat;\n }\n\n /**\n * VALIDATION\n */\n hasFormat(date: string, sourceFormat: string): boolean {\n const { weekStartsOn } = this.getOptions();\n\n const realDate = this.toDate(date, sourceFormat);\n if (isValid(realDate)) {\n const formattedValue = format(realDate, sourceFormat, {\n weekStartsOn,\n });\n\n const isOutsideRange =\n isBefore(realDate, new Date(1000, 1, 1)) ||\n isAfter(realDate, new Date(9999, 11, 31));\n if (isOutsideRange) {\n return false;\n }\n\n return (\n formattedValue.replace(/0/gu, \"\").toUpperCase() ===\n date.replace(/0/gu, \"\").toUpperCase()\n );\n }\n\n return false;\n }\n\n /**\n */\n isValid(date: string, inputFormat: string = this._isoFormat): boolean {\n return isValid(this.toDate(date, inputFormat));\n }\n\n /**\n */\n isAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n isAfter(this.toDate(inputDate, inputFormat), this.toDate(afterISODate))\n );\n }\n\n /**\n */\n isSameOrAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n (this.isAfter(inputDate, afterISODate, inputFormat) ||\n this.isSame(inputDate, afterISODate, inputFormat))\n );\n }\n\n /**\n */\n isBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n isBefore(this.toDate(inputDate, inputFormat), this.toDate(beforeISODate))\n );\n }\n\n /**\n */\n isSameOrBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n (this.isBefore(inputDate, beforeISODate, inputFormat) ||\n this.isSame(inputDate, beforeISODate, inputFormat))\n );\n }\n\n /**\n */\n isSame(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n this.toDate(inputDate, inputFormat).getTime() ===\n this.toDate(compareDate).getTime()\n );\n }\n\n /**\n */\n isSameDay(\n inputDate: string,\n compareDate: string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n isSameDay(\n this.toDate(inputDate, inputFormat),\n this.toDate(compareDate, inputFormat)\n )\n );\n }\n\n /**\n */\n isOther(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return !this.isSame(inputDate, compareDate, inputFormat);\n }\n\n /**\n */\n isWeekend(inputDate: string): boolean {\n const SATURDAY_NUMBER = 6;\n const SUNDAY_NUMBER = 0;\n const weekDay = getDay(this.toDate(inputDate));\n\n return weekDay === SATURDAY_NUMBER || weekDay === SUNDAY_NUMBER;\n }\n\n /**\n * CALCULATIONS\n */\n addSeconds(date: string, amount: number): string {\n return this.toISO(addSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n addMinutes(date: string, amount: number): string {\n return this.toISO(addMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n addHours(date: string, amount: number): string {\n return this.toISO(addHours(this.toDate(date), amount));\n }\n\n /**\n */\n addDays(date: string, amount: number): string {\n return this.toISO(addDays(this.toDate(date), amount));\n }\n\n /**\n */\n addWeeks(date: string, amount: number): string {\n return this.toISO(addWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n addMonths(date: string, amount: number): string {\n return this.toISO(addMonths(this.toDate(date), amount));\n }\n\n /**\n */\n addYears(date: string, amount: number): string {\n return this.toISO(addYears(this.toDate(date), amount));\n }\n\n /**\n */\n subtractSeconds(date: string, amount: number): string {\n return this.toISO(subSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMinutes(date: string, amount: number): string {\n return this.toISO(subMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n subtractHours(date: string, amount: number): string {\n return this.toISO(subHours(this.toDate(date), amount));\n }\n\n /**\n */\n subtractDays(date: string, amount: number): string {\n return this.toISO(subDays(this.toDate(date), amount));\n }\n\n /**\n */\n subtractWeeks(date: string, amount: number): string {\n return this.toISO(subWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMonths(date: string, amount: number): string {\n return this.toISO(subMonths(this.toDate(date), amount));\n }\n\n /**\n */\n subtractYears(date: string, amount: number): string {\n return this.toISO(subYears(this.toDate(date), amount));\n }\n\n /**\n * GETTERS\n */\n startOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(startOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n endOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(endOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n startOfWeek(date: string, inputFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n return this.toISO(\n startOfWeek(this.toDate(date, inputFormat), {\n weekStartsOn,\n })\n );\n }\n\n /**\n */\n getHours(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getHours(parsedDate);\n }\n\n /**\n */\n getMinutes(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getMinutes(parsedDate);\n }\n\n /**\n */\n getWeek(date: string): number {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return getWeek(this.toDate(date), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n * SETTERS\n */\n setYear(date: string, year: number): string {\n return this.toISO(setYear(this.toDate(date), year));\n }\n\n /**\n */\n setMonth(date: string, month: number): string {\n return this.toISO(setMonth(this.toDate(date), month));\n }\n\n /**\n */\n setHour(date: string, hour: number): string {\n return this.toISO(setHours(this.toDate(date), hour));\n }\n\n /**\n */\n setMinute(date: string, minute: number): string {\n return this.toISO(setMinutes(this.toDate(date), minute));\n }\n\n /**\n */\n setSecond(date: string, second: number): string {\n return this.toISO(setSeconds(this.toDate(date), second));\n }\n\n /**\n */\n setMilliseconds(date: string, milliseconds: number): string {\n return this.toISO(setMilliseconds(this.toDate(date), milliseconds));\n }\n\n /**\n */\n setTime(\n date: string,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number\n ): string {\n return this.toISO(\n set(this.toDate(date), {\n hours,\n minutes,\n seconds,\n milliseconds,\n })\n );\n }\n}\n\n/**\n * DateUtil\n */\nconst DateUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_DATE_FORMAT);\n\n/**\n * DateTimeUtil\n */\nconst DateTimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_DATETIME_FORMAT\n);\n\n/**\n * TimeUtil\n */\nconst TimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_TIME_FORMAT);\n\n/**\n * TimestampUtil\n */\nconst TimestampUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_TIMESTAMP_FORMAT\n);\n\nexport { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil };\n"],"mappings":";;;AACA,SACEA,KADF,EAEEC,MAFF,EAGEC,OAAO,IAAPA,QAHF,EAIEC,OAAO,IAAPA,QAJF,EAKEC,QAAQ,IAARA,SALF,EAMEC,SAAS,IAATA,UANF,EAOEC,UAAU,IAAVA,WAPF,EAQEC,UAAU,IAAVA,WARF,EASEC,QAAQ,IAARA,SATF,EAUEC,OAAO,IAAPA,QAVF,EAWEC,QAAQ,IAARA,SAXF,EAYEC,SAAS,IAATA,UAZF,EAaEC,QAAQ,IAARA,SAbF,EAcEC,UAdF,EAeEC,UAfF,EAgBEC,QAhBF,EAiBEC,OAjBF,EAkBEC,QAlBF,EAmBEC,SAnBF,EAoBEC,QApBF,EAqBEC,YAAY,IAAZA,aArBF,EAsBEC,UAAU,IAAVA,WAtBF,EAuBEC,WAAW,IAAXA,YAvBF,EAwBEC,QAAQ,IAARA,SAxBF,EAyBEC,UAAU,IAAVA,WAzBF,EA0BEC,MA1BF,EA2BEC,OAAO,IAAPA,QA3BF,EA4BEC,eAAe,IAAfA,gBA5BF,EA6BEC,UA7BF,EA8BEC,UA9BF,EA+BE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AW/B,UAAU,CAAC,KAAK4B,MAAL,CAAYN,IAAZ,CAAD,EAAoB6B,MAApB,CAArB,CAAP;IACD;IAED;AACF;;;;WACE,yBAAgB7B,IAAhB,EAA8B8B,YAA9B,EAA4D;MAC1D,OAAO,KAAKrB,KAAL,CAAWhC,gBAAe,CAAC,KAAK6B,MAAL,CAAYN,IAAZ,CAAD,EAAoB8B,YAApB,CAA1B,CAAP;IACD;IAED;AACF;;;;WACE,iBACE9B,IADF,EAEE+B,KAFF,EAGEC,OAHF,EAIEC,OAJF,EAKEH,YALF,EAMU;MACR,OAAO,KAAKrB,KAAL,CACL1B,GAAG,CAAC,KAAKuB,MAAL,CAAYN,IAAZ,CAAD,EAAoB;QACrB+B,KAAK,EAALA,KADqB;QAErBC,OAAO,EAAPA,OAFqB;QAGrBC,OAAO,EAAPA,OAHqB;QAIrBH,YAAY,EAAZA;MAJqB,CAApB,CADE,CAAP;IAQD;;;;;AAGH;AACA;AACA;;;AACA,IAAMI,QAA0B,GAAG,IAAIxC,gBAAJ,CAAqBN,eAArB,CAAnC;AAEA;AACA;AACA;;AACA,IAAM+C,YAA8B,GAAG,IAAIzC,gBAAJ,CACrCL,mBADqC,CAAvC;AAIA;AACA;AACA;;AACA,IAAM+C,QAA0B,GAAG,IAAI1C,gBAAJ,CAAqBJ,eAArB,CAAnC;AAEA;AACA;AACA;;AACA,IAAM+C,aAA+B,GAAG,IAAI3C,gBAAJ,CACtCH,oBADsC,CAAxC;AAIA,SAAS2C,QAAT,EAAmBC,YAAnB,EAAiCC,QAAjC,EAA2CC,aAA3C"}
@@ -61,10 +61,6 @@ describe("authentication hooks", () => {
61
61
 
62
62
  expect(store.getActions()).toStrictEqual([
63
63
  { type: "START_PROGRESS" },
64
- {
65
- type: "MODULARUI/REMOVE_KEY",
66
- payload: "application(/)(en)",
67
- },
68
64
  {
69
65
  type: "MODULARUI/STATUS",
70
66
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -112,10 +108,6 @@ describe("authentication hooks", () => {
112
108
  expect(store.getActions()).toStrictEqual([
113
109
  { type: "START_PROGRESS" },
114
110
  { type: "MODULARUI/RESET" },
115
- {
116
- type: "MODULARUI/REMOVE_KEY",
117
- payload: "application(/)(en)",
118
- },
119
111
  {
120
112
  type: "MODULARUI/STATUS",
121
113
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -19,14 +19,14 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/hel
19
19
 
20
20
  var _react = require("react");
21
21
 
22
- var _reactRedux = require("react-redux");
23
-
24
22
  var _SourceReferenceCollection = _interopRequireDefault(require("../models/concepts/SourceReferenceCollection"));
25
23
 
26
24
  var _ModularUIRequest = _interopRequireDefault(require("../modularui/ModularUIRequest"));
27
25
 
28
26
  var _useProgressIndicator2 = require("../hooks/useProgressIndicator");
29
27
 
28
+ var _useI18n = require("../hooks/useI18n");
29
+
30
30
  /**
31
31
  * Hook to retrieve multiple source references at once
32
32
  */
@@ -38,11 +38,7 @@ var useContentFromSourceReferences = function useContentFromSourceReferences(sou
38
38
  content = _useState2[0],
39
39
  setContent = _useState2[1];
40
40
 
41
- var localeCode = (0, _reactRedux.useSelector)(function (state) {
42
- var _state$i18n$locale;
43
-
44
- return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
45
- });
41
+ var localeCode = (0, _useI18n.useLocale)();
46
42
 
47
43
  var _useProgressIndicator = (0, _useProgressIndicator2.useProgressIndicator)(),
48
44
  start = _useProgressIndicator.start,
@@ -1,11 +1,11 @@
1
1
  // @flow
2
2
  import { useState, useEffect } from "react";
3
- import { useSelector } from "react-redux";
4
3
 
5
4
  import SourceReferenceCollection from "../models/concepts/SourceReferenceCollection";
6
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
7
6
 
8
7
  import { useProgressIndicator } from "../hooks/useProgressIndicator";
8
+ import { useLocale } from "../hooks/useI18n";
9
9
 
10
10
  import type ContentModel from "../models/content/ContentModel";
11
11
 
@@ -17,7 +17,7 @@ export const useContentFromSourceReferences = (
17
17
  renderChildSections: boolean
18
18
  ): Array<ContentModel> => {
19
19
  const [content, setContent] = useState([]);
20
- const localeCode = useSelector((state) => state.i18n.locale ?? "en");
20
+ const localeCode = useLocale();
21
21
 
22
22
  const { start, finish } = useProgressIndicator();
23
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"useContent.js","names":["useContentFromSourceReferences","sourceReferences","renderChildSections","useState","content","setContent","localeCode","useSelector","state","i18n","locale","useProgressIndicator","start","finish","hrefs","sourceReference","link","selfhref","href","index","self","indexOf","toString","allHrefs","useEffect","requests","JSON","parse","modularuiRequest","ModularUIRequest","fetchContent","all","then","responseContent"],"sources":["../../src/hooks/useContent.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\nimport { useSelector } from \"react-redux\";\n\nimport SourceReferenceCollection from \"../models/concepts/SourceReferenceCollection\";\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport { useProgressIndicator } from \"../hooks/useProgressIndicator\";\n\nimport type ContentModel from \"../models/content/ContentModel\";\n\n/**\n * Hook to retrieve multiple source references at once\n */\nexport const useContentFromSourceReferences = (\n sourceReferences: SourceReferenceCollection,\n renderChildSections: boolean\n): Array<ContentModel> => {\n const [content, setContent] = useState([]);\n const localeCode = useSelector((state) => state.i18n.locale ?? \"en\");\n\n const { start, finish } = useProgressIndicator();\n\n const hrefs = sourceReferences\n .map((sourceReference) => sourceReference.link.selfhref.href)\n .filter((href, index, self) => self.indexOf(href) === index)\n .map((href) => href.toString());\n\n const allHrefs = JSON.stringify(hrefs);\n useEffect(() => {\n const requests = JSON.parse(allHrefs).map((href) => {\n const modularuiRequest = new ModularUIRequest(href);\n modularuiRequest.locale = localeCode;\n return modularuiRequest.fetchContent(renderChildSections);\n });\n\n start();\n Promise.all(requests).then((responseContent) => {\n setContent(responseContent);\n finish();\n });\n\n // start and finish don't change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allHrefs,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B,CAA8B5B,mBAA9B,CAAP;IACD,CAJgB,CAAjB;IAMAU,KAAK;;IACL,iBAAQmB,GAAR,CAAYN,QAAZ,EAAsBO,IAAtB,CAA2B,UAACC,eAAD,EAAqB;MAC9C5B,UAAU,CAAC4B,eAAD,CAAV;MACApB,MAAM;IACP,CAHD,EARc,CAad;IACA;;EACD,CAfD,EAeG,CAACU,QAAD,EAAWjB,UAAX,EAAuBJ,mBAAvB,CAfH;EAiBA,OAAOE,OAAP;AACD,CAjCM"}
1
+ {"version":3,"file":"useContent.js","names":["useContentFromSourceReferences","sourceReferences","renderChildSections","useState","content","setContent","localeCode","useLocale","useProgressIndicator","start","finish","hrefs","sourceReference","link","selfhref","href","index","self","indexOf","toString","allHrefs","useEffect","requests","JSON","parse","modularuiRequest","ModularUIRequest","locale","fetchContent","all","then","responseContent"],"sources":["../../src/hooks/useContent.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport SourceReferenceCollection from \"../models/concepts/SourceReferenceCollection\";\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport { useProgressIndicator } from \"../hooks/useProgressIndicator\";\nimport { useLocale } from \"../hooks/useI18n\";\n\nimport type ContentModel from \"../models/content/ContentModel\";\n\n/**\n * Hook to retrieve multiple source references at once\n */\nexport const useContentFromSourceReferences = (\n sourceReferences: SourceReferenceCollection,\n renderChildSections: boolean\n): Array<ContentModel> => {\n const [content, setContent] = useState([]);\n const localeCode = useLocale();\n\n const { start, finish } = useProgressIndicator();\n\n const hrefs = sourceReferences\n .map((sourceReference) => sourceReference.link.selfhref.href)\n .filter((href, index, self) => self.indexOf(href) === index)\n .map((href) => href.toString());\n\n const allHrefs = JSON.stringify(hrefs);\n useEffect(() => {\n const requests = JSON.parse(allHrefs).map((href) => {\n const modularuiRequest = new ModularUIRequest(href);\n modularuiRequest.locale = localeCode;\n return modularuiRequest.fetchContent(renderChildSections);\n });\n\n start();\n Promise.all(requests).then((responseContent) => {\n setContent(responseContent);\n finish();\n });\n\n // start and finish don't change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allHrefs, localeCode, renderChildSections]);\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AAIA;AACA;AACA;AACO,IAAMA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAC5CC,gBAD4C,EAE5CC,mBAF4C,EAGpB;EAAA;;EACxB,gBAA8B,IAAAC,eAAA,EAAS,EAAT,CAA9B;EAAA;EAAA,IAAOC,OAAP;EAAA,IAAgBC,UAAhB;;EACA,IAAMC,UAAU,GAAG,IAAAC,kBAAA,GAAnB;;EAEA,4BAA0B,IAAAC,2CAAA,GAA1B;EAAA,IAAQC,KAAR,yBAAQA,KAAR;EAAA,IAAeC,MAAf,yBAAeA,MAAf;;EAEA,IAAMC,KAAK,GAAG,gFAAAV,gBAAgB,MAAhB,CAAAA,gBAAgB,EACvB,UAACW,eAAD;IAAA,OAAqBA,eAAe,CAACC,IAAhB,CAAqBC,QAArB,CAA8BC,IAAnD;EAAA,CADuB,CAAhB,kBAEJ,UAACA,IAAD,EAAOC,KAAP,EAAcC,IAAd;IAAA,OAAuBA,IAAI,CAACC,OAAL,CAAaH,IAAb,MAAuBC,KAA9C;EAAA,CAFI,kBAGP,UAACD,IAAD;IAAA,OAAUA,IAAI,CAACI,QAAL,EAAV;EAAA,CAHO,CAAd;EAKA,IAAMC,QAAQ,GAAG,wBAAeT,KAAf,CAAjB;EACA,IAAAU,gBAAA,EAAU,YAAM;IAAA;;IACd,IAAMC,QAAQ,GAAG,8BAAAC,IAAI,CAACC,KAAL,CAAWJ,QAAX,mBAAyB,UAACL,IAAD,EAAU;MAClD,IAAMU,gBAAgB,GAAG,IAAIC,yBAAJ,CAAqBX,IAArB,CAAzB;MACAU,gBAAgB,CAACE,MAAjB,GAA0BrB,UAA1B;MACA,OAAOmB,gBAAgB,CAACG,YAAjB,CAA8B1B,mBAA9B,CAAP;IACD,CAJgB,CAAjB;IAMAO,KAAK;;IACL,iBAAQoB,GAAR,CAAYP,QAAZ,EAAsBQ,IAAtB,CAA2B,UAACC,eAAD,EAAqB;MAC9C1B,UAAU,CAAC0B,eAAD,CAAV;MACArB,MAAM;IACP,CAHD,EARc,CAad;IACA;;EACD,CAfD,EAeG,CAACU,QAAD,EAAWd,UAAX,EAAuBJ,mBAAvB,CAfH;EAiBA,OAAOE,OAAP;AACD,CAjCM"}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.useTranslate = exports.useMessage = void 0;
8
+ exports.useTranslate = exports.useMessage = exports.useLocale = void 0;
9
9
 
10
10
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
11
11
 
@@ -15,15 +15,9 @@ var _reselect = require("reselect");
15
15
 
16
16
  var _memoize = _interopRequireDefault(require("lodash/memoize"));
17
17
 
18
- var getLocaleCode = function getLocaleCode(state) {
19
- return state.i18n.locale || "en";
20
- };
21
-
22
- var getLocales = function getLocales(state) {
23
- return state.i18n.locales;
24
- };
18
+ var _i18n = require("../redux/selectors/i18n");
25
19
 
26
- var getMessage = (0, _reselect.createSelector)([getLocales, getLocaleCode], function (locales, localeCode) {
20
+ var getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], function (locales, localeCode) {
27
21
  return (0, _memoize.default)(function (id, defaultMessage, placeholders) {
28
22
  return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
29
23
  }, function () {
@@ -49,6 +43,15 @@ exports.useMessage = useMessage;
49
43
  var useTranslate = function useTranslate() {
50
44
  return (0, _reactRedux.useSelector)(getMessage);
51
45
  };
46
+ /**
47
+ */
48
+
52
49
 
53
50
  exports.useTranslate = useTranslate;
51
+
52
+ var useLocale = function useLocale() {
53
+ return (0, _reactRedux.useSelector)(_i18n.getLocale);
54
+ };
55
+
56
+ exports.useLocale = useLocale;
54
57
  //# sourceMappingURL=useI18n.js.map
@@ -3,18 +3,13 @@ import { useSelector } from "react-redux";
3
3
  import { createSelector } from "reselect";
4
4
  import memoize from "lodash/memoize";
5
5
 
6
- const getLocaleCode = (state) => state.i18n.locale || "en";
7
- const getLocales = (state) => state.i18n.locales;
6
+ import { getLocales, getLocale } from "../redux/selectors/i18n";
8
7
 
9
8
  const getMessage = createSelector(
10
- [getLocales, getLocaleCode],
9
+ [getLocales, getLocale],
11
10
  (locales, localeCode) =>
12
11
  memoize(
13
- (
14
- id?: string | null,
15
- defaultMessage?: string | null,
16
- placeholders?: Object
17
- ) =>
12
+ (id: string, defaultMessage?: string, placeholders?: Object) =>
18
13
  locales
19
14
  .getLocale(localeCode)
20
15
  .getMessage(id, defaultMessage, placeholders),
@@ -25,8 +20,8 @@ const getMessage = createSelector(
25
20
  /**
26
21
  */
27
22
  const useMessage = (
28
- id?: string | null,
29
- defaultMessage?: string | null,
23
+ id: string,
24
+ defaultMessage?: string,
30
25
  placeholders?: Object | null
31
26
  ): any => useSelector(getMessage)(id, defaultMessage, placeholders);
32
27
 
@@ -34,4 +29,8 @@ const useMessage = (
34
29
  */
35
30
  const useTranslate = (): ((...any) => any) => useSelector(getMessage);
36
31
 
37
- export { useTranslate, useMessage };
32
+ /**
33
+ */
34
+ const useLocale = (): string => useSelector(getLocale);
35
+
36
+ export { useTranslate, useMessage, useLocale };
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.js","names":["getLocaleCode","state","i18n","locale","getLocales","locales","getMessage","createSelector","localeCode","memoize","id","defaultMessage","placeholders","getLocale","args","useMessage","useSelector","useTranslate"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nconst getLocaleCode = (state) => state.i18n.locale || \"en\";\nconst getLocales = (state) => state.i18n.locales;\n\nconst getMessage = createSelector(\n [getLocales, getLocaleCode],\n (locales, localeCode) =>\n memoize(\n (\n id?: string | null,\n defaultMessage?: string | null,\n placeholders?: Object\n ) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\n/**\n */\nconst useMessage = (\n id?: string | null,\n defaultMessage?: string | null,\n placeholders?: Object | null\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\nexport { useTranslate, useMessage };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWC,MAAX,IAAqB,IAAhC;AAAA,CAAtB;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACH,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWG,OAAtB;AAAA,CAAnB;;AAEA,IAAMC,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACH,UAAD,EAAaJ,aAAb,CADiB,EAEjB,UAACK,OAAD,EAAUG,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UACEC,EADF,EAEEC,cAFF,EAGEC,YAHF;IAAA,OAKEP,OAAO,CACJQ,SADH,CACaL,UADb,EAEGF,UAFH,CAEcI,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CALF;EAAA,CADF,EASE;IAAA,kCAAIE,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CATF,CADF;AAAA,CAFiB,CAAnB;AAgBA;AACA;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBL,EADiB,EAEjBC,cAFiB,EAGjBC,YAHiB;EAAA,OAIT,IAAAI,uBAAA,EAAYV,UAAZ,EAAwBI,EAAxB,EAA4BC,cAA5B,EAA4CC,YAA5C,CAJS;AAAA,CAAnB;AAMA;AACA;;;;;AACA,IAAMK,YAAY,GAAG,SAAfA,YAAe;EAAA,OAAyB,IAAAD,uBAAA,EAAYV,UAAZ,CAAzB;AAAA,CAArB"}
1
+ {"version":3,"file":"useI18n.js","names":["getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","useMessage","useSelector","useTranslate","useLocale"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\nexport { useTranslate, useMessage, useLocale };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA,IAAMA,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACC,gBAAD,EAAaC,eAAb,CADiB,EAEjB,UAACC,OAAD,EAAUC,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEL,OAAO,CACJD,SADH,CACaE,UADb,EAEGL,UAFH,CAEcO,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;AAYA;AACA;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBJ,EADiB,EAEjBC,cAFiB,EAGjBC,YAHiB;EAAA,OAIT,IAAAG,uBAAA,EAAYZ,UAAZ,EAAwBO,EAAxB,EAA4BC,cAA5B,EAA4CC,YAA5C,CAJS;AAAA,CAAnB;AAMA;AACA;;;;;AACA,IAAMI,YAAY,GAAG,SAAfA,YAAe;EAAA,OAAyB,IAAAD,uBAAA,EAAYZ,UAAZ,CAAzB;AAAA,CAArB;AAEA;AACA;;;;;AACA,IAAMc,SAAS,GAAG,SAAZA,SAAY;EAAA,OAAc,IAAAF,uBAAA,EAAYT,eAAZ,CAAd;AAAA,CAAlB"}
@@ -19,14 +19,14 @@ var _actions = require("../redux/_modularui/actions");
19
19
 
20
20
  var _useDeepCompareEffect = _interopRequireDefault(require("./useDeepCompareEffect"));
21
21
 
22
+ var _useI18n = require("./useI18n");
23
+
22
24
  /**
23
25
  */
24
26
  var useKeyForHook = function useKeyForHook(modelKey, url) {
25
27
  var _context, _context2;
26
28
 
27
- var locale = (0, _reactRedux.useSelector)(function (state) {
28
- return state.i18n.locale;
29
- });
29
+ var locale = (0, _useI18n.useLocale)();
30
30
  return (0, _concat.default)(_context = (0, _concat.default)(_context2 = "".concat(modelKey, "(")).call(_context2, url.split("?")[0], ")(")).call(_context, locale, ")");
31
31
  };
32
32
  /**
@@ -7,14 +7,15 @@ import { loadModularUI, removeModelByKey } from "../redux/_modularui/actions";
7
7
 
8
8
  import useDeepCompareEffect from "./useDeepCompareEffect";
9
9
 
10
+ import { useLocale } from "./useI18n";
11
+
10
12
  import type Href from "../models/href/Href";
11
13
  import type { RequestBaseOptions } from "../utils";
12
14
 
13
15
  /**
14
16
  */
15
17
  const useKeyForHook = (modelKey: string, url: string) => {
16
- const locale = useSelector((state) => state.i18n.locale);
17
-
18
+ const locale = useLocale();
18
19
  return `${modelKey}(${url.split("?")[0]})(${locale})`;
19
20
  };
20
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useKeyForHook","modelKey","url","locale","useSelector","state","i18n","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui/actions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useSelector((state) => state.i18n.locale);\n\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestBaseOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n }\n): any => {\n const dispatch = useDispatch();\n const href = url.toString();\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (!isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAKA;AACA;AACA,IA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,CAbH;EAeA,4BAAoCA,OAApC,CAAQI,eAAR;EAAA,IAAQA,eAAR,sCAA0B,KAA1B;EACA,IAAAc,gBAAA,EAAU,YAAM;IACd,OAAO,YAAM;MACX,IAAId,eAAJ,EAAqB;QACnBC,QAAQ,CAAC,IAAAc,yBAAA,EAAiBV,GAAjB,CAAD,CAAR;MACD;IACF,CAJD;EAKD,CAND,EAMG,CAACJ,QAAD,EAAWI,GAAX,EAAgBL,eAAhB,CANH,EAzBQ,CAiCR;;EACA,OAAO,IAAAT,uBAAA,EAAY,UAACC,KAAD,EAAW;IAC5B,OAAOA,KAAK,CAACwB,SAAN,CAAgBX,GAAhB,CAAP;EACD,CAFM,CAAP;AAGD,CA5CM"}
1
+ {"version":3,"file":"useModularUI.js","names":["useKeyForHook","modelKey","url","locale","useLocale","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","useSelector","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui/actions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestBaseOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n }\n): any => {\n const dispatch = useDispatch();\n const href = url.toString();\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (!isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AAKA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,QAAD,EAAmBC,GAAnB,EAAmC;EAAA;;EACvD,IAAMC,MAAM,GAAG,IAAAC,kBAAA,GAAf;EACA,kFAAUH,QAAV,wBAAsBC,GAAG,CAACG,KAAJ,CAAU,GAAV,EAAe,CAAf,CAAtB,wBAA4CF,MAA5C;AACD,CAHD;AAKA;AACA;AACA;;;AACO,IAAMG,YAAY,GAAG,SAAfA,YAAe,CAC1BL,QAD0B,EAE1BC,GAF0B,EAOlB;EAAA,IAJRK,OAIQ,uEAJsB;IAC5BC,MAAM,EAAEC,uBAAA,CAAaC,GADO;IAE5BC,eAAe,EAAE;EAFW,CAItB;EACR,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EACA,IAAMC,IAAI,GAAGZ,GAAG,CAACa,QAAJ,EAAb;EACA,IAAMC,GAAG,GAAGhB,aAAa,CAACC,QAAD,EAAWa,IAAX,CAAzB;EAEA,IAAMG,WAAW,GAAG,IAAAC,aAAA,EAAOX,OAAP,CAApB;EACA,IAAMY,QAAQ,GAAG,IAAAD,aAAA,EAAOJ,IAAP,CAAjB,CANQ,CAQR;;EACA,IAAAM,6BAAA,EAAqB,YAAM;IACzB;IACA,IAAMC,WAAW,GACfF,QAAQ,CAACG,OAAT,KAAqBR,IAArB,IACAG,WAAW,CAACK,OAAZ,CAAoBC,QADpB,IAEA,CAAChB,OAAO,CAACgB,QAHX;;IAKA,IAAI,CAACF,WAAL,EAAkB;MAChBT,QAAQ,CAAC,IAAAY,sBAAA,EAAcR,GAAd,EAAmBF,IAAnB,EAAyBP,OAAzB,CAAD,CAAR;IACD;;IAEDU,WAAW,CAACK,OAAZ,GAAsBf,OAAtB;IACAY,QAAQ,CAACG,OAAT,GAAmBR,IAAnB;EACD,CAbD,EAaG,CAACE,GAAD,EAAMF,IAAN,EAAYP,OAAZ,CAbH;EAeA,4BAAoCA,OAApC,CAAQI,eAAR;EAAA,IAAQA,eAAR,sCAA0B,KAA1B;EACA,IAAAc,gBAAA,EAAU,YAAM;IACd,OAAO,YAAM;MACX,IAAId,eAAJ,EAAqB;QACnBC,QAAQ,CAAC,IAAAc,yBAAA,EAAiBV,GAAjB,CAAD,CAAR;MACD;IACF,CAJD;EAKD,CAND,EAMG,CAACJ,QAAD,EAAWI,GAAX,EAAgBL,eAAhB,CANH,EAzBQ,CAiCR;;EACA,OAAO,IAAAgB,uBAAA,EAAY,UAACC,KAAD,EAAW;IAC5B,OAAOA,KAAK,CAACC,SAAN,CAAgBb,GAAhB,CAAP;EACD,CAFM,CAAP;AAGD,CA5CM"}
@@ -13,11 +13,9 @@ var _reactRedux = require("react-redux");
13
13
 
14
14
  var _ModularUIRequest = _interopRequireDefault(require("../modularui/ModularUIRequest"));
15
15
 
16
- var getModularUIRequest = (0, _reselect.createSelector)([function (state) {
17
- var _state$i18n$locale;
16
+ var _i18n = require("../redux/selectors/i18n");
18
17
 
19
- return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
20
- }], function (localeCode) {
18
+ var getModularUIRequest = (0, _reselect.createSelector)([_i18n.getLocale], function (localeCode) {
21
19
  return function (href, options) {
22
20
  var request = new _ModularUIRequest.default(href, options);
23
21
  request.locale = localeCode;
@@ -3,20 +3,18 @@ import { createSelector } from "reselect";
3
3
  import { useSelector } from "react-redux";
4
4
 
5
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
6
+ import { getLocale } from "../redux/selectors/i18n";
6
7
 
7
8
  import type { RequestBaseOptions } from "../utils";
8
9
  import type Href from "../models/href/Href";
9
10
 
10
- const getModularUIRequest = createSelector(
11
- [(state) => state.i18n.locale ?? "en"],
12
- (localeCode) => {
13
- return (href: Href, options?: $Shape<RequestBaseOptions>) => {
14
- const request = new ModularUIRequest(href, options);
15
- request.locale = localeCode;
16
- return request;
17
- };
18
- }
19
- );
11
+ const getModularUIRequest = createSelector([getLocale], (localeCode) => {
12
+ return (href: Href, options?: $Shape<RequestBaseOptions>) => {
13
+ const request = new ModularUIRequest(href, options);
14
+ request.locale = localeCode;
15
+ return request;
16
+ };
17
+ });
20
18
 
21
19
  /**
22
20
  * Creates a ModularUIRequest with the locale as available in the redux store
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","state","i18n","locale","localeCode","href","options","request","ModularUIRequest","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector(\n [(state) => state.i18n.locale ?? \"en\"],\n (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n }\n);\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AAKA,IAAMA,mBAAmB,GAAG,IAAAC,wBAAA,EAC1B,CAAC,UAACC,KAAD;EAAA;;EAAA,6BAAWA,KAAK,CAACC,IAAN,CAAWC,MAAtB,mEAAgC,IAAhC;AAAA,CAAD,CAD0B,EAE1B,UAACC,UAAD,EAAgB;EACd,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACJ,MAAR,GAAiBC,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CARyB,CAA5B;AAWA;AACA;AACA;;AACO,IAAME,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGT,IAAAC,uBAAA,EAAYX,mBAAZ,CAHS;AAAA,CAA5B"}
1
+ {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n});\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAKA,IAAMA,mBAAmB,GAAG,IAAAC,wBAAA,EAAe,CAACC,eAAD,CAAf,EAA4B,UAACC,UAAD,EAAgB;EACtE,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACE,MAAR,GAAiBL,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CAN2B,CAA5B;AAQA;AACA;AACA;;AACO,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGT,IAAAC,uBAAA,EAAYV,mBAAZ,CAHS;AAAA,CAA5B"}
@@ -6,7 +6,7 @@ import { useMessage } from "../hooks/useI18n";
6
6
 
7
7
  type MessageProps = {
8
8
  +className?: string,
9
- +id?: string | null,
9
+ +id: string,
10
10
  +defaultMessage?: string | null,
11
11
  +children?: string,
12
12
  +data?: Object | null,
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id?: string | null,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n }\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA,IAAMA,OAAqD,gBACzD,IAAAC,WAAA,EACE,gBAQoB;EAAA,IAPlBC,SAOkB,QAPlBA,SAOkB;EAAA,IANlBC,EAMkB,QANlBA,EAMkB;EAAA,IALlBC,cAKkB,QALlBA,cAKkB;EAAA,IAJlBC,QAIkB,QAJlBA,QAIkB;EAAA,IAHlBC,IAGkB,QAHlBA,IAGkB;EAAA,iCAFlBC,gBAEkB;EAAA,IAFlBA,gBAEkB,sCAFC,KAED;EAAA,0BADlBC,SACkB;EAAA,IADlBA,SACkB,+BADN,KACM;EAClB,IAAMC,iBAAiB,GAAG,IAAAC,mBAAA,EACxBP,EADwB,EAExBC,cAAc,IAAIC,QAFM,EAGxBC,IAHwB,CAA1B;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMI,MAAM,qBACP,IAAAC,sBAAA,GADO,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEV,SAAjB;MAA4B,KAAK,EAAES,MAAnC;MAAA,UACGF;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBW,MAAM,EAAEJ;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCH,CADF;AA4CAT,OAAO,CAACc,WAAR,GAAsB,YAAtB;eAEed,O"}
1
+ {"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id: string,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n }\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA,IAAMA,OAAqD,gBACzD,IAAAC,WAAA,EACE,gBAQoB;EAAA,IAPlBC,SAOkB,QAPlBA,SAOkB;EAAA,IANlBC,EAMkB,QANlBA,EAMkB;EAAA,IALlBC,cAKkB,QALlBA,cAKkB;EAAA,IAJlBC,QAIkB,QAJlBA,QAIkB;EAAA,IAHlBC,IAGkB,QAHlBA,IAGkB;EAAA,iCAFlBC,gBAEkB;EAAA,IAFlBA,gBAEkB,sCAFC,KAED;EAAA,0BADlBC,SACkB;EAAA,IADlBA,SACkB,+BADN,KACM;EAClB,IAAMC,iBAAiB,GAAG,IAAAC,mBAAA,EACxBP,EADwB,EAExBC,cAAc,IAAIC,QAFM,EAGxBC,IAHwB,CAA1B;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMI,MAAM,qBACP,IAAAC,sBAAA,GADO,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEV,SAAjB;MAA4B,KAAK,EAAES,MAAnC;MAAA,UACGF;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBW,MAAM,EAAEJ;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCH,CADF;AA4CAT,OAAO,CAACc,WAAR,GAAsB,YAAtB;eAEed,O"}
@@ -15,15 +15,9 @@ var _reselect = require("reselect");
15
15
 
16
16
  var _memoize = _interopRequireDefault(require("lodash/memoize"));
17
17
 
18
- var getLocaleCode = function getLocaleCode(state) {
19
- return state.i18n.locale || "en";
20
- };
21
-
22
- var getLocales = function getLocales(state) {
23
- return state.i18n.locales;
24
- };
18
+ var _i18n = require("../redux/selectors/i18n");
25
19
 
26
- var getMessage = (0, _reselect.createSelector)([getLocales, getLocaleCode], function (locales, localeCode) {
20
+ var getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], function (locales, localeCode) {
27
21
  return (0, _memoize.default)(function (id, defaultMessage, placeholders) {
28
22
  return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
29
23
  }, function () {
@@ -4,6 +4,8 @@ import { connect } from "react-redux";
4
4
  import { createSelector } from "reselect";
5
5
  import memoize from "lodash/memoize";
6
6
 
7
+ import { getLocales, getLocale } from "../redux/selectors/i18n";
8
+
7
9
  import type { ReduxState } from "../redux/types";
8
10
  import type { ComponentType } from "react";
9
11
 
@@ -20,11 +22,8 @@ type Props = {
20
22
  ...
21
23
  };
22
24
 
23
- const getLocaleCode = (state) => state.i18n.locale || "en";
24
- const getLocales = (state) => state.i18n.locales;
25
-
26
25
  const getMessage = createSelector(
27
- [getLocales, getLocaleCode],
26
+ [getLocales, getLocale],
28
27
  (locales, localeCode) =>
29
28
  memoize(
30
29
  (id: string, defaultMessage?: string, placeholders?: Object) =>
@@ -1 +1 @@
1
- {"version":3,"file":"withMessage.js","names":["getLocaleCode","state","i18n","locale","getLocales","locales","getMessage","createSelector","localeCode","memoize","id","defaultMessage","placeholders","getLocale","args","mapStateToProps","message","withMessage","connect"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... }\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getLocaleCode = (state) => state.i18n.locale || \"en\";\nconst getLocales = (state) => state.i18n.locales;\n\nconst getMessage = createSelector(\n [getLocales, getLocaleCode],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AAkBA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWC,MAAX,IAAqB,IAAhC;AAAA,CAAtB;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACH,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWG,OAAtB;AAAA,CAAnB;;AAEA,IAAMC,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACH,UAAD,EAAaJ,aAAb,CADiB,EAEjB,UAACK,OAAD,EAAUG,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEP,OAAO,CACJQ,SADH,CACaL,UADb,EAEGF,UAFH,CAEcI,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIE,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACd,KAAD;EAAA,OAAoC;IAC1De,OAAO,EAAEV,UAAU,CAACL,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAMgB,WAA+B,GAAG,IAAAC,mBAAA,EACtCH,eADsC,CAAxC;eAIeE,W"}
1
+ {"version":3,"file":"withMessage.js","names":["getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","mapStateToProps","state","message","withMessage","connect"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... }\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAkBA,IAAMA,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACC,gBAAD,EAAaC,eAAb,CADiB,EAEjB,UAACC,OAAD,EAAUC,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEL,OAAO,CACJD,SADH,CACaE,UADb,EAEGL,UAFH,CAEcO,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DC,OAAO,EAAEb,UAAU,CAACY,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAME,WAA+B,GAAG,IAAAC,mBAAA,EACtCJ,eADsC,CAAxC;eAIeG,W"}
@@ -37,6 +37,8 @@ var _modularuiUtils = require("./modularuiUtils");
37
37
 
38
38
  var _useModularUI = require("../../hooks/useModularUI");
39
39
 
40
+ var _useI18n = require("../../hooks/useI18n");
41
+
40
42
  var _jsxRuntime = require("react/jsx-runtime");
41
43
 
42
44
  var _excluded = ["propName", "removeOnUnmount"];
@@ -100,9 +102,7 @@ var connector = function connector(name, resource) {
100
102
  };
101
103
  }, [dispatch, modelKey]); // Create new properties object to inject modularui properties to own props
102
104
 
103
- var locale = (0, _reactRedux.useSelector)(function (state) {
104
- return state.i18n.locale;
105
- });
105
+ var locale = (0, _useI18n.useLocale)();
106
106
  var newProps = (_newProps = {
107
107
  modelKey: modelKey
108
108
  }, (0, _defineProperty2.default)(_newProps, propName, modelEntry ? modelEntry.model : null), (0, _defineProperty2.default)(_newProps, "location", location), (0, _defineProperty2.default)(_newProps, "status", modelEntry ? modelEntry.status : null), (0, _defineProperty2.default)(_newProps, "lastModification", modelEntry ? modelEntry.lastModification : null), (0, _defineProperty2.default)(_newProps, "hasModel", Boolean(modelEntry)), (0, _defineProperty2.default)(_newProps, "locale", locale), (0, _defineProperty2.default)(_newProps, "fetchModularUI", handleFetch), (0, _defineProperty2.default)(_newProps, "reloadModel", handleManualReload), _newProps);
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import { useEffect } from "react";
3
- import { useDispatch, useSelector } from "react-redux";
3
+ import { useDispatch } from "react-redux";
4
4
  import { useLocation } from "react-router";
5
5
 
6
6
  import { loadModularUI, reloadModel, removeModelByKey } from "./actions";
@@ -10,6 +10,7 @@ import { getDisplayName } from "../../react/utils";
10
10
 
11
11
  import { useUrl, useReload } from "./modularuiUtils";
12
12
  import { useModularUI } from "../../hooks/useModularUI";
13
+ import { useLocale } from "../../hooks/useI18n";
13
14
 
14
15
  import type { ComponentType, Node } from "react";
15
16
  import type { Location } from "react-router";
@@ -88,7 +89,7 @@ const connector = (
88
89
  }, [dispatch, modelKey]);
89
90
 
90
91
  // Create new properties object to inject modularui properties to own props
91
- const locale = useSelector((state) => state.i18n.locale);
92
+ const locale = useLocale();
92
93
  const newProps: InjectedProps = {
93
94
  modelKey,
94
95
  [propName]: modelEntry ? modelEntry.model : null,
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useSelector","i18n","newProps","status","lastModification","Boolean"],"sources":["../../../src/redux/_modularui/connector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel, removeModelByKey } from \"./actions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./modularuiUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst connector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false }\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, { ...otherOptions, isReload: true })\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useSelector((state) => state.i18n.locale);\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default connector;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAmBA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAChBC,IADgB,EAEhBC,QAFgB,EAI8C;EAAA,IAD9DC,OAC8D,uEADlC;IAAEC,QAAQ,EAAE,MAAZ;IAAoBC,eAAe,EAAE;EAArC,CACkC;EAC9D,wBAIIF,OAJJ,CACEC,QADF;EAAA,IACEA,QADF,kCACa,MADb;EAAA,4BAIID,OAJJ,CAEEE,eAFF;EAAA,IAEEA,eAFF,sCAEoB,KAFpB;EAAA,IAGKC,YAHL,0CAIIH,OAJJ;EAMA,OAAO,UAACI,SAAD,EAAmC;IACxC,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAgB;MAAA;;MACvC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;MACA,IAAMC,QAAQ,GAAG,IAAAC,wBAAA,GAAjB;MAEA,IAAMC,GAAG,GAAG,IAAAC,sBAAA,EAAOb,QAAP;QAAmBU,QAAQ,EAARA;MAAnB,GAAgCH,KAAhC,EAAZ;MACA,IAAMO,WAAW,GAAG,IAAAC,qBAAA,EAAeV,SAAf,EAA0BN,IAA1B,EAAgCQ,KAAK,CAACS,SAAtC,CAApB,CALuC,CAOvC;;MACA,IAAMC,UAAU,GAAG,IAAA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ArCuC,CA6CvC;;MACA,IAAMiB,MAAM,GAAG,IAAAC,uBAAA,EAAY,UAACP,KAAD;QAAA,OAAWA,KAAK,CAACQ,IAAN,CAAWF,MAAtB;MAAA,CAAZ,CAAf;MACA,IAAMG,QAAuB;QAC3BpB,QAAQ,EAARA;MAD2B,4CAE1BjB,QAF0B,EAEfe,UAAU,GAAGA,UAAU,CAACG,KAAd,GAAsB,IAFjB,wDAG3BV,QAH2B,sDAInBO,UAAU,GAAGA,UAAU,CAACuB,MAAd,GAAuB,IAJd,gEAKTvB,UAAU,GAAGA,UAAU,CAACwB,gBAAd,GAAiC,IALlC,wDAMjBC,OAAO,CAACzB,UAAD,CANU,sDAO3BmB,MAP2B,8DAQXX,WARW,2DASdH,kBATc,aAA7B;MAYA,oBAAO,qBAAC,SAAD,kCAAef,KAAf,GAA0BgC,QAA1B,EAAP;IACD,CA5DD;;IA8DAjC,gBAAgB,CAACQ,WAAjB,0BAA+C,IAAAC,qBAAA,EAC7CT,gBAD6C,EAE7CP,IAF6C,CAA/C;IAKA,OAAOO,gBAAP;EACD,CArED;AAsED,CAjFD;;eAmFeR,S"}
1
+ {"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useLocale","newProps","status","lastModification","Boolean"],"sources":["../../../src/redux/_modularui/connector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel, removeModelByKey } from \"./actions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./modularuiUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst connector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false }\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, { ...otherOptions, isReload: true })\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useLocale();\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default connector;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAmBA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAChBC,IADgB,EAEhBC,QAFgB,EAI8C;EAAA,IAD9DC,OAC8D,uEADlC;IAAEC,QAAQ,EAAE,MAAZ;IAAoBC,eAAe,EAAE;EAArC,CACkC;EAC9D,wBAIIF,OAJJ,CACEC,QADF;EAAA,IACEA,QADF,kCACa,MADb;EAAA,4BAIID,OAJJ,CAEEE,eAFF;EAAA,IAEEA,eAFF,sCAEoB,KAFpB;EAAA,IAGKC,YAHL,0CAIIH,OAJJ;EAMA,OAAO,UAACI,SAAD,EAAmC;IACxC,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAgB;MAAA;;MACvC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;MACA,IAAMC,QAAQ,GAAG,IAAAC,wBAAA,GAAjB;MAEA,IAAMC,GAAG,GAAG,IAAAC,sBAAA,EAAOb,QAAP;QAAmBU,QAAQ,EAARA;MAAnB,GAAgCH,KAAhC,EAAZ;MACA,IAAMO,WAAW,GAAG,IAAAC,qBAAA,EAAeV,SAAf,EAA0BN,IAA1B,EAAgCQ,KAAK,CAACS,SAAtC,CAApB,CALuC,CAOvC;;MACA,IAAMC,UAAU,GAAG,IAAAC,0BAAA,EAAaJ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