@beinformed/ui 1.63.2 → 1.63.3

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 (460) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/esm/constants/Settings.js +3 -14
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/exceptions/NotFoundException.js +1 -2
  5. package/esm/exceptions/NotFoundException.js.map +1 -1
  6. package/esm/hooks/useI18n.js +1 -6
  7. package/esm/hooks/useI18n.js.map +1 -1
  8. package/esm/hooks/useModal.js +3 -4
  9. package/esm/hooks/useModal.js.map +1 -1
  10. package/esm/hooks/useModelCatalog.js +10 -30
  11. package/esm/hooks/useModelCatalog.js.map +1 -1
  12. package/esm/hooks/useModularUI.js +4 -5
  13. package/esm/hooks/useModularUI.js.map +1 -1
  14. package/esm/hooks/useModularUIBasic.js +7 -8
  15. package/esm/hooks/useModularUIBasic.js.map +1 -1
  16. package/esm/i18n/Locale.js +2 -5
  17. package/esm/i18n/Locale.js.map +1 -1
  18. package/esm/i18n/Locales.js +2 -5
  19. package/esm/i18n/Locales.js.map +1 -1
  20. package/esm/i18n/Message.js +9 -10
  21. package/esm/i18n/Message.js.map +1 -1
  22. package/esm/i18n/withMessage.js +1 -6
  23. package/esm/i18n/withMessage.js.map +1 -1
  24. package/esm/models/actions/ActionCollection.js +3 -6
  25. package/esm/models/actions/ActionCollection.js.map +1 -1
  26. package/esm/models/actions/ActionModel.js +1 -4
  27. package/esm/models/actions/ActionModel.js.map +1 -1
  28. package/esm/models/application/ApplicationModel.js +2 -2
  29. package/esm/models/application/ApplicationModel.js.map +1 -1
  30. package/esm/models/attributes/AttributeCollection.js +4 -14
  31. package/esm/models/attributes/AttributeCollection.js.map +1 -1
  32. package/esm/models/attributes/AttributeDataHelper.js +1 -2
  33. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  34. package/esm/models/attributes/AttributeSetModel.js +1 -5
  35. package/esm/models/attributes/AttributeSetModel.js.map +1 -1
  36. package/esm/models/attributes/CaptchaAttributeModel.js +2 -2
  37. package/esm/models/attributes/CaptchaAttributeModel.js.map +1 -1
  38. package/esm/models/attributes/ChoiceAttributeModel.js +1 -3
  39. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  40. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -9
  41. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  42. package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -8
  43. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  44. package/esm/models/attributes/PasswordAttributeModel.js +2 -2
  45. package/esm/models/attributes/PasswordAttributeModel.js.map +1 -1
  46. package/esm/models/attributes/UploadAttributeModel.js +2 -2
  47. package/esm/models/attributes/UploadAttributeModel.js.map +1 -1
  48. package/esm/models/attributes/input-constraints/ConstraintCollection.js +1 -2
  49. package/esm/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
  50. package/esm/models/attributes/input-constraints/ConstraintModel.js +1 -2
  51. package/esm/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
  52. package/esm/models/attributes/input-constraints/DateBoundaryConstraint.js +1 -4
  53. package/esm/models/attributes/input-constraints/DateBoundaryConstraint.js.map +1 -1
  54. package/esm/models/attributes/input-constraints/NumberBoundaryConstraint.js +1 -6
  55. package/esm/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
  56. package/esm/models/attributes/input-constraints/NumberGroupingConstraint.js +1 -4
  57. package/esm/models/attributes/input-constraints/NumberGroupingConstraint.js.map +1 -1
  58. package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +1 -2
  59. package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
  60. package/esm/models/attributes/layouthint-rules/DependentAttribute.js +2 -2
  61. package/esm/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
  62. package/esm/models/base/BaseCollection.js +1 -2
  63. package/esm/models/base/BaseCollection.js.map +1 -1
  64. package/esm/models/base/BaseModel.js +6 -9
  65. package/esm/models/base/BaseModel.js.map +1 -1
  66. package/esm/models/base/ResourceModel.js +1 -2
  67. package/esm/models/base/ResourceModel.js.map +1 -1
  68. package/esm/models/concepts/BusinessScenarioModel.js +2 -2
  69. package/esm/models/concepts/BusinessScenarioModel.js.map +1 -1
  70. package/esm/models/concepts/ConceptDetailModel.js +1 -2
  71. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  72. package/esm/models/concepts/ConceptLinkModel.js +1 -3
  73. package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
  74. package/esm/models/concepts/ConceptRelationCollection.js +1 -4
  75. package/esm/models/concepts/ConceptRelationCollection.js.map +1 -1
  76. package/esm/models/concepts/ConceptRelationModel.js +1 -3
  77. package/esm/models/concepts/ConceptRelationModel.js.map +1 -1
  78. package/esm/models/concepts/SourceReferenceCollection.js +1 -4
  79. package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
  80. package/esm/models/concepts/SourceReferenceModel.js +7 -3
  81. package/esm/models/concepts/SourceReferenceModel.js.flow +6 -0
  82. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  83. package/esm/models/content/ContentLinkModel.js +1 -3
  84. package/esm/models/content/ContentLinkModel.js.map +1 -1
  85. package/esm/models/content/ContentTOCModel.js +2 -2
  86. package/esm/models/content/ContentTOCModel.js.map +1 -1
  87. package/esm/models/contentconfiguration/ContentConfigurationElements.js +1 -2
  88. package/esm/models/contentconfiguration/ContentConfigurationElements.js.map +1 -1
  89. package/esm/models/error/ErrorModel.js +1 -3
  90. package/esm/models/error/ErrorModel.js.map +1 -1
  91. package/esm/models/filters/FilterCollection.js +1 -4
  92. package/esm/models/filters/FilterCollection.js.map +1 -1
  93. package/esm/models/form/FormModel.js +3 -9
  94. package/esm/models/form/FormModel.js.map +1 -1
  95. package/esm/models/form/FormObjectModel.js +2 -4
  96. package/esm/models/form/FormObjectModel.js.map +1 -1
  97. package/esm/models/href/Href.js +3 -6
  98. package/esm/models/href/Href.js.map +1 -1
  99. package/esm/models/href/ListHref.js +1 -2
  100. package/esm/models/href/ListHref.js.map +1 -1
  101. package/esm/models/layouthint/LayoutHintCollection.js +3 -10
  102. package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
  103. package/esm/models/links/LinkCollection.js +6 -15
  104. package/esm/models/links/LinkCollection.js.map +1 -1
  105. package/esm/models/list/ListModel.js +2 -2
  106. package/esm/models/list/ListModel.js.map +1 -1
  107. package/esm/models/modelcatalog/ModelCategoryCollection.js +1 -2
  108. package/esm/models/modelcatalog/ModelCategoryCollection.js.map +1 -1
  109. package/esm/models/parameter/Parameter.js +2 -4
  110. package/esm/models/parameter/Parameter.js.map +1 -1
  111. package/esm/models/resolveModel.js +1 -2
  112. package/esm/models/resolveModel.js.map +1 -1
  113. package/esm/models/sorting/SortingModel.js +1 -2
  114. package/esm/models/sorting/SortingModel.js.map +1 -1
  115. package/esm/models/user/UserServicesModel.js +2 -2
  116. package/esm/models/user/UserServicesModel.js.map +1 -1
  117. package/esm/modularui/ModularUIRequest.js +1 -2
  118. package/esm/modularui/ModularUIRequest.js.map +1 -1
  119. package/esm/react/ErrorBoundary.js +2 -2
  120. package/esm/react/ErrorBoundary.js.map +1 -1
  121. package/esm/react/ErrorBoundaryFallback.js +13 -16
  122. package/esm/react/ErrorBoundaryFallback.js.map +1 -1
  123. package/esm/react/utils.js +1 -3
  124. package/esm/react/utils.js.map +1 -1
  125. package/esm/react-client/Init.js +20 -23
  126. package/esm/react-client/Init.js.map +1 -1
  127. package/esm/react-client/client.js +9 -13
  128. package/esm/react-client/client.js.map +1 -1
  129. package/esm/react-server/renderSSRComplete.js +9 -10
  130. package/esm/react-server/renderSSRComplete.js.map +1 -1
  131. package/esm/react-server/renderSSRMinimal.js +7 -8
  132. package/esm/react-server/renderSSRMinimal.js.map +1 -1
  133. package/esm/react-server/serverNoSSR.js +11 -12
  134. package/esm/react-server/serverNoSSR.js.map +1 -1
  135. package/esm/react-server/serverSSR.js +11 -12
  136. package/esm/react-server/serverSSR.js.map +1 -1
  137. package/esm/react-server/serverUtil.js +1 -3
  138. package/esm/react-server/serverUtil.js.map +1 -1
  139. package/esm/react-theme/ThemeProvider.js +7 -11
  140. package/esm/react-theme/ThemeProvider.js.map +1 -1
  141. package/esm/react-theme/createTheme.js +3 -10
  142. package/esm/react-theme/createTheme.js.map +1 -1
  143. package/esm/react-theme/utils/background.js +3 -4
  144. package/esm/react-theme/utils/background.js.map +1 -1
  145. package/esm/react-theme/utils/colors.js +7 -16
  146. package/esm/react-theme/utils/colors.js.map +1 -1
  147. package/esm/react-theme/utils/contrast.js +11 -19
  148. package/esm/react-theme/utils/contrast.js.map +1 -1
  149. package/esm/react-theme/utils/corners.js +10 -16
  150. package/esm/react-theme/utils/corners.js.map +1 -1
  151. package/esm/react-theme/utils/spacers.js +15 -38
  152. package/esm/react-theme/utils/spacers.js.map +1 -1
  153. package/esm/react-theme/utils/themeProps.js +7 -22
  154. package/esm/react-theme/utils/themeProps.js.map +1 -1
  155. package/esm/redux/_i18n/I18nReducer.js +5 -8
  156. package/esm/redux/_i18n/I18nReducer.js.map +1 -1
  157. package/esm/redux/_modularui/ModularUIActions.js +19 -23
  158. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  159. package/esm/redux/_modularui/ModularUIConnector.js +4 -5
  160. package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
  161. package/esm/redux/_modularui/ModularUIReducer.js +14 -19
  162. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  163. package/esm/redux/_modularui/ModularUIUtils.js +1 -2
  164. package/esm/redux/_modularui/ModularUIUtils.js.map +1 -1
  165. package/esm/redux/_modularui/withModularUI.js +1 -2
  166. package/esm/redux/_modularui/withModularUI.js.map +1 -1
  167. package/esm/redux/_router/RouterReducer.js +1 -3
  168. package/esm/redux/_router/RouterReducer.js.map +1 -1
  169. package/esm/redux/actions/FormAttributeSet.js +34 -37
  170. package/esm/redux/actions/FormAttributeSet.js.map +1 -1
  171. package/esm/redux/actions/FormAutosubmit.js +1 -2
  172. package/esm/redux/actions/FormAutosubmit.js.map +1 -1
  173. package/esm/redux/actions/Preferences.js +8 -15
  174. package/esm/redux/actions/Preferences.js.map +1 -1
  175. package/esm/redux/connectors/CaseView.js +3 -6
  176. package/esm/redux/connectors/CaseView.js.map +1 -1
  177. package/esm/redux/connectors/ConceptDetail.js +4 -7
  178. package/esm/redux/connectors/ConceptDetail.js.map +1 -1
  179. package/esm/redux/connectors/ContentBrowser.js +3 -6
  180. package/esm/redux/connectors/ContentBrowser.js.map +1 -1
  181. package/esm/redux/connectors/ContentDetail.js +4 -7
  182. package/esm/redux/connectors/ContentDetail.js.map +1 -1
  183. package/esm/redux/connectors/ContentDetailSection.js +5 -8
  184. package/esm/redux/connectors/ContentDetailSection.js.map +1 -1
  185. package/esm/redux/connectors/Form.js +4 -5
  186. package/esm/redux/connectors/Form.js.map +1 -1
  187. package/esm/redux/connectors/FormAttributeSet.js +5 -8
  188. package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
  189. package/esm/redux/connectors/ListDetail.js +3 -6
  190. package/esm/redux/connectors/ListDetail.js.map +1 -1
  191. package/esm/redux/connectors/ModelCatalog.js +3 -6
  192. package/esm/redux/connectors/ModelCatalog.js.map +1 -1
  193. package/esm/redux/connectors/PanelRenderer.js +5 -6
  194. package/esm/redux/connectors/PanelRenderer.js.map +1 -1
  195. package/esm/redux/connectors/QuickSearch.js +3 -6
  196. package/esm/redux/connectors/QuickSearch.js.map +1 -1
  197. package/esm/redux/connectors/Tab.js +3 -6
  198. package/esm/redux/connectors/Tab.js.map +1 -1
  199. package/esm/redux/reducers/AuthReducer.js +1 -3
  200. package/esm/redux/reducers/AuthReducer.js.map +1 -1
  201. package/esm/redux/reducers/ErrorReducer.js +1 -3
  202. package/esm/redux/reducers/ErrorReducer.js.map +1 -1
  203. package/esm/redux/reducers/ModalsReducer.js +1 -3
  204. package/esm/redux/reducers/ModalsReducer.js.map +1 -1
  205. package/esm/redux/reducers/ModelCatalogReducer.js +1 -3
  206. package/esm/redux/reducers/ModelCatalogReducer.js.map +1 -1
  207. package/esm/redux/reducers/NotificationReducer.js +1 -3
  208. package/esm/redux/reducers/NotificationReducer.js.map +1 -1
  209. package/esm/redux/reducers/PreferencesReducer.js +1 -3
  210. package/esm/redux/reducers/PreferencesReducer.js.map +1 -1
  211. package/esm/redux/reducers/ProgressIndicatorReducer.js +1 -3
  212. package/esm/redux/reducers/ProgressIndicatorReducer.js.map +1 -1
  213. package/esm/redux/store/beforeRenderHooks.js +1 -3
  214. package/esm/redux/store/beforeRenderHooks.js.map +1 -1
  215. package/esm/utils/browser/Cache.js +1 -5
  216. package/esm/utils/browser/Cache.js.map +1 -1
  217. package/esm/utils/datetime/DateTimeUtil.js +45 -91
  218. package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
  219. package/esm/utils/fetch/xhr.js +1 -2
  220. package/esm/utils/fetch/xhr.js.map +1 -1
  221. package/esm/utils/helpers/repositoryResource.js +1 -3
  222. package/esm/utils/helpers/repositoryResource.js.map +1 -1
  223. package/esm/utils/helpers/sanitizeHtml.js +3 -4
  224. package/esm/utils/helpers/sanitizeHtml.js.map +1 -1
  225. package/esm/utils/number/DecimalFormat.js +1 -2
  226. package/esm/utils/number/DecimalFormat.js.map +1 -1
  227. package/esm/utils/number/formatValue.js +1 -4
  228. package/esm/utils/number/formatValue.js.map +1 -1
  229. package/esm/utils/number/parseNumbers.js +2 -6
  230. package/esm/utils/number/parseNumbers.js.map +1 -1
  231. package/lib/constants/Settings.js +3 -14
  232. package/lib/constants/Settings.js.map +1 -1
  233. package/lib/exceptions/NotFoundException.js +1 -2
  234. package/lib/exceptions/NotFoundException.js.map +1 -1
  235. package/lib/hooks/useI18n.js +1 -6
  236. package/lib/hooks/useI18n.js.map +1 -1
  237. package/lib/hooks/useModal.js +3 -4
  238. package/lib/hooks/useModal.js.map +1 -1
  239. package/lib/hooks/useModelCatalog.js +10 -30
  240. package/lib/hooks/useModelCatalog.js.map +1 -1
  241. package/lib/hooks/useModularUI.js +4 -5
  242. package/lib/hooks/useModularUI.js.map +1 -1
  243. package/lib/hooks/useModularUIBasic.js +7 -8
  244. package/lib/hooks/useModularUIBasic.js.map +1 -1
  245. package/lib/i18n/Locale.js +2 -5
  246. package/lib/i18n/Locale.js.map +1 -1
  247. package/lib/i18n/Locales.js +2 -5
  248. package/lib/i18n/Locales.js.map +1 -1
  249. package/lib/i18n/Message.js +9 -10
  250. package/lib/i18n/Message.js.map +1 -1
  251. package/lib/i18n/withMessage.js +1 -6
  252. package/lib/i18n/withMessage.js.map +1 -1
  253. package/lib/models/actions/ActionCollection.js +3 -6
  254. package/lib/models/actions/ActionCollection.js.map +1 -1
  255. package/lib/models/actions/ActionModel.js +1 -4
  256. package/lib/models/actions/ActionModel.js.map +1 -1
  257. package/lib/models/application/ApplicationModel.js +2 -2
  258. package/lib/models/application/ApplicationModel.js.map +1 -1
  259. package/lib/models/attributes/AttributeCollection.js +4 -14
  260. package/lib/models/attributes/AttributeCollection.js.map +1 -1
  261. package/lib/models/attributes/AttributeDataHelper.js +1 -2
  262. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  263. package/lib/models/attributes/AttributeSetModel.js +1 -5
  264. package/lib/models/attributes/AttributeSetModel.js.map +1 -1
  265. package/lib/models/attributes/CaptchaAttributeModel.js +2 -2
  266. package/lib/models/attributes/CaptchaAttributeModel.js.map +1 -1
  267. package/lib/models/attributes/ChoiceAttributeModel.js +1 -3
  268. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  269. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -9
  270. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  271. package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -8
  272. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  273. package/lib/models/attributes/PasswordAttributeModel.js +2 -2
  274. package/lib/models/attributes/PasswordAttributeModel.js.map +1 -1
  275. package/lib/models/attributes/UploadAttributeModel.js +2 -2
  276. package/lib/models/attributes/UploadAttributeModel.js.map +1 -1
  277. package/lib/models/attributes/input-constraints/ConstraintCollection.js +1 -2
  278. package/lib/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
  279. package/lib/models/attributes/input-constraints/ConstraintModel.js +1 -2
  280. package/lib/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
  281. package/lib/models/attributes/input-constraints/DateBoundaryConstraint.js +1 -4
  282. package/lib/models/attributes/input-constraints/DateBoundaryConstraint.js.map +1 -1
  283. package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js +1 -6
  284. package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
  285. package/lib/models/attributes/input-constraints/NumberGroupingConstraint.js +1 -4
  286. package/lib/models/attributes/input-constraints/NumberGroupingConstraint.js.map +1 -1
  287. package/lib/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +1 -2
  288. package/lib/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
  289. package/lib/models/attributes/layouthint-rules/DependentAttribute.js +2 -2
  290. package/lib/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
  291. package/lib/models/base/BaseCollection.js +1 -2
  292. package/lib/models/base/BaseCollection.js.map +1 -1
  293. package/lib/models/base/BaseModel.js +6 -9
  294. package/lib/models/base/BaseModel.js.map +1 -1
  295. package/lib/models/base/ResourceModel.js +1 -2
  296. package/lib/models/base/ResourceModel.js.map +1 -1
  297. package/lib/models/concepts/BusinessScenarioModel.js +2 -2
  298. package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
  299. package/lib/models/concepts/ConceptDetailModel.js +1 -2
  300. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  301. package/lib/models/concepts/ConceptLinkModel.js +1 -3
  302. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  303. package/lib/models/concepts/ConceptRelationCollection.js +1 -4
  304. package/lib/models/concepts/ConceptRelationCollection.js.map +1 -1
  305. package/lib/models/concepts/ConceptRelationModel.js +1 -3
  306. package/lib/models/concepts/ConceptRelationModel.js.map +1 -1
  307. package/lib/models/concepts/SourceReferenceCollection.js +1 -4
  308. package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
  309. package/lib/models/concepts/SourceReferenceModel.js +7 -3
  310. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  311. package/lib/models/content/ContentLinkModel.js +1 -3
  312. package/lib/models/content/ContentLinkModel.js.map +1 -1
  313. package/lib/models/content/ContentTOCModel.js +2 -2
  314. package/lib/models/content/ContentTOCModel.js.map +1 -1
  315. package/lib/models/contentconfiguration/ContentConfigurationElements.js +1 -2
  316. package/lib/models/contentconfiguration/ContentConfigurationElements.js.map +1 -1
  317. package/lib/models/error/ErrorModel.js +1 -3
  318. package/lib/models/error/ErrorModel.js.map +1 -1
  319. package/lib/models/filters/FilterCollection.js +1 -4
  320. package/lib/models/filters/FilterCollection.js.map +1 -1
  321. package/lib/models/form/FormModel.js +3 -9
  322. package/lib/models/form/FormModel.js.map +1 -1
  323. package/lib/models/form/FormObjectModel.js +2 -4
  324. package/lib/models/form/FormObjectModel.js.map +1 -1
  325. package/lib/models/href/Href.js +3 -6
  326. package/lib/models/href/Href.js.map +1 -1
  327. package/lib/models/href/ListHref.js +1 -2
  328. package/lib/models/href/ListHref.js.map +1 -1
  329. package/lib/models/layouthint/LayoutHintCollection.js +3 -10
  330. package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
  331. package/lib/models/links/LinkCollection.js +6 -15
  332. package/lib/models/links/LinkCollection.js.map +1 -1
  333. package/lib/models/list/ListModel.js +2 -2
  334. package/lib/models/list/ListModel.js.map +1 -1
  335. package/lib/models/modelcatalog/ModelCategoryCollection.js +1 -2
  336. package/lib/models/modelcatalog/ModelCategoryCollection.js.map +1 -1
  337. package/lib/models/parameter/Parameter.js +2 -4
  338. package/lib/models/parameter/Parameter.js.map +1 -1
  339. package/lib/models/resolveModel.js +1 -2
  340. package/lib/models/resolveModel.js.map +1 -1
  341. package/lib/models/sorting/SortingModel.js +1 -2
  342. package/lib/models/sorting/SortingModel.js.map +1 -1
  343. package/lib/models/user/UserServicesModel.js +2 -2
  344. package/lib/models/user/UserServicesModel.js.map +1 -1
  345. package/lib/modularui/ModularUIRequest.js +1 -2
  346. package/lib/modularui/ModularUIRequest.js.map +1 -1
  347. package/lib/react/ErrorBoundary.js +2 -2
  348. package/lib/react/ErrorBoundary.js.map +1 -1
  349. package/lib/react/ErrorBoundaryFallback.js +13 -16
  350. package/lib/react/ErrorBoundaryFallback.js.map +1 -1
  351. package/lib/react/utils.js +1 -3
  352. package/lib/react/utils.js.map +1 -1
  353. package/lib/react-client/Init.js +20 -23
  354. package/lib/react-client/Init.js.map +1 -1
  355. package/lib/react-client/client.js +9 -13
  356. package/lib/react-client/client.js.map +1 -1
  357. package/lib/react-server/renderSSRComplete.js +9 -10
  358. package/lib/react-server/renderSSRComplete.js.map +1 -1
  359. package/lib/react-server/renderSSRMinimal.js +7 -8
  360. package/lib/react-server/renderSSRMinimal.js.map +1 -1
  361. package/lib/react-server/serverNoSSR.js +11 -12
  362. package/lib/react-server/serverNoSSR.js.map +1 -1
  363. package/lib/react-server/serverSSR.js +11 -12
  364. package/lib/react-server/serverSSR.js.map +1 -1
  365. package/lib/react-server/serverUtil.js +1 -3
  366. package/lib/react-server/serverUtil.js.map +1 -1
  367. package/lib/react-theme/ThemeProvider.js +7 -11
  368. package/lib/react-theme/ThemeProvider.js.map +1 -1
  369. package/lib/react-theme/createTheme.js +3 -10
  370. package/lib/react-theme/createTheme.js.map +1 -1
  371. package/lib/react-theme/utils/background.js +3 -4
  372. package/lib/react-theme/utils/background.js.map +1 -1
  373. package/lib/react-theme/utils/colors.js +7 -16
  374. package/lib/react-theme/utils/colors.js.map +1 -1
  375. package/lib/react-theme/utils/contrast.js +11 -19
  376. package/lib/react-theme/utils/contrast.js.map +1 -1
  377. package/lib/react-theme/utils/corners.js +10 -16
  378. package/lib/react-theme/utils/corners.js.map +1 -1
  379. package/lib/react-theme/utils/spacers.js +15 -38
  380. package/lib/react-theme/utils/spacers.js.map +1 -1
  381. package/lib/react-theme/utils/themeProps.js +7 -22
  382. package/lib/react-theme/utils/themeProps.js.map +1 -1
  383. package/lib/redux/_i18n/I18nReducer.js +5 -8
  384. package/lib/redux/_i18n/I18nReducer.js.map +1 -1
  385. package/lib/redux/_modularui/ModularUIActions.js +19 -23
  386. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  387. package/lib/redux/_modularui/ModularUIConnector.js +4 -5
  388. package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
  389. package/lib/redux/_modularui/ModularUIReducer.js +14 -19
  390. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  391. package/lib/redux/_modularui/ModularUIUtils.js +1 -2
  392. package/lib/redux/_modularui/ModularUIUtils.js.map +1 -1
  393. package/lib/redux/_modularui/withModularUI.js +1 -2
  394. package/lib/redux/_modularui/withModularUI.js.map +1 -1
  395. package/lib/redux/_router/RouterReducer.js +1 -3
  396. package/lib/redux/_router/RouterReducer.js.map +1 -1
  397. package/lib/redux/actions/FormAttributeSet.js +34 -37
  398. package/lib/redux/actions/FormAttributeSet.js.map +1 -1
  399. package/lib/redux/actions/FormAutosubmit.js +1 -2
  400. package/lib/redux/actions/FormAutosubmit.js.map +1 -1
  401. package/lib/redux/actions/Preferences.js +8 -15
  402. package/lib/redux/actions/Preferences.js.map +1 -1
  403. package/lib/redux/connectors/CaseView.js +3 -6
  404. package/lib/redux/connectors/CaseView.js.map +1 -1
  405. package/lib/redux/connectors/ConceptDetail.js +4 -7
  406. package/lib/redux/connectors/ConceptDetail.js.map +1 -1
  407. package/lib/redux/connectors/ContentBrowser.js +3 -6
  408. package/lib/redux/connectors/ContentBrowser.js.map +1 -1
  409. package/lib/redux/connectors/ContentDetail.js +4 -7
  410. package/lib/redux/connectors/ContentDetail.js.map +1 -1
  411. package/lib/redux/connectors/ContentDetailSection.js +5 -8
  412. package/lib/redux/connectors/ContentDetailSection.js.map +1 -1
  413. package/lib/redux/connectors/Form.js +4 -5
  414. package/lib/redux/connectors/Form.js.map +1 -1
  415. package/lib/redux/connectors/FormAttributeSet.js +5 -8
  416. package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
  417. package/lib/redux/connectors/ListDetail.js +3 -6
  418. package/lib/redux/connectors/ListDetail.js.map +1 -1
  419. package/lib/redux/connectors/ModelCatalog.js +3 -6
  420. package/lib/redux/connectors/ModelCatalog.js.map +1 -1
  421. package/lib/redux/connectors/PanelRenderer.js +5 -6
  422. package/lib/redux/connectors/PanelRenderer.js.map +1 -1
  423. package/lib/redux/connectors/QuickSearch.js +3 -6
  424. package/lib/redux/connectors/QuickSearch.js.map +1 -1
  425. package/lib/redux/connectors/Tab.js +3 -6
  426. package/lib/redux/connectors/Tab.js.map +1 -1
  427. package/lib/redux/reducers/AuthReducer.js +1 -3
  428. package/lib/redux/reducers/AuthReducer.js.map +1 -1
  429. package/lib/redux/reducers/ErrorReducer.js +1 -3
  430. package/lib/redux/reducers/ErrorReducer.js.map +1 -1
  431. package/lib/redux/reducers/ModalsReducer.js +1 -3
  432. package/lib/redux/reducers/ModalsReducer.js.map +1 -1
  433. package/lib/redux/reducers/ModelCatalogReducer.js +1 -3
  434. package/lib/redux/reducers/ModelCatalogReducer.js.map +1 -1
  435. package/lib/redux/reducers/NotificationReducer.js +1 -3
  436. package/lib/redux/reducers/NotificationReducer.js.map +1 -1
  437. package/lib/redux/reducers/PreferencesReducer.js +1 -3
  438. package/lib/redux/reducers/PreferencesReducer.js.map +1 -1
  439. package/lib/redux/reducers/ProgressIndicatorReducer.js +1 -3
  440. package/lib/redux/reducers/ProgressIndicatorReducer.js.map +1 -1
  441. package/lib/redux/store/beforeRenderHooks.js +1 -3
  442. package/lib/redux/store/beforeRenderHooks.js.map +1 -1
  443. package/lib/utils/browser/Cache.js +1 -5
  444. package/lib/utils/browser/Cache.js.map +1 -1
  445. package/lib/utils/datetime/DateTimeUtil.js +45 -91
  446. package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
  447. package/lib/utils/fetch/xhr.js +1 -2
  448. package/lib/utils/fetch/xhr.js.map +1 -1
  449. package/lib/utils/helpers/repositoryResource.js +1 -3
  450. package/lib/utils/helpers/repositoryResource.js.map +1 -1
  451. package/lib/utils/helpers/sanitizeHtml.js +3 -4
  452. package/lib/utils/helpers/sanitizeHtml.js.map +1 -1
  453. package/lib/utils/number/DecimalFormat.js +1 -2
  454. package/lib/utils/number/DecimalFormat.js.map +1 -1
  455. package/lib/utils/number/formatValue.js +1 -4
  456. package/lib/utils/number/formatValue.js.map +1 -1
  457. package/lib/utils/number/parseNumbers.js +2 -6
  458. package/lib/utils/number/parseNumbers.js.map +1 -1
  459. package/package.json +22 -22
  460. package/src/models/concepts/SourceReferenceModel.js +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getEnabledLocales().includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AASA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAM,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAA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AMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAACpF,OAAA,CAAA8E,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getEnabledLocales().includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAA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P,GAAG,IAAIG,KAAK,CAACI,SAAS,EAAE;IACjC,MAAM;MAAEC,MAAM;MAAEP,KAAK;MAAEQ;IAAiB,CAAC,GAAGN,KAAK,CAACI,SAAS,CAACP,GAAG,CAAC;IAEhE,IAAIC,KAAK,EAAE;MACTM,SAAS,CAACP,GAAG,CAAC,GAAG;QACfQ,MAAM;QACNC,gBAAgB;QAChBR,KAAK,EAAEA,KAAK,CAACK,SAAS,CAAC;MACzB,CAAC;IACH,CAAC,MAAM;MACLC,SAAS,CAACP,GAAG,CAAC,GAAG;QACfQ,MAAM;QACNC,gBAAgB;QAChBR,KAAK,EAAES;MACT,CAAC;IACH;EACF;EAEA,MAAMC,aAAa,GAAG;IACpB,GAAGR,KAAK;IACRI;EACF,CAAC;EAED,OAAO,IAAAK,UAAA,CAAA7F,OAAA,EAAe4F,aAAa,CAAC,CAACE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;AAC/D,CAAC;;AAED;AACA;AADA3E,OAAA,CAAAoE,SAAA,GAAAA,SAAA;AAEA,MAAMQ,UAAU,GAAGA,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAAClF,OAAA,CAAA4E,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -11,17 +11,13 @@ var _createTheme = _interopRequireDefault(require("./createTheme"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  */
14
- const ThemeProvider = _ref => {
15
- let {
16
- theme,
17
- children
18
- } = _ref;
19
- const storedTheme = (0, _reactRedux.useSelector)(_ref2 => {
20
- let {
21
- preferences
22
- } = _ref2;
23
- return preferences.theme;
24
- });
14
+ const ThemeProvider = ({
15
+ theme,
16
+ children
17
+ }) => {
18
+ const storedTheme = (0, _reactRedux.useSelector)(({
19
+ preferences
20
+ }) => preferences.theme);
25
21
  const finalTheme = (0, _createTheme.default)(storedTheme, theme);
26
22
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledComponents.ThemeProvider, {
27
23
  theme: finalTheme,
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","names":["_reactRedux","require","_styledComponents","_createTheme","_interopRequireDefault","_jsxRuntime","ThemeProvider","_ref","theme","children","storedTheme","useSelector","_ref2","preferences","finalTheme","createTheme","jsx","displayName","_default","exports","default"],"sources":["../../src/react-theme/ThemeProvider.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { ThemeProvider as SCThemeProvider } from \"styled-components\";\n\nimport createTheme from \"./createTheme\";\n\nimport type { Node } from \"react\";\nimport type { Theme } from \"./types\";\n\nexport type Props = {\n +theme?: Theme | Array<Theme>,\n +children: Node,\n};\n\n/**\n */\nconst ThemeProvider = ({ theme, children }: Props): Node => {\n const storedTheme = useSelector(({ preferences }) => preferences.theme);\n const finalTheme = createTheme(storedTheme, theme);\n\n return <SCThemeProvider theme={finalTheme}>{children}</SCThemeProvider>;\n};\nThemeProvider.displayName = \"BI.ThemeProvider\";\n\nexport default ThemeProvider;\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAUxC;AACA;AACA,MAAMK,aAAa,GAAGC,IAAA,IAAsC;EAAA,IAArC;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAAF,IAAA;EAC/C,MAAMG,WAAW,GAAG,IAAAC,uBAAW,EAACC,KAAA;IAAA,IAAC;MAAEC;IAAY,CAAC,GAAAD,KAAA;IAAA,OAAKC,WAAW,CAACL,KAAK;EAAA,EAAC;EACvE,MAAMM,UAAU,GAAG,IAAAC,oBAAW,EAACL,WAAW,EAAEF,KAAK,CAAC;EAElD,oBAAO,IAAAH,WAAA,CAAAW,GAAA,EAACd,iBAAA,CAAAI,aAAe;IAACE,KAAK,EAAEM,UAAW;IAAAL,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AACzE,CAAC;AACDH,aAAa,CAACW,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEhCd,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"ThemeProvider.js","names":["_reactRedux","require","_styledComponents","_createTheme","_interopRequireDefault","_jsxRuntime","ThemeProvider","theme","children","storedTheme","useSelector","preferences","finalTheme","createTheme","jsx","displayName","_default","exports","default"],"sources":["../../src/react-theme/ThemeProvider.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { ThemeProvider as SCThemeProvider } from \"styled-components\";\n\nimport createTheme from \"./createTheme\";\n\nimport type { Node } from \"react\";\nimport type { Theme } from \"./types\";\n\nexport type Props = {\n +theme?: Theme | Array<Theme>,\n +children: Node,\n};\n\n/**\n */\nconst ThemeProvider = ({ theme, children }: Props): Node => {\n const storedTheme = useSelector(({ preferences }) => preferences.theme);\n const finalTheme = createTheme(storedTheme, theme);\n\n return <SCThemeProvider theme={finalTheme}>{children}</SCThemeProvider>;\n};\nThemeProvider.displayName = \"BI.ThemeProvider\";\n\nexport default ThemeProvider;\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAUxC;AACA;AACA,MAAMK,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAgB,CAAC,KAAW;EAC1D,MAAMC,WAAW,GAAG,IAAAC,uBAAW,EAAC,CAAC;IAAEC;EAAY,CAAC,KAAKA,WAAW,CAACJ,KAAK,CAAC;EACvE,MAAMK,UAAU,GAAG,IAAAC,oBAAW,EAACJ,WAAW,EAAEF,KAAK,CAAC;EAElD,oBAAO,IAAAF,WAAA,CAAAS,GAAA,EAACZ,iBAAA,CAAAI,aAAe;IAACC,KAAK,EAAEK,UAAW;IAAAJ,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AACzE,CAAC;AACDF,aAAa,CAACS,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEhCZ,aAAa","ignoreList":[]}
@@ -15,8 +15,7 @@ const replacePlaceholders = inputTheme => {
15
15
  var _context;
16
16
  const possibleKeys = (0, _map.default)(_context = (0, _keys.default)(inputTheme)).call(_context, key => `\\b${key}\\b`).join("|");
17
17
  const re = new RegExp(`\\$(${possibleKeys})`, "g");
18
- (0, _entries.default)(inputTheme).forEach(_ref => {
19
- let [key, value] = _ref;
18
+ (0, _entries.default)(inputTheme).forEach(([key, value]) => {
20
19
  if (key !== "settings" && typeof value === "string") {
21
20
  inputTheme[key] = value.replace(re,
22
21
  // $FlowIssue[incompatible-call]
@@ -25,14 +24,11 @@ const replacePlaceholders = inputTheme => {
25
24
  });
26
25
  return inputTheme;
27
26
  };
28
- const generateTheme = function (storedTheme) {
27
+ const generateTheme = (storedTheme, ...themeElements) => {
29
28
  const storedSettings = storedTheme?.settings ?? {};
30
29
  let generatedTheme = {
31
30
  settings: {}
32
31
  };
33
- for (var _len = arguments.length, themeElements = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34
- themeElements[_key - 1] = arguments[_key];
35
- }
36
32
  for (const element of themeElements) {
37
33
  if (typeof element === "function") {
38
34
  generatedTheme = element(replacePlaceholders(generatedTheme));
@@ -101,10 +97,7 @@ const generateTheme = function (storedTheme) {
101
97
  * SECONDARY_COLOR: "#00ff00",
102
98
  * }
103
99
  */
104
- const createTheme = function (storedTheme) {
105
- for (var _len2 = arguments.length, themeConfigs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
106
- themeConfigs[_key2 - 1] = arguments[_key2];
107
- }
100
+ const createTheme = (storedTheme, ...themeConfigs) => {
108
101
  const customTheme = generateTheme(storedTheme, ...(0, _flattenDeep.default)(themeConfigs));
109
102
  if (customTheme) {
110
103
  (0, _Settings.setSettings)(customTheme.settings);
@@ -1 +1 @@
1
- {"version":3,"file":"createTheme.js","names":["_flattenDeep","_interopRequireDefault","require","_objects","_Settings","replacePlaceholders","inputTheme","_context","possibleKeys","_map","default","_keys","call","key","join","re","RegExp","_entries","forEach","_ref","value","replace","match","capture","generateTheme","storedTheme","storedSettings","settings","generatedTheme","_len","arguments","length","themeElements","Array","_key","element","isPlainObject","generatedSettings","createTheme","_len2","themeConfigs","_key2","customTheme","flattenDeep","setSettings","_default","exports"],"sources":["../../src/react-theme/createTheme.js"],"sourcesContent":["// @flow\nimport flattenDeep from \"lodash/flattenDeep\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport { setSettings } from \"../constants/Settings\";\n\nimport type { Theme } from \"./types\";\n\nconst replacePlaceholders = (inputTheme: Theme) => {\n const possibleKeys = Object.keys(inputTheme)\n .map((key) => `\\\\b${key}\\\\b`)\n .join(\"|\");\n\n const re = new RegExp(`\\\\$(${possibleKeys})`, \"g\");\n Object.entries(inputTheme).forEach(([key, value]) => {\n if (key !== \"settings\" && typeof value === \"string\") {\n inputTheme[key] = value.replace(\n re,\n // $FlowIssue[incompatible-call]\n (match, capture) => inputTheme[capture],\n );\n }\n });\n\n return inputTheme;\n};\n\nconst generateTheme = (storedTheme: Theme, ...themeElements: Array<Theme>) => {\n const storedSettings = storedTheme?.settings ?? {};\n\n let generatedTheme = { settings: {} };\n for (const element of themeElements) {\n if (typeof element === \"function\") {\n generatedTheme = element(replacePlaceholders(generatedTheme));\n } else if (isPlainObject(element)) {\n const generatedSettings = generatedTheme.settings;\n // $FlowFixMe[cannot-spread-indexer]\n generatedTheme = { ...generatedTheme, ...element, ...storedTheme };\n if (\"settings\" in element) {\n generatedTheme.settings = {\n ...generatedSettings,\n ...element.settings,\n ...storedSettings,\n };\n }\n }\n }\n\n // final - replace any assignments inside the theme\n return replacePlaceholders(generatedTheme);\n};\n\n/**\n * Create a theme from multiple theme configuration objects.\n * Properties are overwriten by iterating the configuration objects from left to right.\n *\n * The first argument represents a stored theme part, this is optional. The stored theme part will overwrite every part in the collection of theme parts.\n * Thus a stored configuration is leading as it can be configured by a modeller through the repository.\n *\n * Placeholders can be used, they are replaced before calling a function theme part or at the end of the theme creation.\n *\n * Both objects and function can be used, where a function receives the previous objects as input arguments.\n * For example using the method createTheme(ThemeObject, ThemeObject2, ThemeFunction, ThemeFunction2), will be handled as:\n *\n * ThemeFunction2(ThemeFunction1({ ...ThemeObject, ...ThemeObject2 }))\n *\n * @example\n * Example where the primary color of the default theme is overwritten with a primary color of the custom theme,\n * but the button bg still uses the yiq function of the default theme:\n *\n * const DefaultTheme = {\n * PRIMARY_COLOR: \"#0000ff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * BUTTON_COLOR: \"$PRIMARY_COLOR\"\n * }\n *\n * const createDefaultTheme = (input) => ({\n * ...input,\n * BUTTON_BG: getContrastYIQ(input.BUTTON_COLOR)\n * })\n *\n * const CustomTheme = {\n * PRIMARY_COLOR: \"#ff0000\"\n * }\n *\n * createTheme(null, DefaultTheme, CustomTheme, createDefaultTheme);\n *\n * // Result:\n * {\n * PRIMARY_COLOR: \"#ff0000\",\n * BUTTON_COLOR: \"#ff0000\",\n * BUTTON_BG: \"#fff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * }\n */\nconst createTheme = (\n storedTheme: Theme,\n ...themeConfigs: Array<Theme | Array<Theme> | void>\n):\n | any\n | {}\n | {\n INPUT_FOCUS_BORDER_COLOR?: string,\n LINK_HOVER_COLOR?: string,\n PAGING_HOVER_COLOR?: string,\n settings?: { [settingName: string]: string },\n } => {\n const customTheme = generateTheme(storedTheme, ...flattenDeep(themeConfigs));\n\n if (customTheme) {\n setSettings(customTheme.settings);\n }\n\n return customTheme;\n};\n\nexport default createTheme;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAIA,MAAMG,mBAAmB,GAAIC,UAAiB,IAAK;EAAA,IAAAC,QAAA;EACjD,MAAMC,YAAY,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAH,QAAA,OAAAI,KAAA,CAAAD,OAAA,EAAYJ,UAAU,CAAC,EAAAM,IAAA,CAAAL,QAAA,EACpCM,GAAG,IAAK,MAAMA,GAAG,KAAK,CAAC,CAC5BC,IAAI,CAAC,GAAG,CAAC;EAEZ,MAAMC,EAAE,GAAG,IAAIC,MAAM,CAAC,OAAOR,YAAY,GAAG,EAAE,GAAG,CAAC;EAClD,IAAAS,QAAA,CAAAP,OAAA,EAAeJ,UAAU,CAAC,CAACY,OAAO,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACN,GAAG,EAAEO,KAAK,CAAC,GAAAD,IAAA;IAC9C,IAAIN,GAAG,KAAK,UAAU,IAAI,OAAOO,KAAK,KAAK,QAAQ,EAAE;MACnDd,UAAU,CAACO,GAAG,CAAC,GAAGO,KAAK,CAACC,OAAO,CAC7BN,EAAE;MACF;MACA,CAACO,KAAK,EAAEC,OAAO,KAAKjB,UAAU,CAACiB,OAAO,CACxC,CAAC;IACH;EACF,CAAC,CAAC;EAEF,OAAOjB,UAAU;AACnB,CAAC;AAED,MAAMkB,aAAa,GAAG,SAAAA,CAACC,WAAkB,EAAqC;EAC5E,MAAMC,cAAc,GAAGD,WAAW,EAAEE,QAAQ,IAAI,CAAC,CAAC;EAElD,IAAIC,cAAc,GA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EAAAE,KAAA;IAAZD,YAAY,CAAAC,KAAA,QAAAX,SAAA,CAAAW,KAAA;EAAA;EAUf,MAAMC,WAAW,GAAGlB,aAAa,CAACC,WAAW,EAAE,GAAG,IAAAkB,oBAAW,EAACH,YAAY,CAAC,CAAC;EAE5E,IAAIE,WAAW,EAAE;IACf,IAAAE,qBAAW,EAACF,WAAW,CAACf,QAAQ,CAAC;EACnC;EAEA,OAAOe,WAAW;AACpB,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAApC,OAAA,GAEa4B,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"createTheme.js","names":["_flattenDeep","_interopRequireDefault","require","_objects","_Settings","replacePlaceholders","inputTheme","_context","possibleKeys","_map","default","_keys","call","key","join","re","RegExp","_entries","forEach","value","replace","match","capture","generateTheme","storedTheme","themeElements","storedSettings","settings","generatedTheme","element","isPlainObject","generatedSettings","createTheme","themeConfigs","customTheme","flattenDeep","setSettings","_default","exports"],"sources":["../../src/react-theme/createTheme.js"],"sourcesContent":["// @flow\nimport flattenDeep from \"lodash/flattenDeep\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport { setSettings } from \"../constants/Settings\";\n\nimport type { Theme } from \"./types\";\n\nconst replacePlaceholders = (inputTheme: Theme) => {\n const possibleKeys = Object.keys(inputTheme)\n .map((key) => `\\\\b${key}\\\\b`)\n .join(\"|\");\n\n const re = new RegExp(`\\\\$(${possibleKeys})`, \"g\");\n Object.entries(inputTheme).forEach(([key, value]) => {\n if (key !== \"settings\" && typeof value === \"string\") {\n inputTheme[key] = value.replace(\n re,\n // $FlowIssue[incompatible-call]\n (match, capture) => inputTheme[capture],\n );\n }\n });\n\n return inputTheme;\n};\n\nconst generateTheme = (storedTheme: Theme, ...themeElements: Array<Theme>) => {\n const storedSettings = storedTheme?.settings ?? {};\n\n let generatedTheme = { settings: {} };\n for (const element of themeElements) {\n if (typeof element === \"function\") {\n generatedTheme = element(replacePlaceholders(generatedTheme));\n } else if (isPlainObject(element)) {\n const generatedSettings = generatedTheme.settings;\n // $FlowFixMe[cannot-spread-indexer]\n generatedTheme = { ...generatedTheme, ...element, ...storedTheme };\n if (\"settings\" in element) {\n generatedTheme.settings = {\n ...generatedSettings,\n ...element.settings,\n ...storedSettings,\n };\n }\n }\n }\n\n // final - replace any assignments inside the theme\n return replacePlaceholders(generatedTheme);\n};\n\n/**\n * Create a theme from multiple theme configuration objects.\n * Properties are overwriten by iterating the configuration objects from left to right.\n *\n * The first argument represents a stored theme part, this is optional. The stored theme part will overwrite every part in the collection of theme parts.\n * Thus a stored configuration is leading as it can be configured by a modeller through the repository.\n *\n * Placeholders can be used, they are replaced before calling a function theme part or at the end of the theme creation.\n *\n * Both objects and function can be used, where a function receives the previous objects as input arguments.\n * For example using the method createTheme(ThemeObject, ThemeObject2, ThemeFunction, ThemeFunction2), will be handled as:\n *\n * ThemeFunction2(ThemeFunction1({ ...ThemeObject, ...ThemeObject2 }))\n *\n * @example\n * Example where the primary color of the default theme is overwritten with a primary color of the custom theme,\n * but the button bg still uses the yiq function of the default theme:\n *\n * const DefaultTheme = {\n * PRIMARY_COLOR: \"#0000ff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * BUTTON_COLOR: \"$PRIMARY_COLOR\"\n * }\n *\n * const createDefaultTheme = (input) => ({\n * ...input,\n * BUTTON_BG: getContrastYIQ(input.BUTTON_COLOR)\n * })\n *\n * const CustomTheme = {\n * PRIMARY_COLOR: \"#ff0000\"\n * }\n *\n * createTheme(null, DefaultTheme, CustomTheme, createDefaultTheme);\n *\n * // Result:\n * {\n * PRIMARY_COLOR: \"#ff0000\",\n * BUTTON_COLOR: \"#ff0000\",\n * BUTTON_BG: \"#fff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * }\n */\nconst createTheme = (\n storedTheme: Theme,\n ...themeConfigs: Array<Theme | Array<Theme> | void>\n):\n | any\n | {}\n | {\n INPUT_FOCUS_BORDER_COLOR?: string,\n LINK_HOVER_COLOR?: string,\n PAGING_HOVER_COLOR?: string,\n settings?: { [settingName: string]: string },\n } => {\n const customTheme = generateTheme(storedTheme, ...flattenDeep(themeConfigs));\n\n if (customTheme) {\n setSettings(customTheme.settings);\n }\n\n return customTheme;\n};\n\nexport default createTheme;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAIA,MAAMG,mBAAmB,GAAIC,UAAiB,IAAK;EAAA,IAAAC,QAAA;EACjD,MAAMC,YAAY,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAH,QAAA,OAAAI,KAAA,CAAAD,OAAA,EAAYJ,UAAU,CAAC,EAAAM,IAAA,CAAAL,QAAA,EACpCM,GAAG,IAAK,MAAMA,GAAG,KAAK,CAAC,CAC5BC,IAAI,CAAC,GAAG,CAAC;EAEZ,MAAMC,EAAE,GAAG,IAAIC,MAAM,CAAC,OAAOR,YAAY,GAAG,EAAE,GAAG,CAAC;EAClD,IAAAS,QAAA,CAAAP,OAAA,EAAeJ,UAAU,CAAC,CAACY,OAAO,CAAC,CAAC,CAACL,GAAG,EAAEM,KAAK,CAAC,KAAK;IACnD,IAAIN,GAAG,KAAK,UAAU,IAAI,OAAOM,KAAK,KAAK,QAAQ,EAAE;MACnDb,UAAU,CAACO,GAAG,CAAC,GAAGM,KAAK,CAACC,OAAO,CAC7BL,EAAE;MACF;MACA,CAACM,KAAK,EAAEC,OAAO,KAAKhB,UAAU,CAACgB,OAAO,CACxC,CAAC;IACH;EACF,CAAC,CAAC;EAEF,OAAOhB,UAAU;AACnB,CAAC;AAED,MAAMiB,aAAa,GAAGA,CAACC,WAAkB,EAAE,GAAGC,aAA2B,KAAK;EAC5E,MAAMC,cAAc,GAAGF,WAAW,EAAEG,QAAQ,IAAI,CAAC,CAAC;EAElD,IAAIC,cAAc,GAAG;IAAED,QAAQ,EAAE,CAAC;EAAE,CAAC;EACrC,KAAK,MAAME,OAAO,IAAIJ,aAAa,EAAE;IACnC,IAAI,OAAOI,OAAO,KAAK,UAAU,EAAE;MACjCD,cAAc,GAAGC,OAAO,CAACxB,mBAAmB,CAACuB,cAAc,CAAC,CAAC;IAC/D,CAAC,MAAM,IAAI,IAAAE,sBAAa,EAACD,OAAO,CAAC,EAAE;MACjC,MAAME,iBAAiB,GAAGH,cAAc,CAACD,QAAQ;MACjD;MACAC,cAAc,GAAG;QAAE,GAAGA,cAAc;QAAE,GAAGC,OAAO;QAAE,GAAGL;MAAY,CAAC;MAClE,IAAI,UAAU,IAAIK,OAAO,EAAE;QACzBD,cAAc,CAACD,QAAQ,GAAG;UACxB,GAAGI,iBAAiB;UACpB,GAAGF,OAAO,CAACF,QAAQ;UACnB,GAAGD;QACL,CAAC;MACH;IACF;EACF;;EAEA;EACA,OAAOrB,mBAAmB,CAACuB,cAAc,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAGA,CAClBR,WAAkB,EAClB,GAAGS,YAAgD,KAS5C;EACP,MAAMC,WAAW,GAAGX,aAAa,CAACC,WAAW,EAAE,GAAG,IAAAW,oBAAW,EAACF,YAAY,CAAC,CAAC;EAE5E,IAAIC,WAAW,EAAE;IACf,IAAAE,qBAAW,EAACF,WAAW,CAACP,QAAQ,CAAC;EACnC;EAEA,OAAOO,WAAW;AACpB,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA5B,OAAA,GAEasB,WAAW","ignoreList":[]}
@@ -7,10 +7,9 @@ exports.renderBackground = void 0;
7
7
  var _themeProps = require("./themeProps");
8
8
  /**
9
9
  */
10
- const renderBackground = (path, defaultValue) => _ref => {
11
- let {
12
- theme
13
- } = _ref;
10
+ const renderBackground = (path, defaultValue) => ({
11
+ theme
12
+ }) => {
14
13
  const value = (0, _themeProps.getThemeProp)(theme, path, defaultValue);
15
14
  if (typeof value === "string") {
16
15
  return `background: ${value}`;
@@ -1 +1 @@
1
- {"version":3,"file":"background.js","names":["_themeProps","require","renderBackground","path","defaultValue","_ref","theme","value","getThemeProp","exports"],"sources":["../../../src/react-theme/utils/background.js"],"sourcesContent":["// @flow\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { ThemePropValue, UtilThemeProps } from \"../types\";\n\n/**\n */\nconst renderBackground =\n (path: string, defaultValue?: string): ((UtilThemeProps) => ThemePropValue) =>\n ({ theme }: UtilThemeProps) => {\n const value = getThemeProp(theme, path, defaultValue);\n\n if (typeof value === \"string\") {\n return `background: ${value}`;\n }\n\n return value;\n };\n\nexport { renderBackground };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA;AACA;AACA,MAAMC,gBAAgB,GACpBA,CAACC,IAAY,EAAEC,YAAqB,KACpCC,IAAA,IAA+B;EAAA,IAA9B;IAAEC;EAAsB,CAAC,GAAAD,IAAA;EACxB,MAAME,KAAK,GAAG,IAAAC,wBAAY,EAACF,KAAK,EAAEH,IAAI,EAAEC,YAAY,CAAC;EAErD,IAAI,OAAOG,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,eAAeA,KAAK,EAAE;EAC/B;EAEA,OAAOA,KAAK;AACd,CAAC;AAACE,OAAA,CAAAP,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"background.js","names":["_themeProps","require","renderBackground","path","defaultValue","theme","value","getThemeProp","exports"],"sources":["../../../src/react-theme/utils/background.js"],"sourcesContent":["// @flow\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { ThemePropValue, UtilThemeProps } from \"../types\";\n\n/**\n */\nconst renderBackground =\n (path: string, defaultValue?: string): ((UtilThemeProps) => ThemePropValue) =>\n ({ theme }: UtilThemeProps) => {\n const value = getThemeProp(theme, path, defaultValue);\n\n if (typeof value === \"string\") {\n return `background: ${value}`;\n }\n\n return value;\n };\n\nexport { renderBackground };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA;AACA;AACA,MAAMC,gBAAgB,GACpBA,CAACC,IAAY,EAAEC,YAAqB,KACpC,CAAC;EAAEC;AAAsB,CAAC,KAAK;EAC7B,MAAMC,KAAK,GAAG,IAAAC,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC;EAErD,IAAI,OAAOE,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,eAAeA,KAAK,EAAE;EAC/B;EAEA,OAAOA,KAAK;AACd,CAAC;AAACE,OAAA,CAAAN,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -11,12 +11,9 @@ var _themeProps = require("./themeProps");
11
11
  */
12
12
  /**
13
13
  */
14
- const darkenColor = (amount, path, defaultValue) => _ref => {
15
- let {
16
- theme
17
- } = _ref;
18
- return (0, _polished.darken)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
19
- };
14
+ const darkenColor = (amount, path, defaultValue) => ({
15
+ theme
16
+ }) => (0, _polished.darken)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
20
17
 
21
18
  /*
22
19
  * Themed color x amount lightened
@@ -24,12 +21,9 @@ const darkenColor = (amount, path, defaultValue) => _ref => {
24
21
  /**
25
22
  */
26
23
  exports.darkenColor = darkenColor;
27
- const lightenColor = (amount, path, defaultValue) => _ref2 => {
28
- let {
29
- theme
30
- } = _ref2;
31
- return (0, _polished.lighten)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
32
- };
24
+ const lightenColor = (amount, path, defaultValue) => ({
25
+ theme
26
+ }) => (0, _polished.lighten)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
33
27
 
34
28
  /*
35
29
  * Make a color lighter or darker in the same color family
@@ -37,9 +31,6 @@ const lightenColor = (amount, path, defaultValue) => _ref2 => {
37
31
  /**
38
32
  */
39
33
  exports.lightenColor = lightenColor;
40
- const changeHSL = function (color, saturation, lightness) {
41
- let hueAdjustment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
42
- return (0, _polished.hsl)((0, _polished.parseToHsl)(color).hue + hueAdjustment, saturation, lightness);
43
- };
34
+ const changeHSL = (color, saturation, lightness, hueAdjustment = 0) => (0, _polished.hsl)((0, _polished.parseToHsl)(color).hue + hueAdjustment, saturation, lightness);
44
35
  exports.changeHSL = changeHSL;
45
36
  //# sourceMappingURL=colors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colors.js","names":["_polished","require","_themeProps","darkenColor","amount","path","defaultValue","_ref","theme","darken","getThemeProp","exports","lightenColor","_ref2","lighten","changeHSL","color","saturation","lightness","hueAdjustment","arguments","length","undefined","hsl","parseToHsl","hue"],"sources":["../../../src/react-theme/utils/colors.js"],"sourcesContent":["// @flow\nimport { darken, hsl, lighten, parseToHsl } from \"polished\";\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\n/*\n * Themed color x amount darkened\n */\n/**\n */\nconst darkenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n darken(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Themed color x amount lightened\n */\n/**\n */\nconst lightenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n lighten(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Make a color lighter or darker in the same color family\n */\n/**\n */\nconst changeHSL = (\n color: string,\n saturation?: number,\n lightness?: number,\n hueAdjustment: number = 0,\n): string => hsl(parseToHsl(color).hue + hueAdjustment, saturation, lightness);\n\nexport { darkenColor, lightenColor, changeHSL };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA,MAAME,WAAW,GACfA,CACEC,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvBC,IAAA;EAAA,IAAC;IAAEC;EAAsB,CAAC,GAAAD,IAAA;EAAA,OACxB,IAAAE,gBAAM,EAACL,MAAM,EAAE,IAAAM,wBAAY,EAACF,KAAK,EAAEH,IAAI,EAAEC,YAAY,CAAC,CAAC;AAAA;;AAE3D;AACA;AACA;AACA;AACA;AADAK,OAAA,CAAAR,WAAA,GAAAA,WAAA;AAEA,MAAMS,YAAY,GAChBA,CACER,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvBO,KAAA;EAAA,IAAC;IAAEL;EAAsB,CAAC,GAAAK,KAAA;EAAA,OACxB,IAAAC,iBAAO,EAACV,MAAM,EAAE,IAAAM,wBAAY,EAACF,KAAK,EAAEH,IAAI,EAAEC,YAAY,CAAC,CAAC;AAAA;;AAE5D;AACA;AACA;AACA;AACA;AADAK,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEA,MAAMG,SAAS,GAAG,SAAAA,CAChBC,KAAa,EACbC,UAAmB,EACnBC,SAAkB;EAAA,IAClBC,aAAqB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,OACd,IAAAG,aAAG,EAAC,IAAAC,oBAAU,EAACR,KAAK,CAAC,CAACS,GAAG,GAAGN,aAAa,EAAEF,UAAU,EAAEC,SAAS,CAAC;AAAA;AAACP,OAAA,CAAAI,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"colors.js","names":["_polished","require","_themeProps","darkenColor","amount","path","defaultValue","theme","darken","getThemeProp","exports","lightenColor","lighten","changeHSL","color","saturation","lightness","hueAdjustment","hsl","parseToHsl","hue"],"sources":["../../../src/react-theme/utils/colors.js"],"sourcesContent":["// @flow\nimport { darken, hsl, lighten, parseToHsl } from \"polished\";\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\n/*\n * Themed color x amount darkened\n */\n/**\n */\nconst darkenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n darken(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Themed color x amount lightened\n */\n/**\n */\nconst lightenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n lighten(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Make a color lighter or darker in the same color family\n */\n/**\n */\nconst changeHSL = (\n color: string,\n saturation?: number,\n lightness?: number,\n hueAdjustment: number = 0,\n): string => hsl(parseToHsl(color).hue + hueAdjustment, saturation, lightness);\n\nexport { darkenColor, lightenColor, changeHSL };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA,MAAME,WAAW,GACfA,CACEC,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvB,CAAC;EAAEC;AAAsB,CAAC,KACxB,IAAAC,gBAAM,EAACJ,MAAM,EAAE,IAAAK,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC,CAAC;;AAE3D;AACA;AACA;AACA;AACA;AADAI,OAAA,CAAAP,WAAA,GAAAA,WAAA;AAEA,MAAMQ,YAAY,GAChBA,CACEP,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvB,CAAC;EAAEC;AAAsB,CAAC,KACxB,IAAAK,iBAAO,EAACR,MAAM,EAAE,IAAAK,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AADAI,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEA,MAAME,SAAS,GAAGA,CAChBC,KAAa,EACbC,UAAmB,EACnBC,SAAkB,EAClBC,aAAqB,GAAG,CAAC,KACd,IAAAC,aAAG,EAAC,IAAAC,oBAAU,EAACL,KAAK,CAAC,CAACM,GAAG,GAAGH,aAAa,EAAEF,UAAU,EAAEC,SAAS,CAAC;AAACN,OAAA,CAAAG,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -35,10 +35,7 @@ const getYIQ = color => {
35
35
  * the preferred color is returned
36
36
  */
37
37
  exports.getYIQ = getYIQ;
38
- const getContrastYIQ = function (color) {
39
- let dark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "#212529";
40
- let light = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "#fff";
41
- let preferredColor = arguments.length > 3 ? arguments[3] : undefined;
38
+ const getContrastYIQ = (color, dark = "#212529", light = "#fff", preferredColor) => {
42
39
  const yiqColor = getYIQ(color);
43
40
  if (preferredColor && getColorContrast(color, preferredColor) >= 4.5) {
44
41
  return preferredColor;
@@ -75,21 +72,16 @@ const getBackgroundColor = (theme, bgColorProperty, defaultValue) => {
75
72
  * Retrieve the contrast color for the given background property,
76
73
  * based on theme properties
77
74
  */
78
- const renderContrastColor = function (bgColorProperty, preferredColorProperty) {
79
- let standardDarkProperty = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "YIQ_DARK_COLOR";
80
- let standardLightProperty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "YIQ_LIGHT_COLOR";
81
- return _ref => {
82
- let {
83
- theme = {
84
- settings: {}
85
- }
86
- } = _ref;
87
- const bgColor = getBackgroundColor(theme, bgColorProperty, "#ffffff");
88
- const preferredColor = (0, _themeProps.getThemeStringProp)(theme, preferredColorProperty);
89
- const darkColor = (0, _themeProps.getThemeStringProp)(theme, standardDarkProperty, "#212529");
90
- const lightColor = (0, _themeProps.getThemeStringProp)(theme, standardLightProperty, "#fff");
91
- return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);
92
- };
75
+ const renderContrastColor = (bgColorProperty, preferredColorProperty, standardDarkProperty = "YIQ_DARK_COLOR", standardLightProperty = "YIQ_LIGHT_COLOR") => ({
76
+ theme = {
77
+ settings: {}
78
+ }
79
+ }) => {
80
+ const bgColor = getBackgroundColor(theme, bgColorProperty, "#ffffff");
81
+ const preferredColor = (0, _themeProps.getThemeStringProp)(theme, preferredColorProperty);
82
+ const darkColor = (0, _themeProps.getThemeStringProp)(theme, standardDarkProperty, "#212529");
83
+ const lightColor = (0, _themeProps.getThemeStringProp)(theme, standardLightProperty, "#fff");
84
+ return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);
93
85
  };
94
86
  exports.renderContrastColor = renderContrastColor;
95
87
  //# sourceMappingURL=contrast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contrast.js","names":["_polished","require","_themeProps","_exceptions","getColorContrast","color1","color2","luminance1","getLuminance","luminance2","parseFloat","toFixed","exports","getYIQ","color","rgb","parseToRgb","red","green","blue","getContrastYIQ","dark","arguments","length","undefined","light","preferredColor","yiqColor","darkColor","lightColor","getBackgroundColor","theme","bgColorProperty","defaultValue","bgColor","getProp","backgroundColor","ThemePropertyException","renderContrastColor","preferredColorProperty","standardDarkProperty","standardLightProperty","_ref","settings","getThemeStringProp"],"sources":["../../../src/react-theme/utils/contrast.js"],"sourcesContent":["// @flow\nimport { getLuminance, parseToRgb } from \"polished\";\n\nimport { getThemeStringProp, getProp } from \"./themeProps\";\n\nimport { ThemePropertyException } from \"../../exceptions\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\n\n/**\n * calculate the contrast ratio of two colors\n */\nconst getColorContrast = (color1: string, color2: string): number => {\n const luminance1 = getLuminance(color1);\n const luminance2 = getLuminance(color2);\n return parseFloat(\n (luminance1 > luminance2\n ? (luminance1 + 0.05) / (luminance2 + 0.05)\n : (luminance2 + 0.05) / (luminance1 + 0.05)\n ).toFixed(2),\n );\n};\n\n/*\n * The YIQ equation converts the RGB color (0 to 255) into a YIQ color space.\n * YIQ is the standard formula for calculating the perceived brightness of a color,\n * and is recommended by the World Wide Web Consortium (W3C).\n */\n/**\n */\nconst getYIQ = (color: string): number => {\n const rgb = parseToRgb(color);\n\n return (rgb.red * 299 + rgb.green * 587 + rgb.blue * 114) / 1000;\n};\n\n/**\n * Get dark or light color, depending on the given color\n * When the contrast between the color and the light or dark color is too low,\n * the preferred color is returned\n */\nconst getContrastYIQ = (\n color: string,\n dark: string = \"#212529\",\n light: string = \"#fff\",\n preferredColor?: string,\n): string => {\n const yiqColor = getYIQ(color);\n\n if (preferredColor && getColorContrast(color, preferredColor) >= 4.5) {\n return preferredColor;\n }\n\n const darkColor = getYIQ(dark) < 127.5 ? dark : \"#212529\";\n const lightColor = getYIQ(light) > 127.5 ? light : \"#fff\";\n\n if (yiqColor > 127.5) {\n if (getColorContrast(color, darkColor) < 3) {\n return \"#212529\";\n }\n\n return darkColor;\n }\n\n if (getColorContrast(color, lightColor) < 3) {\n return \"#fff\";\n }\n return lightColor;\n};\n\n/**\n */\nconst getBackgroundColor = (\n theme: Theme,\n bgColorProperty: string,\n defaultValue: string,\n) => {\n let bgColor = getProp(theme, bgColorProperty, defaultValue);\n\n if (typeof bgColor === \"object\") {\n bgColor = bgColor?.backgroundColor ?? defaultValue;\n }\n\n if (typeof bgColor === \"string\") {\n return bgColor;\n }\n\n throw new ThemePropertyException(\n `${bgColorProperty} is not a string, but: ${typeof bgColor}`,\n );\n};\n\n/**\n * Retrieve the contrast color for the given background property,\n * based on theme properties\n */\nconst renderContrastColor =\n (\n bgColorProperty: string,\n preferredColorProperty?: string,\n standardDarkProperty: string = \"YIQ_DARK_COLOR\",\n standardLightProperty: string = \"YIQ_LIGHT_COLOR\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n const bgColor = getBackgroundColor(theme, bgColorProperty, \"#ffffff\");\n const preferredColor = getThemeStringProp(theme, preferredColorProperty);\n const darkColor = getThemeStringProp(\n theme,\n standardDarkProperty,\n \"#212529\",\n );\n const lightColor = getThemeStringProp(theme, standardLightProperty, \"#fff\");\n\n return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);\n };\n\nexport { getColorContrast, getYIQ, getContrastYIQ, renderContrastColor };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACA;AACA,MAAMG,gBAAgB,GAAGA,CAACC,MAAc,EAAEC,MAAc,KAAa;EACnE,MAAMC,UAAU,GAAG,IAAAC,sBAAY,EAACH,MAAM,CAAC;EACvC,MAAMI,UAAU,GAAG,IAAAD,sBAAY,EAACF,MAAM,CAAC;EACvC,OAAOI,UAAU,CACf,CAACH,UAAU,GAAGE,UAAU,GACpB,CAACF,UAAU,GAAG,IAAI,KAAKE,UAAU,GAAG,IAAI,CAAC,GACzC,CAACA,UAAU,GAAG,IAAI,KAAKF,UAAU,GAAG,IAAI,CAAC,EAC3CI,OAAO,CAAC,CAAC,CACb,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AADAC,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAEA,MAAMS,MAAM,GAAIC,KAAa,IAAa;EACxC,MAAMC,GAAG,GAAG,IAAAC,oBAAU,EAACF,KAAK,CAAC;EAE7B,OAAO,CAACC,GAAG,CAACE,GAAG,GAAG,GAAG,GAAGF,GAAG,CAACG,KAAK,GAAG,GAAG,GAAGH,GAAG,CAACI,IAAI,GAAG,GAAG,IAAI,IAAI;AAClE,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAP,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAKA,MAAMO,cAAc,GAAG,SAAAA,CACrBN,KAAa,EAIF;EAAA,IAHXO,IAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EAAA,IACxBG,KAAa,GAAAH,SAAA,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5D,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMI,mBAAmB,GACvB,SAAAA,CACEN,eAAuB,EACvBO,sBAA+B;EAAA,IAC/BC,oBAA4B,GAAAlB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,gBAAgB;EAAA,IAC/CmB,qBAA6B,GAAAnB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,iBAAiB;EAAA,OAEnDoB,IAAA,IAAkD;IAAA,IAAjD;MAAEX,KAAK,GAAG;QAAEY,QAAQ,EAAE,CAAC;MAAE;IAAkB,CAAC,GAAAD,IAAA;IAC3C,MAAMR,OAAO,GAAGJ,kBAAkB,CAACC,KAAK,EAAEC,eAAe,EAAE,SAAS,CAAC;IACrE,MAAMN,cAAc,GAAG,IAAAkB,8BAAkB,EAACb,KAAK,EAAEQ,sBAAsB,CAAC;IACxE,MAAMX,SAAS,GAAG,IAAAgB,8BAAkB,EAClCb,KAAK,EACLS,oBAAoB,EACpB,SACF,CAAC;IACD,MAAMX,UAAU,GAAG,IAAAe,8BAAkB,EAACb,KAAK,EAAEU,qBAAqB,EAAE,MAAM,CAAC;IAE3E,OAAOrB,cAAc,CAACc,OAAO,EAAEN,SAAS,EAAEC,UAAU,EAAEH,cAAc,CAAC;EACvE,CAAC;AAAA;AAACd,OAAA,CAAA0B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"contrast.js","names":["_polished","require","_themeProps","_exceptions","getColorContrast","color1","color2","luminance1","getLuminance","luminance2","parseFloat","toFixed","exports","getYIQ","color","rgb","parseToRgb","red","green","blue","getContrastYIQ","dark","light","preferredColor","yiqColor","darkColor","lightColor","getBackgroundColor","theme","bgColorProperty","defaultValue","bgColor","getProp","backgroundColor","ThemePropertyException","renderContrastColor","preferredColorProperty","standardDarkProperty","standardLightProperty","settings","getThemeStringProp"],"sources":["../../../src/react-theme/utils/contrast.js"],"sourcesContent":["// @flow\nimport { getLuminance, parseToRgb } from \"polished\";\n\nimport { getThemeStringProp, getProp } from \"./themeProps\";\n\nimport { ThemePropertyException } from \"../../exceptions\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\n\n/**\n * calculate the contrast ratio of two colors\n */\nconst getColorContrast = (color1: string, color2: string): number => {\n const luminance1 = getLuminance(color1);\n const luminance2 = getLuminance(color2);\n return parseFloat(\n (luminance1 > luminance2\n ? (luminance1 + 0.05) / (luminance2 + 0.05)\n : (luminance2 + 0.05) / (luminance1 + 0.05)\n ).toFixed(2),\n );\n};\n\n/*\n * The YIQ equation converts the RGB color (0 to 255) into a YIQ color space.\n * YIQ is the standard formula for calculating the perceived brightness of a color,\n * and is recommended by the World Wide Web Consortium (W3C).\n */\n/**\n */\nconst getYIQ = (color: string): number => {\n const rgb = parseToRgb(color);\n\n return (rgb.red * 299 + rgb.green * 587 + rgb.blue * 114) / 1000;\n};\n\n/**\n * Get dark or light color, depending on the given color\n * When the contrast between the color and the light or dark color is too low,\n * the preferred color is returned\n */\nconst getContrastYIQ = (\n color: string,\n dark: string = \"#212529\",\n light: string = \"#fff\",\n preferredColor?: string,\n): string => {\n const yiqColor = getYIQ(color);\n\n if (preferredColor && getColorContrast(color, preferredColor) >= 4.5) {\n return preferredColor;\n }\n\n const darkColor = getYIQ(dark) < 127.5 ? dark : \"#212529\";\n const lightColor = getYIQ(light) > 127.5 ? light : \"#fff\";\n\n if (yiqColor > 127.5) {\n if (getColorContrast(color, darkColor) < 3) {\n return \"#212529\";\n }\n\n return darkColor;\n }\n\n if (getColorContrast(color, lightColor) < 3) {\n return \"#fff\";\n }\n return lightColor;\n};\n\n/**\n */\nconst getBackgroundColor = (\n theme: Theme,\n bgColorProperty: string,\n defaultValue: string,\n) => {\n let bgColor = getProp(theme, bgColorProperty, defaultValue);\n\n if (typeof bgColor === \"object\") {\n bgColor = bgColor?.backgroundColor ?? defaultValue;\n }\n\n if (typeof bgColor === \"string\") {\n return bgColor;\n }\n\n throw new ThemePropertyException(\n `${bgColorProperty} is not a string, but: ${typeof bgColor}`,\n );\n};\n\n/**\n * Retrieve the contrast color for the given background property,\n * based on theme properties\n */\nconst renderContrastColor =\n (\n bgColorProperty: string,\n preferredColorProperty?: string,\n standardDarkProperty: string = \"YIQ_DARK_COLOR\",\n standardLightProperty: string = \"YIQ_LIGHT_COLOR\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n const bgColor = getBackgroundColor(theme, bgColorProperty, \"#ffffff\");\n const preferredColor = getThemeStringProp(theme, preferredColorProperty);\n const darkColor = getThemeStringProp(\n theme,\n standardDarkProperty,\n \"#212529\",\n );\n const lightColor = getThemeStringProp(theme, standardLightProperty, \"#fff\");\n\n return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);\n };\n\nexport { getColorContrast, getYIQ, getContrastYIQ, renderContrastColor };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACA;AACA,MAAMG,gBAAgB,GAAGA,CAACC,MAAc,EAAEC,MAAc,KAAa;EACnE,MAAMC,UAAU,GAAG,IAAAC,sBAAY,EAACH,MAAM,CAAC;EACvC,MAAMI,UAAU,GAAG,IAAAD,sBAAY,EAACF,MAAM,CAAC;EACvC,OAAOI,UAAU,CACf,CAACH,UAAU,GAAGE,UAAU,GACpB,CAACF,UAAU,GAAG,IAAI,KAAKE,UAAU,GAAG,IAAI,CAAC,GACzC,CAACA,UAAU,GAAG,IAAI,KAAKF,UAAU,GAAG,IAAI,CAAC,EAC3CI,OAAO,CAAC,CAAC,CACb,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AADAC,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAEA,MAAMS,MAAM,GAAIC,KAAa,IAAa;EACxC,MAAMC,GAAG,GAAG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EAAE;IAC/BA,OAAO,GAAGA,OAAO,EAAEE,eAAe,IAAIH,YAAY;EACpD;EAEA,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAM,IAAIG,kCAAsB,CAC9B,GAAGL,eAAe,0BAA0B,OAAOE,OAAO,EAC5D,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMI,mBAAmB,GACvBA,CACEN,eAAuB,EACvBO,sBAA+B,EAC/BC,oBAA4B,GAAG,gBAAgB,EAC/CC,qBAA6B,GAAG,iBAAiB,KAEnD,CAAC;EAAEV,KAAK,GAAG;IAAEW,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAAK;EAChD,MAAMR,OAAO,GAAGJ,kBAAkB,CAACC,KAAK,EAAEC,eAAe,EAAE,SAAS,CAAC;EACrE,MAAMN,cAAc,GAAG,IAAAiB,8BAAkB,EAACZ,KAAK,EAAEQ,sBAAsB,CAAC;EACxE,MAAMX,SAAS,GAAG,IAAAe,8BAAkB,EAClCZ,KAAK,EACLS,oBAAoB,EACpB,SACF,CAAC;EACD,MAAMX,UAAU,GAAG,IAAAc,8BAAkB,EAACZ,KAAK,EAAEU,qBAAqB,EAAE,MAAM,CAAC;EAE3E,OAAOlB,cAAc,CAACW,OAAO,EAAEN,SAAS,EAAEC,UAAU,EAAEH,cAAc,CAAC;AACvE,CAAC;AAACX,OAAA,CAAAuB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -13,22 +13,16 @@ const DEFAULT_CORNER_PROPERTY = "border-radius";
13
13
  */
14
14
  /**
15
15
  */
16
- const roundedCorners = function () {
17
- let property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CORNER_PROPERTY;
18
- let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BORDER_RADIUS";
19
- let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "0.25rem";
20
- return _ref => {
21
- let {
22
- theme = {
23
- settings: {}
24
- }
25
- } = _ref;
26
- if (theme.ROUNDED_CORNERS) {
27
- const propertyName = property && property !== DEFAULT_CORNER_PROPERTY ? `border-${property}-radius` : DEFAULT_CORNER_PROPERTY;
28
- return `${propertyName}: ${(0, _themeProps.getThemeStringProp)(theme, path, defaultValue)}`;
29
- }
30
- return "";
31
- };
16
+ const roundedCorners = (property = DEFAULT_CORNER_PROPERTY, path = "BORDER_RADIUS", defaultValue = "0.25rem") => ({
17
+ theme = {
18
+ settings: {}
19
+ }
20
+ }) => {
21
+ if (theme.ROUNDED_CORNERS) {
22
+ const propertyName = property && property !== DEFAULT_CORNER_PROPERTY ? `border-${property}-radius` : DEFAULT_CORNER_PROPERTY;
23
+ return `${propertyName}: ${(0, _themeProps.getThemeStringProp)(theme, path, defaultValue)}`;
24
+ }
25
+ return "";
32
26
  };
33
27
  exports.roundedCorners = roundedCorners;
34
28
  //# sourceMappingURL=corners.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"corners.js","names":["_themeProps","require","DEFAULT_CORNER_PROPERTY","roundedCorners","property","arguments","length","undefined","path","defaultValue","_ref","theme","settings","ROUNDED_CORNERS","propertyName","getThemeStringProp","exports"],"sources":["../../../src/react-theme/utils/corners.js"],"sourcesContent":["// @flow\nimport { getThemeStringProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\nconst DEFAULT_CORNER_PROPERTY = \"border-radius\";\n\n/*\n * Border radius based on the theme setting for rounded corners\n * When ROUNDED_CORNERS is not true in the theme, no rounded corners are returned\n */\n/**\n */\nconst roundedCorners =\n (\n property: string = DEFAULT_CORNER_PROPERTY,\n path: string = \"BORDER_RADIUS\",\n defaultValue: string = \"0.25rem\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n if (theme.ROUNDED_CORNERS) {\n const propertyName =\n property && property !== DEFAULT_CORNER_PROPERTY\n ? `border-${property}-radius`\n : DEFAULT_CORNER_PROPERTY;\n\n return `${propertyName}: ${getThemeStringProp(\n theme,\n path,\n defaultValue,\n )}`;\n }\n\n return \"\";\n };\n\nexport { roundedCorners };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA,MAAMC,uBAAuB,GAAG,eAAe;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAClB,SAAAA,CAAA;EAAA,IACEC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGH,uBAAuB;EAAA,IAC1CM,IAAY,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BI,YAAoB,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EAAA,OAElCK,IAAA,IAAkD;IAAA,IAAjD;MAAEC,KAAK,GAAG;QAAEC,QAAQ,EAAE,CAAC;MAAE;IAAkB,CAAC,GAAAF,IAAA;IAC3C,IAAIC,KAAK,CAACE,eAAe,EAAE;MACzB,MAAMC,YAAY,GAChBV,QAAQ,IAAIA,QAAQ,KAAKF,uBAAuB,GAC5C,UAAUE,QAAQ,SAAS,GAC3BF,uBAAuB;MAE7B,OAAO,GAAGY,YAAY,KAAK,IAAAC,8BAAkB,EAC3CJ,KAAK,EACLH,IAAI,EACJC,YACF,CAAC,EAAE;IACL;IAEA,OAAO,EAAE;EACX,CAAC;AAAA;AAACO,OAAA,CAAAb,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"corners.js","names":["_themeProps","require","DEFAULT_CORNER_PROPERTY","roundedCorners","property","path","defaultValue","theme","settings","ROUNDED_CORNERS","propertyName","getThemeStringProp","exports"],"sources":["../../../src/react-theme/utils/corners.js"],"sourcesContent":["// @flow\nimport { getThemeStringProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\nconst DEFAULT_CORNER_PROPERTY = \"border-radius\";\n\n/*\n * Border radius based on the theme setting for rounded corners\n * When ROUNDED_CORNERS is not true in the theme, no rounded corners are returned\n */\n/**\n */\nconst roundedCorners =\n (\n property: string = DEFAULT_CORNER_PROPERTY,\n path: string = \"BORDER_RADIUS\",\n defaultValue: string = \"0.25rem\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n if (theme.ROUNDED_CORNERS) {\n const propertyName =\n property && property !== DEFAULT_CORNER_PROPERTY\n ? `border-${property}-radius`\n : DEFAULT_CORNER_PROPERTY;\n\n return `${propertyName}: ${getThemeStringProp(\n theme,\n path,\n defaultValue,\n )}`;\n }\n\n return \"\";\n };\n\nexport { roundedCorners };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA,MAAMC,uBAAuB,GAAG,eAAe;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAClBA,CACEC,QAAgB,GAAGF,uBAAuB,EAC1CG,IAAY,GAAG,eAAe,EAC9BC,YAAoB,GAAG,SAAS,KAElC,CAAC;EAAEC,KAAK,GAAG;IAAEC,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAAK;EAChD,IAAID,KAAK,CAACE,eAAe,EAAE;IACzB,MAAMC,YAAY,GAChBN,QAAQ,IAAIA,QAAQ,KAAKF,uBAAuB,GAC5C,UAAUE,QAAQ,SAAS,GAC3BF,uBAAuB;IAE7B,OAAO,GAAGQ,YAAY,KAAK,IAAAC,8BAAkB,EAC3CJ,KAAK,EACLF,IAAI,EACJC,YACF,CAAC,EAAE;EACL;EAEA,OAAO,EAAE;AACX,CAAC;AAACM,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -12,10 +12,7 @@ var _IllegalArgumentException = _interopRequireDefault(require("../../exceptions
12
12
  var _IllegalStateException = _interopRequireDefault(require("../../exceptions/IllegalStateException"));
13
13
  /**
14
14
  */
15
- const getSize = function (theme) {
16
- let ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
17
- let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "SPACER";
18
- let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "rem";
15
+ const getSize = (theme, ratio = 1, path = "SPACER", unit = "rem") => {
19
16
  if (typeof ratio === "string") {
20
17
  return ratio;
21
18
  }
@@ -34,17 +31,11 @@ const getSize = function (theme) {
34
31
  */
35
32
  /**
36
33
  */
37
- const spacer = function () {
38
- let ratio = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
39
- return _ref => {
40
- let {
41
- theme = {
42
- settings: {}
43
- }
44
- } = _ref;
45
- return getSize(theme, ratio);
46
- };
47
- };
34
+ const spacer = (ratio = 1) => ({
35
+ theme = {
36
+ settings: {}
37
+ }
38
+ }) => getSize(theme, ratio);
48
39
 
49
40
  /*
50
41
  * Render spacers based on the given ratio * theme SPACER
@@ -54,19 +45,11 @@ const spacer = function () {
54
45
  /**
55
46
  */
56
47
  exports.spacer = spacer;
57
- const spacers = function () {
58
- for (var _len = arguments.length, ratios = new Array(_len), _key = 0; _key < _len; _key++) {
59
- ratios[_key] = arguments[_key];
48
+ const spacers = (...ratios) => ({
49
+ theme = {
50
+ settings: {}
60
51
  }
61
- return _ref2 => {
62
- let {
63
- theme = {
64
- settings: {}
65
- }
66
- } = _ref2;
67
- return (0, _map.default)(ratios).call(ratios, ratio => getSize(theme, ratio)).join(" ");
68
- };
69
- };
52
+ }) => (0, _map.default)(ratios).call(ratios, ratio => getSize(theme, ratio)).join(" ");
70
53
 
71
54
  /*
72
55
  * Render a gutter based on GUTTER property
@@ -74,16 +57,10 @@ const spacers = function () {
74
57
  /**
75
58
  */
76
59
  exports.spacers = spacers;
77
- const gutter = function () {
78
- let ratio = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
79
- return _ref3 => {
80
- let {
81
- theme = {
82
- settings: {}
83
- }
84
- } = _ref3;
85
- return getSize(theme, ratio, "GRID_GUTTER", "px");
86
- };
87
- };
60
+ const gutter = (ratio = 1) => ({
61
+ theme = {
62
+ settings: {}
63
+ }
64
+ }) => getSize(theme, ratio, "GRID_GUTTER", "px");
88
65
  exports.gutter = gutter;
89
66
  //# sourceMappingURL=spacers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spacers.js","names":["_big","_interopRequireDefault","require","_IllegalArgumentException","_IllegalStateException","getSize","theme","ratio","arguments","length","undefined","path","unit","size","Big","times","IllegalStateException","IllegalArgumentException","_stringify","default","spacer","_ref","settings","exports","spacers","_len","ratios","Array","_key","_ref2","_map","call","join","gutter","_ref3"],"sources":["../../../src/react-theme/utils/spacers.js"],"sourcesContent":["// @flow\nimport Big from \"big.js\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\nimport IllegalArgumentException from \"../../exceptions/IllegalArgumentException\";\nimport IllegalStateException from \"../../exceptions/IllegalStateException\";\n\n/**\n */\nconst getSize = (\n theme: Theme,\n ratio: number | string = 1,\n path: string = \"SPACER\",\n unit: string = \"rem\",\n) => {\n if (typeof ratio === \"string\") {\n return ratio;\n }\n\n if (typeof ratio === \"number\") {\n if (typeof theme[path] === \"number\") {\n const size = Big(ratio).times(theme[path]);\n return `${size}${unit}`;\n }\n throw new IllegalStateException(`Size ${path} must be a number`);\n }\n\n throw new IllegalArgumentException(\n `Ratio ${JSON.stringify(ratio)} must be a string or number`,\n );\n};\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n */\n/**\n */\nconst spacer =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio);\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n * Ratio's can be given clockwise with shorthand,\n * spacers(0.5, 1) with a spacer of 0.8 will give \"0.4rem 1rem\";\n */\n/**\n */\nconst spacers =\n (...ratios: Array<number | \"auto\">): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n ratios.map((ratio) => getSize(theme, ratio)).join(\" \");\n\n/*\n * Render a gutter based on GUTTER property\n */\n/**\n */\nconst gutter =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio, \"GRID_GUTTER\", \"px\");\n\nexport { spacer, spacers, gutter };\n"],"mappings":";;;;;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,yBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA,MAAMG,OAAO,GAAG,SAAAA,CACdC,KAAY,EAIT;EAAA,IAHHC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IAC1BG,IAAY,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,QAAQ;EAAA,IACvBI,IAAY,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEpB,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EAEA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAI,OAAOD,KAAK,CAACK,IAAI,CAAC,KAAK,QAAQ,EAAE;MACnC,MAAME,IAAI,GAAG,IAAAC,YAAG,EAACP,KAAK,CAAC,CAACQ,KAAK,CAACT,KAAK,CAACK,IAAI,CAAC,CAAC;MAC1C,OAAO,GAAGE,IAAI,GAAGD,IAAI,EAAE;IACzB;IACA,MAAM,IAAII,8BAAqB,CAAC,QAAQL,IAAI,mBAAmB,CAAC;EAClE;EAEA,MAAM,IAAIM,iCAAwB,CAChC,SAAS,IAAAC,UAAA,CAAAC,OAAA,EAAeZ,KAAK,CAAC,6BAChC,CAAC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,CAAC;MAAE;IAAkB,CAAC,GAAAY,KAAA;IAAA,OAC3C7B,OAAO,CAACC,KAAK,EAAEC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC;EAAA;AAAA;AAACgB,OAAA,CAAAU,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"file":"spacers.js","names":["_big","_interopRequireDefault","require","_IllegalArgumentException","_IllegalStateException","getSize","theme","ratio","path","unit","size","Big","times","IllegalStateException","IllegalArgumentException","_stringify","default","spacer","settings","exports","spacers","ratios","_map","call","join","gutter"],"sources":["../../../src/react-theme/utils/spacers.js"],"sourcesContent":["// @flow\nimport Big from \"big.js\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\nimport IllegalArgumentException from \"../../exceptions/IllegalArgumentException\";\nimport IllegalStateException from \"../../exceptions/IllegalStateException\";\n\n/**\n */\nconst getSize = (\n theme: Theme,\n ratio: number | string = 1,\n path: string = \"SPACER\",\n unit: string = \"rem\",\n) => {\n if (typeof ratio === \"string\") {\n return ratio;\n }\n\n if (typeof ratio === \"number\") {\n if (typeof theme[path] === \"number\") {\n const size = Big(ratio).times(theme[path]);\n return `${size}${unit}`;\n }\n throw new IllegalStateException(`Size ${path} must be a number`);\n }\n\n throw new IllegalArgumentException(\n `Ratio ${JSON.stringify(ratio)} must be a string or number`,\n );\n};\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n */\n/**\n */\nconst spacer =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio);\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n * Ratio's can be given clockwise with shorthand,\n * spacers(0.5, 1) with a spacer of 0.8 will give \"0.4rem 1rem\";\n */\n/**\n */\nconst spacers =\n (...ratios: Array<number | \"auto\">): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n ratios.map((ratio) => getSize(theme, ratio)).join(\" \");\n\n/*\n * Render a gutter based on GUTTER property\n */\n/**\n */\nconst gutter =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio, \"GRID_GUTTER\", \"px\");\n\nexport { spacer, spacers, gutter };\n"],"mappings":";;;;;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,yBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA,MAAMG,OAAO,GAAGA,CACdC,KAAY,EACZC,KAAsB,GAAG,CAAC,EAC1BC,IAAY,GAAG,QAAQ,EACvBC,IAAY,GAAG,KAAK,KACjB;EACH,IAAI,OAAOF,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EAEA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAI,OAAOD,KAAK,CAACE,IAAI,CAAC,KAAK,QAAQ,EAAE;MACnC,MAAME,IAAI,GAAG,IAAAC,YAAG,EAACJ,KAAK,CAAC,CAACK,KAAK,CAACN,KAAK,CAACE,IAAI,CAAC,CAAC;MAC1C,OAAO,GAAGE,IAAI,GAAGD,IAAI,EAAE;IACzB;IACA,MAAM,IAAII,8BAAqB,CAAC,QAAQL,IAAI,mBAAmB,CAAC;EAClE;EAEA,MAAM,IAAIM,iCAAwB,CAChC,SAAS,IAAAC,UAAA,CAAAC,OAAA,EAAeT,KAAK,CAAC,6BAChC,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMU,MAAM,GACVA,CAACV,KAAa,GAAG,CAAC,KAClB,CAAC;EAAED,KAAK,GAAG;IAAEY,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAC3Cb,OAAO,CAACC,KAAK,EAAEC,KAAK,CAAC;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AADAY,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAEA,MAAMG,OAAO,GACXA,CAAC,GAAGC,MAA8B,KAClC,CAAC;EAAEf,KAAK,GAAG;IAAEY,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAC3C,IAAAI,IAAA,CAAAN,OAAA,EAAAK,MAAM,EAAAE,IAAA,CAANF,MAAM,EAAMd,KAAK,IAAKF,OAAO,CAACC,KAAK,EAAEC,KAAK,CAAC,CAAC,CAACiB,IAAI,CAAC,GAAG,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AADAL,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAEA,MAAMK,MAAM,GACVA,CAAClB,KAAa,GAAG,CAAC,KAClB,CAAC;EAAED,KAAK,GAAG;IAAEY,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAC3Cb,OAAO,CAACC,KAAK,EAAEC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC;AAACY,OAAA,CAAAM,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -8,20 +8,14 @@ var _objects = require("../../utils/helpers/objects");
8
8
  var _exceptions = require("../../exceptions");
9
9
  /**
10
10
  */
11
- const getProp = function () {
12
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
- let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
14
- let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
11
+ const getProp = (theme = {}, path = "", defaultValue = "") => {
15
12
  return path === "" ? defaultValue : (0, _objects.get)(theme, path, defaultValue);
16
13
  };
17
14
 
18
15
  /**
19
16
  */
20
17
  exports.getProp = getProp;
21
- const getThemeProp = function () {
22
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
- let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
24
- let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
18
+ const getThemeProp = (theme = {}, path = "", defaultValue = "") => {
25
19
  const value = getProp(theme, path, defaultValue);
26
20
  if (value != null && (typeof value === "string" || typeof value === "number" || typeof value === "object")) {
27
21
  return value;
@@ -32,10 +26,7 @@ const getThemeProp = function () {
32
26
  /**
33
27
  */
34
28
  exports.getThemeProp = getThemeProp;
35
- const getThemeStringProp = function () {
36
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
37
- let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
38
- let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
29
+ const getThemeStringProp = (theme = {}, path = "", defaultValue = "") => {
39
30
  const value = getProp(theme, path, defaultValue);
40
31
  if (typeof value === "string") {
41
32
  return value;
@@ -48,10 +39,7 @@ const getThemeStringProp = function () {
48
39
  /**
49
40
  */
50
41
  exports.getThemeStringProp = getThemeStringProp;
51
- const getThemeNumberProp = function () {
52
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
53
- let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
54
- let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
42
+ const getThemeNumberProp = (theme = {}, path = "", defaultValue = 0) => {
55
43
  const value = getProp(theme, path, defaultValue);
56
44
  if (typeof value === "number") {
57
45
  return value;
@@ -65,11 +53,8 @@ const getThemeNumberProp = function () {
65
53
  /**
66
54
  */
67
55
  exports.getThemeNumberProp = getThemeNumberProp;
68
- const themeProp = (path, defaultValue) => _ref => {
69
- let {
70
- theme
71
- } = _ref;
72
- return getThemeProp(theme, path, defaultValue);
73
- };
56
+ const themeProp = (path, defaultValue) => ({
57
+ theme
58
+ }) => getThemeProp(theme, path, defaultValue);
74
59
  exports.themeProp = themeProp;
75
60
  //# sourceMappingURL=themeProps.js.map