Skip to content

Commit 5b9dde4

Browse files
Merge pull request #2675 from volkanunsal/typescript-typings
Add TypeScript typings
2 parents 657b2b1 + 432f272 commit 5b9dde4

File tree

185 files changed

+10884
-0
lines changed

Some content is hidden

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

185 files changed

+10884
-0
lines changed

components/accordion.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
declare module "@salesforce/design-system-react/components/accordion" {
2+
import React from "react";
3+
type Props = {
4+
/**
5+
* CSS class names to be added to the accordion component. _Tested with snapshot testing._
6+
*/
7+
className?: any[] | Record<string, any> | string;
8+
/**
9+
* HTML id for accordion component. _Tested with snapshot testing._
10+
*/
11+
id?: number | string;
12+
/**
13+
* The panel content for the Accordion component. Accordion panels should be added as <AccordionPanel />. Event handler for the accordion panels should be added to `<AccordionPanel />`. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._
14+
*
15+
* Example:
16+
* ```
17+
* <SLDSAccordion>
18+
* <SLDSAccordionpanel />
19+
* <SLDSAccordionpanel />
20+
* <SLDSAccordionpanel />
21+
* </SLDSAccordion>
22+
* ```
23+
*/
24+
children: React.ReactNode /*.isRequired*/;
25+
};
26+
27+
function Component(props: Props): React.ReactElement;
28+
export default Component;
29+
}

components/accordion/panel.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
declare module '@salesforce/design-system-react/components/accordion/panel' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* The panel content for the Accordion component. Accordion panels should be added as <AccordionPanel />. Event handler for the accordion panels should be added to `<AccordionPanel />`. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._
6+
*/
7+
children?: React.ReactNode;
8+
/**
9+
* Indicates whether item is expanded or not, which should be handled by `onTogglePanel`. _Tested with Mocha framework and snapshot testing._
10+
*/
11+
expanded: boolean /*.isRequired*/;
12+
/**
13+
* Id of the item belonging to this panel. _Tested with snapshot testing._
14+
*/
15+
id: number | string /*.isRequired*/;
16+
/**
17+
* Component that can be passed as prop to `<Panel />`. As an example, a menu dropdown could be used here to handle additional actions for each accordion panel. _Tested with Mocha framework._
18+
*/
19+
panelContentActions?: React.ReactNode;
20+
/**
21+
* Callback that will run whenever there is a keydown on the panel button. Function doesn't change the state of the component.
22+
*/
23+
onKeyDownSummary?: (v: any) => any;
24+
/**
25+
* Callback that will run whenever a panel is toggled. Function should handle state to toggle `expanded` prop. _Tested with Mocha framework._
26+
*/
27+
onTogglePanel: (v: any) => any /*.isRequired*/;
28+
/**
29+
* Ref callback that will pass in panel's `input` tag
30+
*/
31+
refs?: Partial<{
32+
summaryButton?: (v: any) => any;
33+
}>;
34+
/**
35+
* Summary in the span element in the header of this panel. The summary is truncated and so the title element should contain the full text so that it is accessible on hover. _Tested with snapshot testing._
36+
*/
37+
summary: string | React.ReactNode /*.isRequired*/;
38+
/**
39+
* HTML title attribute. _Tested with snapshot testing._
40+
*/
41+
title?: string;
42+
};
43+
44+
function Component(props: Props): React.ReactNode;
45+
export default Component;
46+
}

