Skip to content

Commit 1aea7b8

Browse files
committed
refactor: update various components and stories for improved consistency and functionality
- Refactored components across multiple packages including Button, Checkbox, and Modal for better code organization and readability. - Enhanced stories for components like Table, Tabs, and ListBox to ensure comprehensive testing and demonstration. - Cleaned up unused imports and improved type definitions in several files. - Updated build scripts in package.json to streamline the development process.
1 parent 64bcedb commit 1aea7b8

File tree

275 files changed

+19483
-20937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+19483
-20937
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"build": "make build",
3636
"test:ssr": "cross-env STRICT_MODE=1 yarn jest --config jest.ssr.config.js",
3737
"ci-test": "cross-env STRICT_MODE=1 yarn jest --maxWorkers=2 && cross-env STRICT_MODE=1 yarn test:ssr --runInBand",
38-
"lint": "concurrently \"yarn check-types\" \"eslint packages\" \"node scripts/lint-packages.js\" \"yarn constraints\"",
38+
"lint": "concurrently \"yarn check-types\" \"eslint packages --fix\" \"node scripts/lint-packages.js\" \"yarn constraints\"",
3939
"jest": "jest",
4040
"copyrights": "babel-node --presets @babel/env ./scripts/addHeaders.js",
4141
"build:icons": "babel-node --presets @babel/env ./scripts/buildIcons.js",

packages/@react-aria-nutrient/calendar/stories/Example.tsx

+51-57
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
* OF ANY KIND, either express or implied. See the License for the specific language
1010
* governing permissions and limitations under the License.
1111
*/
12-
import { Button } from "@react-spectrum/button";
12+
import {Button} from '@react-spectrum/button';
1313
import {
1414
CalendarState,
1515
RangeCalendarState,
16-
useCalendarState,
17-
} from "@react-stately/calendar";
16+
useCalendarState
17+
} from '@react-stately/calendar';
1818
import {
1919
createCalendar,
2020
DateDuration,
21-
startOfWeek,
22-
} from "@internationalized/date";
23-
import React, { ReactElement, useMemo, useRef } from "react";
24-
import { useCalendar, useCalendarCell, useCalendarGrid } from "../src";
25-
import { useDateFormatter, useLocale } from "@react-aria-nutrient/i18n";
21+
startOfWeek
22+
} from '@internationalized/date';
23+
import React, {ReactElement, useMemo, useRef} from 'react';
24+
import {useCalendar, useCalendarCell, useCalendarGrid} from '../src';
25+
import {useDateFormatter, useLocale} from '@react-aria-nutrient/i18n';
2626

