@prototyp/skeletor 1.0.2

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 (216) hide show
  1. package/.eslintrc.json +19 -0
  2. package/.github/CODEOWNERS +2 -0
  3. package/.gitignore +5 -0
  4. package/README.md +418 -0
  5. package/lib/module/components/Block/Block.js +71 -0
  6. package/lib/module/components/Block/Block.js.map +1 -0
  7. package/lib/module/components/Block/index.js +2 -0
  8. package/lib/module/components/Block/index.js.map +1 -0
  9. package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js +93 -0
  10. package/lib/module/components/InputFocusScrollView/InputFocusScrollView.js.map +1 -0
  11. package/lib/module/components/InputFocusScrollView/index.js +2 -0
  12. package/lib/module/components/InputFocusScrollView/index.js.map +1 -0
  13. package/lib/module/components/Screen/Screen.js +55 -0
  14. package/lib/module/components/Screen/Screen.js.map +1 -0
  15. package/lib/module/components/Screen/index.js +2 -0
  16. package/lib/module/components/Screen/index.js.map +1 -0
  17. package/lib/module/components/SkeletorProvider/SkeletorContext.js +9 -0
  18. package/lib/module/components/SkeletorProvider/SkeletorContext.js.map +1 -0
  19. package/lib/module/components/SkeletorProvider/SkeletorProvider.js +17 -0
  20. package/lib/module/components/SkeletorProvider/SkeletorProvider.js.map +1 -0
  21. package/lib/module/components/SkeletorProvider/index.js +3 -0
  22. package/lib/module/components/SkeletorProvider/index.js.map +1 -0
  23. package/lib/module/components/Text/Text.js +64 -0
  24. package/lib/module/components/Text/Text.js.map +1 -0
  25. package/lib/module/components/Text/index.js +2 -0
  26. package/lib/module/components/Text/index.js.map +1 -0
  27. package/lib/module/components/index.js +6 -0
  28. package/lib/module/components/index.js.map +1 -0
  29. package/lib/module/hooks/index.js +7 -0
  30. package/lib/module/hooks/index.js.map +1 -0
  31. package/lib/module/hooks/useAndroidBackHandler.js +24 -0
  32. package/lib/module/hooks/useAndroidBackHandler.js.map +1 -0
  33. package/lib/module/hooks/useAnimation.js +33 -0
  34. package/lib/module/hooks/useAnimation.js.map +1 -0
  35. package/lib/module/hooks/useAnimationTimeline.js +97 -0
  36. package/lib/module/hooks/useAnimationTimeline.js.map +1 -0
  37. package/lib/module/hooks/useAppState.js +21 -0
  38. package/lib/module/hooks/useAppState.js.map +1 -0
  39. package/lib/module/hooks/useForm.js +159 -0
  40. package/lib/module/hooks/useForm.js.map +1 -0
  41. package/lib/module/hooks/useSkeletor.js +6 -0
  42. package/lib/module/hooks/useSkeletor.js.map +1 -0
  43. package/lib/module/index.js +5 -0
  44. package/lib/module/index.js.map +1 -0
  45. package/lib/module/models/Alignment.js +2 -0
  46. package/lib/module/models/Alignment.js.map +1 -0
  47. package/lib/module/models/Border.js +2 -0
  48. package/lib/module/models/Border.js.map +1 -0
  49. package/lib/module/models/Size.js +2 -0
  50. package/lib/module/models/Size.js.map +1 -0
  51. package/lib/module/models/SkeletorConfig.js +2 -0
  52. package/lib/module/models/SkeletorConfig.js.map +1 -0
  53. package/lib/module/models/Spacing.js +2 -0
  54. package/lib/module/models/Spacing.js.map +1 -0
  55. package/lib/module/models/index.js +6 -0
  56. package/lib/module/models/index.js.map +1 -0
  57. package/lib/module/types/Font.d.js +2 -0
  58. package/lib/module/types/Font.d.js.map +1 -0
  59. package/lib/module/utils/extractAlignmentProperties.js +10 -0
  60. package/lib/module/utils/extractAlignmentProperties.js.map +1 -0
  61. package/lib/module/utils/extractSizeProperties.js +12 -0
  62. package/lib/module/utils/extractSizeProperties.js.map +1 -0
  63. package/lib/module/utils/index.js +3 -0
  64. package/lib/module/utils/index.js.map +1 -0
  65. package/lib/typescript/lib/module/components/Block/Block.d.ts +4 -0
  66. package/lib/typescript/lib/module/components/Block/Block.d.ts.map +1 -0
  67. package/lib/typescript/lib/module/components/Block/index.d.ts +2 -0
  68. package/lib/typescript/lib/module/components/Block/index.d.ts.map +1 -0
  69. package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts +4 -0
  70. package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -0
  71. package/lib/typescript/lib/module/components/InputFocusScrollView/index.d.ts +2 -0
  72. package/lib/typescript/lib/module/components/InputFocusScrollView/index.d.ts.map +1 -0
  73. package/lib/typescript/lib/module/components/Screen/Screen.d.ts +5 -0
  74. package/lib/typescript/lib/module/components/Screen/Screen.d.ts.map +1 -0
  75. package/lib/typescript/lib/module/components/Screen/index.d.ts +2 -0
  76. package/lib/typescript/lib/module/components/Screen/index.d.ts.map +1 -0
  77. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts +14 -0
  78. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -0
  79. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts +8 -0
  80. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -0
  81. package/lib/typescript/lib/module/components/SkeletorProvider/index.d.ts +3 -0
  82. package/lib/typescript/lib/module/components/SkeletorProvider/index.d.ts.map +1 -0
  83. package/lib/typescript/lib/module/components/Text/Text.d.ts +4 -0
  84. package/lib/typescript/lib/module/components/Text/Text.d.ts.map +1 -0
  85. package/lib/typescript/lib/module/components/Text/index.d.ts +2 -0
  86. package/lib/typescript/lib/module/components/Text/index.d.ts.map +1 -0
  87. package/lib/typescript/lib/module/components/index.d.ts +6 -0
  88. package/lib/typescript/lib/module/components/index.d.ts.map +1 -0
  89. package/lib/typescript/lib/module/hooks/index.d.ts +7 -0
  90. package/lib/typescript/lib/module/hooks/index.d.ts.map +1 -0
  91. package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts +2 -0
  92. package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts.map +1 -0
  93. package/lib/typescript/lib/module/hooks/useAnimation.d.ts +9 -0
  94. package/lib/typescript/lib/module/hooks/useAnimation.d.ts.map +1 -0
  95. package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts +10 -0
  96. package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts.map +1 -0
  97. package/lib/typescript/lib/module/hooks/useAppState.d.ts +2 -0
  98. package/lib/typescript/lib/module/hooks/useAppState.d.ts.map +1 -0
  99. package/lib/typescript/lib/module/hooks/useForm.d.ts +33 -0
  100. package/lib/typescript/lib/module/hooks/useForm.d.ts.map +1 -0
  101. package/lib/typescript/lib/module/hooks/useSkeletor.d.ts +7 -0
  102. package/lib/typescript/lib/module/hooks/useSkeletor.d.ts.map +1 -0
  103. package/lib/typescript/lib/module/index.d.ts +5 -0
  104. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  105. package/lib/typescript/lib/module/models/Alignment.d.ts +2 -0
  106. package/lib/typescript/lib/module/models/Alignment.d.ts.map +1 -0
  107. package/lib/typescript/lib/module/models/Border.d.ts +1 -0
  108. package/lib/typescript/lib/module/models/Border.d.ts.map +1 -0
  109. package/lib/typescript/lib/module/models/Size.d.ts +1 -0
  110. package/lib/typescript/lib/module/models/Size.d.ts.map +1 -0
  111. package/lib/typescript/lib/module/models/SkeletorConfig.d.ts +1 -0
  112. package/lib/typescript/lib/module/models/SkeletorConfig.d.ts.map +1 -0
  113. package/lib/typescript/lib/module/models/Spacing.d.ts +1 -0
  114. package/lib/typescript/lib/module/models/Spacing.d.ts.map +1 -0
  115. package/lib/typescript/lib/module/models/index.d.ts +2 -0
  116. package/lib/typescript/lib/module/models/index.d.ts.map +1 -0
  117. package/lib/typescript/lib/module/types/Font.d.d.ts +1 -0
  118. package/lib/typescript/lib/module/types/Font.d.d.ts.map +1 -0
  119. package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts +8 -0
  120. package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts.map +1 -0
  121. package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts +10 -0
  122. package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts.map +1 -0
  123. package/lib/typescript/lib/module/utils/index.d.ts +3 -0
  124. package/lib/typescript/lib/module/utils/index.d.ts.map +1 -0
  125. package/lib/typescript/src/components/Block/Block.d.ts +23 -0
  126. package/lib/typescript/src/components/Block/Block.d.ts.map +1 -0
  127. package/lib/typescript/src/components/Block/index.d.ts +2 -0
  128. package/lib/typescript/src/components/Block/index.d.ts.map +1 -0
  129. package/lib/typescript/src/components/InputFocusScrollView/InputFocusScrollView.d.ts +18 -0
  130. package/lib/typescript/src/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -0
  131. package/lib/typescript/src/components/InputFocusScrollView/index.d.ts +2 -0
  132. package/lib/typescript/src/components/InputFocusScrollView/index.d.ts.map +1 -0
  133. package/lib/typescript/src/components/Screen/Screen.d.ts +16 -0
  134. package/lib/typescript/src/components/Screen/Screen.d.ts.map +1 -0
  135. package/lib/typescript/src/components/Screen/index.d.ts +2 -0
  136. package/lib/typescript/src/components/Screen/index.d.ts.map +1 -0
  137. package/lib/typescript/src/components/SkeletorProvider/SkeletorContext.d.ts +5 -0
  138. package/lib/typescript/src/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -0
  139. package/lib/typescript/src/components/SkeletorProvider/SkeletorProvider.d.ts +8 -0
  140. package/lib/typescript/src/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -0
  141. package/lib/typescript/src/components/SkeletorProvider/index.d.ts +3 -0
  142. package/lib/typescript/src/components/SkeletorProvider/index.d.ts.map +1 -0
  143. package/lib/typescript/src/components/Text/Text.d.ts +21 -0
  144. package/lib/typescript/src/components/Text/Text.d.ts.map +1 -0
  145. package/lib/typescript/src/components/Text/index.d.ts +2 -0
  146. package/lib/typescript/src/components/Text/index.d.ts.map +1 -0
  147. package/lib/typescript/src/components/index.d.ts +6 -0
  148. package/lib/typescript/src/components/index.d.ts.map +1 -0
  149. package/lib/typescript/src/hooks/index.d.ts +7 -0
  150. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  151. package/lib/typescript/src/hooks/useAndroidBackHandler.d.ts +16 -0
  152. package/lib/typescript/src/hooks/useAndroidBackHandler.d.ts.map +1 -0
  153. package/lib/typescript/src/hooks/useAnimation.d.ts +20 -0
  154. package/lib/typescript/src/hooks/useAnimation.d.ts.map +1 -0
  155. package/lib/typescript/src/hooks/useAnimationTimeline.d.ts +30 -0
  156. package/lib/typescript/src/hooks/useAnimationTimeline.d.ts.map +1 -0
  157. package/lib/typescript/src/hooks/useAppState.d.ts +7 -0
  158. package/lib/typescript/src/hooks/useAppState.d.ts.map +1 -0
  159. package/lib/typescript/src/hooks/useForm.d.ts +52 -0
  160. package/lib/typescript/src/hooks/useForm.d.ts.map +1 -0
  161. package/lib/typescript/src/hooks/useSkeletor.d.ts +3 -0
  162. package/lib/typescript/src/hooks/useSkeletor.d.ts.map +1 -0
  163. package/lib/typescript/src/index.d.ts +5 -0
  164. package/lib/typescript/src/index.d.ts.map +1 -0
  165. package/lib/typescript/src/models/Alignment.d.ts +9 -0
  166. package/lib/typescript/src/models/Alignment.d.ts.map +1 -0
  167. package/lib/typescript/src/models/Border.d.ts +16 -0
  168. package/lib/typescript/src/models/Border.d.ts.map +1 -0
  169. package/lib/typescript/src/models/Size.d.ts +10 -0
  170. package/lib/typescript/src/models/Size.d.ts.map +1 -0
  171. package/lib/typescript/src/models/SkeletorConfig.d.ts +7 -0
  172. package/lib/typescript/src/models/SkeletorConfig.d.ts.map +1 -0
  173. package/lib/typescript/src/models/Spacing.d.ts +21 -0
  174. package/lib/typescript/src/models/Spacing.d.ts.map +1 -0
  175. package/lib/typescript/src/models/index.d.ts +6 -0
  176. package/lib/typescript/src/models/index.d.ts.map +1 -0
  177. package/lib/typescript/src/utils/extractAlignmentProperties.d.ts +3 -0
  178. package/lib/typescript/src/utils/extractAlignmentProperties.d.ts.map +1 -0
  179. package/lib/typescript/src/utils/extractSizeProperties.d.ts +3 -0
  180. package/lib/typescript/src/utils/extractSizeProperties.d.ts.map +1 -0
  181. package/lib/typescript/src/utils/index.d.ts +3 -0
  182. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  183. package/package.json +63 -0
  184. package/prototyp-skeletor-v1.0.0.tgz +0 -0
  185. package/src/components/Block/Block.tsx +106 -0
  186. package/src/components/Block/index.ts +1 -0
  187. package/src/components/InputFocusScrollView/InputFocusScrollView.tsx +120 -0
  188. package/src/components/InputFocusScrollView/index.ts +1 -0
  189. package/src/components/Screen/Screen.tsx +91 -0
  190. package/src/components/Screen/index.ts +1 -0
  191. package/src/components/SkeletorProvider/SkeletorContext.ts +12 -0
  192. package/src/components/SkeletorProvider/SkeletorProvider.tsx +18 -0
  193. package/src/components/SkeletorProvider/index.ts +2 -0
  194. package/src/components/Text/Text.tsx +99 -0
  195. package/src/components/Text/index.ts +1 -0
  196. package/src/components/index.ts +5 -0
  197. package/src/hooks/index.ts +6 -0
  198. package/src/hooks/useAndroidBackHandler.ts +45 -0
  199. package/src/hooks/useAnimation.ts +62 -0
  200. package/src/hooks/useAnimationTimeline.ts +139 -0
  201. package/src/hooks/useAppState.ts +26 -0
  202. package/src/hooks/useForm.ts +190 -0
  203. package/src/hooks/useSkeletor.ts +7 -0
  204. package/src/index.ts +4 -0
  205. package/src/models/Alignment.ts +9 -0
  206. package/src/models/Border.ts +15 -0
  207. package/src/models/Size.ts +9 -0
  208. package/src/models/SkeletorConfig.ts +6 -0
  209. package/src/models/Spacing.ts +20 -0
  210. package/src/models/index.ts +5 -0
  211. package/src/types/Font.d.ts +1 -0
  212. package/src/utils/extractAlignmentProperties.ts +13 -0
  213. package/src/utils/extractSizeProperties.ts +13 -0
  214. package/src/utils/index.ts +2 -0
  215. package/tsconfig.json +16 -0
  216. package/yarn.lock +6080 -0