components/alert.d.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
declare module '@salesforce/design-system-react/components/alert' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* **Assistive text for accessibility**
6+
* This object is merged with the default props object on every render.
7+
* * `closeButton`: This is a visually hidden label for the close button.
8+
* _Tested with snapshot testing._
9+
*/
10+
assistiveText?: Partial<{
11+
closeButton?: string | React.ReactNode;
12+
}>;
13+
/**
14+
* CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames).
15+
* _Tested with snapshot testing._
16+
*/
17+
className?: any[] | Record<string, any> | string;
18+
/**
19+
* Allows user to click a close button. Banners should be dismissible only if they communicate future impact to the system,
20+
* _Tested with snapshot testing._
21+
*/
22+
dismissible?: boolean;
23+
/**
24+
* Icon of type `~/components/icon`. This icon will be cloned and additional props appended. The default icons are:
25+
* * info variant: `utility:info`
26+
* * error variant: `utility:error`
27+
* * offline variant: `utility:offline`
28+
* * warning variant: `utility:warning`
29+
*
30+
* _Tested with snapshot testing._
31+
*/
32+
icon?: React.ReactNode;
33+
/**
34+
* **Text labels for internationalization**
35+
* This object is merged with the default props object on every render.
36+
* * `heading`: text within heading tag
37+
* * `headingLink`: Text of link that triggers `onClickHeadingLink`. Inline links should pass a keyed array of React components into `labels.heading`.
38+
*
39+
* _Tested with snapshot testing._
40+
*/
41+
labels?: Partial<{
42+
heading?: string | React.ReactNode;
43+
headingLink?: string | React.ReactNode;
44+
}>;
45+
/**
46+
* Triggered by link. _Tested with Mocha testing._
47+
*/
48+
onClickHeadingLink?: (v: any) => any;
49+
/**
50+
* Triggered by close button. This is a controlled component. _Tested with Mocha testing._
51+
*/
52+
onRequestClose?: (v: any) => any;
53+
/**
54+
* Custom styles to be passed to the component. _Tested with Mocha testing._
55+
*/
56+
style?: Record<string, any>;
57+
/**
58+
* The type of alert. _Tested with snapshot testing._
59+
*/
60+
variant: 'error' | 'info' | 'offline' | 'warning' /*.isRequired*/;
61+
};
62+
/**
63+
* Alert banners communicate a state that affects the entire system, not just a feature or page. It persists over a session and appears without the user initiating the action. View [banner guidelines](https://www.lightningdesignsystem.com/guidelines/messaging/components/banners/).
64+
*/
65+
function Component(props: Props): React.ReactElement;
66+
export default Component;
67+
}

components/alert/container.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare module '@salesforce/design-system-react/components/alert/container' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames).
6+
*/
7+
className?: any[] | Record<string, any> | string;
8+
/**
9+
* Alert components
10+
*/
11+
children?: React.ReactNode;
12+
};
13+
/**
14+
* A fixed container for alert banners.
15+
*/
16+
function Component(props: Props): React.ReactNode;
17+
export default Component;
18+
}

components/app-launcher.d.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
declare module '@salesforce/design-system-react/components/app-launcher' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* **Assistive text for accessibility.**
6+
* This object is merged with the default props object on every render.
7+
* * `trigger`: This is a visually hidden label for the app launcher icon.
8+
*/
9+
assistiveText?: Partial<{
10+
trigger?: string;
11+
}>;
12+
/**
13+
* Boolean indicating if the appElement should be hidden.
14+
*/
15+
ariaHideApp?: boolean;
16+
/**
17+
* One or more `<AppLauncherExpandableSection />`s, each containing one or more `<AppLauncherTile />`s or `<AppLauncherLink />`s
18+
*/
19+
children: React.ReactNode /*.isRequired*/;
20+
/**
21+
* The app launcher id. If not provided, one will be generated for accessibility
22+
*/
23+
id?: string;
24+
/**
25+
* Control the open/close state of the App Launcher
26+
*/
27+
isOpen?: boolean;
28+
/**
29+
* CSS classes to be added to App Launcher Modal.
30+
*/
31+
modalClassName?: any[] | Record<string, any> | string;
32+
/**
33+
* Button that exists in the upper right hand corner of the App Launcher modal
34+
*/
35+
modalHeaderButton?: React.ReactNode;
36+
/**
37+
* Allows longer application names without truncating them.
38+
*/
39+
noTruncate?: boolean;
40+
/**
41+
* Callback when the App Launcher Modal is closed
42+
*/
43+
onClose?: (v: any) => any;
44+
/**
45+
* Search bar for the Modal's header. Will typically be an instance of `design-system-react/input/search`
46+
*/
47+
search?: React.ReactNode;
48+
/**
49+
* Set the App Launcher's title text (for localization)
50+
*/
51+
title?: string;
52+
/**
53+
* This is typically the name of the cloud or application
54+
*/
55+
triggerName?: React.ReactNode;
56+
/**
57+
* Callback when the App Launcher icon is clicked
58+
*/
59+
triggerOnClick?: (v: any) => any;
60+
};
61+
/**
62+
* The App Launcher allows the user to quickly access all the apps and functionality with their organization.
63+
* The App Launcher should generally only be used as a sub-component of the [Global Navigation Bar](/components/global-navigation-bar)
64+
*
65+
* USAGE EXAMPLE:
66+
* ```
67+
* <AppLauncher>
68+
* <AppLauncherExpandableSection>
69+
* <AppLauncherTile />
70+
* <AppLauncherTile />
71+
* <AppLauncherTile />
72+
* </AppLauncherExpandableSection>
73+
* <AppLauncherExpandableSection>
74+
* <AppLauncherTile />
75+
* <AppLauncherTile />
76+
* </AppLauncherExpandableSection>
77+
* </AppLauncher>
78+
* ```
79+
*
80+
* By default, `Modal`, a child component of App Launcher, will add `aria-hidden=true` to the `body` tag, but this disables some assistive technologies. To prevent this you can add the following to your application with `#mount` being the root node of your application that you would like to hide from assistive technologies when the `Modal` is open.
81+
* ```
82+
* import settings from 'design-system-react/components/settings';
83+
* settings.setAppElement('#mount');
84+
* ```
85+
*/
86+
function Component(props: Props): React.ReactElement;
87+
export default Component;
88+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
declare module '@salesforce/design-system-react/components/app-launcher/expandable-section' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* **Assistive text for accessibility.**
6+
* * `toggleSection`: Label for the icon that expands / collapses the section
7+
*/
8+
assistiveText?: Partial<{
9+
toggleSection?: string;
10+
}>;
11+
/**
12+
* Contents of the section
13+
*/
14+
children?: React.ReactNode;
15+
/**
16+
* Class names to be added to the `slds-section` classed node
17+
*/
18+
className?: any[] | Record<string, any> | string;
19+
/**
20+
* Unique identifier for the expandable section. The id is automatically generated if not provided
21+
*/
22+
id?: string;
23+
/**
24+
* Specifies whether the section is expanded or collapsed. If not provided, component will use its own state to manage this itself
25+
*/
26+
isOpen?: boolean;
27+
/**
28+
* Specifies whether the section can be expanded or collapsed. Defaults to `false`
29+
*/
30+
nonCollapsible?: boolean;
31+
/**
32+
* Callback for when the section is expanded or collapsed. Passes event object and data object with `isOpen` bool.
33+
*/
34+
onToggleOpen?: (v: any) => any;
35+
/**
36+
* The title for the section
37+
*/
38+
title: string /*.isRequired*/;
39+
};
40+
/**
41+
* App Launcher Sections allow users to categorize App Tiles & Links as well as toggle their display. It is a superset of components/expandable-section with content formatting.
42+
* All Expandable Section props are compatible with props passed to this component.
43+
*/
44+
function Component(props: Props): React.ReactNode;
45+
export default Component;
46+
}

