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.
- package/dist/ActionSheet.js.map +1 -1
- package/dist/Common.d.ts +1 -1
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/DecimalRangeActionSheet.js.map +1 -1
- package/dist/ErrorBoundary.d.ts +1 -1
- package/dist/Field.d.ts +12 -14
- package/dist/Field.js +95 -98
- package/dist/Field.js.map +1 -1
- package/dist/Form.d.ts +1 -1
- package/dist/HeightActionSheet.js.map +1 -1
- package/dist/Hyperlink.d.ts +43 -0
- package/dist/Hyperlink.js +135 -0
- package/dist/Hyperlink.js.map +1 -0
- package/dist/NumberPickerActionSheet.js.map +1 -1
- package/dist/PickerSelect.d.ts +4 -4
- package/dist/SelectList.d.ts +1 -1
- package/dist/SelectList.js.map +1 -1
- package/dist/SplitPage.js.map +1 -1
- package/dist/Text.js +2 -6
- package/dist/Text.js.map +1 -1
- package/dist/TextField.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.js.map +1 -1
- package/dist/Unifier.js +5 -11
- package/dist/Unifier.js.map +1 -1
- package/package.json +28 -27
- package/src/Field.tsx +91 -98
- package/src/Form.tsx +1 -1
- package/src/Hyperlink.tsx +181 -0
- package/src/SelectList.tsx +2 -1
- package/src/Text.tsx +4 -5
- package/src/TextFieldNumberActionSheet.tsx +1 -1
- package/src/Unifier.ts +4 -2
- package/dist/Banner.stories.d.ts +0 -1
- package/dist/Banner.stories.js +0 -13
- package/dist/Banner.stories.js.map +0 -1
- package/dist/Box.stories.d.ts +0 -1
- package/dist/Box.stories.js +0 -45
- package/dist/Box.stories.js.map +0 -1
- package/dist/Button.stories.d.ts +0 -1
- package/dist/Button.stories.js +0 -41
- package/dist/Button.stories.js.map +0 -1
- package/dist/Card.stories.d.ts +0 -6
- package/dist/Card.stories.js +0 -18
- package/dist/Card.stories.js.map +0 -1
- package/dist/CheckBox.stories.d.ts +0 -1
- package/dist/CheckBox.stories.js +0 -28
- package/dist/CheckBox.stories.js.map +0 -1
- package/dist/Field.stories.d.ts +0 -6
- package/dist/Field.stories.js +0 -38
- package/dist/Field.stories.js.map +0 -1
- package/dist/Form.stories.d.ts +0 -6
- package/dist/Form.stories.js +0 -36
- package/dist/Form.stories.js.map +0 -1
- package/dist/HeaderButtons.stories.d.ts +0 -6
- package/dist/HeaderButtons.stories.js +0 -6
- package/dist/HeaderButtons.stories.js.map +0 -1
- package/dist/Heading.stories.d.ts +0 -1
- package/dist/Heading.stories.js +0 -22
- package/dist/Heading.stories.js.map +0 -1
- package/dist/Icon.stories.d.ts +0 -1
- package/dist/Icon.stories.js +0 -30
- package/dist/Icon.stories.js.map +0 -1
- package/dist/IconButton.stories.d.ts +0 -1
- package/dist/IconButton.stories.js +0 -16
- package/dist/IconButton.stories.js.map +0 -1
- package/dist/Link.stories.d.ts +0 -1
- package/dist/Link.stories.js +0 -18
- package/dist/Link.stories.js.map +0 -1
- package/dist/Mask.stories.d.ts +0 -1
- package/dist/Mask.stories.js +0 -28
- package/dist/Mask.stories.js.map +0 -1
- package/dist/Pill.stories.d.ts +0 -1
- package/dist/Pill.stories.js +0 -38
- package/dist/Pill.stories.js.map +0 -1
- package/dist/SegmentedControl.stories.d.ts +0 -1
- package/dist/SegmentedControl.stories.js +0 -31
- package/dist/SegmentedControl.stories.js.map +0 -1
- package/dist/SelectList.stories.d.ts +0 -1
- package/dist/SelectList.stories.js +0 -26
- package/dist/SelectList.stories.js.map +0 -1
- package/dist/Spinner.stories.d.ts +0 -1
- package/dist/Spinner.stories.js +0 -12
- package/dist/Spinner.stories.js.map +0 -1
- package/dist/SplitPage.stories.d.ts +0 -1
- package/dist/SplitPage.stories.js +0 -15
- package/dist/SplitPage.stories.js.map +0 -1
- package/dist/StorybookContainer.d.ts +0 -4
- package/dist/StorybookContainer.js +0 -8
- package/dist/StorybookContainer.js.map +0 -1
- package/dist/Switch.stories.d.ts +0 -1
- package/dist/Switch.stories.js +0 -34
- package/dist/Switch.stories.js.map +0 -1
- package/dist/Text.stories.d.ts +0 -1
- package/dist/Text.stories.js +0 -37
- package/dist/Text.stories.js.map +0 -1
- package/dist/TextArea.stories.d.ts +0 -10
- package/dist/TextArea.stories.js +0 -24
- package/dist/TextArea.stories.js.map +0 -1
- package/dist/TextField.stories.d.ts +0 -6
- package/dist/TextField.stories.js +0 -18
- package/dist/TextField.stories.js.map +0 -1
- package/dist/dist/ActionSheet.d.ts +0 -139
- package/dist/dist/ActionSheet.js +0 -637
- package/dist/dist/ActionSheet.js.map +0 -1
- package/dist/dist/Banner.d.ts +0 -12
- package/dist/dist/Banner.js +0 -49
- package/dist/dist/Banner.js.map +0 -1
- package/dist/dist/Banner.stories.d.ts +0 -1
- package/dist/dist/Banner.stories.js +0 -9
- package/dist/dist/Banner.stories.js.map +0 -1
- package/dist/dist/BlurBox.d.ts +0 -7
- package/dist/dist/BlurBox.js +0 -29
- package/dist/dist/BlurBox.js.map +0 -1
- package/dist/dist/BlurBox.native.d.ts +0 -9
- package/dist/dist/BlurBox.native.js +0 -32
- package/dist/dist/BlurBox.native.js.map +0 -1
- package/dist/dist/Body.d.ts +0 -12
- package/dist/dist/Body.js +0 -19
- package/dist/dist/Body.js.map +0 -1
- package/dist/dist/Box.d.ts +0 -205
- package/dist/dist/Box.js +0 -229
- package/dist/dist/Box.js.map +0 -1
- package/dist/dist/Box.stories.d.ts +0 -1
- package/dist/dist/Box.stories.js +0 -37
- package/dist/dist/Box.stories.js.map +0 -1
- package/dist/dist/Button.d.ts +0 -16
- package/dist/dist/Button.js +0 -98
- package/dist/dist/Button.js.map +0 -1
- package/dist/dist/Button.stories.d.ts +0 -13
- package/dist/dist/Button.stories.js +0 -26
- package/dist/dist/Button.stories.js.map +0 -1
- package/dist/dist/Card.d.ts +0 -6
- package/dist/dist/Card.js +0 -9
- package/dist/dist/Card.js.map +0 -1
- package/dist/dist/Card.stories.d.ts +0 -6
- package/dist/dist/Card.stories.js +0 -11
- package/dist/dist/Card.stories.js.map +0 -1
- package/dist/dist/CheckBox.d.ts +0 -8
- package/dist/dist/CheckBox.js +0 -23
- package/dist/dist/CheckBox.js.map +0 -1
- package/dist/dist/CheckBox.stories.d.ts +0 -1
- package/dist/dist/CheckBox.stories.js +0 -22
- package/dist/dist/CheckBox.stories.js.map +0 -1
- package/dist/dist/Common.d.ts +0 -5
- package/dist/dist/Common.js +0 -47
- package/dist/dist/Common.js.map +0 -1
- package/dist/dist/DateTimeActionSheet.d.ts +0 -5
- package/dist/dist/DateTimeActionSheet.js +0 -24
- package/dist/dist/DateTimeActionSheet.js.map +0 -1
- package/dist/dist/DecimalRangeActionSheet.d.ts +0 -9
- package/dist/dist/DecimalRangeActionSheet.js +0 -57
- package/dist/dist/DecimalRangeActionSheet.js.map +0 -1
- package/dist/dist/ErrorBoundary.d.ts +0 -12
- package/dist/dist/ErrorBoundary.js +0 -32
- package/dist/dist/ErrorBoundary.js.map +0 -1
- package/dist/dist/ErrorPage.d.ts +0 -7
- package/dist/dist/ErrorPage.js +0 -15
- package/dist/dist/ErrorPage.js.map +0 -1
- package/dist/dist/Field.d.ts +0 -17
- package/dist/dist/Field.js +0 -136
- package/dist/dist/Field.js.map +0 -1
- package/dist/dist/Field.stories.d.ts +0 -6
- package/dist/dist/Field.stories.js +0 -25
- package/dist/dist/Field.stories.js.map +0 -1
- package/dist/dist/FieldWithLabels.d.ts +0 -10
- package/dist/dist/FieldWithLabels.js +0 -7
- package/dist/dist/FieldWithLabels.js.map +0 -1
- package/dist/dist/FlatList.d.ts +0 -1
- package/dist/dist/FlatList.js +0 -4
- package/dist/dist/FlatList.js.map +0 -1
- package/dist/dist/Form.d.ts +0 -15
- package/dist/dist/Form.js +0 -56
- package/dist/dist/Form.js.map +0 -1
- package/dist/dist/Form.stories.d.ts +0 -6
- package/dist/dist/Form.stories.js +0 -27
- package/dist/dist/Form.stories.js.map +0 -1
- package/dist/dist/HeaderButtons.d.ts +0 -39
- package/dist/dist/HeaderButtons.js +0 -50
- package/dist/dist/HeaderButtons.js.map +0 -1
- package/dist/dist/HeaderButtons.stories.d.ts +0 -6
- package/dist/dist/HeaderButtons.stories.js +0 -7
- package/dist/dist/HeaderButtons.stories.js.map +0 -1
- package/dist/dist/Heading.d.ts +0 -32
- package/dist/dist/Heading.js +0 -47
- package/dist/dist/Heading.js.map +0 -1
- package/dist/dist/Heading.stories.d.ts +0 -1
- package/dist/dist/Heading.stories.js +0 -11
- package/dist/dist/Heading.stories.js.map +0 -1
- package/dist/dist/HeightActionSheet.d.ts +0 -9
- package/dist/dist/HeightActionSheet.js +0 -50
- package/dist/dist/HeightActionSheet.js.map +0 -1
- package/dist/dist/Icon.d.ts +0 -12
- package/dist/dist/Icon.js +0 -126
- package/dist/dist/Icon.js.map +0 -1
- package/dist/dist/Icon.stories.d.ts +0 -1
- package/dist/dist/Icon.stories.js +0 -11
- package/dist/dist/Icon.stories.js.map +0 -1
- package/dist/dist/IconButton.d.ts +0 -42
- package/dist/dist/IconButton.js +0 -41
- package/dist/dist/IconButton.js.map +0 -1
- package/dist/dist/IconButton.stories.d.ts +0 -1
- package/dist/dist/IconButton.stories.js +0 -8
- package/dist/dist/IconButton.stories.js.map +0 -1
- package/dist/dist/Image.d.ts +0 -9
- package/dist/dist/Image.js +0 -37
- package/dist/dist/Image.js.map +0 -1
- package/dist/dist/ImageBackground.d.ts +0 -6
- package/dist/dist/ImageBackground.js +0 -9
- package/dist/dist/ImageBackground.js.map +0 -1
- package/dist/dist/Layer.d.ts +0 -5
- package/dist/dist/Layer.js +0 -13
- package/dist/dist/Layer.js.map +0 -1
- package/dist/dist/Link.d.ts +0 -7
- package/dist/dist/Link.js +0 -13
- package/dist/dist/Link.js.map +0 -1
- package/dist/dist/Link.stories.d.ts +0 -1
- package/dist/dist/Link.stories.js +0 -8
- package/dist/dist/Link.stories.js.map +0 -1
- package/dist/dist/Mask.d.ts +0 -5
- package/dist/dist/Mask.js +0 -23
- package/dist/dist/Mask.js.map +0 -1
- package/dist/dist/Mask.stories.d.ts +0 -1
- package/dist/dist/Mask.stories.js +0 -13
- package/dist/dist/Mask.stories.js.map +0 -1
- package/dist/dist/MediaQuery.d.ts +0 -2
- package/dist/dist/MediaQuery.js +0 -34
- package/dist/dist/MediaQuery.js.map +0 -1
- package/dist/dist/Meta.d.ts +0 -6
- package/dist/dist/Meta.js +0 -8
- package/dist/dist/Meta.js.map +0 -1
- package/dist/dist/ModalSheet.d.ts +0 -3
- package/dist/dist/ModalSheet.js +0 -43
- package/dist/dist/ModalSheet.js.map +0 -1
- package/dist/dist/NumberPickerActionSheet.d.ts +0 -5
- package/dist/dist/NumberPickerActionSheet.js +0 -25
- package/dist/dist/NumberPickerActionSheet.js.map +0 -1
- package/dist/dist/Page.d.ts +0 -9
- package/dist/dist/Page.js +0 -26
- package/dist/dist/Page.js.map +0 -1
- package/dist/dist/Permissions.d.ts +0 -1
- package/dist/dist/Permissions.js +0 -36
- package/dist/dist/Permissions.js.map +0 -1
- package/dist/dist/PickerSelect.d.ts +0 -172
- package/dist/dist/PickerSelect.js +0 -403
- package/dist/dist/PickerSelect.js.map +0 -1
- package/dist/dist/Pill.d.ts +0 -7
- package/dist/dist/Pill.js +0 -10
- package/dist/dist/Pill.js.map +0 -1
- package/dist/dist/Pill.stories.d.ts +0 -1
- package/dist/dist/Pill.stories.js +0 -36
- package/dist/dist/Pill.stories.js.map +0 -1
- package/dist/dist/Pog.d.ts +0 -7
- package/dist/dist/Pog.js +0 -144
- package/dist/dist/Pog.js.map +0 -1
- package/dist/dist/ProgressBar.d.ts +0 -16
- package/dist/dist/ProgressBar.js +0 -40
- package/dist/dist/ProgressBar.js.map +0 -1
- package/dist/dist/ScrollView.d.ts +0 -1
- package/dist/dist/ScrollView.js +0 -4
- package/dist/dist/ScrollView.js.map +0 -1
- package/dist/dist/SegmentedControl.d.ts +0 -9
- package/dist/dist/SegmentedControl.js +0 -18
- package/dist/dist/SegmentedControl.js.map +0 -1
- package/dist/dist/SegmentedControl.stories.d.ts +0 -1
- package/dist/dist/SegmentedControl.stories.js +0 -32
- package/dist/dist/SegmentedControl.stories.js.map +0 -1
- package/dist/dist/SelectList.d.ts +0 -9
- package/dist/dist/SelectList.js +0 -29
- package/dist/dist/SelectList.js.map +0 -1
- package/dist/dist/SelectList.stories.d.ts +0 -1
- package/dist/dist/SelectList.stories.js +0 -24
- package/dist/dist/SelectList.stories.js.map +0 -1
- package/dist/dist/Spinner.d.ts +0 -44
- package/dist/dist/Spinner.js +0 -58
- package/dist/dist/Spinner.js.map +0 -1
- package/dist/dist/Spinner.stories.d.ts +0 -1
- package/dist/dist/Spinner.stories.js +0 -10
- package/dist/dist/Spinner.stories.js.map +0 -1
- package/dist/dist/SplitPage.d.ts +0 -7
- package/dist/dist/SplitPage.js +0 -20
- package/dist/dist/SplitPage.js.map +0 -1
- package/dist/dist/SplitPage.stories.d.ts +0 -1
- package/dist/dist/SplitPage.stories.js +0 -7
- package/dist/dist/SplitPage.stories.js.map +0 -1
- package/dist/dist/StorybookContainer.d.ts +0 -7
- package/dist/dist/StorybookContainer.js +0 -9
- package/dist/dist/StorybookContainer.js.map +0 -1
- package/dist/dist/Switch.d.ts +0 -6
- package/dist/dist/Switch.js +0 -10
- package/dist/dist/Switch.js.map +0 -1
- package/dist/dist/Switch.stories.d.ts +0 -1
- package/dist/dist/Switch.stories.js +0 -27
- package/dist/dist/Switch.stories.js.map +0 -1
- package/dist/dist/TapToEdit.d.ts +0 -9
- package/dist/dist/TapToEdit.js +0 -27
- package/dist/dist/TapToEdit.js.map +0 -1
- package/dist/dist/Text.d.ts +0 -36
- package/dist/dist/Text.js +0 -86
- package/dist/dist/Text.js.map +0 -1
- package/dist/dist/Text.stories.d.ts +0 -1
- package/dist/dist/Text.stories.js +0 -13
- package/dist/dist/Text.stories.js.map +0 -1
- package/dist/dist/TextArea.d.ts +0 -6
- package/dist/dist/TextArea.js +0 -13
- package/dist/dist/TextArea.js.map +0 -1
- package/dist/dist/TextArea.stories.d.ts +0 -12
- package/dist/dist/TextArea.stories.js +0 -21
- package/dist/dist/TextArea.stories.js.map +0 -1
- package/dist/dist/TextField.d.ts +0 -47
- package/dist/dist/TextField.js +0 -199
- package/dist/dist/TextField.js.map +0 -1
- package/dist/dist/TextField.stories.d.ts +0 -6
- package/dist/dist/TextField.stories.js +0 -15
- package/dist/dist/TextField.stories.js.map +0 -1
- package/dist/dist/TextFieldNumberActionSheet.d.ts +0 -5
- package/dist/dist/TextFieldNumberActionSheet.js +0 -24
- package/dist/dist/TextFieldNumberActionSheet.js.map +0 -1
- package/dist/dist/UnifiedScreens.d.ts +0 -2
- package/dist/dist/UnifiedScreens.js +0 -26
- package/dist/dist/UnifiedScreens.js.map +0 -1
- package/dist/dist/Unifier.d.ts +0 -131
- package/dist/dist/Unifier.js +0 -198
- package/dist/dist/Unifier.js.map +0 -1
- package/dist/dist/Utilities.d.ts +0 -51
- package/dist/dist/Utilities.js +0 -77
- package/dist/dist/Utilities.js.map +0 -1
- package/dist/dist/WithLabel.d.ts +0 -6
- package/dist/dist/WithLabel.js +0 -23
- package/dist/dist/WithLabel.js.map +0 -1
- package/dist/dist/index.d.ts +0 -43
- package/dist/dist/index.js +0 -49
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
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
|
-
|
|
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 = (
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
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",
|
|
51
|
-
if (
|
|
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 (
|
|
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 !
|
|
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 !
|
|
65
|
+
return !value || isNumber(value);
|
|
68
66
|
case "password":
|
|
69
67
|
return true;
|
|
70
68
|
case "percent":
|
|
71
|
-
return !
|
|
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 (
|
|
88
|
-
if (!
|
|
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={
|
|
95
|
-
id={
|
|
96
|
-
options={
|
|
97
|
-
value={
|
|
98
|
-
onChange={
|
|
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 (
|
|
99
|
+
} else if (props.type === "textarea") {
|
|
102
100
|
return (
|
|
103
101
|
<TextArea
|
|
104
|
-
disabled={
|
|
105
|
-
id={
|
|
106
|
-
placeholder={
|
|
107
|
-
rows={
|
|
108
|
-
value={String(
|
|
109
|
-
onChange={(
|
|
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 (
|
|
110
|
+
} else if (props.type === "boolean") {
|
|
113
111
|
return (
|
|
114
112
|
<Switch
|
|
115
|
-
disabled={
|
|
116
|
-
id={
|
|
117
|
-
name={
|
|
118
|
-
switched={Boolean(
|
|
119
|
-
onChange={(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 (
|
|
123
|
-
const
|
|
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={
|
|
130
|
-
placeholder={
|
|
125
|
+
id={props.name}
|
|
126
|
+
placeholder={props.placeholder}
|
|
131
127
|
type="text"
|
|
132
128
|
// TODO: allow editing with a date picker
|
|
133
|
-
value={
|
|
134
|
-
onChange={(result) =>
|
|
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 (
|
|
142
|
-
type =
|
|
143
|
-
} else if (
|
|
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
|
|
153
|
-
// if (
|
|
154
|
-
// value = `${Number(
|
|
155
|
-
// } else if (
|
|
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={
|
|
163
|
-
id={
|
|
164
|
-
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={
|
|
167
|
-
onChange={(result) =>
|
|
162
|
+
value={stringValue}
|
|
163
|
+
onChange={(result) => handleChange(result.value)}
|
|
168
164
|
/>
|
|
169
165
|
);
|
|
170
166
|
}
|
|
171
|
-
}
|
|
167
|
+
};
|
|
172
168
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
@@ -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
|
+
}
|
package/src/SelectList.tsx
CHANGED
|
@@ -4,7 +4,8 @@ import {FieldWithLabelsProps} from "./Common";
|
|
|
4
4
|
import RNPickerSelect from "./PickerSelect";
|
|
5
5
|
import {Unifier} from "./Unifier";
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<Hyperlink linkDefault>{inner}</Hyperlink>
|
|
85
|
+
<Hyperlink linkDefault linkStyle={{textDecorationLine: "underline"}}>
|
|
86
|
+
{inner}
|
|
87
|
+
</Hyperlink>
|
|
89
88
|
);
|
|
90
89
|
}
|
|
91
90
|
}
|
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
|
-
|
|
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);
|
package/dist/Banner.stories.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/Banner.stories.js
DELETED
|
@@ -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"}
|
package/dist/Box.stories.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/Box.stories.js
DELETED
|
@@ -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
|
package/dist/Box.stories.js.map
DELETED
|
@@ -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,OAAO,CAAC;AAE1B,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,GAAgB;IAC1B,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,MAAM;IACN,OAAO;IACP,WAAW;IACX,QAAQ;IACR,UAAU;IACV,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,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@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Primary: any;
|
package/dist/Button.stories.js
DELETED
|
@@ -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,o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