@@ -0,0 +1,55 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React from "react";
3
+ import { SafeAreaView, View, StyleSheet, StatusBar, Platform, Dimensions } from "react-native";
4
+ import { useSkeletor } from "../../hooks";
5
+ import { Block } from "../Block";
6
+ export const Screen = _ref => {
7
+ let {
8
+ background,
9
+ children,
10
+ hideBottomSafeArea,
11
+ hideTopSafeArea,
12
+ bottomSafeAreaColor,
13
+ topSafeAreaColor,
14
+ style,
15
+ statusBarType,
16
+ isLandscape,
17
+ ...rest
18
+ } = _ref;
19
+ const {
20
+ defaultStatusBarType
21
+ } = useSkeletor();
22
+ return /*#__PURE__*/React.createElement(React.Fragment, null, background && (typeof background === "string" ? /*#__PURE__*/React.createElement(View, {
23
+ style: [styles.container, {
24
+ backgroundColor: background
25
+ }]
26
+ }) : /*#__PURE__*/React.createElement(View, {
27
+ style: styles.container
28
+ }, background)), !hideTopSafeArea && /*#__PURE__*/React.createElement(SafeAreaView, {
29
+ style: {
30
+ backgroundColor: topSafeAreaColor
31
+ }
32
+ }), /*#__PURE__*/React.createElement(StatusBar, {
33
+ translucent: true,
34
+ backgroundColor: "transparent",
35
+ barStyle: statusBarType || defaultStatusBarType
36
+ }), /*#__PURE__*/React.createElement(Block, _extends({
37
+ paddings: {
38
+ paddingTop: Platform.OS === "android" && !isLandscape ? StatusBar.currentHeight || 24 : 0
39
+ },
40
+ flex: 1,
41
+ style: style
42
+ }, rest), children), !hideBottomSafeArea && /*#__PURE__*/React.createElement(SafeAreaView, {
43
+ style: {
44
+ backgroundColor: bottomSafeAreaColor
45
+ }
46
+ }));
47
+ };
48
+ const styles = StyleSheet.create({
49
+ container: {
50
+ position: "absolute",
51
+ height: Dimensions.get("screen").height,
52
+ width: Dimensions.get("screen").width
53
+ }
54
+ });
55
+ //# sourceMappingURL=Screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","SafeAreaView","View","StyleSheet","StatusBar","Platform","Dimensions","useSkeletor","Block","Screen","background","children","hideBottomSafeArea","hideTopSafeArea","bottomSafeAreaColor","topSafeAreaColor","style","statusBarType","isLandscape","rest","defaultStatusBarType","styles","container","backgroundColor","paddingTop","OS","currentHeight","create","position","height","get","width"],"sourceRoot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EAAET;IACnB;EAAE,EAEL,CACA;AAEP,CAAC;AAED,MAAMO,MAAM,GAAGlB,UAAU,CAACwB,MAAM,CAAC;EAC/BL,SAAS,EAAE;IACTM,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAEvB,UAAU,CAACwB,GAAG,CAAC,QAAQ,CAAC,CAACD,MAAM;IACvCE,KAAK,EAAEzB,UAAU,CAACwB,GAAG,CAAC,QAAQ,CAAC,CAACC;EAClC;AACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./Screen";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,UAAU"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export const SkeletorDefaults = {
3
+ defaultFont: undefined,
4
+ defaultFontSize: [12, 16],
5
+ defaultStatusBarType: "dark-content",
6
+ defaultTextColor: "black"
7
+ };
8
+ export const SkeletorContext = /*#__PURE__*/React.createContext(SkeletorDefaults);
9
+ //# sourceMappingURL=SkeletorContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","SkeletorDefaults","defaultFont","undefined","defaultFontSize","defaultStatusBarType","defaultTextColor","SkeletorContext","createContext"],"sourceRoot":"../../src","sources":["SkeletorContext.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAO,MAAMC,gBAAgC,GAAG;EAC9CC,WAAW,EAAEC,SAAS;EACtBC,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;EACzBC,oBAAoB,EAAE,cAAc;EACpCC,gBAAgB,EAAE;AACpB,CAAC;AAED,OAAO,MAAMC,eAAe,gBAC1BP,KAAK,CAACQ,aAAa,CAAiBP,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { SkeletorContext, SkeletorDefaults } from "./SkeletorContext";
3
+ /** Create a Font.d.ts type in your typescript types directory and define fonts as follows:
4
+ * @example type Font = "Helvetica" | "Montserrat" ... */
5
+ export const SkeletorProvider = _ref => {
6
+ let {
7
+ children,
8
+ ...config
9
+ } = _ref;
10
+ return /*#__PURE__*/React.createElement(SkeletorContext.Provider, {
11
+ value: {
12
+ ...SkeletorDefaults,
13
+ ...config
14
+ }
15
+ }, children);
16
+ };
17
+ //# sourceMappingURL=SkeletorProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","SkeletorContext","SkeletorDefaults","SkeletorProvider","children","config"],"sourceRoot":"../../src","sources":["SkeletorProvider.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;AAEhD,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,mBAAmB;AAIrE;AACA;AACA,OAAO,MAAMC,gBAAoD,GAAG,QAG9D;EAAA,IAH+D;IACnEC,QAAQ;IACR,GAAGC;EACL,CAAC;EACC,oBACE,oBAAC,eAAe,CAAC,QAAQ;IAAC,KAAK,EAAE;MAAE,GAAGH,gBAAgB;MAAE,GAAGG;IAAO;EAAE,GACjED,QAAQ,CACgB;AAE/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./SkeletorProvider";
2
+ export * from "./SkeletorContext";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,mBAAmB"}
@@ -0,0 +1,64 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React, { useMemo } from "react";
3
+ import { StyleSheet, Text as RNText } from "react-native";
4
+ import { extractSizeProperties } from "../../utils";
5
+ import { useSkeletor } from "../../hooks";
6
+ /** Create a Font.d.ts type in your typescript types directory and define fonts as follows:
7
+ * @example type Font = "Helvetica" | "Montserrat" ... */
8
+ export const Text = _ref => {
9
+ let {
10
+ font,
11
+ size,
12
+ textTransform,
13
+ letterSpacing,
14
+ color,
15
+ style,
16
+ children,
17
+ textAlign,
18
+ opacity,
19
+ margins,
20
+ paddings,
21
+ ...props
22
+ } = _ref;
23
+ const {
24
+ defaultFont,
25
+ defaultFontSize,
26
+ defaultTextColor
27
+ } = useSkeletor();
28
+ const sizeProps = extractSizeProperties(props);
29
+ const textSize = useMemo(() => {
30
+ function mapper(value) {
31
+ if (Array.isArray(value)) {
32
+ const [fontSize, lineHeight] = value;
33
+ return {
34
+ fontSize,
35
+ lineHeight
36
+ };
37
+ } else {
38
+ return {
39
+ fontSize: value,
40
+ lineHeight: value
41
+ };
42
+ }
43
+ }
44
+ return mapper(size || defaultFontSize);
45
+ }, [size, defaultFontSize]);
46
+ const styles = useMemo(() => StyleSheet.flatten([{
47
+ color: color || defaultTextColor,
48
+ ...textSize,
49
+ fontFamily: font || defaultFont,
50
+ opacity,
51
+ textAlign,
52
+ textTransform,
53
+ letterSpacing,
54
+ ...margins,
55
+ ...paddings,
56
+ ...sizeProps
57
+ }, style]), [color, font, opacity, textAlign, textTransform, textSize, margins, paddings, style]);
58
+ return /*#__PURE__*/React.createElement(RNText, _extends({
59
+ style: styles,
60
+ allowFontScaling: false,
61
+ maxFontSizeMultiplier: 1
62
+ }, props), children);
63
+ };
64
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useMemo","StyleSheet","Text","RNText","extractSizeProperties","useSkeletor","font","size","textTransform","letterSpacing","color","style","children","textAlign","opacity","margins","paddings","props","defaultFont","defaultFontSize","defaultTextColor","sizeProps","textSize","mapper","value","Array","isArray","fontSize","lineHeight","styles","flatten","fontFamily"],"sourceRoot":"../../src","sources":["Text.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAuBC,OAAO,QAAQ,OAAO;AACzD,SACEC,UAAU,EACVC,IAAI,IAAIC,MAAM,QAGT,cA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Q,OAAO,EACPD,SAAS,EACTL,aAAa,EACbc,QAAQ,EACRP,OAAO,EACPC,QAAQ,EACRL,KAAK,CACN,CACF;EAED,oBACE,oBAAC,MAAM;IACL,KAAK,EAAEkB,MAAO;IACd,gBAAgB,EAAE,KAAM;IACxB,qBAAqB,EAAE;EAAE,GACrBZ,KAAK,GAERL,QAAQ,CACF;AAEb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./Text";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,QAAQ"}
@@ -0,0 +1,6 @@
1
+ export * from "./Text";
2
+ export * from "./Screen";
3
+ export * from "./Block";
4
+ export * from "./SkeletorProvider";
5
+ export * from "./InputFocusScrollView";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,wBAAwB"}
@@ -0,0 +1,7 @@
1
+ export * from "./useForm";
2
+ export * from "./useAnimation";
3
+ export * from "./useAnimationTimeline";
4
+ export * from "./useAppState";
5
+ export * from "./useSkeletor";
6
+ export * from "./useAndroidBackHandler";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,yBAAyB"}
@@ -0,0 +1,24 @@
1
+ import { useEffect } from "react";
2
+ import { BackHandler } from "react-native";
3
+ function isWithCallback(props) {
4
+ return Object.keys(props).some(key => key === "handlePress");
5
+ }
6
+ export function useAndroidBackHandler(props) {
7
+ const {
8
+ enabled
9
+ } = props;
10
+ useEffect(() => {
11
+ if (!enabled) {
12
+ return;
13
+ }
14
+ const handler = BackHandler.addEventListener("hardwareBackPress", () => {
15
+ if (isWithCallback(props)) {
16
+ props.handlePress();
17
+ return true;
18
+ }
19
+ return props.disableDefault;
20
+ });
21
+ return handler.remove;
22
+ }, [enabled]);
23
+ }
24
+ //# sourceMappingURL=useAndroidBackHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","BackHandler","isWithCallback","props","Object","keys","some","key","useAndroidBackHandler","enabled","handler","addEventListener","handlePress","disableDefault","remove"],"sourceRoot":"../../src","sources":["useAndroidBackHandler.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAQ,cAAc;AAkB1C,SAASC,cAAc,CACrBC,KAA+B,EACR;EACvB,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,IAAI,CAAEC,GAAG,IAAKA,GAAG,KAAK,aAAa,CAAC;AAChE;AAEA,OAAO,SAASC,qBAAqB,CAACL,KAA+B,EAAE;EACrE,MAAM;IAAEM;EAAQ,CAAC,GAAGN,KAAK;EAEzBH,SAAS,CAAC,MAAM;IACd,IAAI,CAACS,OAAO,EAAE;MACZ;IACF;IAEA,MAAMC,OAAO,GAAGT,WAAW,CAACU,gBAAgB,CAAC,mBAAmB,EAAE,MAAM;MACtE,IAAIT,cAAc,CAACC,KAAK,CAAC,EAAE;QACzBA,KAAK,CAACS,WAAW,EAAE;QACnB,OAAO,IAAI;MACb;MAEA,OAAOT,KAAK,CAACU,cAAc;IAC7B,CAAC,CAAC;IAEF,OAAOH,OAAO,CAACI,MAAM;EACvB,CAAC,EAAE,CAACL,OAAO,CAAC,CAAC;AACf"}
@@ -0,0 +1,33 @@
1
+ import { useMemo, useRef } from "react";
2
+ import { Animated } from "react-native";
3
+
4
+ /** Any is a hotfix, requires more investigation */
5
+
6
+ export function useAnimation(styles, configuration) {
7
+ const keys = Object.keys(styles).map(key => key);
8
+ /** Values always start at 0. These are not output values, more like indexes to output values defined in the array. */
9
+ const values = useRef(keys.map(() => new Animated.Value(0))).current;
10
+ const animations = useMemo(() => {
11
+ const result = {};
12
+ keys.forEach((key, index) => {
13
+ const value = values[index];
14
+ // We know the definition exists, otherwise we wouldn't be here.
15
+ const definition = styles[key];
16
+ const interpolation = value.interpolate({
17
+ inputRange: definition.map((_, i) => i),
18
+ outputRange: definition
19
+ });
20
+ result[key] = interpolation;
21
+ });
22
+ return result;
23
+ }, [styles]);
24
+ return {
25
+ values,
26
+ animations,
27
+ configuration: configuration || {
28
+ duration: 250
29
+ },
30
+ definitions: styles
31
+ };
32
+ }
33
+ //# sourceMappingURL=useAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","useRef","Animated","useAnimation","styles","configuration","keys","Object","map","key","values","Value","current","animations","result","forEach","index","value","definition","interpolation","interpolate","inputRange","_","i","outputRange","duration","definitions"],"sourceRoot":"../../src","sources":["useAnimation.ts"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACvC,SAASC,QAAQ,QAAmB,cAAc;;AAElD;;AAyBA,OAAO,SAASC,YAAY,CAC1BC,MAAwB,EACxBC,aAA6B,EACT;EACpB,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,MAAM,CAAC,CAACI,GAAG,CAAEC,GAAG,IAAKA,GAAW,CAAC;EAC1D;EACA,MAAMC,MAAM,GAAGT,MAAM,CAACK,IAAI,CAACE,GAAG,CAAC,MAAM,IAAIN,QAAQ,CAACS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO;EAEpE,MAAMC,UAAU,GAAGb,OAAO,CAAC,MAAM;IAC/B,MAAMc,MAAgC,GAAG,CAAC,CAAC;IAE3CR,IAAI,CAACS,OAAO,CAAC,CAACN,GAAG,EAAEO,KAAK,KAAK;MAC3B,MAAMC,KAAK,GAAGP,MAAM,CAACM,KAAK,CAAC;MAC3B;MACA,MAAME,UAAU,GAAGd,MAAM,CAACK,GAAG,CAAE;MAE/B,MAAMU,aAAa,GAAGF,KAAK,CAACG,WAAW,CAAC;QACtCC,UAAU,EAAEH,UAAU,CAACV,GAAG,CAAC,CAACc,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAAC;QACvCC,WAAW,EAAEN;MACf,CAAC,CAAC;MAEFJ,MAAM,CAACL,GAAG,CAAC,GAAGU,aAAa;IAC7B,CAAC,CAAC;IAEF,OAAOL,MAAM;EACf,CAAC,EAAE,CAACV,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLM,MAAM;IACNG,UAAU;IACVR,aAAa,EAAEA,aAAa,IAAI;MAAEoB,QAAQ,EAAE;IAAI,CAAC;IACjDC,WAAW,EAAEtB;EACf,CAAC;AACH"}
@@ -0,0 +1,97 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Animated } from "react-native";
3
+ /** Used to layout animated values on a timeline and handle starting/reversing the animations.
4
+ * Supports all Animated types (delay, stagger, parallel, sequence).
5
+ * @example
6
+ * useAnimationTimeline({
7
+ stagger: { elements: [ring1, ring2, ring3], stagger: 900, start: show },
8
+ sequence: { elements: [button], start: Boolean(show && !disabled) },
9
+ });
10
+ */
11
+ export function useAnimationTimeline(config) {
12
+ const {
13
+ delay,
14
+ parallel,
15
+ sequence,
16
+ stagger
17
+ } = config;
18
+ const staggerStart = Boolean(stagger === null || stagger === void 0 ? void 0 : stagger.start);
19
+ const delayStart = Boolean(delay === null || delay === void 0 ? void 0 : delay.start);
20
+ const sequenceStart = Boolean(sequence === null || sequence === void 0 ? void 0 : sequence.start);
21
+ const parallelStart = Boolean(parallel === null || parallel === void 0 ? void 0 : parallel.start);
22
+ const [previousDelayStart, setPreviousDelayStart] = useState(false);
23
+ const [previousStaggerStart, setPreviousStaggerStart] = useState(false);
24
+ const [previousSequenceStart, setPreviousSequenceStart] = useState(false);
25
+ const [previousParallelStart, setPreviousParallelStart] = useState(false);
26
+ function getBaseAnimations(timeline) {
27
+ const compositions = [];
28
+ timeline.elements.forEach(_ref => {
29
+ let {
30
+ values,
31
+ animations,
32
+ configuration,
33
+ definitions
34
+ } = _ref;
35
+ const keys = Object.keys(animations).map(key => key);
36
+ const elementCompositions = keys.map((key, index) => {
37
+ const value = values[index];
38
+ const lastValue = definitions[key].length - 1;
39
+ const nativeAnimation = configuration.loop ? false : configuration.useNativeDriver || false;
40
+ const base = Animated.timing(value, {
41
+ toValue: timeline.start ? lastValue : 0,
42
+ duration: configuration.duration,
43
+ useNativeDriver: nativeAnimation
44
+ });
45
+ return configuration.loop ? Animated.loop(base) : base;
46
+ });
47
+ compositions.push(Animated.parallel(elementCompositions));
48
+ });
49
+ return compositions;
50
+ }
51
+ function setupParallelAnimations(timeline) {
52
+ if (timeline.onStarted) {
53
+ timeline.onStarted();
54
+ }
55
+ Animated.parallel(getBaseAnimations(timeline)).start(timeline.onFinished);
56
+ }
57
+ function setupSequenceAnimations(timeline) {
58
+ if (timeline.onStarted) {
59
+ timeline.onStarted();
60
+ }
61
+ Animated.sequence(getBaseAnimations(timeline)).start(timeline.onFinished);
62
+ }
63
+ function setupStaggerAnimations(timeline) {
64
+ if (timeline.onStarted) {
65
+ timeline.onStarted();
66
+ }
67
+ Animated.stagger(timeline.stagger, getBaseAnimations(timeline)).start(timeline.onFinished);
68
+ }
69
+ function setupDelayAnimations(timeline) {
70
+ Animated.delay(timeline.delay).start(() => setupParallelAnimations(timeline));
71
+ }
72
+ useEffect(() => {
73
+ if (stagger && previousStaggerStart !== staggerStart) {
74
+ setupStaggerAnimations(stagger);
75
+ }
76
+ setPreviousStaggerStart(staggerStart);
77
+ }, [previousStaggerStart, staggerStart, stagger]);
78
+ useEffect(() => {
79
+ if (parallel && previousParallelStart !== parallelStart) {
80
+ setupParallelAnimations(parallel);
81
+ }
82
+ setPreviousParallelStart(parallelStart);
83
+ }, [previousParallelStart, parallelStart, parallel]);
84
+ useEffect(() => {
85
+ if (sequence && previousSequenceStart !== sequenceStart) {
86
+ setupSequenceAnimations(sequence);
87
+ }
88
+ setPreviousSequenceStart(sequenceStart);
89
+ }, [previousSequenceStart, sequenceStart, sequence]);
90
+ useEffect(() => {
91
+ if (delay && previousDelayStart !== delayStart) {
92
+ setupDelayAnimations(delay);
93
+ }
94
+ setPreviousDelayStart(delayStart);
95
+ }, [previousDelayStart, delayStart, delay]);
96
+ }
97
+ //# sourceMappingURL=useAnimationTimeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","Animated","useAnimationTimeline","config","delay","parallel","sequence","stagger","staggerStart","Boolean","start","delayStart","sequenceStart","parallelStart","previousDelayStart","setPreviousDelayStart","previousStaggerStart","setPreviousStaggerStart","previousSequenceStart","setPreviousSequenceStart","previousParallelStart","setPreviousParallelStart","getBaseAnimations","timeline","compositions","elements","forEach","values","animations","configuration","definitions","keys","Object","map","key","elementCompositions","index","value","lastValue","length","nativeAnimation","loop","useNativeDriver","base","timing","toValue","duration","push","setupParallelAnimations","onStarted","onFinished","setupSequenceAnimations","setupStaggerAnimations","setupDelayAnimations"],"sourceRoot":"../../src","sources":["useAnimationTimeline.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAmB,cAAc;AAwBlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoB,CAACC,MAA6B,EAAQ;EACxE,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EACrD,MAAMK,YAAY,GAAGC,OAAO,CAACF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,KAAK,CAAC;EAC5C,MAAMC,UAAU,GAAGF,OAAO,CAACL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEM,KAAK,CAAC;EACxC,MAAME,aAAa,GAAGH,OAAO,CAACH,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,KAAK,CAAC;EAC9C,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AIQ,OAAO,IAAIS,oBAAoB,KAAKR,YAAY,EAAE;MACpD4C,sBAAsB,CAAC7C,OAAO,CAAC;IACjC;IAEAU,uBAAuB,CAACT,YAAY,CAAC;EACvC,CAAC,EAAE,CAACQ,oBAAoB,EAAER,YAAY,EAAED,OAAO,CAAC,CAAC;EAEjDR,SAAS,CAAC,MAAM;IACd,IAAIM,QAAQ,IAAIe,qBAAqB,KAAKP,aAAa,EAAE;MACvDmC,uBAAuB,CAAC3C,QAAQ,CAAC;IACnC;IAEAgB,wBAAwB,CAACR,aAAa,CAAC;EACzC,CAAC,EAAE,CAACO,qBAAqB,EAAEP,aAAa,EAAER,QAAQ,CAAC,CAAC;EAEpDN,SAAS,CAAC,MAAM;IACd,IAAIO,QAAQ,IAAIY,qBAAqB,KAAKN,aAAa,EAAE;MACvDuC,uBAAuB,CAAC7C,QAAQ,CAAC;IACnC;IAEAa,wBAAwB,CAACP,aAAa,CAAC;EACzC,CAAC,EAAE,CAACM,qBAAqB,EAAEN,aAAa,EAAEN,QAAQ,CAAC,CAAC;EAEpDP,SAAS,CAAC,MAAM;IACd,IAAIK,KAAK,IAAIU,kBAAkB,KAAKH,UAAU,EAAE;MAC9C0C,oBAAoB,CAACjD,KAAK,CAAC;IAC7B;IAEAW,qBAAqB,CAACJ,UAAU,CAAC;EACnC,CAAC,EAAE,CAACG,kBAAkB,EAAEH,UAAU,EAAEP,KAAK,CAAC,CAAC;AAC7C"}
@@ -0,0 +1,21 @@
1
+ import { useCallback, useEffect } from "react";
2
+ import { AppState } from "react-native";
3
+ export function useAppState(_ref) {
4
+ let {
5
+ onForeground,
6
+ onBackground
7
+ } = _ref;
8
+ const handleAppStateChange = useCallback(state => {
9
+ if (state.match(/background|inactive/)) {
10
+ onBackground === null || onBackground === void 0 ? void 0 : onBackground();
11
+ }
12
+ if (state === "active") {
13
+ onForeground === null || onForeground === void 0 ? void 0 : onForeground();
14
+ }
15
+ }, [onBackground, onForeground]);
16
+ useEffect(() => {
17
+ const event = AppState.addEventListener("change", handleAppStateChange);
18
+ return event.remove;
19
+ }, [handleAppStateChange]);
20
+ }
21
+ //# sourceMappingURL=useAppState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","AppState","useAppState","onForeground","onBackground","handleAppStateChange","state","match","event","addEventListener","remove"],"sourceRoot":"../../src","sources":["useAppState.ts"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,QAAQ,OAAO;AAC9C,SAASC,QAAQ,QAAwB,cAAc;AAOvD,OAAO,SAASC,WAAW,OAAyC;EAAA,IAAxC;IAAEC,YAAY;IAAEC;EAAqB,CAAC;EAChE,MAAMC,oBAAoB,GAAGN,WAAW,CACrCO,KAAqB,IAAK;IACzB,IAAIA,KAAK,CAACC,KAAK,CAAC,qBAAqB,CAAC,EAAE;MACtCH,YAAY,aAAZA,YAAY,uBAAZA,YAAY,EAAI;IAClB;IACA,IAAIE,KAAK,KAAK,QAAQ,EAAE;MACtBH,YAAY,aAAZA,YAAY,uBAAZA,YAAY,EAAI;IAClB;EACF,CAAC,EACD,CAACC,YAAY,EAAED,YAAY,CAAC,CAC7B;EAEDH,SAAS,CAAC,MAAM;IACd,MAAMQ,KAAK,GAAGP,QAAQ,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,oBAAoB,CAAC;IACvE,OAAOG,KAAK,CAACE,MAAM;EACrB,CAAC,EAAE,CAACL,oBAAoB,CAAC,CAAC;AAC5B"}
@@ -0,0 +1,159 @@
1
+ import { useEffect, useState } from "react";
2
+ /** One-fits-all solution to manage state changes, field validation and optional entries within a form.
3
+ * @example <caption>Simple use case:</caption>
4
+ * const { state, validation, update } = useForm({ email: '', password: '', });
5
+ *
6
+ *
7
+ * @example <caption>For more complex form states (ie one field can be of multiple types), you should pass the form's type:</caption>
8
+ * const { state, validation, update } = useForm<{ numericOrUndefined: number | undefined }>({ numericOrUndefined: undefined }, { rules: { numericOrUndefined: (value: number | undefined): boolean | undefined => ... }});
9
+ *
10
+ */
11
+ export function useForm(values, config) {
12
+ const keys = Object.keys(values);
13
+ const [validation, setValidation] = useState({});
14
+ const [initialState, setInitialState] = useState(values);
15
+ const [state, setState] = useState(values);
16
+ const {
17
+ fieldValidation,
18
+ stateValidation,
19
+ isOptional
20
+ } = useFormUtils(config);
21
+ useEffect(() => {
22
+ const changed = keys.filter(key => values[key] !== initialState[key]);
23
+ if (!changed.length) {
24
+ return;
25
+ }
26
+ const updatedState = {
27
+ ...state
28
+ };
29
+ changed.forEach(key => updatedState[key] = values[key]);
30
+ setInitialState({
31
+ ...values,
32
+ ...updatedState
33
+ });
34
+ setState(updatedState);
35
+ }, [values]);
36
+
37
+ /** This function updates the specific property with a new value and validates it if it needs to do so.
38
+ * @example <caption>Usage:</caption>
39
+ * <TextInput ... onChange={(event) => update("nameOfProp", event.nativeEvent.text, false)} onBlur={(event) => update("nameOfProp", event.nativeEvent.text, true)}
40
+ * */
41
+ function update(key, value, shouldValidate) {
42
+ setState(s => ({
43
+ ...s,
44
+ [key]: value
45
+ }));
46
+ setValidation(s => ({
47
+ ...s,
48
+ [key]: shouldValidate ? fieldValidation(key, value, state) : undefined
49
+ }));
50
+ }
51
+ function validate(key) {
52
+ setValidation(s => ({
53
+ ...s,
54
+ [key]: fieldValidation(key, state[key], state)
55
+ }));
56
+ }
57
+
58
+ /** Validate entire form, store validation state and return validation value.
59
+ * In human readable terms, use this when you want to validate the form on submit.
60
+ */
61
+ function validateForm() {
62
+ const formValidationState = stateValidation(state);
63
+ setValidation(formValidationState.validation);
64
+ return formValidationState.valid;
65
+ }
66
+
67
+ /** Boolean value of whether the form is valid (ie can be submitted). Use this to disable/enable form submission.
68
+ * Only use when validating fields separately, has no value when valiating on form submit. */
69
+ function isFormValid() {
70
+ return !keys.some(key => isOptional(key) ? validation[key] === false : !validation[key]);
71
+ }
72
+
73
+ /** Resets changed values to initial state */
74
+ function resetState() {
75
+ setState(values);
76
+ }
77
+
78
+ /** Re-initializes initial state from currently passed values. Use this if you need to reinitialize the form after the source values change, i.e. if a different state object comes into play after submitting the form (such as reducer data or API endpoint response data) */
79
+ function resetInitialValues() {
80
+ setInitialState(values);
81
+ }
82
+
83
+ /** Resets validation to initial state. */
84
+ function resetValidation() {
85
+ setValidation({});
86
+ }
87
+
88
+ /** Resets entire form, state and validation included */
89
+ function clearForm() {
90
+ resetInitialValues();
91
+ resetState();
92
+ resetValidation();
93
+ }
94
+ return {
95
+ state,
96
+ validation,
97
+ update,
98
+ validate,
99
+ validateForm,
100
+ isFormValid,
101
+ clearForm,
102
+ resetState,
103
+ resetValidation,
104
+ resetInitialValues
105
+ };
106
+ }
107
+
108
+ /** Helper hook to validate form state outside of the scope of useForm. */
109
+ export function useFormUtils(config) {
110
+ function doesValueExist(value) {
111
+ if (value === null || value === undefined || value === "" || value < 0) {
112
+ return false;
113
+ }
114
+ return true;
115
+ }
116
+ function validateByRule(key, value, state) {
117
+ // If rule exists, validate with rule
118
+ if (config !== null && config !== void 0 && config.rules && config.rules[key]) {
119
+ var _config$rules$key, _config$rules;
120
+ return (_config$rules$key = (_config$rules = config.rules)[key]) === null || _config$rules$key === void 0 ? void 0 : _config$rules$key.call(_config$rules, value, state);
121
+ }
122
+ // else return true because we know the value exists already.
123
+ return true;
124
+ }
125
+ function isOptional(key) {
126
+ var _config$optional;
127
+ return config === null || config === void 0 ? void 0 : (_config$optional = config.optional) === null || _config$optional === void 0 ? void 0 : _config$optional.includes(key);
128
+ }
129
+ function fieldValidation(key, value, state) {
130
+ const hasValue = doesValueExist(value);
131
+ const optional = isOptional(key);
132
+ if (!hasValue) {
133
+ return !!optional;
134
+ } else {
135
+ return validateByRule(key, value, state);
136
+ }
137
+ }
138
+ function stateValidation(state) {
139
+ const keys = Object.keys(state).map(key => key);
140
+ const validation = {};
141
+ keys.forEach(key => {
142
+ const value = state[key];
143
+ // Force true / false values for entire form. Undefined has no value when submitting.
144
+ validation[key] = fieldValidation(key, value, state) || false;
145
+ });
146
+ return {
147
+ valid: !keys.some(key => !validation[key]),
148
+ validation
149
+ };
150
+ }
151
+ return {
152
+ doesValueExist,
153
+ validateByRule,
154
+ isOptional,
155
+ fieldValidation,
156
+ stateValidation
157
+ };
158
+ }
159
+ //# sourceMappingURL=useForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","useForm","values","config","keys","Object","validation","setValidation","initialState","setInitialState","state","setState","fieldValidation","stateValidation","isOptional","useFormUtils","changed","filter","key","length","updatedState","forEach","update","value","shouldValidate","s","undefined","validate","validateForm","formValidationState","valid","isFormValid","some","resetState","resetInitialValues","resetValidation","clearForm","doesValueExist","validateByRule","rules","optional","includes","hasValue","map"],"sourceRoot":"../../src","sources":["useForm.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAqB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAO,CAAIC,MAAiB,EAAEC,MAAsB,EAAE;EACpE,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,MAAM,CAAmB;EAClD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAQ,CAAgB,CAAC,CAAC,CAAC;EAC/D,MAAM,CAACQ,YAAY,EAAEC,eAAe,CAAC,GAAGT,QAAQ,CAACE,MAAM,CAAC;EACxD,MAAM,CAACQ,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAACE,MAAM,CAAC;EAC1C,MAAM;IAAEU,eAAe;IAAEC,eAAe;IAAEC;EAAW,CAAC,GAAGC,YAAY,CAACZ,MAAM,CAAC;EAE7EJ,SAAS,CAAC,MAAM;IACd,MAAMiB,OAAO,GAAGZ,IAAI,CAACa,MAAM,CAAEC,GAAG,IAAKhB,MAAM,CAACgB,GAAG,CAAC,KAAKV,YAAY,CAACU,GAAG,CAAC,CAAC;IACvE,IAAI,CAACF,OAAO,CAACG,MAAM,EAAE;MACnB;IACF;IAEA,MAAMC,YAAY,GAAG;MAAE,GAAGV;I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M,GAAY,EACZK,KAA6B,EAC7Bb,KAAgB,EAChB;IACA,MAAMgC,QAAQ,GAAGL,cAAc,CAACd,KAAK,CAAC;IACtC,MAAMiB,QAAQ,GAAG1B,UAAU,CAACI,GAAG,CAAC;IAChC,IAAI,CAACwB,QAAQ,EAAE;MACb,OAAO,CAAC,CAACF,QAAQ;IACnB,CAAC,MAAM;MACL,OAAOF,cAAc,CAACpB,GAAG,EAAEK,KAAK,EAAEb,KAAK,CAAC;IAC1C;EACF;EAEA,SAASG,eAAe,CAACH,KAAgB,EAAE;IACzC,MAAMN,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACM,KAAK,CAAC,CAACiC,GAAG,CAAEzB,GAAG,IAAKA,GAAc,CAAC;IAC5D,MAAMZ,UAAyB,GAAG,CAAC,CAAC;IAEpCF,IAAI,CAACiB,OAAO,CAAEH,GAAG,IAAK;MACpB,MAAMK,KAAK,GAAGb,KAAK,CAACQ,GAAG,CAAC;MACxB;MACAZ,UAAU,CAACY,GAAG,CAAC,GAAGN,eAAe,CAACM,GAAG,EAAEK,KAAK,EAAEb,KAAK,CAAC,IAAI,KAAK;IAC/D,CAAC,CAAC;IAEF,OAAO;MACLoB,KAAK,EAAE,CAAC1B,IAAI,CAAC4B,IAAI,CAAEd,GAAG,IAAK,CAACZ,UAAU,CAACY,GAAG,CAAC,CAAC;MAC5CZ;IACF,CAAC;EACH;EAEA,OAAO;IACL+B,cAAc;IACdC,cAAc;IACdxB,UAAU;IACVF,eAAe;IACfC;EACF,CAAC;AACH"}
@@ -0,0 +1,6 @@
1
+ import { useContext } from "react";
2
+ import { SkeletorContext } from "../components";
3
+ export function useSkeletor() {
4
+ return useContext(SkeletorContext);
5
+ }
6
+ //# sourceMappingURL=useSkeletor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useContext","SkeletorContext","useSkeletor"],"sourceRoot":"../../src","sources":["useSkeletor.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,SAASC,WAAW,GAAmB;EAC5C,OAAOF,UAAU,CAACC,eAAe,CAAC;AACpC"}
@@ -0,0 +1,5 @@
1
+ export * from "./components";
2
+ export * from "./hooks";
3
+ export * from "./models";
4
+ export * from "./utils";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,SAAS"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Alignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["Alignment.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Border.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["Border.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["Size.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=SkeletorConfig.js.map