@axelor/aos-mobile-ui 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/README.md +234 -0
  2. package/lib/components/atoms/BlockInteractionScreen/BlockInteractionScreen.d.ts +7 -0
  3. package/lib/components/atoms/BlockInteractionScreen/BlockInteractionScreen.js +50 -0
  4. package/lib/components/atoms/BlockInteractionScreen/BlockInteractionScreen.js.map +1 -0
  5. package/lib/components/atoms/Card/Card.d.ts +6 -0
  6. package/lib/components/atoms/Card/Card.js +37 -0
  7. package/lib/components/atoms/Card/Card.js.map +1 -0
  8. package/lib/components/atoms/DottedLine/DottedLine.d.ts +5 -0
  9. package/lib/components/atoms/DottedLine/DottedLine.js +38 -0
  10. package/lib/components/atoms/DottedLine/DottedLine.js.map +1 -0
  11. package/lib/components/atoms/HorizontalRule/HorizontalRule.d.ts +5 -0
  12. package/lib/components/atoms/HorizontalRule/HorizontalRule.js +35 -0
  13. package/lib/components/atoms/HorizontalRule/HorizontalRule.js.map +1 -0
  14. package/lib/components/atoms/HtmlInput/HtmlInput.d.ts +9 -0
  15. package/lib/components/atoms/HtmlInput/HtmlInput.js +50 -0
  16. package/lib/components/atoms/HtmlInput/HtmlInput.js.map +1 -0
  17. package/lib/components/atoms/Icon/Icon.d.ts +13 -0
  18. package/lib/components/atoms/Icon/Icon.js +49 -0
  19. package/lib/components/atoms/Icon/Icon.js.map +1 -0
  20. package/lib/components/atoms/Input/Input.d.ts +18 -0
  21. package/lib/components/atoms/Input/Input.js +37 -0
  22. package/lib/components/atoms/Input/Input.js.map +1 -0
  23. package/lib/components/atoms/RenderHtml/RenderHtml.d.ts +6 -0
  24. package/lib/components/atoms/RenderHtml/RenderHtml.js +50 -0
  25. package/lib/components/atoms/RenderHtml/RenderHtml.js.map +1 -0
  26. package/lib/components/atoms/Screen/Screen.d.ts +9 -0
  27. package/lib/components/atoms/Screen/Screen.js +74 -0
  28. package/lib/components/atoms/Screen/Screen.js.map +1 -0
  29. package/lib/components/atoms/ScrollView/ScrollView.d.ts +6 -0
  30. package/lib/components/atoms/ScrollView/ScrollView.js +33 -0
  31. package/lib/components/atoms/ScrollView/ScrollView.js.map +1 -0
  32. package/lib/components/atoms/Switch/Switch.d.ts +6 -0
  33. package/lib/components/atoms/Switch/Switch.js +34 -0
  34. package/lib/components/atoms/Switch/Switch.js.map +1 -0
  35. package/lib/components/atoms/Text/Text.d.ts +12 -0
  36. package/lib/components/atoms/Text/Text.js +37 -0
  37. package/lib/components/atoms/Text/Text.js.map +1 -0
  38. package/lib/components/atoms/index.d.ts +12 -0
  39. package/lib/components/atoms/index.js +30 -0
  40. package/lib/components/atoms/index.js.map +1 -0
  41. package/lib/components/index.d.ts +3 -0
  42. package/lib/components/index.js +21 -0
  43. package/lib/components/index.js.map +1 -0
  44. package/lib/components/molecules/AttachmentCard/AttachmentCard.d.ts +8 -0
  45. package/lib/components/molecules/AttachmentCard/AttachmentCard.js +61 -0
  46. package/lib/components/molecules/AttachmentCard/AttachmentCard.js.map +1 -0
  47. package/lib/components/molecules/Badge/Badge.d.ts +10 -0
  48. package/lib/components/molecules/Badge/Badge.js +43 -0
  49. package/lib/components/molecules/Badge/Badge.js.map +1 -0
  50. package/lib/components/molecules/Button/Button.d.ts +10 -0
  51. package/lib/components/molecules/Button/Button.js +48 -0
  52. package/lib/components/molecules/Button/Button.js.map +1 -0
  53. package/lib/components/molecules/CardIconButton/CardIconButton.d.ts +8 -0
  54. package/lib/components/molecules/CardIconButton/CardIconButton.js +42 -0
  55. package/lib/components/molecules/CardIconButton/CardIconButton.js.map +1 -0
  56. package/lib/components/molecules/Chip/Chip.d.ts +11 -0
  57. package/lib/components/molecules/Chip/Chip.js +69 -0
  58. package/lib/components/molecules/Chip/Chip.js.map +1 -0
  59. package/lib/components/molecules/ClearableCard/ClearableCard.d.ts +8 -0
  60. package/lib/components/molecules/ClearableCard/ClearableCard.js +43 -0
  61. package/lib/components/molecules/ClearableCard/ClearableCard.js.map +1 -0
  62. package/lib/components/molecules/DropdownCard/DropdownCard.d.ts +10 -0
  63. package/lib/components/molecules/DropdownCard/DropdownCard.js +84 -0
  64. package/lib/components/molecules/DropdownCard/DropdownCard.js.map +1 -0
  65. package/lib/components/molecules/DropdownMenu/DropdownMenu.d.ts +5 -0
  66. package/lib/components/molecules/DropdownMenu/DropdownMenu.js +57 -0
  67. package/lib/components/molecules/DropdownMenu/DropdownMenu.js.map +1 -0
  68. package/lib/components/molecules/DropdownMenuItem/DropdownMenuItem.d.ts +7 -0
  69. package/lib/components/molecules/DropdownMenuItem/DropdownMenuItem.js +42 -0
  70. package/lib/components/molecules/DropdownMenuItem/DropdownMenuItem.js.map +1 -0
  71. package/lib/components/molecules/EditableInput/EditableInput.d.ts +9 -0
  72. package/lib/components/molecules/EditableInput/EditableInput.js +65 -0
  73. package/lib/components/molecules/EditableInput/EditableInput.js.map +1 -0
  74. package/lib/components/molecules/FromTo/FromTo.d.ts +8 -0
  75. package/lib/components/molecules/FromTo/FromTo.js +44 -0
  76. package/lib/components/molecules/FromTo/FromTo.js.map +1 -0
  77. package/lib/components/molecules/HalfLabelCard/HalfLabelCard.d.ts +8 -0
  78. package/lib/components/molecules/HalfLabelCard/HalfLabelCard.js +51 -0
  79. package/lib/components/molecules/HalfLabelCard/HalfLabelCard.js.map +1 -0
  80. package/lib/components/molecules/HeaderIndicator/HeaderIndicator.d.ts +2 -0
  81. package/lib/components/molecules/HeaderIndicator/HeaderIndicator.js +65 -0
  82. package/lib/components/molecules/HeaderIndicator/HeaderIndicator.js.map +1 -0
  83. package/lib/components/molecules/IconButton/IconButton.d.ts +11 -0
  84. package/lib/components/molecules/IconButton/IconButton.js +48 -0
  85. package/lib/components/molecules/IconButton/IconButton.js.map +1 -0
  86. package/lib/components/molecules/IconInput/IconInput.d.ts +19 -0
  87. package/lib/components/molecules/IconInput/IconInput.js +50 -0
  88. package/lib/components/molecules/IconInput/IconInput.js.map +1 -0
  89. package/lib/components/molecules/Image/Image.d.ts +10 -0
  90. package/lib/components/molecules/Image/Image.js +36 -0
  91. package/lib/components/molecules/Image/Image.js.map +1 -0
  92. package/lib/components/molecules/Increment/Increment.d.ts +8 -0
  93. package/lib/components/molecules/Increment/Increment.js +97 -0
  94. package/lib/components/molecules/Increment/Increment.js.map +1 -0
  95. package/lib/components/molecules/InfoBubble/InfoBubble.d.ts +9 -0
  96. package/lib/components/molecules/InfoBubble/InfoBubble.js +73 -0
  97. package/lib/components/molecules/InfoBubble/InfoBubble.js.map +1 -0
  98. package/lib/components/molecules/LabelText/LabelText.d.ts +14 -0
  99. package/lib/components/molecules/LabelText/LabelText.js +45 -0
  100. package/lib/components/molecules/LabelText/LabelText.js.map +1 -0
  101. package/lib/components/molecules/LoadingIndicator/LoadingIndicator.d.ts +6 -0
  102. package/lib/components/molecules/LoadingIndicator/LoadingIndicator.js +49 -0
  103. package/lib/components/molecules/LoadingIndicator/LoadingIndicator.js.map +1 -0
  104. package/lib/components/molecules/MessageBox/MessageBox.d.ts +9 -0
  105. package/lib/components/molecules/MessageBox/MessageBox.js +60 -0
  106. package/lib/components/molecules/MessageBox/MessageBox.js.map +1 -0
  107. package/lib/components/molecules/MovementIndicationCard/MovementIndicationCard.d.ts +14 -0
  108. package/lib/components/molecules/MovementIndicationCard/MovementIndicationCard.js +66 -0
  109. package/lib/components/molecules/MovementIndicationCard/MovementIndicationCard.js.map +1 -0
  110. package/lib/components/molecules/MultiValuePickerButton/MultiValuePickerButton.d.ts +11 -0
  111. package/lib/components/molecules/MultiValuePickerButton/MultiValuePickerButton.js +80 -0
  112. package/lib/components/molecules/MultiValuePickerButton/MultiValuePickerButton.js.map +1 -0
  113. package/lib/components/molecules/NotesCard/NotesCard.d.ts +6 -0
  114. package/lib/components/molecules/NotesCard/NotesCard.js +55 -0
  115. package/lib/components/molecules/NotesCard/NotesCard.js.map +1 -0
  116. package/lib/components/molecules/PopUp/PopUp.d.ts +9 -0
  117. package/lib/components/molecules/PopUp/PopUp.js +74 -0
  118. package/lib/components/molecules/PopUp/PopUp.js.map +1 -0
  119. package/lib/components/molecules/RightIconButton/RightIconButton.d.ts +10 -0
  120. package/lib/components/molecules/RightIconButton/RightIconButton.js +49 -0
  121. package/lib/components/molecules/RightIconButton/RightIconButton.js.map +1 -0
  122. package/lib/components/molecules/SelectionContainer/SelectionContainer.d.ts +11 -0
  123. package/lib/components/molecules/SelectionContainer/SelectionContainer.js +111 -0
  124. package/lib/components/molecules/SelectionContainer/SelectionContainer.js.map +1 -0
  125. package/lib/components/molecules/StarScore/StarScore.d.ts +11 -0
  126. package/lib/components/molecules/StarScore/StarScore.js +58 -0
  127. package/lib/components/molecules/StarScore/StarScore.js.map +1 -0
  128. package/lib/components/molecules/SwitchCard/SwitchCard.d.ts +8 -0
  129. package/lib/components/molecules/SwitchCard/SwitchCard.js +31 -0
  130. package/lib/components/molecules/SwitchCard/SwitchCard.js.map +1 -0
  131. package/lib/components/molecules/TitledValue/TitledValue.d.ts +7 -0
  132. package/lib/components/molecules/TitledValue/TitledValue.js +40 -0
  133. package/lib/components/molecules/TitledValue/TitledValue.js.map +1 -0
  134. package/lib/components/molecules/ToggleSwitch/ToggleSwitch.d.ts +8 -0
  135. package/lib/components/molecules/ToggleSwitch/ToggleSwitch.js +66 -0
  136. package/lib/components/molecules/ToggleSwitch/ToggleSwitch.js.map +1 -0
  137. package/lib/components/molecules/UnorderedList/UnorderedList.d.ts +8 -0
  138. package/lib/components/molecules/UnorderedList/UnorderedList.js +51 -0
  139. package/lib/components/molecules/UnorderedList/UnorderedList.js.map +1 -0
  140. package/lib/components/molecules/ViewAllContainer/ViewAllContainer.d.ts +14 -0
  141. package/lib/components/molecules/ViewAllContainer/ViewAllContainer.js +91 -0
  142. package/lib/components/molecules/ViewAllContainer/ViewAllContainer.js.map +1 -0
  143. package/lib/components/molecules/index.d.ts +33 -0
  144. package/lib/components/molecules/index.js +51 -0
  145. package/lib/components/molecules/index.js.map +1 -0
  146. package/lib/components/organisms/AutoCompleteSearch/AutoCompleteSearch.d.ts +19 -0
  147. package/lib/components/organisms/AutoCompleteSearch/AutoCompleteSearch.js +148 -0
  148. package/lib/components/organisms/AutoCompleteSearch/AutoCompleteSearch.js.map +1 -0
  149. package/lib/components/organisms/ChipSelect/ChipSelect.d.ts +6 -0
  150. package/lib/components/organisms/ChipSelect/ChipSelect.js +39 -0
  151. package/lib/components/organisms/ChipSelect/ChipSelect.js.map +1 -0
  152. package/lib/components/organisms/DropdownCardSwitch/DropdownCardSwitch.d.ts +12 -0
  153. package/lib/components/organisms/DropdownCardSwitch/DropdownCardSwitch.js +40 -0
  154. package/lib/components/organisms/DropdownCardSwitch/DropdownCardSwitch.js.map +1 -0
  155. package/lib/components/organisms/HeaderContainer/HeaderContainer.d.ts +9 -0
  156. package/lib/components/organisms/HeaderContainer/HeaderContainer.js +65 -0
  157. package/lib/components/organisms/HeaderContainer/HeaderContainer.js.map +1 -0
  158. package/lib/components/organisms/ImageBubble/ImageBubble.d.ts +10 -0
  159. package/lib/components/organisms/ImageBubble/ImageBubble.js +105 -0
  160. package/lib/components/organisms/ImageBubble/ImageBubble.js.map +1 -0
  161. package/lib/components/organisms/MultiValuePicker/MultiValuePicker.d.ts +16 -0
  162. package/lib/components/organisms/MultiValuePicker/MultiValuePicker.js +103 -0
  163. package/lib/components/organisms/MultiValuePicker/MultiValuePicker.js.map +1 -0
  164. package/lib/components/organisms/Picker/Picker.d.ts +18 -0
  165. package/lib/components/organisms/Picker/Picker.js +101 -0
  166. package/lib/components/organisms/Picker/Picker.js.map +1 -0
  167. package/lib/components/organisms/PopUpOneButton/PopUpOneButton.d.ts +9 -0
  168. package/lib/components/organisms/PopUpOneButton/PopUpOneButton.js +35 -0
  169. package/lib/components/organisms/PopUpOneButton/PopUpOneButton.js.map +1 -0
  170. package/lib/components/organisms/PopUpTwoButton/PopUpTwoButton.d.ts +11 -0
  171. package/lib/components/organisms/PopUpTwoButton/PopUpTwoButton.js +38 -0
  172. package/lib/components/organisms/PopUpTwoButton/PopUpTwoButton.js.map +1 -0
  173. package/lib/components/organisms/ScrollList/ScrollList.d.ts +13 -0
  174. package/lib/components/organisms/ScrollList/ScrollList.js +70 -0
  175. package/lib/components/organisms/ScrollList/ScrollList.js.map +1 -0
  176. package/lib/components/organisms/SearchBar/SearchBar.d.ts +14 -0
  177. package/lib/components/organisms/SearchBar/SearchBar.js +44 -0
  178. package/lib/components/organisms/SearchBar/SearchBar.js.map +1 -0
  179. package/lib/components/organisms/index.d.ts +11 -0
  180. package/lib/components/organisms/index.js +29 -0
  181. package/lib/components/organisms/index.js.map +1 -0
  182. package/lib/config/ConfigContext.d.ts +26 -0
  183. package/lib/config/ConfigContext.js +184 -0
  184. package/lib/config/ConfigContext.js.map +1 -0
  185. package/lib/hooks/use-click-outside.d.ts +6 -0
  186. package/lib/hooks/use-click-outside.helper.d.ts +10 -0
  187. package/lib/hooks/use-click-outside.helper.js +35 -0
  188. package/lib/hooks/use-click-outside.helper.js.map +1 -0
  189. package/lib/hooks/use-click-outside.js +123 -0
  190. package/lib/hooks/use-click-outside.js.map +1 -0
  191. package/lib/index.d.ts +8 -0
  192. package/lib/index.js +26 -0
  193. package/lib/index.js.map +1 -0
  194. package/lib/theme/ThemeContext.d.ts +19 -0
  195. package/lib/theme/ThemeContext.js +110 -0
  196. package/lib/theme/ThemeContext.js.map +1 -0
  197. package/lib/theme/WritingThemeContext.d.ts +10 -0
  198. package/lib/theme/WritingThemeContext.js +77 -0
  199. package/lib/theme/WritingThemeContext.js.map +1 -0
  200. package/lib/theme/index.d.ts +4 -0
  201. package/lib/theme/index.js +22 -0
  202. package/lib/theme/index.js.map +1 -0
  203. package/lib/theme/themes.d.ts +32 -0
  204. package/lib/theme/themes.js +178 -0
  205. package/lib/theme/themes.js.map +1 -0
  206. package/lib/theme/writingTheme.d.ts +19 -0
  207. package/lib/theme/writingTheme.js +45 -0
  208. package/lib/theme/writingTheme.js.map +1 -0
  209. package/lib/tools/AnimationUtil.d.ts +12 -0
  210. package/lib/tools/AnimationUtil.js +40 -0
  211. package/lib/tools/AnimationUtil.js.map +1 -0
  212. package/lib/types/file.d.ts +5 -0
  213. package/lib/types/file.js +62 -0
  214. package/lib/types/file.js.map +1 -0
  215. package/lib/utils/arrays.d.ts +2 -0
  216. package/lib/utils/arrays.js +31 -0
  217. package/lib/utils/arrays.js.map +1 -0
  218. package/lib/utils/commons-styles.d.ts +34 -0
  219. package/lib/utils/commons-styles.js +53 -0
  220. package/lib/utils/commons-styles.js.map +1 -0
  221. package/lib/utils/formatters.d.ts +2 -0
  222. package/lib/utils/formatters.js +48 -0
  223. package/lib/utils/formatters.js.map +1 -0
  224. package/lib/utils/headerStyle.d.ts +12 -0
  225. package/lib/utils/headerStyle.js +31 -0
  226. package/lib/utils/headerStyle.js.map +1 -0
  227. package/lib/utils/list.d.ts +2 -0
  228. package/lib/utils/list.js +47 -0
  229. package/lib/utils/list.js.map +1 -0
  230. package/lib/utils/number.d.ts +4 -0
  231. package/lib/utils/number.js +34 -0
  232. package/lib/utils/number.js.map +1 -0
  233. package/lib/utils/strings.d.ts +2 -0
  234. package/lib/utils/strings.js +33 -0
  235. package/lib/utils/strings.js.map +1 -0
  236. package/package.json +49 -0
