Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling weekends correctly #10

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/size.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"storybook": "^8.2.9",
"typescript": "^5.5.4",
"vite": "^4.0.0",
"vite-plugin-dts": "^4.0.3",
"vite-plugin-dts": "^4.2.1",
"vitest": "^0.32.2"
},
"eslintConfig": {
Expand Down
11 changes: 7 additions & 4 deletions src/WeeklyCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ export function WeeklyCalendar<T extends GenericEvent>({
onSelectDate,
weekends = false,
currentDate,
value
}: CalendarContainerProps<T>) {
const [startWeek, setStartWeek] = useState(startOfWeek(currentDate || new Date(), { weekStartsOn: 0 }));
const dateToUse = currentDate || value;

const [startWeek, setStartWeek] = useState(startOfWeek(dateToUse || new Date(), { weekStartsOn: 0 }));
const weekPeriod = {
startDate: startWeek,
endDate: endOfWeek(startWeek),
};

useEffect(() => {
if (currentDate && startOfWeek(currentDate).getTime() !== startWeek.getTime()) {
setStartWeek(currentDate);
if (dateToUse && startOfWeek(dateToUse).getTime() !== startWeek.getTime()) {
setStartWeek(dateToUse);
}
}, [currentDate]);
}, [dateToUse]);

useEffect(() => {
onSelectDate && onSelectDate(startWeek);
Expand Down
5 changes: 5 additions & 0 deletions src/components/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export interface BaseCalendarProps<T extends GenericEvent = GenericEvent> {
export interface CalendarContainerProps<T extends GenericEvent = GenericEvent>
extends BaseCalendarProps<T> {
events: T[];
/**
* @deprecated Use `currentDate` instead.
*/
value?: Date;

currentDate?: Date;
}

Expand Down
11 changes: 11 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"noEmit": false,
"removeComments": true,
"sourceMap": false
},
"exclude": ["node_modules", "dist", "**/*.stories.*", "**/*.test.*", "**/*.spec.*"]
}

6 changes: 5 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import dts from 'vite-plugin-dts'

export default defineConfig({
plugins: [react()],
plugins: [react(), dts({
tsconfigPath: './tsconfig.build.json',
}),],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'), // This is correct
Expand All @@ -20,6 +23,7 @@ export default defineConfig({
},
},
},

emptyOutDir: false, // Prevent Vite from clearing the output directory
},
});
116 changes: 53 additions & 63 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1612,27 +1612,27 @@
dependencies:
"@types/mdx" "^2.0.0"

"@microsoft/[email protected].4":
version "7.29.4"
resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.29.4.tgz#098f94f304db98f3cea8618fd1107946e212eaf5"
integrity sha512-LHOMxmT8/tU1IiiiHOdHFF83Qsi+V8d0kLfscG4EvQE9cafiR8blOYr8SfkQKWB1wgEilQgXJX3MIA4vetDLZw==
"@microsoft/[email protected].6":
version "7.29.6"
resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.29.6.tgz#e5941514502049b06ca9af21e2096f8f1ad5a01b"
integrity sha512-gC0KGtrZvxzf/Rt9oMYD2dHvtN/1KPEYsrQPyMKhLHnlVuO/f4AFN3E4toqZzD2pt4LhkKoYmL2H9tX3yCOyRw==
dependencies:
"@microsoft/tsdoc" "~0.15.0"
"@microsoft/tsdoc-config" "~0.17.0"
"@rushstack/node-core-library" "5.5.1"
"@rushstack/node-core-library" "5.7.0"

"@microsoft/[email protected].4":
version "7.47.4"
resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.47.4.tgz#1a66dc9d6f316fe86eef336e7f8004ab9222499b"
integrity sha512-HKm+P4VNzWwvq1Ey+Jfhhj/3MjsD+ka2hbt8L5AcRM95lu1MFOYnz3XlU7Gr79Q/ZhOb7W/imAKeYrOI0bFydg==
"@microsoft/[email protected].7":
version "7.47.7"
resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.47.7.tgz#3bc4450fe46c265bef857ab938aa15b9fc7a85de"
integrity sha512-fNiD3G55ZJGhPOBPMKD/enozj8yxJSYyVJWxRWdcUtw842rvthDHJgUWq9gXQTensFlMHv2wGuCjjivPv53j0A==
dependencies:
"@microsoft/api-extractor-model" "7.29.4"
"@microsoft/api-extractor-model" "7.29.6"
"@microsoft/tsdoc" "~0.15.0"
"@microsoft/tsdoc-config" "~0.17.0"
"@rushstack/node-core-library" "5.5.1"
"@rushstack/node-core-library" "5.7.0"
"@rushstack/rig-package" "0.5.3"
"@rushstack/terminal" "0.13.3"
"@rushstack/ts-command-line" "4.22.3"
"@rushstack/terminal" "0.14.0"
"@rushstack/ts-command-line" "4.22.6"
lodash "~4.17.15"
minimatch "~3.0.3"
resolve "~1.22.1"
Expand Down Expand Up @@ -1780,10 +1780,10 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@rushstack/node-core-library@5.5.1":
version "5.5.1"
resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-5.5.1.tgz#890db37eafaab582c79eb6bf421447b82b3a964b"
integrity sha512-ZutW56qIzH8xIOlfyaLQJFx+8IBqdbVCZdnj+XT1MorQ1JqqxHse8vbCpEM+2MjsrqcbxcgDIbfggB1ZSQ2A3g==
"@rushstack/node-core-library@5.7.0":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-5.7.0.tgz#f28699c7d0b3de0120a207f8b9d5bd7c69806e18"
integrity sha512-Ff9Cz/YlWu9ce4dmqNBZpA45AEya04XaBFIjV7xTVeEf+y/kTjEasmozqFELXlNG4ROdevss75JrrZ5WgufDkQ==
dependencies:
ajv "~8.13.0"
ajv-draft-04 "~1.0.0"
Expand All @@ -1802,20 +1802,20 @@
resolve "~1.22.1"
strip-json-comments "~3.1.1"

