Skip to content
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
2 changes: 1 addition & 1 deletion packages/@adobe/react-spectrum/exports/Toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

export {ToastContainer, ToastQueue} from '../src/toast/ToastContainer';

export type {SpectrumToastOptions, SpectrumToastContainerProps} from '../src/toast/ToastContainer';
export type {SpectrumToastOptions, SpectrumToastContainerProps, CloseFunction} from '../src/toast/ToastContainer';
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface SpectrumToastOptions extends ToastOptions, DOMProps {
shouldCloseOnAction?: boolean
}

type CloseFunction = () => void;
export type CloseFunction = () => void;

function wrapInViewTransition(fn: () => void): void {
if ('startViewTransition' in document) {
Expand Down
2 changes: 2 additions & 0 deletions packages/@internationalized/date/src/CalendarDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} fro
import {GregorianCalendar} from './calendars/GregorianCalendar';
import {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';

export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;

function shiftArgs(args: any[]) {
let calendar: Calendar = typeof args[0] === 'object'
? args.shift()
Expand Down
1 change: 1 addition & 0 deletions packages/@internationalized/date/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type {
CycleOptions,
CycleTimeOptions
} from './types';
export type {DateValue} from './CalendarDate';

export {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';
export {GregorianCalendar} from './calendars/GregorianCalendar';
Expand Down
4 changes: 1 addition & 3 deletions packages/@internationalized/date/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
*/

import {AnyCalendarDate, AnyTime, Calendar} from './types';
import {CalendarDate, CalendarDateTime, ZonedDateTime} from './CalendarDate';
import {CalendarDate, CalendarDateTime, DateValue, ZonedDateTime} from './CalendarDate';
import {fromAbsolute, toAbsolute, toCalendar, toCalendarDate} from './conversion';
import {weekStartData} from './weekStartData';

type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;

/** Returns whether the given dates occur on the same day, regardless of the time or calendar system. */
export function isSameDay(a: DateValue, b: DateValue): boolean {
b = toCalendar(b, a.calendar);
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/s2/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const focusRing = () => ({
outlineOffset: 2
} as const);

interface IconStyle {
export interface IconStyle {
size?: 'XS' | 'S' | 'M' | 'L' |'XL',
color?: 'white' | 'black' | 'accent' | 'neutral' | 'negative' | 'informative' | 'positive' | 'notice' | 'gray' | 'red' | 'orange' | 'yellow' | 'chartreuse' | 'celery' | 'green' | 'seafoam' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'fuchsia' | 'magenta' | 'pink' | 'turquoise' | 'cinnamon' | 'brown' | 'silver',
margin?: Spacing,
Expand Down
28 changes: 18 additions & 10 deletions packages/@react-spectrum/s2/style/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
// package.json in this directory is not the real package.json. Lint rule not smart enough.
import assert from 'assert';
// eslint-disable-next-line rulesdir/imports
import * as tokens from '@adobe/spectrum-tokens/dist/json/variables.json';
import * as originalTokens from '@adobe/spectrum-tokens/dist/json/variables.json';

export function getToken(name: keyof typeof tokens): string {
// This forces TSC to inline the token keys instead of leaving a dependency on it.
function keys<T extends Record<string, any>>(v: T): Record<keyof T, any> {
return v;
}

const tokens = keys(originalTokens);
type TokenName = keyof typeof tokens;

export function getToken(name: TokenName): string {
return (tokens[name] as any).value;
}

Expand All @@ -26,7 +34,7 @@ export interface ColorToken {
forcedColors?: string
}

export function colorToken(name: keyof typeof tokens): ColorToken | ColorRef {
export function colorToken(name: TokenName): ColorToken | ColorRef {
let token = tokens[name] as typeof tokens['gray-25'] | typeof tokens['neutral-content-color-default'];
if ('ref' in token) {
return {
Expand All @@ -43,7 +51,7 @@ export function colorToken(name: keyof typeof tokens): ColorToken | ColorRef {
};
}

export function rawColorToken(name: keyof typeof tokens): string {
export function rawColorToken(name: TokenName): string {
let token = tokens[name] as typeof tokens['gray-25'];
return `light-dark(${token.sets.light.value}, ${token.sets.dark.value})`;
}
Expand All @@ -55,7 +63,7 @@ export interface ColorRef {
forcedColors?: string
}

export function weirdColorToken(name: keyof typeof tokens): ColorRef {
export function weirdColorToken(name: TokenName): ColorRef {
let token = tokens[name] as typeof tokens['accent-background-color-default'];
return {
type: 'ref',
Expand All @@ -66,18 +74,18 @@ export function weirdColorToken(name: keyof typeof tokens): ColorRef {

type ReplaceColor<S extends string> = S extends `${infer S}-color-${infer N}` ? `${S}-${N}` : S;

export function colorScale<S extends string>(scale: S): Record<ReplaceColor<Extract<keyof typeof tokens, `${S}-${number}`>>, ReturnType<typeof colorToken>> {
export function colorScale<S extends string>(scale: S): Record<ReplaceColor<Extract<TokenName, `${S}-${number}`>>, ReturnType<typeof colorToken>> {
let res: any = {};
let re = new RegExp(`^${scale}-\\d+$`);
for (let token in tokens) {
if (re.test(token)) {
res[token.replace('-color', '')] = colorToken(token as keyof typeof tokens);
res[token.replace('-color', '')] = colorToken(token as TokenName);
}
}
return res;
}

export function simpleColorScale<S extends string>(scale: S): Record<Extract<keyof typeof tokens, `${S}-${number}`>, string> {
export function simpleColorScale<S extends string>(scale: S): Record<Extract<TokenName, `${S}-${number}`>, string> {
let res: any = {};
let re = new RegExp(`^${scale}-\\d+$`);
for (let token in tokens) {
Expand Down Expand Up @@ -156,10 +164,10 @@ const indexes = {
};

/** Returns the index of a font token relative to font-size-100 (which is index 0). */
export function fontSizeToken(name: keyof typeof tokens): number {
export function fontSizeToken(name: TokenName): number {
let token = tokens[name] as typeof tokens['font-size-100'] | typeof tokens['heading-size-m'];
if ('ref' in token) {
name = token.ref.slice(1, -1) as keyof typeof tokens;
name = token.ref.slice(1, -1) as TokenName;
}

let index = indexes[name];
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/toast/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

export {ToastContainer, ToastQueue} from '@adobe/react-spectrum/Toast';

export type {SpectrumToastOptions, SpectrumToastContainerProps} from '@adobe/react-spectrum/Toast';
export type {SpectrumToastOptions, SpectrumToastContainerProps, CloseFunction} from '@adobe/react-spectrum/Toast';
2 changes: 1 addition & 1 deletion packages/@react-stately/data/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export {useAsyncList} from 'react-stately/useAsyncList';
export {useTreeData} from 'react-stately/useTreeData';
export {useListData} from 'react-stately/useListData';
export type {ListOptions, ListData} from 'react-stately/useListData';
export type {AsyncListOptions, AsyncListData} from 'react-stately/useAsyncList';
export type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from 'react-stately/useAsyncList';
export type {TreeOptions, TreeData} from 'react-stately/useTreeData';
2 changes: 1 addition & 1 deletion packages/react-stately/exports/useAsyncList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
*/

export {useAsyncList} from '../src/data/useAsyncList';
export type {AsyncListOptions, AsyncListData} from '../src/data/useAsyncList';
export type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from '../src/data/useAsyncList';
6 changes: 3 additions & 3 deletions packages/react-stately/src/data/useAsyncList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export interface AsyncListOptions<T, C> {
sort?: AsyncListLoadFunction<T, C, AsyncListLoadOptions<T, C> & {sortDescriptor: SortDescriptor}>
}

type AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
export type AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;

interface AsyncListLoadOptions<T, C> {
export interface AsyncListLoadOptions<T, C> {
/** The items currently in the list. */
items: T[],
/** The keys of the currently selected items in the list. */
Expand All @@ -51,7 +51,7 @@ interface AsyncListLoadOptions<T, C> {
loadingState?: LoadingState
}

interface AsyncListStateUpdate<T, C> {
export interface AsyncListStateUpdate<T, C> {
/** The new items to append to the list. */
items: Iterable<T>,
/** The keys to add to the selection. */
Expand Down
Loading