ferns-ui 0.2.2 → 0.3.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 (332) hide show
  1. package/dist/ActionSheet.js.map +1 -1
  2. package/dist/Common.d.ts +1 -1
  3. package/dist/DateTimeActionSheet.js.map +1 -1
  4. package/dist/DecimalRangeActionSheet.js.map +1 -1
  5. package/dist/ErrorBoundary.d.ts +1 -1
  6. package/dist/Field.d.ts +12 -14
  7. package/dist/Field.js +95 -98
  8. package/dist/Field.js.map +1 -1
  9. package/dist/Form.d.ts +1 -1
  10. package/dist/HeightActionSheet.js.map +1 -1
  11. package/dist/Hyperlink.d.ts +43 -0
  12. package/dist/Hyperlink.js +135 -0
  13. package/dist/Hyperlink.js.map +1 -0
  14. package/dist/NumberPickerActionSheet.js.map +1 -1
  15. package/dist/PickerSelect.d.ts +4 -4
  16. package/dist/SelectList.d.ts +1 -1
  17. package/dist/SelectList.js.map +1 -1
  18. package/dist/SplitPage.js.map +1 -1
  19. package/dist/Text.js +2 -6
  20. package/dist/Text.js.map +1 -1
  21. package/dist/TextField.js.map +1 -1
  22. package/dist/TextFieldNumberActionSheet.js.map +1 -1
  23. package/dist/Unifier.js +5 -11
  24. package/dist/Unifier.js.map +1 -1
  25. package/package.json +28 -27
  26. package/src/Field.tsx +91 -98
  27. package/src/Form.tsx +1 -1
  28. package/src/Hyperlink.tsx +181 -0
  29. package/src/SelectList.tsx +2 -1
  30. package/src/Text.tsx +4 -5
  31. package/src/TextFieldNumberActionSheet.tsx +1 -1
  32. package/src/Unifier.ts +4 -2
  33. package/dist/Banner.stories.d.ts +0 -1
  34. package/dist/Banner.stories.js +0 -13
  35. package/dist/Banner.stories.js.map +0 -1
  36. package/dist/Box.stories.d.ts +0 -1
  37. package/dist/Box.stories.js +0 -45
  38. package/dist/Box.stories.js.map +0 -1
  39. package/dist/Button.stories.d.ts +0 -1
  40. package/dist/Button.stories.js +0 -41
  41. package/dist/Button.stories.js.map +0 -1
  42. package/dist/Card.stories.d.ts +0 -6
  43. package/dist/Card.stories.js +0 -18
  44. package/dist/Card.stories.js.map +0 -1
  45. package/dist/CheckBox.stories.d.ts +0 -1
  46. package/dist/CheckBox.stories.js +0 -28
  47. package/dist/CheckBox.stories.js.map +0 -1
  48. package/dist/Field.stories.d.ts +0 -6
  49. package/dist/Field.stories.js +0 -38
  50. package/dist/Field.stories.js.map +0 -1
  51. package/dist/Form.stories.d.ts +0 -6
  52. package/dist/Form.stories.js +0 -36
  53. package/dist/Form.stories.js.map +0 -1
  54. package/dist/HeaderButtons.stories.d.ts +0 -6
  55. package/dist/HeaderButtons.stories.js +0 -6
  56. package/dist/HeaderButtons.stories.js.map +0 -1
  57. package/dist/Heading.stories.d.ts +0 -1
  58. package/dist/Heading.stories.js +0 -22
  59. package/dist/Heading.stories.js.map +0 -1
  60. package/dist/Icon.stories.d.ts +0 -1
  61. package/dist/Icon.stories.js +0 -30
  62. package/dist/Icon.stories.js.map +0 -1
  63. package/dist/IconButton.stories.d.ts +0 -1
  64. package/dist/IconButton.stories.js +0 -16
  65. package/dist/IconButton.stories.js.map +0 -1
  66. package/dist/Link.stories.d.ts +0 -1
  67. package/dist/Link.stories.js +0 -18
  68. package/dist/Link.stories.js.map +0 -1
  69. package/dist/Mask.stories.d.ts +0 -1
  70. package/dist/Mask.stories.js +0 -28
  71. package/dist/Mask.stories.js.map +0 -1
  72. package/dist/Pill.stories.d.ts +0 -1
  73. package/dist/Pill.stories.js +0 -38
  74. package/dist/Pill.stories.js.map +0 -1
  75. package/dist/SegmentedControl.stories.d.ts +0 -1
  76. package/dist/SegmentedControl.stories.js +0 -31
  77. package/dist/SegmentedControl.stories.js.map +0 -1
  78. package/dist/SelectList.stories.d.ts +0 -1
  79. package/dist/SelectList.stories.js +0 -26
  80. package/dist/SelectList.stories.js.map +0 -1
  81. package/dist/Spinner.stories.d.ts +0 -1
  82. package/dist/Spinner.stories.js +0 -12
  83. package/dist/Spinner.stories.js.map +0 -1
  84. package/dist/SplitPage.stories.d.ts +0 -1
  85. package/dist/SplitPage.stories.js +0 -15
  86. package/dist/SplitPage.stories.js.map +0 -1
  87. package/dist/StorybookContainer.d.ts +0 -4
  88. package/dist/StorybookContainer.js +0 -8
  89. package/dist/StorybookContainer.js.map +0 -1
  90. package/dist/Switch.stories.d.ts +0 -1
  91. package/dist/Switch.stories.js +0 -34
  92. package/dist/Switch.stories.js.map +0 -1
  93. package/dist/Text.stories.d.ts +0 -1
  94. package/dist/Text.stories.js +0 -37
  95. package/dist/Text.stories.js.map +0 -1
  96. package/dist/TextArea.stories.d.ts +0 -10
  97. package/dist/TextArea.stories.js +0 -24
  98. package/dist/TextArea.stories.js.map +0 -1
  99. package/dist/TextField.stories.d.ts +0 -6
  100. package/dist/TextField.stories.js +0 -18
  101. package/dist/TextField.stories.js.map +0 -1
  102. package/dist/dist/ActionSheet.d.ts +0 -139
  103. package/dist/dist/ActionSheet.js +0 -637
  104. package/dist/dist/ActionSheet.js.map +0 -1
  105. package/dist/dist/Banner.d.ts +0 -12
  106. package/dist/dist/Banner.js +0 -49
  107. package/dist/dist/Banner.js.map +0 -1
  108. package/dist/dist/Banner.stories.d.ts +0 -1
  109. package/dist/dist/Banner.stories.js +0 -9
  110. package/dist/dist/Banner.stories.js.map +0 -1
  111. package/dist/dist/BlurBox.d.ts +0 -7
  112. package/dist/dist/BlurBox.js +0 -29
  113. package/dist/dist/BlurBox.js.map +0 -1
  114. package/dist/dist/BlurBox.native.d.ts +0 -9
  115. package/dist/dist/BlurBox.native.js +0 -32
  116. package/dist/dist/BlurBox.native.js.map +0 -1
  117. package/dist/dist/Body.d.ts +0 -12
  118. package/dist/dist/Body.js +0 -19
  119. package/dist/dist/Body.js.map +0 -1
  120. package/dist/dist/Box.d.ts +0 -205
  121. package/dist/dist/Box.js +0 -229
  122. package/dist/dist/Box.js.map +0 -1
  123. package/dist/dist/Box.stories.d.ts +0 -1
  124. package/dist/dist/Box.stories.js +0 -37
  125. package/dist/dist/Box.stories.js.map +0 -1
  126. package/dist/dist/Button.d.ts +0 -16
  127. package/dist/dist/Button.js +0 -98
  128. package/dist/dist/Button.js.map +0 -1
  129. package/dist/dist/Button.stories.d.ts +0 -13
  130. package/dist/dist/Button.stories.js +0 -26
  131. package/dist/dist/Button.stories.js.map +0 -1
  132. package/dist/dist/Card.d.ts +0 -6
  133. package/dist/dist/Card.js +0 -9
  134. package/dist/dist/Card.js.map +0 -1
  135. package/dist/dist/Card.stories.d.ts +0 -6
  136. package/dist/dist/Card.stories.js +0 -11
  137. package/dist/dist/Card.stories.js.map +0 -1
  138. package/dist/dist/CheckBox.d.ts +0 -8
  139. package/dist/dist/CheckBox.js +0 -23
  140. package/dist/dist/CheckBox.js.map +0 -1
  141. package/dist/dist/CheckBox.stories.d.ts +0 -1
  142. package/dist/dist/CheckBox.stories.js +0 -22
  143. package/dist/dist/CheckBox.stories.js.map +0 -1
  144. package/dist/dist/Common.d.ts +0 -5
  145. package/dist/dist/Common.js +0 -47
  146. package/dist/dist/Common.js.map +0 -1
  147. package/dist/dist/DateTimeActionSheet.d.ts +0 -5
  148. package/dist/dist/DateTimeActionSheet.js +0 -24
  149. package/dist/dist/DateTimeActionSheet.js.map +0 -1
  150. package/dist/dist/DecimalRangeActionSheet.d.ts +0 -9
  151. package/dist/dist/DecimalRangeActionSheet.js +0 -57
  152. package/dist/dist/DecimalRangeActionSheet.js.map +0 -1
  153. package/dist/dist/ErrorBoundary.d.ts +0 -12
  154. package/dist/dist/ErrorBoundary.js +0 -32
  155. package/dist/dist/ErrorBoundary.js.map +0 -1
  156. package/dist/dist/ErrorPage.d.ts +0 -7
  157. package/dist/dist/ErrorPage.js +0 -15
  158. package/dist/dist/ErrorPage.js.map +0 -1
  159. package/dist/dist/Field.d.ts +0 -17
  160. package/dist/dist/Field.js +0 -136
  161. package/dist/dist/Field.js.map +0 -1
  162. package/dist/dist/Field.stories.d.ts +0 -6
  163. package/dist/dist/Field.stories.js +0 -25
  164. package/dist/dist/Field.stories.js.map +0 -1
  165. package/dist/dist/FieldWithLabels.d.ts +0 -10
  166. package/dist/dist/FieldWithLabels.js +0 -7
  167. package/dist/dist/FieldWithLabels.js.map +0 -1
  168. package/dist/dist/FlatList.d.ts +0 -1
  169. package/dist/dist/FlatList.js +0 -4
  170. package/dist/dist/FlatList.js.map +0 -1
  171. package/dist/dist/Form.d.ts +0 -15
  172. package/dist/dist/Form.js +0 -56
  173. package/dist/dist/Form.js.map +0 -1
  174. package/dist/dist/Form.stories.d.ts +0 -6
  175. package/dist/dist/Form.stories.js +0 -27
  176. package/dist/dist/Form.stories.js.map +0 -1
  177. package/dist/dist/HeaderButtons.d.ts +0 -39
  178. package/dist/dist/HeaderButtons.js +0 -50
  179. package/dist/dist/HeaderButtons.js.map +0 -1
  180. package/dist/dist/HeaderButtons.stories.d.ts +0 -6
  181. package/dist/dist/HeaderButtons.stories.js +0 -7
  182. package/dist/dist/HeaderButtons.stories.js.map +0 -1
  183. package/dist/dist/Heading.d.ts +0 -32
  184. package/dist/dist/Heading.js +0 -47
  185. package/dist/dist/Heading.js.map +0 -1
  186. package/dist/dist/Heading.stories.d.ts +0 -1
  187. package/dist/dist/Heading.stories.js +0 -11
  188. package/dist/dist/Heading.stories.js.map +0 -1
  189. package/dist/dist/HeightActionSheet.d.ts +0 -9
  190. package/dist/dist/HeightActionSheet.js +0 -50
  191. package/dist/dist/HeightActionSheet.js.map +0 -1
  192. package/dist/dist/Icon.d.ts +0 -12
  193. package/dist/dist/Icon.js +0 -126
  194. package/dist/dist/Icon.js.map +0 -1
  195. package/dist/dist/Icon.stories.d.ts +0 -1
  196. package/dist/dist/Icon.stories.js +0 -11
  197. package/dist/dist/Icon.stories.js.map +0 -1
  198. package/dist/dist/IconButton.d.ts +0 -42
  199. package/dist/dist/IconButton.js +0 -41
  200. package/dist/dist/IconButton.js.map +0 -1
  201. package/dist/dist/IconButton.stories.d.ts +0 -1
  202. package/dist/dist/IconButton.stories.js +0 -8
  203. package/dist/dist/IconButton.stories.js.map +0 -1
  204. package/dist/dist/Image.d.ts +0 -9
  205. package/dist/dist/Image.js +0 -37
  206. package/dist/dist/Image.js.map +0 -1
  207. package/dist/dist/ImageBackground.d.ts +0 -6
  208. package/dist/dist/ImageBackground.js +0 -9
  209. package/dist/dist/ImageBackground.js.map +0 -1
  210. package/dist/dist/Layer.d.ts +0 -5
  211. package/dist/dist/Layer.js +0 -13
  212. package/dist/dist/Layer.js.map +0 -1
  213. package/dist/dist/Link.d.ts +0 -7
  214. package/dist/dist/Link.js +0 -13
  215. package/dist/dist/Link.js.map +0 -1
  216. package/dist/dist/Link.stories.d.ts +0 -1
  217. package/dist/dist/Link.stories.js +0 -8
  218. package/dist/dist/Link.stories.js.map +0 -1
  219. package/dist/dist/Mask.d.ts +0 -5
  220. package/dist/dist/Mask.js +0 -23
  221. package/dist/dist/Mask.js.map +0 -1
  222. package/dist/dist/Mask.stories.d.ts +0 -1
  223. package/dist/dist/Mask.stories.js +0 -13
  224. package/dist/dist/Mask.stories.js.map +0 -1
  225. package/dist/dist/MediaQuery.d.ts +0 -2
  226. package/dist/dist/MediaQuery.js +0 -34
  227. package/dist/dist/MediaQuery.js.map +0 -1
  228. package/dist/dist/Meta.d.ts +0 -6
  229. package/dist/dist/Meta.js +0 -8
  230. package/dist/dist/Meta.js.map +0 -1
  231. package/dist/dist/ModalSheet.d.ts +0 -3
  232. package/dist/dist/ModalSheet.js +0 -43
  233. package/dist/dist/ModalSheet.js.map +0 -1
  234. package/dist/dist/NumberPickerActionSheet.d.ts +0 -5
  235. package/dist/dist/NumberPickerActionSheet.js +0 -25
  236. package/dist/dist/NumberPickerActionSheet.js.map +0 -1
  237. package/dist/dist/Page.d.ts +0 -9
  238. package/dist/dist/Page.js +0 -26
  239. package/dist/dist/Page.js.map +0 -1
  240. package/dist/dist/Permissions.d.ts +0 -1
  241. package/dist/dist/Permissions.js +0 -36
  242. package/dist/dist/Permissions.js.map +0 -1
  243. package/dist/dist/PickerSelect.d.ts +0 -172
  244. package/dist/dist/PickerSelect.js +0 -403
  245. package/dist/dist/PickerSelect.js.map +0 -1
  246. package/dist/dist/Pill.d.ts +0 -7
  247. package/dist/dist/Pill.js +0 -10
  248. package/dist/dist/Pill.js.map +0 -1
  249. package/dist/dist/Pill.stories.d.ts +0 -1
  250. package/dist/dist/Pill.stories.js +0 -36
  251. package/dist/dist/Pill.stories.js.map +0 -1
  252. package/dist/dist/Pog.d.ts +0 -7
  253. package/dist/dist/Pog.js +0 -144
  254. package/dist/dist/Pog.js.map +0 -1
  255. package/dist/dist/ProgressBar.d.ts +0 -16
  256. package/dist/dist/ProgressBar.js +0 -40
  257. package/dist/dist/ProgressBar.js.map +0 -1
  258. package/dist/dist/ScrollView.d.ts +0 -1
  259. package/dist/dist/ScrollView.js +0 -4
  260. package/dist/dist/ScrollView.js.map +0 -1
  261. package/dist/dist/SegmentedControl.d.ts +0 -9
  262. package/dist/dist/SegmentedControl.js +0 -18
  263. package/dist/dist/SegmentedControl.js.map +0 -1
  264. package/dist/dist/SegmentedControl.stories.d.ts +0 -1
  265. package/dist/dist/SegmentedControl.stories.js +0 -32
  266. package/dist/dist/SegmentedControl.stories.js.map +0 -1
  267. package/dist/dist/SelectList.d.ts +0 -9
  268. package/dist/dist/SelectList.js +0 -29
  269. package/dist/dist/SelectList.js.map +0 -1
  270. package/dist/dist/SelectList.stories.d.ts +0 -1
  271. package/dist/dist/SelectList.stories.js +0 -24
  272. package/dist/dist/SelectList.stories.js.map +0 -1
  273. package/dist/dist/Spinner.d.ts +0 -44
  274. package/dist/dist/Spinner.js +0 -58
  275. package/dist/dist/Spinner.js.map +0 -1
  276. package/dist/dist/Spinner.stories.d.ts +0 -1
  277. package/dist/dist/Spinner.stories.js +0 -10
  278. package/dist/dist/Spinner.stories.js.map +0 -1
  279. package/dist/dist/SplitPage.d.ts +0 -7
  280. package/dist/dist/SplitPage.js +0 -20
  281. package/dist/dist/SplitPage.js.map +0 -1
  282. package/dist/dist/SplitPage.stories.d.ts +0 -1
  283. package/dist/dist/SplitPage.stories.js +0 -7
  284. package/dist/dist/SplitPage.stories.js.map +0 -1
  285. package/dist/dist/StorybookContainer.d.ts +0 -7
  286. package/dist/dist/StorybookContainer.js +0 -9
  287. package/dist/dist/StorybookContainer.js.map +0 -1
  288. package/dist/dist/Switch.d.ts +0 -6
  289. package/dist/dist/Switch.js +0 -10
  290. package/dist/dist/Switch.js.map +0 -1
  291. package/dist/dist/Switch.stories.d.ts +0 -1
  292. package/dist/dist/Switch.stories.js +0 -27
  293. package/dist/dist/Switch.stories.js.map +0 -1
  294. package/dist/dist/TapToEdit.d.ts +0 -9
  295. package/dist/dist/TapToEdit.js +0 -27
  296. package/dist/dist/TapToEdit.js.map +0 -1
  297. package/dist/dist/Text.d.ts +0 -36
  298. package/dist/dist/Text.js +0 -86
  299. package/dist/dist/Text.js.map +0 -1
  300. package/dist/dist/Text.stories.d.ts +0 -1
  301. package/dist/dist/Text.stories.js +0 -13
  302. package/dist/dist/Text.stories.js.map +0 -1
  303. package/dist/dist/TextArea.d.ts +0 -6
  304. package/dist/dist/TextArea.js +0 -13
  305. package/dist/dist/TextArea.js.map +0 -1
  306. package/dist/dist/TextArea.stories.d.ts +0 -12
  307. package/dist/dist/TextArea.stories.js +0 -21
  308. package/dist/dist/TextArea.stories.js.map +0 -1
  309. package/dist/dist/TextField.d.ts +0 -47
  310. package/dist/dist/TextField.js +0 -199
  311. package/dist/dist/TextField.js.map +0 -1
  312. package/dist/dist/TextField.stories.d.ts +0 -6
  313. package/dist/dist/TextField.stories.js +0 -15
  314. package/dist/dist/TextField.stories.js.map +0 -1
  315. package/dist/dist/TextFieldNumberActionSheet.d.ts +0 -5
  316. package/dist/dist/TextFieldNumberActionSheet.js +0 -24
  317. package/dist/dist/TextFieldNumberActionSheet.js.map +0 -1
  318. package/dist/dist/UnifiedScreens.d.ts +0 -2
  319. package/dist/dist/UnifiedScreens.js +0 -26
  320. package/dist/dist/UnifiedScreens.js.map +0 -1
  321. package/dist/dist/Unifier.d.ts +0 -131
  322. package/dist/dist/Unifier.js +0 -198
  323. package/dist/dist/Unifier.js.map +0 -1
  324. package/dist/dist/Utilities.d.ts +0 -51
  325. package/dist/dist/Utilities.js +0 -77
  326. package/dist/dist/Utilities.js.map +0 -1
  327. package/dist/dist/WithLabel.d.ts +0 -6
  328. package/dist/dist/WithLabel.js +0 -23
  329. package/dist/dist/WithLabel.js.map +0 -1
  330. package/dist/dist/index.d.ts +0 -43
  331. package/dist/dist/index.js +0 -49
  332. package/dist/dist/index.js.map +0 -1
