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

build: update exports in package.json for better compatibility #2535

Merged
merged 7 commits into from
Oct 12, 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
5 changes: 2 additions & 3 deletions examples/Utc.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState } from "react";

import { UTCDate } from "@date-fns/utc";
import { DayPicker } from "react-day-picker/utc";
import { DayPicker, TZDate } from "react-day-picker";

export function Utc() {
const [selected, setSelected] = useState<Date>(new UTCDate());
const [selected, setSelected] = useState<Date>(TZDate.tz("UTC"));
return (
<DayPicker
mode="single"
Expand Down
1 change: 1 addition & 0 deletions jalali.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dist/cjs/jalali.d.ts";
4 changes: 4 additions & 0 deletions jalali.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable no-undef */
const jalali = require("./dist/cjs/jalali.js");
module.exports = jalali;
1 change: 1 addition & 0 deletions locale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "date-fns/locale";
4 changes: 4 additions & 0 deletions locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable no-undef */
const locale = require("./dist/cjs/locale.js");
module.exports = locale;
119 changes: 49 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,121 +15,95 @@
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"module": "./dist/esm/index.js",
"style": "./src/style.css",
"style": "./style.css",
"type": "module",
"exports": {
".": {
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"default": {
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"./lib": {
"require": {
"types": "./dist/cjs/lib/dateLib.d.ts",
"default": "./dist/cjs/lib/dateLib.js"
},
"import": {
"types": "./dist/esm/lib/dateLib.d.ts",
"default": "./dist/esm/lib/dateLib.js"
},
"default": {
"types": "./dist/cjs/lib/dateLib.d.ts",
"default": "./dist/cjs/lib/dateLib.js"
}
},
"./utc": {
"require": {
"types": "./dist/cjs/utc.d.ts",
"default": "./dist/cjs/utc.js"
},
"import": {
"types": "./dist/esm/utc.d.ts",
"default": "./dist/esm/utc.js"
},
"default": {
"types": "./dist/cjs/utc.d.ts",
"default": "./dist/cjs/utc.js"
}
},
"./jalali": {
"require": {
"types": "./dist/cjs/jalali.d.ts",
"default": "./dist/cjs/jalali.js"
},
"import": {
"types": "./dist/esm/jalali.d.ts",
"default": "./dist/esm/jalali.js"
},
"default": {
"require": {
"types": "./dist/cjs/jalali.d.ts",
"default": "./dist/cjs/jalali.js"
}
},
"./locale": {
"require": {
"types": "./dist/cjs/locale.d.ts",
"default": "./dist/cjs/locale.js"
},
"import": {
"types": "./dist/esm/locale.d.ts",
"default": "./dist/esm/locale.js"
},
"default": {
"require": {
"types": "./dist/cjs/locale.d.ts",
"default": "./dist/cjs/locale.js"
}
},
"./style.css": {
"require": "./src/style.css",
"import": "./src/style.css",
"default": "./src/style.css",
"types": "./src/style.css.d.ts"
},
"./dist/style.css": {
"require": "./src/style.css",
"import": "./src/style.css",
"default": "./src/style.css",
"types": "./src/style.css.d.ts"
"import": {
"types": "./style.css.d.ts",
"default": "./style.css"
},
"require": {
"types": "./style.css.d.ts",
"default": "./style.css"
}
},
"./style.module.css": {
"require": "./src/style.module.css",
"import": "./src/style.module.css",
"default": "./src/style.module.css",
"types": "./src/style.module.css.d.ts"
"import": {
"types": "./style.css.d.ts",
"default": "./style.module.css"
},
"require": {
"types": "./style.css.d.ts",
"default": "./style.module.css"
}
},
"./dist/style.css": {
"import": {
"types": "./style.css.d.ts",
"default": "./style.css"
},
"require": {
"types": "./style.css.d.ts",
"default": "./style.css"
}
},
"./dist/style.module.css": {
"require": "./src/style.module.css",
"import": "./src/style.module.css",
"default": "./src/style.module.css",
"types": "./src/style.module.css.d.ts"
"import": {
"types": "./style.css.d.ts",
"default": "./style.module.css"
},
"require": {
"types": "./style.css.d.ts",
"default": "./style.module.css"
}
},
"./package.json": {
"require": "./package.json",
"import": "./package.json",
"require": "./package.json",
"default": "./package.json"
},
"./examples": {
"require": "./examples/index.ts",
"import": "./examples/index.ts",
"default": "./examples/index.ts",
"types": "./examples/index.ts"
"types": "./examples/index.d.ts",
"import": "./examples/index.ts"
}
},
"scripts": {
"prepublish": "pnpm build",
"build": "pnpm build:cjs && pnpm build:esm && pnpm build:css",
"build:cjs": "tsc --project tsconfig-cjs.json && echo '{ \"type\": \"commonjs\" }' > dist/cjs/package.json",
"build:esm": "tsc --project tsconfig-esm.json",
"build:css": "./scripts/build-css.sh ./src/style.css ./src/style.module.css",
"build:css": "./scripts/build-css.sh ./style.css ./style.module.css",
"lint": "eslint .",
"test": "jest",
"test-watch": "jest --watch",
Expand All @@ -142,14 +116,19 @@
"examples",
"website/docs",
"tsconfig.json",
"tsconfig-base.json"
"tsconfig-base.json",
"style.css",
"style.module.css",
"jalali.js",
"jalali.d.ts",
"locale.js",
"locale.d.ts"
],
"dependencies": {
"@date-fns/tz": "^1.1.2",
"date-fns": "^4.1.0"
},
"devDependencies": {
"@date-fns/utc": "^2.1.0",
"@jest/types": "^29.6.3",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
Expand Down
11 changes: 0 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/selection/useMulti.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { dateLib } from "react-day-picker/lib";

import { act, renderHook } from "@/test/render";

import { dateLib } from "../lib";
import { DayPickerProps } from "../types";

import { useMulti } from "./useMulti";
Expand Down
3 changes: 1 addition & 2 deletions src/selection/useSingle.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { dateLib } from "react-day-picker/lib";

import { act, renderHook } from "@/test/render";

import { dateLib } from "../lib";
import { DayPickerProps } from "../types";

import { useSingle } from "./useSingle";
Expand Down
38 changes: 0 additions & 38 deletions src/style.css.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/types/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ export interface PropsBase {
* Use ISO week dates instead of the locale setting. Setting this prop will
* ignore `weekStartsOn` and `firstWeekContainsDate`.
*
* Use the
* [react-day-picker/utc](https://daypicker.dev/docs/localization#utc-dates)
* to set the calendar to UTC.
*
* @see https://daypicker.dev/docs/localization#iso-week-dates
* @see https://en.wikipedia.org/wiki/ISO_week_date
*/
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions website/docs/docs/styling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import "react-day-picker/style.css";
<details>
<summary>Copying the CSS file</summary>

If you are not using a bundler, you can copy the CSS file to your project. See the [style.css](https://github.com/gpbl/react-day-picker/blob/main/src/style.css) file in the DayPicker repository for the source.
If you are not using a bundler, you can copy the CSS file to your project. See the [style.css](https://github.com/gpbl/react-day-picker/blob/main/style.css) file in the DayPicker repository for the source.

```html title="./public/index.html"
<style>
Expand Down Expand Up @@ -152,7 +152,7 @@ If you are including [Tailwind CSS](https://tailwindcss.com) in your project, us

- Add the class names you want to override to the `classNames` prop.
- Extend the default class names with [`getDefaultClassNames`](../api/functions/getDefaultClassNames.md).
- Read the [`style.css`](https://github.com/gpbl/react-day-picker/blob/main/src/style.css) file from the source and get familiar with the [UI elements](../docs/anatomy.mdx).
- Read the [`style.css`](https://github.com/gpbl/react-day-picker/blob/main/style.css) file from the source and get familiar with the [UI elements](../docs/anatomy.mdx).
- Adopt [custom components](../guides/custom-components.mdx) to further customize the HTML elements.

```tsx
Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const config: Config = {
customCss: [
"./src/css/custom.css",
"./src/css/docusaurus-reset.css",
"../src/style.css"
"../style.css"
]
}
} satisfies Preset.Options
Expand Down
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"typecheck-watch": "tsc --noEmit --watch"
},
"dependencies": {
"@date-fns/utc": "^2.1.0",
"@docusaurus/core": "3.5.2",
"@docusaurus/plugin-client-redirects": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
Expand Down