"@rushstack/terminal@0.13.3":
version "0.13.3"
resolved "https://registry.yarnpkg.com/@rushstack/terminal/-/terminal-0.13.3.tgz#9a05b8cf759f14161a49d3ccb09d556e4161caca"
integrity sha512-fc3zjXOw8E0pXS5t9vTiIPx9gHA0fIdTXsu9mT4WbH+P3mYvnrX0iAQ5a6NvyK1+CqYWBTw/wVNx7SDJkI+WYQ==
"@rushstack/terminal@0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@rushstack/terminal/-/terminal-0.14.0.tgz#967ecc586d7172204353059f8fdb1760666e9381"
integrity sha512-juTKMAMpTIJKudeFkG5slD8Z/LHwNwGZLtU441l/u82XdTBfsP+LbGKJLCNwP5se+DMCT55GB8x9p6+C4UL7jw==
dependencies:
"@rushstack/node-core-library" "5.5.1"
"@rushstack/node-core-library" "5.7.0"
supports-color "~8.1.1"

"@rushstack/[email protected].3":
version "4.22.3"
resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.22.3.tgz#dcc75bd25b21031b32b2758ee3f2f4973b112572"
integrity sha512-edMpWB3QhFFZ4KtSzS8WNjBgR4PXPPOVrOHMbb7kNpmQ1UFS9HdVtjCXg1H5fG+xYAbeE+TMPcVPUyX2p84STA==
"@rushstack/[email protected].6":
version "4.22.6"
resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.22.6.tgz#2aee4fc98c6043c026ce278880fbffb5227de5ca"
integrity sha512-QSRqHT/IfoC5nk9zn6+fgyqOPXHME0BfchII9EUPR19pocsNp/xSbeBCbD3PIR2Lg+Q5qk7OFqk1VhWPMdKHJg==
dependencies:
"@rushstack/terminal" "0.13.3"
"@rushstack/terminal" "0.14.0"
"@types/argparse" "1.0.38"
argparse "~1.0.9"
string-argv "~0.3.1"
Expand Down Expand Up @@ -3170,24 +3170,24 @@
loupe "^2.3.7"
pretty-format "^29.7.0"

"@volar/[email protected].0", "@volar/language-core@~2.4.0-alpha.18":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@volar/language-core/-/language-core-2.4.0.tgz#962efc66ff9198ee2412786e99528bf77cdad100"
integrity sha512-FTla+khE+sYK0qJP+6hwPAAUwiNHVMph4RUXpxf/FIPKUP61NFrVZorml4mjFShnueR2y9/j8/vnh09YwVdH7A==
"@volar/[email protected].4", "@volar/language-core@~2.4.1":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@volar/language-core/-/language-core-2.4.4.tgz#4e05ee09f283ab55c37677f80f5faa5e5b3fe2fe"
integrity sha512-kO9k4kTLfxpg+6lq7/KAIv3m2d62IHuCL6GbVgYZTpfKvIGoAIlDxK7pFcB/eczN2+ydg/vnyaeZ6SGyZrJw2w==
dependencies:
"@volar/source-map" "2.4.0"
"@volar/source-map" "2.4.4"

"@volar/[email protected].0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-2.4.0.tgz#b6690f06c600eaf587bbc81b0153203e4f6db72a"
integrity sha512-2ceY8/NEZvN6F44TXw2qRP6AQsvCYhV2bxaBPWxV9HqIfkbRydSksTFObCF1DBDNBfKiZTS8G/4vqV6cvjdOIQ==
"@volar/[email protected].4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-2.4.4.tgz#98612684bfc54620f7b49c969d4657465c306faf"
integrity sha512-xG3PZqOP2haG8XG4Pg3PD1UGDAdqZg24Ru8c/qYjYAnmcj6GBR64mstx+bZux5QOyRaJK+/lNM/RnpvBD3489g==