package/src/Field.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import isDate from "lodash/isDate";
2
2
  import isNumber from "lodash/isNumber";
3
3
  import moment from "moment-timezone";
4
- import React from "react";
4
+ import React, {useState} from "react";
5
5
 
6
6
  import {Box} from "./Box";
7
7
  import {FieldProps, TextFieldType} from "./Common";
@@ -15,60 +15,58 @@ interface State {
15
15
  value: any;
16
16
  }
17
17
 
18
- export class Field extends React.Component<FieldProps, State> {
19
- constructor(props: FieldProps) {
20
- super(props);
21
- this.state = {value: props.initialValue || ""};
22
- }
18
+ /**
19
+ * Field is a fully uncontrolled component for creating various inputs. Fully uncontrolled means Field manages its own
20
+ * state for the TextFields/Switches/etc, not the parent component. When values are updated, Field will pass the data to
21
+ * the parent through the handleChange prop. You can set an initialValue, but you should not update initialValue
22
+ * this prop with the result of handleChange.
23
+ *
24
+ * Note: You MUST set a key={} prop for this component, otherwise you may wind up with stale data. Just changing
25
+ * initialValue will not work.
26
+ *
27
+ */
28
+ export function Field(props: FieldProps) {
29
+ const [value, setValue] = useState(props.initialValue || "");
23
30
 
24
- UNSAFE_componentWillReceiveProps(nextProps: FieldProps) {
25
- if (nextProps.initialValue !== this.state.value) {
26
- this.setState({value: nextProps.initialValue});
31
+ const handleChange = (newValue: string) => {
32
+ if (props.type === "currency") {
33
+ newValue = newValue.replace("$", "");
34
+ } else if (props.type === "percent") {
35
+ newValue = newValue.replace("%", "");
27
36
  }
28
- }
29
-
30
- handleChange = (value: string) => {
31
- if (this.props.type === "currency") {
32
- value = value.replace("$", "");
33
- } else if (this.props.type === "percent") {
34
- value = value.replace("%", "");
35
- }
36
- this.setState({value});
37
- if (this.props.handleChange) {
38
- this.props.handleChange(this.props.name, value);
37
+ setValue(newValue);
38
+ if (props.handleChange) {
39
+ props.handleChange(props.name, newValue);
39
40
  }
40
41
  };
41
42
 
42
- handleSwitchChange = (value: boolean) => {
43
- this.setState({value});
44
- if (this.props.handleChange) {
45
- this.props.handleChange(this.props.name, value);
43
+ const handleSwitchChange = (switchValue: boolean) => {
44
+ setValue(switchValue);
45
+ if (props.handleChange) {
46
+ props.handleChange(props.name, switchValue);
46
47
  }
47
48
  };
48
49
 
49
- validate = () => {
50
- // console.log("VALIDATE", this.props.validate && this.props.validate(this.state.value));
51
- if (this.props.validate && !this.props.validate(this.state.value)) {
50
+ const validate = () => {
51
+ // console.log("VALIDATE", props.validate && props.validate(value));
52
+ if (props.validate && !props.validate(value)) {
52
53
  return false;
53
54
  }
54
- switch (this.props.type) {
55
+ switch (props.type) {
55
56
  case "boolean":
56
57
  return true;
57
58
  case "currency":
58
59
  return true;
59
60
  case "date":
60
- return !this.state.value || isDate(this.state.value);
61
+ return !value || isDate(value);
61
62
  case "email":
62
- return (
63
- !this.state.value ||
64
- (this.state.value.search("@") > -1 && this.state.value.search(".") > -1)
65
- );
63
+ return !value || (value.search("@") > -1 && value.search(".") > -1);
66
64
  case "number":
67
- return !this.state.value || isNumber(this.state.value);
65
+ return !value || isNumber(value);
68
66
  case "password":
69
67
  return true;
70
68
  case "percent":
71
- return !this.state.value || isNumber(this.state.value.replace("%", ""));
69
+ return !value || isNumber(value.replace("%", ""));
72
70
  case "select":
73
71
  return true;
74
72
  case "text":
@@ -83,64 +81,62 @@ export class Field extends React.Component<FieldProps, State> {
83
81
  }
84
82
  };
85
83
 
86
- renderField() {
87
- if (this.props.type === "select") {
88
- if (!this.props.options) {
84
+ const renderField = () => {
85
+ if (props.type === "select") {
86
+ if (!props.options) {
89
87
  console.error("Field with type=select require options");
90
88
  return null;
91
89
  }
92
90
  return (
93
91
  <SelectList
94
- disabled={this.props.disabled}
95
- id={this.props.name}
96
- options={this.props.options}
97
- value={this.state.value}
98
- onChange={this.handleChange}
92
+ disabled={props.disabled}
93
+ id={props.name}
94
+ options={props.options}
95
+ value={value}
96
+ onChange={handleChange}
99
97
  />
100
98
  );
101
- } else if (this.props.type === "textarea") {
99
+ } else if (props.type === "textarea") {
102
100
  return (
103
101
  <TextArea
104
- disabled={this.props.disabled}
105
- id={this.props.name}
106
- placeholder={this.props.placeholder}
107
- rows={this.props.rows}
108
- value={String(this.state.value)}
109
- onChange={({value}) => this.handleChange(value)}
102
+ disabled={props.disabled}
103
+ id={props.name}
104
+ placeholder={props.placeholder}
105
+ rows={props.rows}
106
+ value={String(value)}
107
+ onChange={(result) => handleChange(result.value)}
110
108
  />
111
109
  );
112
- } else if (this.props.type === "boolean") {
110
+ } else if (props.type === "boolean") {
113
111
  return (
114
112
  <Switch
115
- disabled={this.props.disabled}
116
- id={this.props.name}
117
- name={this.props.name}
118
- switched={Boolean(this.state.value)}
119
- onChange={(result) => this.handleSwitchChange(result)}
113
+ disabled={props.disabled}
114
+ id={props.name}
115
+ name={props.name}
116
+ switched={Boolean(value)}
117
+ onChange={(result) => handleSwitchChange(result)}
120
118
  />
121
119
  );
122
- } else if (this.props.type === "date") {
123
- const value = this.state.value.seconds
124
- ? moment(this.state.value.seconds * 1000)
125
- : moment(this.state.value);
120
+ } else if (props.type === "date") {
121
+ const date = value.seconds ? moment(value.seconds * 1000) : moment(value);
126
122
  return (
127
123
  <TextField
128
124
  disabled
129
- id={this.props.name}
130
- placeholder={this.props.placeholder}
125
+ id={props.name}
126
+ placeholder={props.placeholder}
131
127
  type="text"
132
128
  // TODO: allow editing with a date picker
133
- value={value.format("MM/DD/YYYY HH:mmA")}
134
- onChange={(result) => this.handleChange(result.value)}
129
+ value={date.format("MM/DD/YYYY HH:mmA")}
130
+ onChange={(result) => handleChange(result.value)}
135
131
  />
136
132
  );
137
133
  } else {
138
134
  let type: TextFieldType = "text";
139
135
  // Number is supported differently because we need fractional numbers and they don't work
140
136
  // well on iOS.
141
- if (this.props.type && ["date", "email", "password", "url"].indexOf(this.props.type) > -1) {
142
- type = this.props.type as TextFieldType;
143
- } else if (this.props.type === "percent" || this.props.type === "currency") {
137
+ if (props.type && ["date", "email", "password", "url"].indexOf(props.type) > -1) {
138
+ type = props.type as TextFieldType;
139
+ } else if (props.type === "percent" || props.type === "currency") {
144
140
  type = "text";
145
141
  }
146
142
  let autoComplete: "on" | "current-password" | "username" = "on";
@@ -149,46 +145,43 @@ export class Field extends React.Component<FieldProps, State> {
149
145
  } else if (type === "email") {
150
146
  autoComplete = "username";
151
147
  }
152
- const value = String(this.state.value);
153
- // if (this.props.type === "percent") {
154
- // value = `${Number(this.state.value).toFixed(0)}%`;
155
- // } else if (this.props.type === "currency") {
148
+ const stringValue = String(value);
149
+ // if (props.type === "percent") {
150
+ // value = `${Number(value).toFixed(0)}%`;
151
+ // } else if (props.type === "currency") {
156
152
  // value = `$${Number(value).toFixed(2)}`;
157
153
  // }
158
154
  // console.log("VAL", value);
159
155
  return (
160
156
  <TextField
161
157
  autoComplete={autoComplete}
162
- disabled={this.props.disabled}
163
- id={this.props.name}
164
- placeholder={this.props.placeholder}
158
+ disabled={props.disabled}
159
+ id={props.name}
160
+ placeholder={props.placeholder}
165
161
  type={type as "date" | "email" | "number" | "password" | "text" | "url"}
166
- value={value}
167
- onChange={(result) => this.handleChange(result.value)}
162
+ value={stringValue}
163
+ onChange={(result) => handleChange(result.value)}
168
164
  />
169
165
  );
170
166
  }
171
- }
167
+ };
172
168
 
173
- render() {
174
- const children = this.renderField();
175
- const {errorMessage, errorMessageColor, helperText, helperTextColor, label, labelColor} =
176
- this.props;
177
- return (
178
- <Box marginBottom={5}>
179
- <FieldWithLabels
180
- {...{
181
- errorMessage,
182
- errorMessageColor,
183
- helperText,
184
- helperTextColor,
185
- label,
186
- labelColor,
187
- }}
188
- >
189
- {children}
190
- </FieldWithLabels>
191
- </Box>
192
- );
193
- }
169
+ const children = renderField();
170
+ const {errorMessage, errorMessageColor, helperText, helperTextColor, label, labelColor} = props;
171
+ return (
172
+ <Box marginBottom={5}>
173
+ <FieldWithLabels
174
+ {...{
175
+ errorMessage,
176
+ errorMessageColor,
177
+ helperText,
178
+ helperTextColor,
179
+ label,
180
+ labelColor,
181
+ }}
182
+ >
183
+ {children}
184
+ </FieldWithLabels>
185
+ </Box>
186
+ );
194
187
  }
package/src/Form.tsx CHANGED
@@ -21,7 +21,7 @@ interface FormLineProps {
21
21
  value: any;
22
22
  onSave: (value: any) => void;
23
23
  kind: "boolean" | "string" | "textarea" | "select" | "multiboolean";
24
- options?: (string | undefined)[];
24
+ options?: string[];
25
25
  }
26
26
 
27
27
  interface FormLineState {
@@ -0,0 +1,181 @@
1
+ /**
2
+ * @providesModule Hyperlink
3
+ *
4
+ * Forked from https://github.com/obipawan/react-native-hyperlink
5
+ *
6
+ *
7
+ * MIT License
8
+ *
9
+ * Copyright (c) 2019 Pawan
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in all
19
+ * copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ * SOFTWARE.
28
+ * */
29
+
30
+ import mdurl from "mdurl";
31
+ import React from "react";
32
+ import {Linking, Platform, StyleProp, Text, View} from "react-native";
33
+
34
+ const linkifyLib = require("linkify-it")();
35
+
36
+ const {OS} = Platform;
37
+
38
+ interface Props {
39
+ linkDefault?: boolean;
40
+ linkify?: any;
41
+ linkStyle?: StyleProp<any>;
42
+ linkText?: string | ((url: string) => string);
43
+ onPress?: (url: string) => void;
44
+ onLongPress?: (url: string, text: string) => void;
45
+ injectViewProps?: (url: string) => any;
46
+ children?: React.ReactNode;
47
+ style?: StyleProp<any>;
48
+ }
49
+
50
+ // Leaving this as a class component because it was easier to handle the `pasrse(this)` in `render()`
51
+ class HyperlinkComponent extends React.Component<Props> {
52
+ isTextNested = (component: any) => {
53
+ if (!React.isValidElement(component)) throw new Error("Invalid component");
54
+ const {type: {displayName} = {} as any} = component;
55
+ if (displayName !== "Text") throw new Error("Not a Text component");
56
+ return typeof (component.props as any).children !== "string";
57
+ };
58
+
59
+ linkify = (component: any) => {
60
+ const linkifyIt = this.props.linkify || linkifyLib;
61
+
62
+ if (!linkifyIt.pretest(component.props.children) || !linkifyIt.test(component.props.children))
63
+ return component;
64
+
65
+ const elements = [];
66
+ let _lastIndex = 0;
67
+
68
+ const componentProps = {
69
+ ...component.props,
70
+ ref: undefined,
71
+ key: undefined,
72
+ };
73
+
74
+ try {
75
+ linkifyIt.match(component.props.children).forEach(({index, lastIndex, text, url}: any) => {
76
+ const nonLinkedText = component.props.children.substring(_lastIndex, index);
77
+ nonLinkedText && elements.push(nonLinkedText);
78
+ _lastIndex = lastIndex;
79
+ if (this.props.linkText)
80
+ text =
81
+ typeof this.props.linkText === "function"
82
+ ? this.props.linkText(url)
83
+ : this.props.linkText;
84
+
85
+ const clickHandlerProps: any = {};
86
+ if (OS !== "web") {
87
+ if (this.props.onLongPress) {
88
+ clickHandlerProps.onLongPress = () => (this.props as any).onLongPress(url, text);
89
+ }
90
+ }
91
+ if (this.props.onPress) {
92
+ clickHandlerProps.onPress = () => (this.props as any).onPress(url, text);
93
+ }
94
+
95
+ let injected: any = {};
96
+ if (this.props.injectViewProps) {
97
+ injected = this.props.injectViewProps(url);
98
+ }
99
+
100
+ elements.push(
101
+ <Text
102
+ {...componentProps}
103
+ {...clickHandlerProps}
104
+ key={url + index}
105
+ style={[component.props.style, this.props.linkStyle]}
106
+ {...injected}
107
+ >
108
+ {text}
109
+ </Text>
110
+ );
111
+ });
112
+ elements.push(
113
+ component.props.children.substring(_lastIndex, component.props.children.length)
114
+ );
115
+ return React.cloneElement(component, componentProps, elements);
116
+ } catch (err) {
117
+ return component;
118
+ }
119
+ };
120
+
121
+ parse = (component: any): React.ReactElement => {
122
+ const {props: {children} = {} as any} = component || {};
123
+ if (!children) return component;
124
+
125
+ const componentProps = {
126
+ ...component.props,
127
+ ref: undefined,
128
+ key: undefined,
129
+ };
130
+
131
+ const linkifyIt = this.props.linkify || linkifyLib;
132
+
133
+ return React.cloneElement(
134
+ component,
135
+ componentProps,
136
+ React.Children.map(children, (child) => {
137
+ const {type: {displayName} = {} as any} = child || {};
138
+ if (typeof child === "string" && linkifyIt.pretest(child))
139
+ return this.linkify(
140
+ <Text {...componentProps} style={component.props.style}>
141
+ {child}
142
+ </Text>
143
+ );
144
+ if (displayName === "Text" && !this.isTextNested(child)) return this.linkify(child);
145
+ return this.parse(child);
146
+ })
147
+ );
148
+ };
149
+
150
+ render() {
151
+ const {...viewProps} = this.props;
152
+ delete viewProps.onPress;
153
+ delete viewProps.linkDefault;
154
+ delete viewProps.onLongPress;
155
+ delete viewProps.linkStyle;
156
+
157
+ return (
158
+ <View {...viewProps} style={this.props.style}>
159
+ {!this.props.onPress && !this.props.onLongPress && !this.props.linkStyle
160
+ ? this.props.children
161
+ : this.parse(this).props.children}
162
+ </View>
163
+ );
164
+ }
165
+ }
166
+
167
+ export function Hyperlink(props: Props) {
168
+ const handleLink = (url: string) => {
169
+ const urlObject = mdurl.parse(url);
170
+ urlObject.protocol = urlObject.protocol.toLowerCase();
171
+ const normalizedURL = mdurl.format(urlObject);
172
+
173
+ Linking.canOpenURL(normalizedURL).then(
174
+ (supported) => supported && Linking.openURL(normalizedURL)
175
+ );
176
+ };
177
+
178
+ const onPress = handleLink || props.onPress;
179
+ if (props.linkDefault) return <HyperlinkComponent {...props} onPress={onPress} />;
180
+ return <HyperlinkComponent {...props} />;
181
+ }
@@ -4,7 +4,8 @@ import {FieldWithLabelsProps} from "./Common";
4
4
  import RNPickerSelect from "./PickerSelect";
5
5
  import {Unifier} from "./Unifier";
6
6
 
7
- export type SelectListOptions = {label: string; value: string | undefined}[];
7
+ // Use "" if you want to have an "unset" value.
8
+ export type SelectListOptions = {label: string; value: string | number}[];
8
9
  export interface SelectListProps extends FieldWithLabelsProps {
9
10
  id?: string;
10
11
  name?: string;
package/src/Text.tsx CHANGED
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import {Text as NativeText} from "react-native";
3
- import Hyperlink from "react-native-hyperlink";
4
3
 
5
4
  import {TextProps} from "./Common";
5
+ import {Hyperlink} from "./Hyperlink";
6
6
  import {Unifier} from "./Unifier";
7
7
 
8
8
  export class Text extends React.Component<TextProps, {}> {
@@ -82,10 +82,9 @@ export class Text extends React.Component<TextProps, {}> {
82
82
  return inner;
83
83
  } else {
84
84
  return (
85
- // <Hyperlink linkDefault={true} linkStyle={{textDecorationLine: "underline"}}>
86
- // {inner}
87
- // </Hyperlink>
88
- <Hyperlink linkDefault>{inner}</Hyperlink>
85
+ <Hyperlink linkDefault linkStyle={{textDecorationLine: "underline"}}>
86
+ {inner}
87
+ </Hyperlink>
89
88
  );
90
89
  }
91
90
  }
@@ -1,6 +1,6 @@
1
1
  import DateTimePicker from "@react-native-community/datetimepicker";
2
2
  import moment from "moment-timezone";
3
- import React, {SyntheticEvent} from "react";
3
+ import React from "react";
4
4
 
5
5
  import {ActionSheet} from "./ActionSheet";
6
6
  import {Box} from "./Box";
package/src/Unifier.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-empty-function */
3
3
 
4
4
  import AsyncStorage from "@react-native-async-storage/async-storage";
5
- import {Clipboard, Dimensions, Keyboard, Linking, Vibration} from "react-native";
5
+ import {Clipboard, Dimensions, Keyboard, Linking, Platform, Vibration} from "react-native";
6
6
  import ReactNativeHapticFeedback from "react-native-haptic-feedback";
7
7
 
8
8
  import {PermissionKind, UnifiedTheme} from "./Common";
@@ -206,7 +206,9 @@ class UnifierClass {
206
206
  enableVibrateFallback: true,
207
207
  ignoreAndroidSystemSettings: false,
208
208
  };
209
- ReactNativeHapticFeedback.trigger("impactLight", options);
209
+ if (Platform.OS !== "web") {
210
+ ReactNativeHapticFeedback.trigger("impactLight", options);
211
+ }
210
212
  },
211
213
  openUrl: async (url: string) => {
212
214
  return Linking.openURL(url);
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { Box } from "./Box";
2
- import { Banner } from "./Banner";
3
- import React from "react";
4
- import { storiesOf } from "@storybook/react-native";
5
- storiesOf("Banner", module)
6
- .add("Plain banner", () => (React.createElement(Box, { width: "100%", height: "100%", display: "flex", direction: "column" },
7
- React.createElement(Banner, { id: "banner", text: "When you click this banner, it dismisses", subtext: "And in a real app, it would stay dismissed", color: "primary", textColor: "white" }))))
8
- .add("Shape banner", () => (React.createElement(Box, { width: "100%", height: "100%", display: "flex", direction: "column" },
9
- React.createElement(Box, { paddingY: 2, width: "100%" },
10
- React.createElement(Banner, { id: "banner", text: "Banners can have multiple shapes like Boxes", subtext: "Here's a pill.", color: "primary", textColor: "white", shape: "pill" })),
11
- React.createElement(Box, { paddingY: 2, width: "100%" },
12
- React.createElement(Banner, { id: "banner", text: "And a rounded banner", color: "secondary", textColor: "white", shape: 3 })))));
13
- //# sourceMappingURL=Banner.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Banner.stories.js","sourceRoot":"","sources":["../unifier/Banner.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAElD,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;KACxB,GAAG,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CACzB,oBAAC,GAAG,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ;IAC/D,oBAAC,MAAM,IACL,EAAE,EAAC,QAAQ,EACX,IAAI,EAAC,0CAA0C,EAC/C,OAAO,EAAC,4CAA4C,EACpD,KAAK,EAAC,SAAS,EACf,SAAS,EAAC,OAAO,GACjB,CACE,CACP,CAAC;KACD,GAAG,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CACzB,oBAAC,GAAG,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ;IAC/D,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAC,MAAM;QAC5B,oBAAC,MAAM,IACL,EAAE,EAAC,QAAQ,EACX,IAAI,EAAC,6CAA6C,EAClD,OAAO,EAAC,gBAAgB,EACxB,KAAK,EAAC,SAAS,EACf,SAAS,EAAC,OAAO,EACjB,KAAK,EAAC,MAAM,GACZ,CACE;IACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAC,MAAM;QAC5B,oBAAC,MAAM,IACL,EAAE,EAAC,QAAQ,EACX,IAAI,EAAC,sBAAsB,EAC3B,KAAK,EAAC,WAAW,EACjB,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,CAAC,GACR,CACE,CACF,CACP,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- import React from "react";
2
- import { Box } from "./Box";
3
- import { storiesOf } from "@storybook/react-native";
4
- import { Text } from "./Text";
5
- import { StorybookContainer } from "./StorybookContainer";
6
- const colors = [
7
- "primary",
8
- "secondary",
9
- "tertiary",
10
- "accent",
11
- "blue",
12
- "darkGray",
13
- "eggplant",
14
- "gray",
15
- "green",
16
- "lightGray",
17
- "maroon",
18
- "midnight",
19
- "navy",
20
- "olive",
21
- "orange",
22
- "orchid",
23
- "pine",
24
- "purple",
25
- "red",
26
- "watermelon",
27
- "white",
28
- "neutral900",
29
- "neutral200",
30
- "neutral70",
31
- "neutral10",
32
- ];
33
- storiesOf("Box", module)
34
- .add("FlexBox", () => (React.createElement(StorybookContainer, null,
35
- React.createElement(Box, { display: "flex", justifyContent: "center", alignItems: "center", width: 50, height: 50, rounding: "circle", color: "blue", marginRight: 2 },
36
- React.createElement(Text, { size: "lg" }, "JG")),
37
- React.createElement(Box, { paddingX: 2, direction: "column" },
38
- React.createElement(Text, { weight: "bold" }, "Josh Gachnang"),
39
- React.createElement(Text, null, "joined 2 years ago")))))
40
- .add("Box Colors", () => (React.createElement(StorybookContainer, null, colors.map((c) => (React.createElement(Box, { key: c, display: "flex", direction: "column" },
41
- React.createElement(Box, { marginBottom: 2 },
42
- React.createElement(Text, { align: "center" }, c)),
43
- React.createElement(Box, { key: c, color: c, rounding: "circle", height: 50, width: 50 },
44
- React.createElement(Text, null, " "))))))));
45
- //# sourceMappingURL=Box.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Box.stories.js","sourceRoot":"","sources":["../unifier/Box.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAC,MAAM,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M,EAAC,SAAS,EAAC,QAAQ;IAC5C,oBAAC,GAAG,IAAC,YAAY,EAAE,CAAC;QAClB,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,IAAE,CAAC,CAAQ,CAC3B;IACN,oBAAC,GAAG,IAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAC,QAAQ,EAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;QAC5D,oBAAC,IAAI,YAAS,CACV,CACF,CACP,CAAC,CACiB,CACtB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare const Primary: any;
@@ -1,41 +0,0 @@
1
- import { action } from "@storybook/addon-actions";
2
- import React from "react";
3
- import { Button } from "./Button";
4
- import { storiesOf } from "@storybook/react-native";
5
- import { Box } from "./Box";
6
- import { StorybookContainer } from "./StorybookContainer";
7
- function allColorButtons(props) {
8
- return (React.createElement(StorybookContainer, null,
9
- React.createElement(Box, { paddingY: 1 },
10
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Default" }, props))),
11
- React.createElement(Box, { paddingY: 1 },
12
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Primary", color: "primary" }, props))),
13
- React.createElement(Box, { paddingY: 1 },
14
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Secondary", color: "secondary" }, props))),
15
- React.createElement(Box, { paddingY: 1 },
16
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Tertiary", color: "tertiary" }, props))),
17
- React.createElement(Box, { paddingY: 1 },
18
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Accent", color: "accent" }, props))),
19
- React.createElement(Box, { paddingY: 1 },
20
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Red", color: "red" }, props))),
21
- React.createElement(Box, { paddingY: 1 },
22
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Dark Gray", color: "darkGray" }, props))),
23
- React.createElement(Box, { paddingY: 1 },
24
- React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Gray", color: "gray" }, props)))));
25
- }
26
- storiesOf("Button", module)
27
- .add("Colors", () => allColorButtons({}))
28
- .add("Loading", () => allColorButtons({ loading: true }))
29
- .add("Ghost", () => allColorButtons({ type: "ghost" }))
30
- .add("Outline", () => allColorButtons({ type: "outline" }));
31
- const Template = (args) => React.createElement(Button, Object.assign({ onClick: action("clicked"), text: "Button" }, args));
32
- export const Primary = Template.bind({});
33
- Primary.args = {
34
- size: "md",
35
- color: "primary",
36
- text: "PRIMARY",
37
- type: "solid",
38
- inline: false,
39
- disabled: false,
40
- };
41
- //# sourceMappingURL=Button.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../unifier/Button.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD,SAAS,eAAe,CAAC,KAA2B;IAClD,OAAO,CACL,oBAAC,kBAAkB;QACjB,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;YACd,oBAAC,MAAM,kBAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAC,SAAS,IAAK,KAAK,EAAI,CAC5D;QACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;YACd,oBAAC,MAAM,kBAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAC,SAAS,EAAC,KAAK,EAAC,SAAS,IAAK,KAAK,EAAI,CAC5E;QACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;YACd,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