components/app-launcher/link.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
declare module '@salesforce/design-system-react/components/app-launcher/link' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* Contents of the link
6+
*/
7+
children?: React.ReactNode;
8+
/**
9+
* Classes to be applied to the link
10+
*/
11+
className?: any[] | Record<string, any> | string;
12+
/**
13+
* The `href` attribute of the link. If the `onClick` callback is specified this URL will be prevented from changing the browser's location.
14+
*/
15+
href?: string;
16+
/**
17+
* Callback for when the link is clicked. Passes back event and data object with href prop. Prevents click from changing browser's location if set.
18+
*/
19+
onClick?: (v: any) => any;
20+
/**
21+
* Text used to highlight content in link
22+
*/
23+
search?: string;
24+
/**
25+
* The title for the link. If not provided it will attempt to use child content if that content is a string.
26+
*/
27+
title?: string;
28+
};
29+
/**
30+
* App Launcher Link component creates simple links to be used in "All Items" sections
31+
*/
32+
function Component(props: Props): React.ReactNode;
33+
export default Component;
34+
}

components/app-launcher/section.d.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
declare module '@salesforce/design-system-react/components/app-launcher/section' {
2+
import React from 'react';
3+
type Props = {
4+
/**
5+
* **Assistive text for accessibility.**
6+
* This object is merged with the default props object on every render.
7+
* * `collapseSection`: The assistive text for the section collapse icons.
8+
*/
9+
10+
assistiveText?: Partial<{
11+
collapseSection?: string;
12+
}>;
13+
/**
14+
* The title for this section of apps
15+
*/
16+
17+
title: string /*.isRequired*/;
18+
/**
19+
* Allows the user to show/hide the section
20+
*/
21+
22+
toggleable?: boolean;
23+
/**
24+
* An array of applications to display
25+
*/
26+
27+
children: React.ReactNode /*.isRequired*/;
28+
/**
29+
* Controls the open/closed state of the section
30+
*/
31+
32+
isOpen?: boolean;
33+
/**
34+
* Callback for when section is toggled. Passes "isOpen" bool. Forces `toggleable` to true
35+
*/
36+
37+
onToggleClick?: (v: any) => any;
38+
};
39+
/**
40+
* App Launcher Sections allow users to categorize App Tiles as well as toggle their display
41+
*/
42+
function Component(props: Props): React.ReactNode;
43+
export default Component;
44+
}

0 commit comments

Comments
 (0)