"@volar/typescript@^2.3.4", "@volar/typescript@~2.4.0-alpha.18":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@volar/typescript/-/typescript-2.4.0.tgz#f909d20dfe43dd846d30695f6e5467276ff4418e"
integrity sha512-9zx3lQWgHmVd+JRRAHUSRiEhe4TlzL7U7e6ulWXOxHH/WNYxzKwCvZD7WYWEZFdw4dHfTD9vUR0yPQO6GilCaQ==
"@volar/typescript@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@volar/typescript/-/typescript-2.4.4.tgz#c6679dc6bc1e86483f1d34f22ed2c2b0100f9838"
integrity sha512-QQMQRVj0fVHJ3XdRKiS1LclhG0VBXdFYlyuHRQF/xLk2PuJuHNWP26MDZNvEVCvnyUQuUQhIAfylwY5TGPgc6w==
dependencies:
"@volar/language-core" "2.4.0"
"@volar/language-core" "2.4.4"
path-browserify "^1.0.1"
vscode-uri "^3.0.8"

Expand Down Expand Up @@ -3218,12 +3218,12 @@
de-indent "^1.0.2"
he "^1.2.0"

"@vue/language-core@2.0.29":
version "2.0.29"
resolved "https://registry.yarnpkg.com/@vue/language-core/-/language-core-2.0.29.tgz#19462d786cd7a1c21dbe575b46970a57094e0357"
integrity sha512-o2qz9JPjhdoVj8D2+9bDXbaI4q2uZTHQA/dbyZT4Bj1FR9viZxDJnLcKVHfxdn6wsOzRgpqIzJEEmSSvgMvDTQ==
"@vue/language-core@2.1.6":
version "2.1.6"
resolved "https://registry.yarnpkg.com/@vue/language-core/-/language-core-2.1.6.tgz#b48186bdb9b3ef2b83e1f76d5b1ac357b3a7ed94"
integrity sha512-MW569cSky9R/ooKMh6xa2g1D0AtRKbL56k83dzus/bx//RDJk24RHWkMzbAlXjMdDNyxAaagKPRquBIxkxlCkg==
dependencies:
"@volar/language-core" "~2.4.0-alpha.18"
"@volar/language-core" "~2.4.1"
"@vue/compiler-dom" "^3.4.0"
"@vue/compiler-vue2" "^2.7.16"
"@vue/shared" "^3.4.0"
Expand Down Expand Up @@ -10922,21 +10922,20 @@ [email protected]:
picocolors "^1.0.0"
vite "^3.0.0 || ^4.0.0"

vite-plugin-dts@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.0.3.tgz#0f452be5ea81a50fa27ade4e0f3a0d750873affc"
integrity sha512-+xnTsaONwU2kV6zhRjtbRJSGN41uFR/whqmcb4k4fftLFDJElxthp0PP5Fq8gMeM9ytWMt1yk5gGgekLREWYQQ==
vite-plugin-dts@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.2.1.tgz#f8bee33b732929717ce13ef7a382696d51200c30"
integrity sha512-/QlYvgUMiv8+ZTEerhNCYnYaZMM07cdlX6hQCR/w/g/nTh0tUXPoYwbT6SitizLJ9BybT1lnrcZgqheI6wromQ==
dependencies:
"@microsoft/api-extractor" "7.47.4"
"@microsoft/api-extractor" "7.47.7"
"@rollup/pluginutils" "^5.1.0"
"@volar/typescript" "^2.3.4"
"@vue/language-core" "2.0.29"
"@volar/typescript" "^2.4.4"
"@vue/language-core" "2.1.6"
compare-versions "^6.1.1"
debug "^4.3.6"
kolorist "^1.8.0"
local-pkg "^0.5.0"
magic-string "^0.30.11"
vue-tsc "2.0.29"

"vite@^3.0.0 || ^4.0.0", vite@^4.0.0:
version "4.5.3"
Expand Down Expand Up @@ -10989,15 +10988,6 @@ vscode-uri@^3.0.8:
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.8.tgz#1770938d3e72588659a172d0fd4642780083ff9f"
integrity sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==

[email protected]:
version "2.0.29"
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-2.0.29.tgz#bf7e9605af9fadec7fd6037d242217f5c6ad2c3b"
integrity sha512-MHhsfyxO3mYShZCGYNziSbc63x7cQ5g9kvijV7dRe1TTXBRLxXyL0FnXWpUF1xII2mJ86mwYpYsUmMwkmerq7Q==
dependencies:
"@volar/typescript" "~2.4.0-alpha.18"
"@vue/language-core" "2.0.29"
semver "^7.5.4"

w3c-xmlserializer@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz#f925ba26855158594d907313cedd1476c5967f6c"
Expand Down
Loading