Skip to content

Commit e4ea723

Browse files
authored
fix: Add some missing TS exports (adobe#9836)
* export some additional types * Fix tokens types * we don't need the spread
1 parent a911b98 commit e4ea723

File tree

11 files changed

+31
-22
lines changed

11 files changed

+31
-22
lines changed

packages/@adobe/react-spectrum/exports/Toast.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

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

17-
export type {SpectrumToastOptions, SpectrumToastContainerProps} from '../src/toast/ToastContainer';
17+
export type {SpectrumToastOptions, SpectrumToastContainerProps, CloseFunction} from '../src/toast/ToastContainer';

packages/@adobe/react-spectrum/src/toast/ToastContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface SpectrumToastOptions extends ToastOptions, DOMProps {
3737
shouldCloseOnAction?: boolean
3838
}
3939

40-
type CloseFunction = () => void;
40+
export type CloseFunction = () => void;
4141

4242
function wrapInViewTransition(fn: () => void): void {
4343
if ('startViewTransition' in document) {

packages/@internationalized/date/src/CalendarDate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} fro
1717
import {GregorianCalendar} from './calendars/GregorianCalendar';
1818
import {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';
1919

20+
export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
21+
2022
function shiftArgs(args: any[]) {
2123
let calendar: Calendar = typeof args[0] === 'object'
2224
? args.shift()

packages/@internationalized/date/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type {
2727
CycleOptions,
2828
CycleTimeOptions
2929
} from './types';
30+
export type {DateValue} from './CalendarDate';
3031

3132
export {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';
3233
export {GregorianCalendar} from './calendars/GregorianCalendar';

packages/@internationalized/date/src/queries.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
*/
1212

1313
import {AnyCalendarDate, AnyTime, Calendar} from './types';
14-
import {CalendarDate, CalendarDateTime, ZonedDateTime} from './CalendarDate';
14+
import {CalendarDate, CalendarDateTime, DateValue, ZonedDateTime} from './CalendarDate';
1515
import {fromAbsolute, toAbsolute, toCalendar, toCalendarDate} from './conversion';
1616
import {weekStartData} from './weekStartData';
1717

18-
type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
19-
2018
/** Returns whether the given dates occur on the same day, regardless of the time or calendar system. */
2119
export function isSameDay(a: DateValue, b: DateValue): boolean {
2220
b = toCalendar(b, a.calendar);

packages/@react-spectrum/s2/style/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const focusRing = () => ({
8686
outlineOffset: 2
8787
} as const);
8888

89-
interface IconStyle {
89+
export interface IconStyle {
9090
size?: 'XS' | 'S' | 'M' | 'L' |'XL',
9191
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',
9292
margin?: Spacing,

packages/@react-spectrum/s2/style/tokens.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313
// package.json in this directory is not the real package.json. Lint rule not smart enough.
1414
import assert from 'assert';
1515
// eslint-disable-next-line rulesdir/imports
16-
import * as tokens from '@adobe/spectrum-tokens/dist/json/variables.json';
16+
import * as originalTokens from '@adobe/spectrum-tokens/dist/json/variables.json';
1717

18-
export function getToken(name: keyof typeof tokens): string {
18+
// This forces TSC to inline the token keys instead of leaving a dependency on it.
19+
function keys<T extends Record<string, any>>(v: T): Record<keyof T, any> {
20+
return v;
21+
}
22+
23+
const tokens = keys(originalTokens);
24+
type TokenName = keyof typeof tokens;
25+
26+
export function getToken(name: TokenName): string {
1927
return (tokens[name] as any).value;
2028
}
2129

@@ -26,7 +34,7 @@ export interface ColorToken {
2634
forcedColors?: string
2735
}
2836

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

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

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

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

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

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

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

165173
let index = indexes[name];

packages/@react-spectrum/toast/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

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

17-
export type {SpectrumToastOptions, SpectrumToastContainerProps} from '@adobe/react-spectrum/Toast';
17+
export type {SpectrumToastOptions, SpectrumToastContainerProps, CloseFunction} from '@adobe/react-spectrum/Toast';

packages/@react-stately/data/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export {useAsyncList} from 'react-stately/useAsyncList';
1515
export {useTreeData} from 'react-stately/useTreeData';
1616
export {useListData} from 'react-stately/useListData';
1717
export type {ListOptions, ListData} from 'react-stately/useListData';
18-
export type {AsyncListOptions, AsyncListData} from 'react-stately/useAsyncList';
18+
export type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from 'react-stately/useAsyncList';
1919
export type {TreeOptions, TreeData} from 'react-stately/useTreeData';

packages/react-stately/exports/useAsyncList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
*/
1212

1313
export {useAsyncList} from '../src/data/useAsyncList';
14-
export type {AsyncListOptions, AsyncListData} from '../src/data/useAsyncList';
14+
export type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from '../src/data/useAsyncList';

0 commit comments

Comments
 (0)