@@ -0,0 +1,6 @@
1
+ export const OUTSIDE_INDICATOR: "outside";
2
+ export const INSIDE_INDICATOR: "inside";
3
+ export function OutsideAlerterProvider({ children }: {
4
+ children: any;
5
+ }): JSX.Element;
6
+ export function useClickOutside({ wrapperRef, visible }: any): any;
@@ -0,0 +1,10 @@
1
+ interface refProps {
2
+ nativeTag: number;
3
+ wrapperRef: any;
4
+ visible: boolean;
5
+ }
6
+ export declare const pushRef: (refList: Array<refProps>, ref: refProps) => Array<refProps>;
7
+ export declare const findVisibleRef: (refList: Array<refProps>) => refProps;
8
+ export declare const findRef: (refList: Array<refProps>, ref: refProps) => refProps;
9
+ export declare const replaceRef: (refList: Array<refProps>, oldRef: refProps, newRef: refProps) => Array<refProps>;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import { replace } from '../utils/arrays';
19
+ export const pushRef = (refList, ref) => {
20
+ if (ref == null || ref?.nativeTag == null) {
21
+ return refList;
22
+ }
23
+ if (refList == null || refList.length === 0) {
24
+ return [ref];
25
+ }
26
+ const _ref = findRef(refList, ref);
27
+ if (_ref) {
28
+ return replaceRef(refList, _ref, ref);
29
+ }
30
+ return [...refList, ref];
31
+ };
32
+ export const findVisibleRef = (refList) => refList.find(refItem => refItem.visible);
33
+ export const findRef = (refList, ref) => refList.find(refItem => refItem.nativeTag === ref.nativeTag);
34
+ export const replaceRef = (refList, oldRef, newRef) => replace(refList, oldRef, newRef, 'nativeTag');
35
+ //# sourceMappingURL=use-click-outside.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-click-outside.helper.js","sourceRoot":"","sources":["../../src/hooks/use-click-outside.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAQxC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,OAAwB,EACxB,GAAa,EACI,EAAE;IACnB,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,SAAS,IAAI,IAAI,EAAE;QACzC,OAAO,OAAO,CAAC;KAChB;IAED,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3C,OAAO,CAAC,GAAG,CAAC,CAAC;KACd;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,IAAI,IAAI,EAAE;QACR,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;KACvC;IAED,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAwB,EAAY,EAAE,CACnE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAwB,EAAE,GAAa,EAAY,EAAE,CAC3E,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAAwB,EACxB,MAAgB,EAChB,MAAgB,EACC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC"}
@@ -0,0 +1,123 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useReducer, } from 'react';
19
+ import { Dimensions, StyleSheet, View } from 'react-native';
20
+ import { findVisibleRef, pushRef } from './use-click-outside.helper';
21
+ export const OUTSIDE_INDICATOR = 'outside';
22
+ export const INSIDE_INDICATOR = 'inside';
23
+ const defaultOutsideAlerterContext = {
24
+ refList: [],
25
+ clickOutside: undefined,
26
+ addRef: () => {
27
+ throw new Error('OutsideAlerter should be mounted to add target component reference');
28
+ },
29
+ handleClickOutside: () => {
30
+ throw new Error('OutsideAlerter should be mounted to set handle click outside event');
31
+ },
32
+ };
33
+ const OutsideAlerterContext = createContext(defaultOutsideAlerterContext);
34
+ const actionTypes = {
35
+ addRef: 'addRef',
36
+ handleClickOutside: 'handleClickOutside',
37
+ };
38
+ const handleClickOutsideReducer = (ref, target) => {
39
+ if (!ref || !target) {
40
+ return undefined;
41
+ }
42
+ if (ref._nativeTag === target._nativeTag) {
43
+ return INSIDE_INDICATOR;
44
+ }
45
+ // check ref if one ref child has target._nativeTag
46
+ if (ref._children) {
47
+ const res = ref._children.map(child => handleClickOutsideReducer(child, target));
48
+ return res.find(r => r === INSIDE_INDICATOR)
49
+ ? INSIDE_INDICATOR
50
+ : OUTSIDE_INDICATOR;
51
+ }
52
+ return OUTSIDE_INDICATOR;
53
+ };
54
+ const outsideAlerterReducer = (state, action) => {
55
+ switch (action.type) {
56
+ case actionTypes.addRef: {
57
+ return {
58
+ ...state,
59
+ refList: pushRef(state.refList, action.payload),
60
+ };
61
+ }
62
+ case actionTypes.handleClickOutside: {
63
+ return {
64
+ ...state,
65
+ clickOutside: handleClickOutsideReducer(findVisibleRef(state.refList)?.wrapperRef?.current, action.payload),
66
+ };
67
+ }
68
+ }
69
+ };
70
+ const actions = {
71
+ addRef: ref => {
72
+ return {
73
+ type: actionTypes.addRef,
74
+ payload: ref,
75
+ };
76
+ },
77
+ handleClickOutside: target => {
78
+ return {
79
+ type: actionTypes.handleClickOutside,
80
+ payload: target,
81
+ };
82
+ },
83
+ };
84
+ export const OutsideAlerterProvider = ({ children }) => {
85
+ const [state, dispatch] = useReducer(outsideAlerterReducer, defaultOutsideAlerterContext);
86
+ const addRef = useCallback(ref => dispatch(actions.addRef(ref)), []);
87
+ const handleClickOutside = useCallback(target => dispatch(actions.handleClickOutside(target)), []);
88
+ const outsideAlerterContextState = useMemo(() => ({
89
+ ...state,
90
+ addRef,
91
+ handleClickOutside,
92
+ }), [state, addRef, handleClickOutside]);
93
+ return (<OutsideAlerterContext.Provider value={outsideAlerterContextState}>
94
+ <View onTouchStart={e => handleClickOutside(e.target)} style={styles.container}>
95
+ {children}
96
+ </View>
97
+ </OutsideAlerterContext.Provider>);
98
+ };
99
+ const styles = StyleSheet.create({
100
+ container: {
101
+ position: 'absolute',
102
+ top: 0,
103
+ right: 0,
104
+ width: Dimensions.get('screen').width,
105
+ height: Dimensions.get('screen').height,
106
+ elevation: -1,
107
+ },
108
+ });
109
+ /**
110
+ * Hook that alerts clicks outside
111
+ * @param {Object} wrapperRef - component reference to track if we click outside of it.
112
+ * @param {Boolean} visible - boolean to track component if it is visible.
113
+ */
114
+ export const useClickOutside = ({ wrapperRef, visible }) => {
115
+ const { clickOutside, addRef } = useContext(OutsideAlerterContext);
116
+ useEffect(() => {
117
+ addRef({ nativeTag: wrapperRef?.current?._nativeTag, wrapperRef, visible });
118
+ }, [addRef, visible, wrapperRef]);
119
+ return useMemo(() => {
120
+ return clickOutside;
121
+ }, [clickOutside]);
122
+ };
123
+ //# sourceMappingURL=use-click-outside.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-click-outside.js","sourceRoot":"","sources":["../../src/hooks/use-click-outside.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,UAAU,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EA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EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,YAAY,CAAC;IACtB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './components';
2
+ export * from './theme';
3
+ export { getCommonStyles } from './utils/commons-styles';
4
+ export { getHeaderStyles } from './utils/headerStyle';
5
+ export { default as File } from './types/file';
6
+ export { ConfigProvider, useConfig } from './config/ConfigContext';
7
+ export { OutsideAlerterProvider, useClickOutside, } from './hooks/use-click-outside';
8
+ export { animationUtil } from './tools/AnimationUtil';
package/lib/index.js ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ export * from './components';
19
+ export * from './theme';
20
+ export { getCommonStyles } from './utils/commons-styles';
21
+ export { getHeaderStyles } from './utils/headerStyle';
22
+ export { default as File } from './types/file';
23
+ export { ConfigProvider, useConfig } from './config/ConfigContext';
24
+ export { OutsideAlerterProvider, useClickOutside, } from './hooks/use-click-outside';
25
+ export { animationUtil } from './tools/AnimationUtil';
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,sBAAsB,EACtB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { Theme } from './themes';
3
+ interface ThemeContextState {
4
+ activeTheme: Theme;
5
+ isColorBlind: boolean;
6
+ themes: Theme[];
7
+ changeTheme: (themeKey: string) => void;
8
+ activateColorBlind: () => void;
9
+ desactivateColorBlind: () => void;
10
+ }
11
+ interface ThemeProviderProps {
12
+ themes?: Theme[];
13
+ defaultTheme?: Theme;
14
+ children?: ReactNode;
15
+ }
16
+ export declare const ThemeProvider: ({ children, themes, defaultTheme, }: ThemeProviderProps) => JSX.Element;
17
+ export declare const useThemeColor: () => import("./themes").ThemeColors;
18
+ export declare const useTheme: () => ThemeContextState;
19
+ export {};
@@ -0,0 +1,110 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import React, { createContext, useCallback, useContext, useMemo, useReducer, } from 'react';
19
+ import { lightTheme, colorBlindTheme } from './themes';
20
+ const DEFAULT_THEME = lightTheme;
21
+ const COLORBLIND_THEME = colorBlindTheme;
22
+ const defaultThemeContext = {
23
+ activeTheme: DEFAULT_THEME,
24
+ isColorBlind: DEFAULT_THEME === COLORBLIND_THEME,
25
+ themes: [lightTheme],
26
+ changeTheme: () => {
27
+ throw new Error('ThemeProvider should be mounted to change theme');
28
+ },
29
+ activateColorBlind() {
30
+ throw new Error('ThemeProvider should be mounted to activate color blind');
31
+ },
32
+ desactivateColorBlind() {
33
+ throw new Error('ThemeProvider should be mounted to desactivate color blind');
34
+ },
35
+ };
36
+ const getInitialThemeState = (additionalThemes = [], defaultTheme = DEFAULT_THEME) => {
37
+ return {
38
+ ...defaultThemeContext,
39
+ activeTheme: defaultTheme,
40
+ themes: [...defaultThemeContext.themes, ...additionalThemes],
41
+ };
42
+ };
43
+ const ThemeContext = createContext(defaultThemeContext);
44
+ const actionTypes = {
45
+ changeTheme: 'changeTheme',
46
+ activateColorBlind: 'activateColorBlind',
47
+ desactivateColorBlind: 'desactivateColorBlind',
48
+ };
49
+ const themeReducer = (state, action) => {
50
+ switch (action.type) {
51
+ case actionTypes.changeTheme: {
52
+ const newActiveTheme = state.themes.find(theme => theme.key === action.payload);
53
+ if (newActiveTheme == null) {
54
+ return state;
55
+ }
56
+ return {
57
+ ...state,
58
+ activeTheme: newActiveTheme,
59
+ isColorBlind: newActiveTheme === COLORBLIND_THEME,
60
+ };
61
+ }
62
+ case actionTypes.activateColorBlind: {
63
+ return {
64
+ ...state,
65
+ activeTheme: colorBlindTheme,
66
+ isColorBlind: true,
67
+ };
68
+ }
69
+ case actionTypes.desactivateColorBlind: {
70
+ return {
71
+ ...state,
72
+ activeTheme: lightTheme,
73
+ isColorBlind: false,
74
+ };
75
+ }
76
+ }
77
+ };
78
+ const actions = {
79
+ changeTheme: themeKey => ({
80
+ type: actionTypes.changeTheme,
81
+ payload: themeKey,
82
+ }),
83
+ activateColorBlind: () => ({
84
+ type: actionTypes.activateColorBlind,
85
+ }),
86
+ desactivateColorBlind: () => ({
87
+ type: actionTypes.desactivateColorBlind,
88
+ }),
89
+ };
90
+ export const ThemeProvider = ({ children, themes, defaultTheme, }) => {
91
+ const [state, dispatch] = useReducer(themeReducer, getInitialThemeState(themes, defaultTheme));
92
+ const changeTheme = useCallback(themeKey => dispatch(actions.changeTheme(themeKey)), []);
93
+ const activateColorBlind = useCallback(() => dispatch(actions.activateColorBlind()), []);
94
+ const desactivateColorBlind = useCallback(() => dispatch(actions.desactivateColorBlind()), []);
95
+ const themeContextState = useMemo(() => ({
96
+ ...state,
97
+ changeTheme,
98
+ activateColorBlind,
99
+ desactivateColorBlind,
100
+ }), [activateColorBlind, changeTheme, desactivateColorBlind, state]);
101
+ return (<ThemeContext.Provider value={themeContextState}>
102
+ {children}
103
+ </ThemeContext.Provider>);
104
+ };
105
+ export const useThemeColor = () => {
106
+ const { activeTheme } = useContext(ThemeContext);
107
+ return useMemo(() => activeTheme.colors, [activeTheme]);
108
+ };
109
+ export const useTheme = () => useContext(ThemeContext);
110
+ //# sourceMappingURL=ThemeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeContext.js","sourceRoot":"","sources":["../../src/theme/ThemeContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,OAAO,EACP,UAAU,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAQ,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAE5D,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAgBzC,MAAM,mBAAmB,GAAG;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,aAAa,KAAK,gBAAgB;IAChD,MAAM,EAAE,CAA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C,CAAC;QACL,GAAG,KAAK;QACR,WAAW;QACX,kBAAkB;QAClB,qBAAqB;KACtB,CAAC,EACF,CAAC,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAChE,CAAC;IAEF,OAAO,CACL,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAC9C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,YAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,EAAC,WAAW,EAAC,GAAG,UAAU,CAAoB,YAAY,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAsB,EAAE,CAC9C,UAAU,CAAoB,YAAY,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { Writing } from './writingTheme';
3
+ interface WritingThemeProviderProps {
4
+ themes?: Writing[];
5
+ defaultTheme?: Writing;
6
+ children?: ReactNode;
7
+ }
8
+ export declare const WritingThemeProvider: ({ children, themes, defaultTheme, }: WritingThemeProviderProps) => JSX.Element;
9
+ export declare const useWritingStyle: () => import("./writingTheme").WritingStyles;
10
+ export {};
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import React, { createContext, useCallback, useContext, useMemo, useReducer, } from 'react';
19
+ import { writingDefaultTheme } from './writingTheme';
20
+ const DEFAULT_WRITING_THEME = writingDefaultTheme;
21
+ const defaultWritingThemeContext = {
22
+ activeWritingTheme: DEFAULT_WRITING_THEME,
23
+ WritingThemes: [writingDefaultTheme],
24
+ changeWritingTheme: () => {
25
+ throw new Error('WritingThemeProvider should be mounted to change theme');
26
+ },
27
+ };
28
+ const getInitialWritingThemeState = (additionalWritingThemes = [], defaultWritingTheme = DEFAULT_WRITING_THEME) => {
29
+ return {
30
+ ...defaultWritingThemeContext,
31
+ activeWritingTheme: defaultWritingTheme,
32
+ themes: [
33
+ ...defaultWritingThemeContext.WritingThemes,
34
+ ...additionalWritingThemes,
35
+ ],
36
+ };
37
+ };
38
+ const WritingThemeContext = createContext(defaultWritingThemeContext);
39
+ const actionWritingTypes = {
40
+ changeWritingTheme: 'changeWritingTheme',
41
+ };
42
+ const themeWritingReducer = (state, action) => {
43
+ switch (action.type) {
44
+ case actionWritingTypes.changeWritingTheme: {
45
+ const newActiveTheme = state.WritingThemes.find(theme => theme.key === action.payload);
46
+ if (newActiveTheme == null) {
47
+ return state;
48
+ }
49
+ return {
50
+ ...state,
51
+ activeWritingTheme: newActiveTheme,
52
+ };
53
+ }
54
+ }
55
+ };
56
+ const writingActions = {
57
+ changeWritingTheme: themeKey => ({
58
+ type: actionWritingTypes.changeWritingTheme,
59
+ payload: themeKey,
60
+ }),
61
+ };
62
+ export const WritingThemeProvider = ({ children, themes, defaultTheme, }) => {
63
+ const [state, dispatch] = useReducer(themeWritingReducer, getInitialWritingThemeState(themes, defaultTheme));
64
+ const changeWritingTheme = useCallback(themeKey => dispatch(writingActions.changeWritingTheme(themeKey)), []);
65
+ const themeWritingContextState = useMemo(() => ({
66
+ ...state,
67
+ changeWritingTheme,
68
+ }), [changeWritingTheme, state]);
69
+ return (<WritingThemeContext.Provider value={themeWritingContextState}>
70
+ {children}
71
+ </WritingThemeContext.Provider>);
72
+ };
73
+ export const useWritingStyle = () => {
74
+ const { activeWritingTheme } = useContext(WritingThemeContext);
75
+ return useMemo(() => activeWritingTheme.style, [activeWritingTheme]);
76
+ };
77
+ //# sourceMappingURL=WritingThemeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WritingThemeContext.js","sourceRoot":"","sources":["../../src/theme/WritingThemeContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,OAAO,EACP,UAAU,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAU,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAE5D,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAalD,MAAM,0BAA0B,GAAG;IACjC,kBAAkB,EAAE,qBAAqB;IACzC,aAAa,EAAE,CAAC,mBAAmB,CAAC;IACpC,kBAAkB,EAAE,GAAG,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAClC,0BAAqC,EAAE,EACvC,sBAA+B,qBAAqB,EACpD,EAAE;IACF,OAAO;QACL,GAAG,0BAA0B;QAC7B,kBAAkB,EAAE,mBAAmB;QACvC,MAAM,EAAE;YACN,GAAG,0BAA0B,CAAC,aAAa;YAC3C,GAAG,uBAAuB;SAC3B;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CACvC,0BAA0B,CAC3B,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,kBAAkB,EAAE,oBAAoB;CACzC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAC1B,KAA+B,EAC/B,MAA0B,EACA,EAAE;IAC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CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,EAAC,kBAAkB,EAAC,GACxB,UAAU,CAA2B,mBAAmB,CAAC,CAAC;IAC5D,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ThemeProvider, useTheme, useThemeColor } from './ThemeContext';
2
+ export { WritingThemeProvider, useWritingStyle } from './WritingThemeContext';
3
+ export { lightTheme, colorBlindTheme, Theme, ThemeColors, Color } from './themes';
4
+ export { writingDefaultTheme, Writing, WritingStyles, TextStyle, useWritingType, } from './writingTheme';
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2023 Axelor (<http://axelor.com>).
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License, version 3,
8
+ * as published by the Free Software Foundation.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ export { ThemeProvider, useTheme, useThemeColor } from './ThemeContext';
19
+ export { WritingThemeProvider, useWritingStyle } from './WritingThemeContext';
20
+ export { lightTheme, colorBlindTheme } from './themes';
21
+ export { writingDefaultTheme, useWritingType, } from './writingTheme';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAE,eAAe,EAA4B,MAAM,UAAU,CAAC;AAChF,OAAO,EACL,mBAAmB,EAInB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,32 @@
1
+ export interface Color {
2
+ background_light: string;
3
+ foreground: string;
4
+ background: string;
5
+ }
6
+ export interface ThemeColors {
7
+ screenBackgroundColor: string;
8
+ backgroundColor: string;
9
+ primaryColor: Color;
10
+ secondaryColor: Color;
11
+ secondaryColor_dark: Color;
12
+ errorColor: Color;
13
+ cautionColor: Color;
14
+ plannedColor: Color;
15
+ progressColor: Color;
16
+ priorityColor: Color;
17
+ defaultColor: Color;
18
+ importantColor: Color;
19
+ successColor: Color;
20
+ warningColor: Color;
21
+ inverseColor: Color;
22
+ infoColor: Color;
23
+ text: string;
24
+ placeholderTextColor: string;
25
+ }
26
+ export interface Theme {
27
+ key: string;
28
+ name: string;
29
+ colors: ThemeColors;
30
+ }
31
+ export declare const lightTheme: Theme;
32
+ export declare const colorBlindTheme: Theme;