@wordpress/components
Version:
UI components for WordPress.
8 lines (7 loc) • 5.6 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/calendar/utils/day-cell.tsx"],
"sourcesContent": ["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * External dependencies\n */\n\n/**\n * Internal dependencies\n */\n\n/**\n * The dash array and offset are calculated by:\n * - measuring the path length (eg 92,28384)\n * - establishing how many segments should the path be split into (eg. 24)\n * - dividing the path length by the number of segments (eg. 92,28384 / 24 = 3,84516)\n * - playing with the dash offset to make sure the dashes look good on rounded corners\n */\n\n/**\n * Dashed rectangle. The dash array and offset are chosen to make sure dashes\n * look good on rounded corners and have similar metrics to the other dash\n * preview shapes.\n */\nconst PreviewDashStartAndEnd = () => {\n return /*#__PURE__*/_jsx(\"svg\", {\n viewBox: \"0 0 32 32\",\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeDasharray: \"3.7677\",\n strokeDashoffset: \"3.2\",\n strokeWidth: \"1\",\n children: /*#__PURE__*/_jsx(\"path\", {\n d: \"M29.5,0.5 h-27 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h27 a2,2 0 0 0 2,-2 v-27 a2,2 0 0 0 -2,-2\"\n })\n });\n};\n\n/**\n * Dashed top, left, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashStart = () => {\n return /*#__PURE__*/_jsx(\"svg\", {\n viewBox: \"0 0 32 32\",\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeDasharray: \"3.84516\",\n strokeDashoffset: \"1.9226\",\n strokeWidth: \"1\",\n children: /*#__PURE__*/_jsx(\"path\", {\n d: \"M32,0.5 h-29.5 a2,2 0 0 0 -2,2 v27 a2,2 0 0 0 2,2 h30\"\n })\n });\n};\n/**\n * Dashed top and bottom sides. The dash array and offset are chosen\n * to make sure that multiple days in a row show a seamless dashed border.\n */\nconst PreviewDashMiddle = () => {\n return /*#__PURE__*/_jsxs(\"svg\", {\n viewBox: \"0 0 32 32\",\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeDasharray: \"3.9 4\",\n strokeDashoffset: \"2\",\n strokeWidth: \"1\",\n children: [/*#__PURE__*/_jsx(\"line\", {\n x1: \"0\",\n y1: \"0.5\",\n x2: \"100\",\n y2: \"0.5\"\n }), /*#__PURE__*/_jsx(\"line\", {\n x1: \"0\",\n y1: \"31.5\",\n x2: \"100\",\n y2: \"31.5\"\n })]\n });\n};\n/**\n * Dashed top, right, and bottom sides, with rounded corners. The dash array and\n * offset are chosen to make sure that multiple days in a row show a seamless\n * dashed border, and the dashes look good on rounded corners.\n */\nconst PreviewDashEnd = () => {\n return /*#__PURE__*/_jsx(\"svg\", {\n viewBox: \"0 0 32 32\",\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeDasharray: \"3.84516\",\n strokeDashoffset: \"1.9226\",\n strokeWidth: \"1\",\n children: /*#__PURE__*/_jsx(\"path\", {\n d: \"M0,0.5 h29.5 a2,2 0 0 1 2,2 v27 a2,2 0 0 1 -2,2 h-29.5\"\n })\n });\n};\n\n/**\n * Render a grid cell for a specific day in the calendar.\n *\n * Handles interaction and focus for the day.\n * @see https://daypicker.dev/guides/custom-components\n */\nexport function Day(props) {\n const {\n day,\n modifiers,\n children,\n ...tdProps\n } = props;\n let PreviewDash;\n if (modifiers.preview_start && modifiers.preview_end) {\n PreviewDash = PreviewDashStartAndEnd;\n } else if (modifiers.preview_start) {\n PreviewDash = PreviewDashStart;\n } else if (modifiers.preview_end) {\n PreviewDash = PreviewDashEnd;\n } else if (modifiers.preview) {\n PreviewDash = PreviewDashMiddle;\n }\n return /*#__PURE__*/_jsxs(\"td\", {\n ...tdProps,\n children: [PreviewDash && /*#__PURE__*/_jsx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