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

next: docs #625

Merged
merged 26 commits into from
Jul 30, 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
1 change: 1 addition & 0 deletions .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
types: [ready_for_review, synchronize, opened, labeled]
paths: [packages/**]
workflow_dispatch:

jobs:
preview-release:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```ts
(date: DateRange) => void
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```ts
import type { DateValue } from "@internationalized/date";

type DateRange = {
start: DateValue | undefined;
end: DateValue | undefined;
};
```
16 changes: 16 additions & 0 deletions sites/docs/src/lib/content/api-reference/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import OnEscapeKeydown from "./extended-types/shared/on-escape-keydown.md";
import EscapeKeydownBehavior from "./extended-types/shared/escape-keydown-behavior.md";
import Dir from "./extended-types/shared/dir.md";
import To from "./extended-types/portal/to.md";
import DateRange from "./extended-types/shared/date-range.md";
import DateRangeChangeFn from "./extended-types/shared/date-range-change-fn.md";
import type { APISchema, CSSVarSchema, DataAttrSchema, PropSchema } from "$lib/types/api.js";
import * as C from "$lib/content/constants.js";

Expand Down Expand Up @@ -518,3 +520,17 @@ export const disabledDataAttr: DataAttrSchema = {
value: "''",
description: "Present when the component is disabled.",
};

export const valueDateRangeProp: PropSchema = createPropSchema({
type: {
type: "DateRange",
definition: DateRange,
},
description: "The selected date range.",
bindable: true,
});

export const valueDateRangeChangeFn: PropSchema = createFunctionProp({
definition: DateRangeChangeFn,
description: "A function that is called when the selected date range changes.",
});
57 changes: 41 additions & 16 deletions sites/docs/src/lib/content/api-reference/range-calendar.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import type { RangeCalendarRootPropsWithoutHTML } from "bits-ui";
import { createApiSchema, createFunctionProp, withChildProps } from "./helpers.js";
import type {
RangeCalendarCellPropsWithoutHTML,
RangeCalendarDayPropsWithoutHTML,
RangeCalendarRootPropsWithoutHTML,
} from "bits-ui";
import {
createApiSchema,
createDataAttrSchema,
valueDateRangeChangeFn,
valueDateRangeProp,
withChildProps,
} from "./helpers.js";
import {
cell as calendarCell,
day as calendarDay,
root as calendarRoot,
cell,
day,
grid,
gridBody,
gridHead,
Expand All @@ -20,18 +30,8 @@ export const root = createApiSchema<RangeCalendarRootPropsWithoutHTML>({
title: "Root",
description: "The root range calendar component which contains all other calendar components.",
props: {
value: {
type: {
type: "DateRange",
definition: "{ start: DateValue | undefined; end: DateValue | undefined; }",
},
description: "The selected date range.",
bindable: true,
},
onValueChange: createFunctionProp({
definition: "(date: DateRange | undefined) => void",
description: "A function that is called when the selected date range changes.",
}),
value: valueDateRangeProp,
onValueChange: valueDateRangeChangeFn,
placeholder: calendarRoot.props!.placeholder,
onPlaceholderChange: calendarRoot.props!.onPlaceholderChange,
pagedNavigation: calendarRoot.props!.pagedNavigation,
Expand Down Expand Up @@ -73,6 +73,31 @@ export const root = createApiSchema<RangeCalendarRootPropsWithoutHTML>({
],
});

const dayCellAttrs = [
...(calendarCell.dataAttributes ?? []),
createDataAttrSchema({
name: "selection-start",
description: "Present when the cell is the start of a selection.",
}),
createDataAttrSchema({
name: "selection-end",
description: "Present when the cell is the end of a selection.",
}),
createDataAttrSchema({
name: "highlighted",
description: "Present when the cell is highlighted within a range.",
}),
];

export const cell = createApiSchema<RangeCalendarCellPropsWithoutHTML>({
...calendarCell,
dataAttributes: dayCellAttrs,
});

export const day = createApiSchema<RangeCalendarDayPropsWithoutHTML>({
...calendarDay,
dataAttributes: dayCellAttrs,
});
export const rangeCalendar = [
root,
header,
Expand Down