mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
adds typings for react-aria-live (#37996)
* adds typings for react-aria-live * added typescript version * formatting * fixed lint error * updated return type of LiveMessenger children * formatting
This commit is contained in:
committed by
Ron Buckton
parent
21e7a33c41
commit
bd8c74539c
25
types/react-aria-live/index.d.ts
vendored
Normal file
25
types/react-aria-live/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for react-aria-live 2.0
|
||||
// Project: https://github.com/AlmeroSteyn/react-aria-live#readme
|
||||
// Definitions by: AJ Livingston <https://github.com/ajliv>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export class LiveAnnouncer extends React.Component {
|
||||
announcePolite(message: string, id?: string): void;
|
||||
announceAssertive(message: string, id?: string): void;
|
||||
}
|
||||
|
||||
export const LiveMessage: React.StatelessComponent<{
|
||||
'aria-live': 'assertive' | 'polite';
|
||||
clearOnUnmount?: boolean | 'true' | 'false';
|
||||
message: string;
|
||||
}>;
|
||||
|
||||
export const LiveMessenger: React.StatelessComponent<{
|
||||
children(contextProps: {
|
||||
announceAssertive(message: string, id?: string): void;
|
||||
announcePolite(message: string, id?: string): void;
|
||||
}): React.ReactNode;
|
||||
}>;
|
||||
39
types/react-aria-live/react-aria-live-tests.tsx
Normal file
39
types/react-aria-live/react-aria-live-tests.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
|
||||
import { LiveAnnouncer, LiveMessage, LiveMessenger } from 'react-aria-live';
|
||||
|
||||
render(
|
||||
<LiveAnnouncer>
|
||||
<LiveMessage
|
||||
aria-live='polite'
|
||||
message='hello'
|
||||
clearOnUnmount
|
||||
/>
|
||||
</LiveAnnouncer>,
|
||||
document.getElementById('main')
|
||||
);
|
||||
|
||||
render(
|
||||
<LiveAnnouncer>
|
||||
<LiveMessenger>
|
||||
{({ announcePolite, announceAssertive }) =>
|
||||
<>
|
||||
<button
|
||||
onClick={() => {
|
||||
announcePolite('Polite message');
|
||||
}}>
|
||||
Press me for a polite message
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
announceAssertive('Assertive message', 'UniqueId');
|
||||
}}>
|
||||
Press me for an assertive message
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
</LiveMessenger>
|
||||
</LiveAnnouncer>,
|
||||
document.getElementById('main')
|
||||
);
|
||||
25
types/react-aria-live/tsconfig.json
Normal file
25
types/react-aria-live/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-aria-live-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-aria-live/tslint.json
Normal file
1
types/react-aria-live/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user