roko-date-picker
Version:
A simple single/multi date picker
69 lines (68 loc) • 2.84 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("react-native");
const react_1 = __importStar(require("react"));
const format_1 = __importDefault(require("date-fns/format"));
const hooks_1 = require("../../../../features/hooks");
const container_1 = __importDefault(require("../../container"));
const constants_1 = require("../../../../features/domain/constants");
const Cell = ({ item, selected, theme, onChange, index }) => {
// #region Variables
const customStyle = (0, hooks_1.useStyles)(styles, theme);
// #endregion
return (<container_1.default activeOpacity={1} style={customStyle.root} onPress={() => onChange(item)} index={index}>
<react_native_1.View style={{
borderBottomWidth: 6,
borderRadius: constants_1.sizes.tiny,
borderCurve: "continuous",
borderBottomColor: selected ? theme?.colors.primary : "transparent",
}}>
<react_native_1.Text style={customStyle.label}>{(0, format_1.default)(item, "yyyy")}</react_native_1.Text>
</react_native_1.View>
</container_1.default>);
};
exports.default = (0, react_1.memo)(Cell);
Cell.displayName = "Cell";
const styles = (theme) => react_native_1.StyleSheet.create({
root: {
height: "25%",
minWidth: "33.3333%",
alignItems: "center",
justifyContent: "center",
},
selected: {
backgroundColor: theme.colors.primary,
},
label: {
color: theme.colors.onBackground,
fontFamily: theme.font?.family,
textTransform: "capitalize",
},
selectedLabel: { color: theme.colors.onPrimary },
});