2727
export function Example(props) {
28-
let { locale } = useLocale();
29-
const { visibleDuration } = props;
28+
let {locale} = useLocale();
29+
const {visibleDuration} = props;
3030

3131
let state = useCalendarState({
3232
createCalendar,
3333
...props,
34-
locale,
34+
locale
3535
});
3636

37-
let { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(
37+
let {calendarProps, prevButtonProps, nextButtonProps} = useCalendar(
3838
props,
3939
state
4040
);
@@ -52,8 +52,7 @@ export function Example(props) {
5252
key={i}
5353
state={state}
5454
visibleDuration={visibleDuration}
55-
offset={{ months: i }}
56-
/>
55+
offset={{months: i}} />
5756
);
5857
}
5958

@@ -62,23 +61,22 @@ export function Example(props) {
6261

6362
return (
6463
<div {...calendarProps}>
65-
<div style={{ textAlign: "center" }} data-testid={"range"}>
66-
{calendarProps["aria-label"]}
64+
<div style={{textAlign: 'center'}} data-testid={'range'}>
65+
{calendarProps['aria-label']}
6766
</div>
6867
<div
6968
style={{
70-
display: "grid",
69+
display: 'grid',
7170
gridTemplateColumns: `repeat(${grids.length}, 1fr)`,
72-
gap: "1em",
73-
}}
74-
>
71+
gap: '1em'
72+
}}>
7573
{grids}
7674
</div>
7775
<div>
78-
<Button variant={"secondary"} {...prevButtonProps}>
76+
<Button variant={'secondary'} {...prevButtonProps}>
7977
prev
8078
</Button>
81-
<Button variant={"secondary"} {...nextButtonProps}>
79+
<Button variant={'secondary'} {...nextButtonProps}>
8280
next
8381
</Button>
8482
</div>
@@ -89,14 +87,14 @@ export function Example(props) {
8987
function CalendarGrid({
9088
state,
9189
visibleDuration,
92-
offset = {},
90+
offset = {}
9391
}: {
94-
state: CalendarState | RangeCalendarState;
95-
visibleDuration: DateDuration;
96-
offset?: DateDuration;
92+
state: CalendarState | RangeCalendarState,
93+
visibleDuration: DateDuration,
94+
offset?: DateDuration
9795
}) {
98-
let { locale } = useLocale();
99-
let { gridProps, weeksInMonth } = useCalendarGrid({}, state);
96+
let {locale} = useLocale();
97+
let {gridProps, weeksInMonth} = useCalendarGrid({}, state);
10098

10199
let weeks = visibleDuration.weeks ?? 1;
102100
let startDate = state.visibleRange.start.add(offset);
@@ -112,8 +110,7 @@ function CalendarGrid({
112110
<Cell
113111
key={dayIndex}
114112
state={state}
115-
date={startDate.add({ weeks: weekIndex, days: dayIndex })}
116-
/>
113+
date={startDate.add({weeks: weekIndex, days: dayIndex})} />
117114
))}
118115
</div>
119116
))}
@@ -123,69 +120,66 @@ function CalendarGrid({
123120

124121
function Cell(props) {
125122
let ref = useRef<HTMLSpanElement | null>(null);
126-
let { cellProps, buttonProps } = useCalendarCell(props, props.state, ref);
123+
let {cellProps, buttonProps} = useCalendarCell(props, props.state, ref);
127124

128125
let dateFormatter = useDateFormatter({
129-
day: "numeric",
126+
day: 'numeric',
130127
timeZone: props.state.timeZone,
131-
calendar: props.date.calendar.identifier,
128+
calendar: props.date.calendar.identifier
132129
});
133130

134131
return (
135-
<div {...cellProps} style={{ display: "inline-block" }}>
132+
<div {...cellProps} style={{display: 'inline-block'}}>
136133
<span
137134
ref={ref}
138135
{...buttonProps}
139136
style={{
140-
display: "block",
137+
display: 'block',
141138
width: 42,
142139
height: 42,
143-
background: props.state.isSelected(props.date) ? "blue" : "",
144-
}}
145-
>
140+
background: props.state.isSelected(props.date) ? 'blue' : ''
141+
}}>
146142
{dateFormatter.format(props.date.toDate(props.state.timeZone))}
147143
</span>
148144
</div>
149145
);
150146
}
151147

152148
export function ExampleCustomFirstDay(props) {
153-
let { locale } = useLocale();
154-
const { firstDayOfWeek } = props;
149+
let {locale} = useLocale();
150+
const {firstDayOfWeek} = props;
155151

156152
let state = useCalendarState({
157153
createCalendar,
158154
...props,
159-
locale,
155+
locale
160156
});
161157

162-
let { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(
158+
let {calendarProps, prevButtonProps, nextButtonProps} = useCalendar(
163159
props,
164160
state
165161
);
166162

167163
return (
168164
<div {...calendarProps}>
169-
<div style={{ textAlign: "center" }} data-testid={"range"}>
170-
{calendarProps["aria-label"]}
165+
<div style={{textAlign: 'center'}} data-testid={'range'}>
166+
{calendarProps['aria-label']}
171167
</div>
172168
<div
173169
style={{
174-
display: "grid",
175-
gridTemplateColumns: "repeat(1, 1fr)",
176-
gap: "1em",
177-
}}
178-
>
170+
display: 'grid',
171+
gridTemplateColumns: 'repeat(1, 1fr)',
172+
gap: '1em'
173+
}}>
179174
<ExampleFirstDayCalendarGrid
180175
state={state}
181-
firstDayOfWeek={firstDayOfWeek}
182-
/>
176+
firstDayOfWeek={firstDayOfWeek} />
183177
</div>
184178
<div>
185-
<Button variant={"secondary"} {...prevButtonProps}>
179+
<Button variant={'secondary'} {...prevButtonProps}>
186180
prev
187181
</Button>
188-
<Button variant={"secondary"} {...nextButtonProps}>
182+
<Button variant={'secondary'} {...nextButtonProps}>
189183
next
190184
</Button>
191185
</div>
@@ -195,12 +189,12 @@ export function ExampleCustomFirstDay(props) {
195189

196190
function ExampleFirstDayCalendarGrid({
197191
state,
198-
firstDayOfWeek,
192+
firstDayOfWeek
199193
}: {
200-
state: CalendarState | RangeCalendarState;
201-
firstDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
194+
state: CalendarState | RangeCalendarState,
195+
firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
202196
}) {
203-
let { gridProps, weeksInMonth } = useCalendarGrid({ firstDayOfWeek }, state);
197+
let {gridProps, weeksInMonth} = useCalendarGrid({firstDayOfWeek}, state);
204198
let startDate = state.visibleRange.start;
205199
return (
206200
<div {...gridProps}>

0 commit comments

Comments
 (0)