-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(docs): calendar dx * fix(docs): incorrect import path
- Loading branch information
Showing
32 changed files
with
400 additions
and
405 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
apps/docs/content/components/calendar/controlled-focused-value.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
let defaultDate = today(getLocalTimeZone()); | ||
let [focusedDate, setFocusedDate] = React.useState(defaultDate); | ||
|
||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled Focused Value)" | ||
focusedValue={focusedDate} | ||
value={defaultDate} | ||
onFocusChange={setFocusedDate} | ||
/> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/docs/content/components/calendar/controlled-focused-value.raw.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type {DateValue} from "@react-types/calendar"; | ||
|
||
import React from "react"; | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
let defaultDate = today(getLocalTimeZone()); | ||
let [focusedDate, setFocusedDate] = React.useState<DateValue>(defaultDate); | ||
|
||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled Focused Value)" | ||
focusedValue={focusedDate} | ||
value={defaultDate} | ||
onFocusChange={setFocusedDate} | ||
/> | ||
); | ||
} |
40 changes: 6 additions & 34 deletions
40
apps/docs/content/components/calendar/controlled-focused-value.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,15 @@ | ||
const App = `import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
export default function App() { | ||
let defaultDate = today(getLocalTimeZone()); | ||
let [focusedDate, setFocusedDate] = React.useState(defaultDate); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled Focused Value)" | ||
focusedValue={focusedDate} | ||
value={defaultDate} | ||
onFocusChange={setFocusedDate} | ||
/> | ||
); | ||
}`; | ||
|
||
const AppTs = `import {Calendar} from "@nextui-org/react"; | ||
import type {DateValue} from "@react-types/calendar"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
export default function App() { | ||
let defaultDate = today(getLocalTimeZone()); | ||
let [focusedDate, setFocusedDate] = React.useState<DateValue>(defaultDate); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled Focused Value)" | ||
focusedValue={focusedDate} | ||
value={defaultDate} | ||
onFocusChange={setFocusedDate} | ||
/> | ||
); | ||
}`; | ||
import App from "./controlled-focused-value.raw.jsx?raw"; | ||
import AppTs from "./controlled-focused-value.raw.tsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
const reactTs = { | ||
"/App.tsx": AppTs, | ||
}; | ||
|
||
export default { | ||
...react, | ||
...reactTs, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {parseDate} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
let [value, setValue] = React.useState(parseDate("2024-03-07")); | ||
|
||
return <Calendar aria-label="Date (Controlled)" value={value} onChange={setValue} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type {DateValue} from "@react-types/calendar"; | ||
|
||
import React from "react"; | ||
import {Calendar} from "@nextui-org/react"; | ||
import {parseDate} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
let [value, setValue] = React.useState<DateValue>(parseDate("2024-03-07")); | ||
|
||
return <Calendar aria-label="Date (Controlled)" value={value} onChange={setValue} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,15 @@ | ||
const App = `import {Calendar} from "@nextui-org/react"; | ||
import {parseDate} from "@internationalized/date"; | ||
export default function App() { | ||
let [value, setValue] = React.useState(parseDate("2024-03-07")); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled)" | ||
value={value} | ||
onChange={setValue} | ||
/> | ||
); | ||
}`; | ||
|
||
const AppTs = `import {Calendar} from "@nextui-org/react"; | ||
import type {DateValue} from "@react-types/calendar"; | ||
import {parseDate} from "@internationalized/date"; | ||
export default function App() { | ||
let [value, setValue] = React.useState<DateValue>(parseDate("2024-03-07")); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Controlled)" | ||
value={value} | ||
onChange={setValue} | ||
/> | ||
); | ||
}`; | ||
import App from "./controlled.raw.jsx?raw"; | ||
import AppTs from "./controlled.raw.tsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
const reactTs = { | ||
"/App.tsx": AppTs, | ||
}; | ||
|
||
export default { | ||
...react, | ||
...reactTs, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return <Calendar isDisabled aria-label="Date (Disabled)" />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apps/docs/content/components/calendar/international-calendars.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {I18nProvider} from "@react-aria/i18n"; | ||
|
||
export default function App() { | ||
return ( | ||
<I18nProvider locale="zh-CN-u-ca-chinese"> | ||
<Calendar aria-label="Date (International Calendar)" /> | ||
</I18nProvider> | ||
); | ||
} |
11 changes: 1 addition & 10 deletions
11
apps/docs/content/components/calendar/international-calendars.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/docs/content/components/calendar/invalid-date.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone, isWeekend} from "@internationalized/date"; | ||
import {useLocale} from "@react-aria/i18n"; | ||
|
||
export default function App() { | ||
let [date, setDate] = React.useState(today(getLocalTimeZone())); | ||
let {locale} = useLocale(); | ||
let isInvalid = isWeekend(date, locale); | ||
|
||
return ( | ||
<Calendar | ||
aria-label="Date (Invalid on weekends)" | ||
errorMessage={isInvalid ? "We are closed on weekends" : undefined} | ||
isInvalid={isInvalid} | ||
value={date} | ||
onChange={setDate} | ||
/> | ||
); | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/docs/content/components/calendar/invalid-date.raw.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {DateValue} from "@react-types/calendar"; | ||
|
||
import React from "react"; | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone, isWeekend} from "@internationalized/date"; | ||
import {useLocale} from "@react-aria/i18n"; | ||
|
||
export default function App() { | ||
let [date, setDate] = React.useState<DateValue>(today(getLocalTimeZone())); | ||
let {locale} = useLocale(); | ||
let isInvalid = isWeekend(date, locale); | ||
|
||
return ( | ||
<Calendar | ||
aria-label="Date (Invalid on weekends)" | ||
errorMessage={isInvalid ? "We are closed on weekends" : undefined} | ||
isInvalid={isInvalid} | ||
value={date} | ||
onChange={setDate} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,15 @@ | ||
const App = `import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone, isWeekend} from "@internationalized/date"; | ||
import {useLocale} from "@react-aria/i18n"; | ||
export default function App() { | ||
let [date, setDate] = React.useState(today(getLocalTimeZone())); | ||
let {locale} = useLocale(); | ||
let isInvalid = isWeekend(date, locale); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Invalid on weekends)" | ||
errorMessage={isInvalid ? "We are closed on weekends" : undefined} | ||
isInvalid={isInvalid} | ||
value={date} | ||
onChange={setDate} | ||
/> | ||
); | ||
}`; | ||
|
||
const AppTs = `import {Calendar} from "@nextui-org/react"; | ||
import type {DateValue} from "@react-types/calendar"; | ||
import {today, getLocalTimeZone, isWeekend} from "@internationalized/date"; | ||
import {useLocale} from "@react-aria/i18n"; | ||
export default function App() { | ||
let [date, setDate] = React.useState<DateValue>(today(getLocalTimeZone())); | ||
let {locale} = useLocale(); | ||
let isInvalid = isWeekend(date, locale); | ||
return ( | ||
<Calendar | ||
aria-label="Date (Invalid on weekends)" | ||
errorMessage={isInvalid ? "We are closed on weekends" : undefined} | ||
isInvalid={isInvalid} | ||
value={date} | ||
onChange={setDate} | ||
/> | ||
); | ||
}`; | ||
import App from "./invalid-date.raw.jsx?raw"; | ||
import AppTs from "./invalid-date.raw.tsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
const reactTs = { | ||
"/App.tsx": AppTs, | ||
}; | ||
|
||
export default { | ||
...react, | ||
...reactTs, | ||
}; |
12 changes: 12 additions & 0 deletions
12
apps/docs/content/components/calendar/max-date-value.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
return ( | ||
<Calendar | ||
aria-label="Date (Max Date Value)" | ||
defaultValue={today(getLocalTimeZone())} | ||
maxValue={today(getLocalTimeZone())} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
apps/docs/content/components/calendar/min-date-value.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
import {today, getLocalTimeZone} from "@internationalized/date"; | ||
|
||
export default function App() { | ||
return ( | ||
<Calendar | ||
aria-label="Date (Min Date Value)" | ||
defaultValue={today(getLocalTimeZone())} | ||
minValue={today(getLocalTimeZone())} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {Calendar} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return <Calendar aria-label="Date (Page Behaviour)" pageBehavior="single" />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.