UNPKG

@crossed/ui

Version:

A universal & performant styling library for React Native, Next.js & React

108 lines (107 loc) 3.6 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var DayButton_exports = {}; __export(DayButton_exports, { DayButton: () => DayButton }); module.exports = __toCommonJS(DayButton_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_react = require("react"); var import_react_native = require("react-native"); var import_styled = require("@crossed/styled"); var import_styles = require("./styles"); var import_typography = require("../../typography"); const button = (0, import_styled.createStyles)(({ colors }) => ({ default: { base: { backgroundColor: colors.background.primary, borderRadius: 8, height: 40, alignItems: "center", justifyContent: "center" }, ":hover": { backgroundColor: colors.background.hover }, ":active": { backgroundColor: colors.background.active }, media: { md: { height: 44 } } }, selected: { base: { backgroundColor: colors.text.brand } }, disabled: { base: { opacity: 0.1 } }, today: { base: { borderWidth: 2, borderColor: colors.text.brand } } })); const text = (0, import_styled.createStyles)(({ colors, components: { Action } }) => ({ default: { base: { fontWeight: "500" } }, noMarginTop: { base: { marginTop: 0 } }, selected: { base: { color: Action.primary.default.text } }, today: { base: { color: colors.text.brand } } })); const DayButton = (0, import_react.memo)( ({ day, style, disabled: disabledProps, ...props }) => { const disabled = disabledProps || day.isAdjacentMonth; const handleStyle = (0, import_react.useCallback)( ({ hovered, pressed, focused }) => (0, import_styled.composeStyles)( import_styles.widthCell, button.default, disabled && button.disabled, day.isToday && button.today, day.isSelected && button.selected, style ).style({ hover: !day.isSelected && hovered, focus: focused, active: pressed }).style, [style, disabled, day] ); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_react_native.Pressable, { ...props, disabled, role: "button", style: handleStyle, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_typography.Headline, { textAlign: "center", size: "md", style: (0, import_styled.composeStyles)( text.default, day.isToday && text.today, day.isSelected && text.selected, !import_styled.isWeb && text.noMarginTop ), children: day.date.getDate() } ) } ); } ); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { DayButton }); //# sourceMappingURL=DayButton.js.map