ripal-ui 1.0.0 → 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.
- package/README.md +0 -0
- package/components/BottomSheet.tsx +197 -0
- package/components/Carousel.tsx +61 -0
- package/components/Circle.tsx +44 -0
- package/components/Tab.tsx +90 -0
- package/components/{Table.jsx → Table.tsx} +32 -10
- package/components/index.ts +5 -0
- package/config.js +4 -0
- package/dist/BottomSheet.js +186 -0
- package/dist/Carousel.js +52 -0
- package/dist/Toast.js +72 -0
- package/dist/index.js +74 -12
- package/elements/{Button.jsx → Button.tsx} +51 -26
- package/elements/Dialog.tsx +87 -0
- package/elements/Dropdown.tsx +88 -0
- package/elements/Inline.tsx +38 -0
- package/elements/Input.tsx +75 -0
- package/elements/ProgressBar.tsx +52 -0
- package/elements/Separator.tsx +72 -0
- package/elements/Skeleton.tsx +64 -0
- package/elements/Switch.tsx +64 -0
- package/elements/Text.tsx +73 -0
- package/elements/Toast.tsx +65 -0
- package/elements/Toggle.tsx +59 -0
- package/elements/index.js +2 -1
- package/package.json +8 -4
- package/scripts/generateConfig.js +79 -0
- package/components/Circle.jsx +0 -24
- package/components/Tab.jsx +0 -71
- package/components/index.js +0 -4
- package/elements/Dialog.jsx +0 -64
- package/elements/Dropdown.jsx +0 -66
- package/elements/Inline.jsx +0 -16
- package/elements/Input.jsx +0 -48
- package/elements/ProgressBar.jsx +0 -29
- package/elements/Separator.jsx +0 -32
- package/elements/Skeleton.jsx +0 -50
- package/elements/Switch.jsx +0 -49
- package/elements/Text.jsx +0 -42
- package/elements/Toggle.jsx +0 -48
package/dist/Carousel.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CarouselItem = exports.Carousel = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _elements = require("../elements");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
var CarouselItem = exports.CarouselItem = function CarouselItem(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
itemWidth = _ref.itemWidth,
|
|
20
|
+
onPress = _ref.onPress,
|
|
21
|
+
style = _ref.style;
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement(_reactNative.Pressable, {
|
|
23
|
+
style: _objectSpread({
|
|
24
|
+
width: itemWidth
|
|
25
|
+
}, style),
|
|
26
|
+
onPress: onPress
|
|
27
|
+
}, children);
|
|
28
|
+
};
|
|
29
|
+
var Carousel = exports.Carousel = function Carousel(_ref2) {
|
|
30
|
+
var children = _ref2.children,
|
|
31
|
+
_ref2$itemWidth = _ref2.itemWidth,
|
|
32
|
+
itemWidth = _ref2$itemWidth === void 0 ? 60 / 100 * _reactNative.Dimensions.get('window').width : _ref2$itemWidth,
|
|
33
|
+
_ref2$showIndicator = _ref2.showIndicator,
|
|
34
|
+
showIndicator = _ref2$showIndicator === void 0 ? false : _ref2$showIndicator;
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement(_reactNative.ScrollView, {
|
|
36
|
+
horizontal: true,
|
|
37
|
+
showsHorizontalScrollIndicator: showIndicator,
|
|
38
|
+
contentContainerStyle: styles.container
|
|
39
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactNative.View, null), _react["default"].Children.map(children, function (child) {
|
|
40
|
+
return /*#__PURE__*/_react["default"].cloneElement(child, {
|
|
41
|
+
itemWidth: itemWidth
|
|
42
|
+
});
|
|
43
|
+
}), /*#__PURE__*/_react["default"].createElement(_reactNative.View, null));
|
|
44
|
+
};
|
|
45
|
+
var styles = _reactNative.StyleSheet.create({
|
|
46
|
+
area: {
|
|
47
|
+
//
|
|
48
|
+
},
|
|
49
|
+
container: {
|
|
50
|
+
gap: 20
|
|
51
|
+
}
|
|
52
|
+
});
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _Inline = _interopRequireDefault(require("./Inline"));
|
|
10
|
+
var _Text = _interopRequireDefault(require("./Text"));
|
|
11
|
+
var _config = _interopRequireDefault(require("../config"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
15
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
+
var Toast = function Toast(_ref) {
|
|
23
|
+
var _ref$label = _ref.label,
|
|
24
|
+
label = _ref$label === void 0 ? "Percakapan berhasil dihapus" : _ref$label,
|
|
25
|
+
_ref$right = _ref.right,
|
|
26
|
+
right = _ref$right === void 0 ? null : _ref$right,
|
|
27
|
+
_ref$visible = _ref.visible,
|
|
28
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
|
29
|
+
setVisible = _ref.setVisible,
|
|
30
|
+
_ref$timeout = _ref.timeout,
|
|
31
|
+
timeout = _ref$timeout === void 0 ? 3000 : _ref$timeout,
|
|
32
|
+
containerStyle = _ref.containerStyle,
|
|
33
|
+
style = _ref.style,
|
|
34
|
+
textProps = _ref.textProps;
|
|
35
|
+
(0, _react.useEffect)(function () {
|
|
36
|
+
if (visible) {
|
|
37
|
+
var to = setTimeout(function () {
|
|
38
|
+
setVisible(false);
|
|
39
|
+
}, timeout);
|
|
40
|
+
return function () {
|
|
41
|
+
return clearTimeout(to);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}, [visible]);
|
|
45
|
+
return visible ? /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
|
|
46
|
+
style: _objectSpread(_objectSpread({}, styles.container), containerStyle)
|
|
47
|
+
}, /*#__PURE__*/_react["default"].createElement(_Inline["default"], {
|
|
48
|
+
style: styles.area
|
|
49
|
+
}, /*#__PURE__*/_react["default"].createElement(_Text["default"], _extends({
|
|
50
|
+
size: 12,
|
|
51
|
+
style: {
|
|
52
|
+
flexGrow: 1
|
|
53
|
+
},
|
|
54
|
+
color: "#fff"
|
|
55
|
+
}, textProps), label), right)) : null;
|
|
56
|
+
};
|
|
57
|
+
var styles = _reactNative.StyleSheet.create({
|
|
58
|
+
container: {
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
bottom: 0,
|
|
61
|
+
left: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
padding: 20
|
|
64
|
+
},
|
|
65
|
+
area: {
|
|
66
|
+
backgroundColor: _config["default"].colors.slate[800],
|
|
67
|
+
borderRadius: 999,
|
|
68
|
+
padding: 20,
|
|
69
|
+
paddingHorizontal: 30
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var _default = exports["default"] = Toast;
|
package/dist/index.js
CHANGED
|
@@ -3,32 +3,94 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "Button", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _Button["default"];
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "Dialog", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function get() {
|
|
15
|
-
return
|
|
15
|
+
return _Dialog.Dialog;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "DialogActions", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return
|
|
21
|
+
return _Dialog.DialogActions;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "Dropdown", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function get() {
|
|
27
|
-
return
|
|
27
|
+
return _Dropdown["default"];
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
Object.defineProperty(exports, "Inline", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _Inline["default"];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "Input", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _Input["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "ProgressBar", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _ProgressBar["default"];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "Separator", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _Separator["default"];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "Skeleton", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _Skeleton["default"];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "Switch", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _Switch["default"];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "Text", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _Text["default"];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "Toast", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _Toast["default"];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "Toggle", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _Toggle["default"];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var _Button = _interopRequireDefault(require("./Button"));
|
|
85
|
+
var _Dialog = require("./Dialog");
|
|
86
|
+
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
87
|
+
var _Inline = _interopRequireDefault(require("./Inline"));
|
|
88
|
+
var _Input = _interopRequireDefault(require("./Input"));
|
|
89
|
+
var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
|
|
90
|
+
var _Separator = _interopRequireDefault(require("./Separator"));
|
|
91
|
+
var _Skeleton = _interopRequireDefault(require("./Skeleton"));
|
|
92
|
+
var _Switch = _interopRequireDefault(require("./Switch"));
|
|
93
|
+
var _Text = _interopRequireDefault(require("./Text"));
|
|
94
|
+
var _Toast = _interopRequireDefault(require("./Toast"));
|
|
95
|
+
var _Toggle = _interopRequireDefault(require("./Toggle"));
|
|
34
96
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -1,36 +1,51 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity, StyleSheet } from 'react-native';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { TouchableOpacity, StyleSheet, ViewStyle } from 'react-native';
|
|
3
3
|
import config from '../config';
|
|
4
4
|
import Text from './Text';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
children
|
|
8
|
-
accent
|
|
9
|
-
onPress
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
interface ButtonProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
accent?: 'primary' | 'secondary' | 'tertiary';
|
|
9
|
+
onPress?: () => void;
|
|
10
|
+
onLongPress?: () => void;
|
|
11
|
+
color?: string;
|
|
12
|
+
height?: number;
|
|
13
|
+
circle?: boolean;
|
|
14
|
+
justifyContent?: ViewStyle['justifyContent'];
|
|
15
|
+
style?: ViewStyle;
|
|
16
|
+
textProps?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Button: FC<ButtonProps> = ({
|
|
20
|
+
children,
|
|
21
|
+
accent = 'primary',
|
|
22
|
+
onPress,
|
|
23
|
+
onLongPress,
|
|
24
|
+
color = config.colors.primary,
|
|
25
|
+
height = 50,
|
|
26
|
+
circle = false,
|
|
27
|
+
justifyContent = 'center',
|
|
28
|
+
style,
|
|
29
|
+
textProps
|
|
15
30
|
}) => {
|
|
16
|
-
const getAccentStyle = () => {
|
|
31
|
+
const getAccentStyle = (): ViewStyle => {
|
|
17
32
|
switch (accent) {
|
|
18
33
|
case 'primary':
|
|
19
34
|
return {
|
|
20
35
|
backgroundColor: color,
|
|
21
36
|
borderColor: color,
|
|
22
|
-
color: '#fff',
|
|
37
|
+
// color: '#fff',
|
|
23
38
|
};
|
|
24
39
|
case 'secondary':
|
|
25
40
|
return {
|
|
26
41
|
backgroundColor: '#fff',
|
|
27
42
|
borderColor: color,
|
|
28
|
-
color: color,
|
|
43
|
+
// color: color,
|
|
29
44
|
};
|
|
30
45
|
case 'tertiary':
|
|
31
46
|
return {
|
|
32
47
|
backgroundColor: '#fff',
|
|
33
|
-
color: color,
|
|
48
|
+
// color: color,
|
|
34
49
|
borderColor: config.colors.transparent
|
|
35
50
|
};
|
|
36
51
|
default:
|
|
@@ -38,7 +53,7 @@ const Button = ({
|
|
|
38
53
|
}
|
|
39
54
|
};
|
|
40
55
|
|
|
41
|
-
const getColorStyle = () => {
|
|
56
|
+
const getColorStyle = (): ViewStyle => {
|
|
42
57
|
switch (color) {
|
|
43
58
|
case 'red':
|
|
44
59
|
return { backgroundColor: '#e74c3c', borderColor: '#e74c3c' };
|
|
@@ -56,19 +71,26 @@ const Button = ({
|
|
|
56
71
|
onPress={onPress}
|
|
57
72
|
onLongPress={onLongPress}
|
|
58
73
|
style={[
|
|
59
|
-
styles.button,
|
|
60
|
-
getAccentStyle(),
|
|
74
|
+
styles.button,
|
|
75
|
+
getAccentStyle(),
|
|
61
76
|
getColorStyle(),
|
|
62
|
-
{
|
|
63
|
-
height: height,
|
|
64
|
-
aspectRatio: circle ? 1 :
|
|
65
|
-
borderRadius: circle ? 999 : 12,
|
|
66
|
-
justifyContent: justifyContent,
|
|
67
|
-
...style
|
|
77
|
+
{
|
|
78
|
+
height: height,
|
|
79
|
+
aspectRatio: circle ? 1 : undefined,
|
|
80
|
+
borderRadius: circle ? 999 : 12,
|
|
81
|
+
justifyContent: justifyContent,
|
|
82
|
+
...style,
|
|
68
83
|
}
|
|
69
84
|
]}
|
|
70
85
|
>
|
|
71
|
-
<Text
|
|
86
|
+
<Text
|
|
87
|
+
{...textProps}
|
|
88
|
+
color={accent === "primary" ? "#fff" : color}
|
|
89
|
+
style={styles.text}
|
|
90
|
+
weight='600SemiBold'
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</Text>
|
|
72
94
|
</TouchableOpacity>
|
|
73
95
|
);
|
|
74
96
|
};
|
|
@@ -77,7 +99,7 @@ const styles = StyleSheet.create({
|
|
|
77
99
|
button: {
|
|
78
100
|
paddingHorizontal: 20,
|
|
79
101
|
height: 50,
|
|
80
|
-
borderRadius:
|
|
102
|
+
borderRadius: 12,
|
|
81
103
|
fontWeight: '600',
|
|
82
104
|
fontSize: 14,
|
|
83
105
|
display: 'flex',
|
|
@@ -86,6 +108,9 @@ const styles = StyleSheet.create({
|
|
|
86
108
|
justifyContent: 'center',
|
|
87
109
|
borderWidth: 1,
|
|
88
110
|
},
|
|
111
|
+
text: {
|
|
112
|
+
// Adjust text style here if necessary
|
|
113
|
+
}
|
|
89
114
|
});
|
|
90
115
|
|
|
91
116
|
export default Button;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Pressable, StyleSheet, View, TouchableOpacity, ViewStyle } from "react-native";
|
|
3
|
+
import config from "../config";
|
|
4
|
+
import Text from "./Text";
|
|
5
|
+
import Inline from "./Inline";
|
|
6
|
+
|
|
7
|
+
interface DialogActionsProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DialogActions: React.FC<DialogActionsProps> = ({ children }) => {
|
|
12
|
+
return (
|
|
13
|
+
<Inline
|
|
14
|
+
justifyContent="flex-end"
|
|
15
|
+
gap={0}
|
|
16
|
+
style={{
|
|
17
|
+
...styles.action_area,
|
|
18
|
+
paddingTop: 20,
|
|
19
|
+
marginTop: 20 / 2,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</Inline>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface DialogProps {
|
|
28
|
+
spacer?: number;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
visible: boolean;
|
|
31
|
+
onDismiss: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const Dialog: React.FC<DialogProps> = ({ spacer = 20, children, visible, onDismiss }) => {
|
|
35
|
+
if (visible) {
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<TouchableOpacity style={styles.overlay} />
|
|
39
|
+
<Pressable style={styles.container} onPress={onDismiss}>
|
|
40
|
+
<Pressable
|
|
41
|
+
style={{
|
|
42
|
+
...styles.content,
|
|
43
|
+
padding: spacer,
|
|
44
|
+
gap: spacer / 2,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</Pressable>
|
|
49
|
+
</Pressable>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return null; // Return null when not visible
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
overlay: {
|
|
58
|
+
backgroundColor: `#000000aa`,
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
top: 0,
|
|
61
|
+
left: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
bottom: 0,
|
|
64
|
+
zIndex: 10,
|
|
65
|
+
},
|
|
66
|
+
container: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
top: 0,
|
|
69
|
+
left: 0,
|
|
70
|
+
right: 0,
|
|
71
|
+
bottom: 0,
|
|
72
|
+
zIndex: 15,
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
},
|
|
76
|
+
content: {
|
|
77
|
+
backgroundColor: '#fff',
|
|
78
|
+
width: '90%',
|
|
79
|
+
borderRadius: 12,
|
|
80
|
+
},
|
|
81
|
+
action_area: {
|
|
82
|
+
borderTopWidth: 1,
|
|
83
|
+
borderTopColor: config.colors.slate[200],
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export { Dialog, DialogActions };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet, View } from "react-native";
|
|
3
|
+
import config from "../config";
|
|
4
|
+
import Text from "./Text";
|
|
5
|
+
import Inline from "./Inline";
|
|
6
|
+
import Ionicons from "@expo/vector-icons/Ionicons";
|
|
7
|
+
|
|
8
|
+
type OptionType<T> =
|
|
9
|
+
| T[] // Array of objects
|
|
10
|
+
| string[]; // Array of strings
|
|
11
|
+
|
|
12
|
+
interface DropdownProps<T> {
|
|
13
|
+
options: OptionType<T>;
|
|
14
|
+
value: T | null;
|
|
15
|
+
setValue: (value: T) => void;
|
|
16
|
+
onChange?: (value: T) => void;
|
|
17
|
+
color?: string;
|
|
18
|
+
label?: string | null;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
objectKey?: keyof T | null; // Key for accessing properties if options are objects
|
|
21
|
+
withSearch?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Dropdown = <T,>({
|
|
25
|
+
options,
|
|
26
|
+
value,
|
|
27
|
+
setValue,
|
|
28
|
+
onChange,
|
|
29
|
+
color = config.colors.primary,
|
|
30
|
+
label = null,
|
|
31
|
+
placeholder = 'Choose',
|
|
32
|
+
objectKey = null,
|
|
33
|
+
withSearch = false,
|
|
34
|
+
}: DropdownProps<T>) => {
|
|
35
|
+
const [isExpanded, setExpanded] = useState(false);
|
|
36
|
+
const isObject = Array.isArray(options) && typeof options[0] === 'object';
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={{ gap: 5 }}>
|
|
40
|
+
{label !== null && <Text size={12} weight="400Regular">{label}</Text>}
|
|
41
|
+
<View style={styles.area}>
|
|
42
|
+
<Inline onPress={() => setExpanded(!isExpanded)}>
|
|
43
|
+
<Text style={{ flexGrow: 1 }}>{value || placeholder}</Text>
|
|
44
|
+
<Ionicons name={isExpanded ? 'chevron-up-outline' : 'chevron-down-outline'} />
|
|
45
|
+
</Inline>
|
|
46
|
+
|
|
47
|
+
{isExpanded && (
|
|
48
|
+
<ScrollView style={{ maxHeight: 200 }}>
|
|
49
|
+
{(options as OptionType<T>).map((opt, o) => {
|
|
50
|
+
const isActive = isObject ? opt[objectKey as keyof T] === value : opt === value;
|
|
51
|
+
const displayValue = isObject ? opt[objectKey as keyof T] : opt;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Inline key={o} style={styles.item} onPress={() => {
|
|
55
|
+
if (onChange) {
|
|
56
|
+
onChange(opt);
|
|
57
|
+
} else {
|
|
58
|
+
setValue(isObject ? opt[objectKey as keyof T] : opt);
|
|
59
|
+
}
|
|
60
|
+
setExpanded(false);
|
|
61
|
+
}}>
|
|
62
|
+
<Text weight={isActive ? '600SemiBold' : '400Regular'} color={isActive ? color : config.colors.slate[500]}>
|
|
63
|
+
{displayValue}
|
|
64
|
+
</Text>
|
|
65
|
+
</Inline>
|
|
66
|
+
);
|
|
67
|
+
})}
|
|
68
|
+
</ScrollView>
|
|
69
|
+
)}
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const styles = StyleSheet.create({
|
|
76
|
+
area: {
|
|
77
|
+
padding: 15,
|
|
78
|
+
borderWidth: 1,
|
|
79
|
+
borderColor: config.colors.slate[200],
|
|
80
|
+
borderRadius: 12,
|
|
81
|
+
gap: 15,
|
|
82
|
+
},
|
|
83
|
+
item: {
|
|
84
|
+
height: 40,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export default Dropdown;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Pressable, PressableProps, StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
interface InlineProps extends PressableProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
alignItems?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
|
|
7
|
+
justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
8
|
+
gap?: number;
|
|
9
|
+
style?: ViewStyle;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Inline: React.FC<InlineProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
alignItems = "center",
|
|
15
|
+
justifyContent = "flex-start",
|
|
16
|
+
gap = 20,
|
|
17
|
+
style,
|
|
18
|
+
onPress,
|
|
19
|
+
onLayout,
|
|
20
|
+
}) => {
|
|
21
|
+
return (
|
|
22
|
+
<Pressable
|
|
23
|
+
style={{
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
alignItems,
|
|
26
|
+
justifyContent,
|
|
27
|
+
gap,
|
|
28
|
+
...style,
|
|
29
|
+
}}
|
|
30
|
+
onPress={onPress}
|
|
31
|
+
onLayout={onLayout}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</Pressable>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default Inline;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { View, TextInput, StyleSheet, TextInputProps, ViewStyle } from "react-native";
|
|
3
|
+
import Text from "./Text";
|
|
4
|
+
import Inline from "./Inline";
|
|
5
|
+
import config from "../config";
|
|
6
|
+
|
|
7
|
+
interface InputProps {
|
|
8
|
+
value?: string;
|
|
9
|
+
label?: string | null;
|
|
10
|
+
left?: React.ReactNode | null; // Allows for any valid React node
|
|
11
|
+
right?: React.ReactNode | null; // Allows for any valid React node
|
|
12
|
+
height?: number;
|
|
13
|
+
placeholder?: string | null;
|
|
14
|
+
mode?: TextInputProps["keyboardType"]; // Use keyboardType from TextInputProps
|
|
15
|
+
secureTextEntry?: boolean;
|
|
16
|
+
onChangeText: (text: string) => void; // Function to handle text changes
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Input: React.FC<InputProps> = ({
|
|
20
|
+
value="",
|
|
21
|
+
label = null,
|
|
22
|
+
left = null,
|
|
23
|
+
right = null,
|
|
24
|
+
height = 50,
|
|
25
|
+
placeholder = null,
|
|
26
|
+
mode = "default",
|
|
27
|
+
secureTextEntry = false,
|
|
28
|
+
onChangeText,
|
|
29
|
+
}) => {
|
|
30
|
+
const [isFocused, setFocused] = useState(false);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<View style={{ gap: 5 }}>
|
|
34
|
+
{label !== null && (
|
|
35
|
+
<Text size={12} weight="400Regular" color={isFocused ? config.colors.primary : config.colors.slate[500]}>
|
|
36
|
+
{label}
|
|
37
|
+
</Text>
|
|
38
|
+
)}
|
|
39
|
+
<Inline
|
|
40
|
+
style={{
|
|
41
|
+
...styles.input,
|
|
42
|
+
borderColor: isFocused ? config.colors.primary : config.colors.slate[200],
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{left !== null && left}
|
|
46
|
+
<TextInput
|
|
47
|
+
value={value}
|
|
48
|
+
placeholder={placeholder}
|
|
49
|
+
style={{
|
|
50
|
+
height,
|
|
51
|
+
flexGrow: 1,
|
|
52
|
+
}}
|
|
53
|
+
onFocus={() => setFocused(true)}
|
|
54
|
+
onChangeText={onChangeText}
|
|
55
|
+
onBlur={() => setFocused(false)}
|
|
56
|
+
// Using 'default' for generic mode
|
|
57
|
+
keyboardType={mode}
|
|
58
|
+
secureTextEntry={secureTextEntry}
|
|
59
|
+
/>
|
|
60
|
+
{right !== null && right}
|
|
61
|
+
</Inline>
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
input: {
|
|
68
|
+
flexGrow: 1,
|
|
69
|
+
borderWidth: 1,
|
|
70
|
+
borderRadius: 12,
|
|
71
|
+
paddingHorizontal: 20,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default Input;
|