Skip to content

Add TypeScript typings #2675

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

Merged
merged 1 commit into from
Jan 22, 2021
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
29 changes: 29 additions & 0 deletions components/accordion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
declare module "@salesforce/design-system-react/components/accordion" {
import React from "react";
type Props = {
/**
* CSS class names to be added to the accordion component. _Tested with snapshot testing._
*/
className?: any[] | Record<string, any> | string;
/**
* HTML id for accordion component. _Tested with snapshot testing._
*/
id?: number | string;
/**
* 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._
*
* Example:
* ```
* <SLDSAccordion>
* <SLDSAccordionpanel />
* <SLDSAccordionpanel />
* <SLDSAccordionpanel />
* </SLDSAccordion>
* ```
*/
children: React.ReactNode /*.isRequired*/;
};

function Component(props: Props): React.ReactElement;
export default Component;
}
46 changes: 46 additions & 0 deletions components/accordion/panel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
declare module '@salesforce/design-system-react/components/accordion/panel' {
import React from 'react';
type Props = {
/**
* 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._
*/
children?: React.ReactNode;
/**
* Indicates whether item is expanded or not, which should be handled by `onTogglePanel`. _Tested with Mocha framework and snapshot testing._
*/
expanded: boolean /*.isRequired*/;
/**
* Id of the item belonging to this panel. _Tested with snapshot testing._
*/
id: number | string /*.isRequired*/;
/**
* 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._
*/
panelContentActions?: React.ReactNode;
/**
* Callback that will run whenever there is a keydown on the panel button. Function doesn't change the state of the component.
*/
onKeyDownSummary?: (v: any) => any;
/**
* Callback that will run whenever a panel is toggled. Function should handle state to toggle `expanded` prop. _Tested with Mocha framework._
*/
onTogglePanel: (v: any) => any /*.isRequired*/;
/**
* Ref callback that will pass in panel's `input` tag
*/
refs?: Partial<{
summaryButton?: (v: any) => any;
}>;
/**
* 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._
*/
summary: string | React.ReactNode /*.isRequired*/;
/**
* HTML title attribute. _Tested with snapshot testing._
*/
title?: string;
};

function Component(props: Props): React.ReactNode;
export default Component;
}
67 changes: 67 additions & 0 deletions components/alert.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
declare module '@salesforce/design-system-react/components/alert' {
import React from 'react';
type Props = {
/**
* **Assistive text for accessibility**
* This object is merged with the default props object on every render.
* * `closeButton`: This is a visually hidden label for the close button.
* _Tested with snapshot testing._
*/
assistiveText?: Partial<{
closeButton?: string | React.ReactNode;
}>;
/**
* CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames).
* _Tested with snapshot testing._
*/
className?: any[] | Record<string, any> | string;
/**
* Allows user to click a close button. Banners should be dismissible only if they communicate future impact to the system,
* _Tested with snapshot testing._
*/
dismissible?: boolean;
/**
* Icon of type `~/components/icon`. This icon will be cloned and additional props appended. The default icons are:
* * info variant: `utility:info`
* * error variant: `utility:error`
* * offline variant: `utility:offline`
* * warning variant: `utility:warning`
*
* _Tested with snapshot testing._
*/
icon?: React.ReactNode;
/**
* **Text labels for internationalization**
* This object is merged with the default props object on every render.
* * `heading`: text within heading tag
* * `headingLink`: Text of link that triggers `onClickHeadingLink`. Inline links should pass a keyed array of React components into `labels.heading`.
*
* _Tested with snapshot testing._
*/
labels?: Partial<{
heading?: string | React.ReactNode;
headingLink?: string | React.ReactNode;
}>;
/**
* Triggered by link. _Tested with Mocha testing._
*/
onClickHeadingLink?: (v: any) => any;
/**
* Triggered by close button. This is a controlled component. _Tested with Mocha testing._
*/
onRequestClose?: (v: any) => any;
/**
* Custom styles to be passed to the component. _Tested with Mocha testing._
*/
style?: Record<string, any>;
/**
* The type of alert. _Tested with snapshot testing._
*/
variant: 'error' | 'info' | 'offline' | 'warning' /*.isRequired*/;
};
/**
* 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/).
*/
function Component(props: Props): React.ReactElement;
export default Component;
}
18 changes: 18 additions & 0 deletions components/alert/container.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare module '@salesforce/design-system-react/components/alert/container' {
import React from 'react';
type Props = {
/**
* CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames).
*/
className?: any[] | Record<string, any> | string;
/**
* Alert components
*/
children?: React.ReactNode;
};
/**
* A fixed container for alert banners.
*/
function Component(props: Props): React.ReactNode;
export default Component;
}
88 changes: 88 additions & 0 deletions components/app-launcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
declare module '@salesforce/design-system-react/components/app-launcher' {
import React from 'react';
type Props = {
/**
* **Assistive text for accessibility.**
* This object is merged with the default props object on every render.
* * `trigger`: This is a visually hidden label for the app launcher icon.
*/
assistiveText?: Partial<{
trigger?: string;
}>;
/**
* Boolean indicating if the appElement should be hidden.
*/
ariaHideApp?: boolean;
/**
* One or more `<AppLauncherExpandableSection />`s, each containing one or more `<AppLauncherTile />`s or `<AppLauncherLink />`s
*/
children: React.ReactNode /*.isRequired*/;
/**
* The app launcher id. If not provided, one will be generated for accessibility
*/
id?: string;
/**
* Control the open/close state of the App Launcher
*/
isOpen?: boolean;
/**
* CSS classes to be added to App Launcher Modal.
*/
modalClassName?: any[] | Record<string, any> | string;
/**
* Button that exists in the upper right hand corner of the App Launcher modal
*/
modalHeaderButton?: React.ReactNode;
/**
* Allows longer application names without truncating them.
*/
noTruncate?: boolean;
/**
* Callback when the App Launcher Modal is closed
*/
onClose?: (v: any) => any;
/**
* Search bar for the Modal's header. Will typically be an instance of `design-system-react/input/search`
*/
search?: React.ReactNode;
/**
* Set the App Launcher's title text (for localization)
*/
title?: string;
/**
* This is typically the name of the cloud or application
*/
triggerName?: React.ReactNode;
/**
* Callback when the App Launcher icon is clicked
*/
triggerOnClick?: (v: any) => any;
};
/**
* The App Launcher allows the user to quickly access all the apps and functionality with their organization.
* The App Launcher should generally only be used as a sub-component of the [Global Navigation Bar](/components/global-navigation-bar)
*
* USAGE EXAMPLE:
* ```
* <AppLauncher>
* <AppLauncherExpandableSection>
* <AppLauncherTile />
* <AppLauncherTile />
* <AppLauncherTile />
* </AppLauncherExpandableSection>
* <AppLauncherExpandableSection>
* <AppLauncherTile />
* <AppLauncherTile />
* </AppLauncherExpandableSection>
* </AppLauncher>
* ```
*
* 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.
* ```
* import settings from 'design-system-react/components/settings';
* settings.setAppElement('#mount');
* ```
*/
function Component(props: Props): React.ReactElement;
export default Component;
}
46 changes: 46 additions & 0 deletions components/app-launcher/expandable-section.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
declare module '@salesforce/design-system-react/components/app-launcher/expandable-section' {
import React from 'react';
type Props = {
/**
* **Assistive text for accessibility.**
* * `toggleSection`: Label for the icon that expands / collapses the section
*/
assistiveText?: Partial<{
toggleSection?: string;
}>;
/**
* Contents of the section
*/
children?: React.ReactNode;
/**
* Class names to be added to the `slds-section` classed node
*/
className?: any[] | Record<string, any> | string;
/**
* Unique identifier for the expandable section. The id is automatically generated if not provided
*/
id?: string;
/**
* Specifies whether the section is expanded or collapsed. If not provided, component will use its own state to manage this itself
*/
isOpen?: boolean;
/**
* Specifies whether the section can be expanded or collapsed. Defaults to `false`
*/
nonCollapsible?: boolean;
/**
* Callback for when the section is expanded or collapsed. Passes event object and data object with `isOpen` bool.
*/
onToggleOpen?: (v: any) => any;
/**
* The title for the section
*/
title: string /*.isRequired*/;
};
/**
* 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.
* All Expandable Section props are compatible with props passed to this component.
*/
function Component(props: Props): React.ReactNode;
export default Component;
}
34 changes: 34 additions & 0 deletions components/app-launcher/link.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare module '@salesforce/design-system-react/components/app-launcher/link' {
import React from 'react';
type Props = {
/**
* Contents of the link
*/
children?: React.ReactNode;
/**
* Classes to be applied to the link
*/
className?: any[] | Record<string, any> | string;
/**
* The `href` attribute of the link. If the `onClick` callback is specified this URL will be prevented from changing the browser's location.
*/
href?: string;
/**
* 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.
*/
onClick?: (v: any) => any;
/**
* Text used to highlight content in link
*/
search?: string;
/**
* The title for the link. If not provided it will attempt to use child content if that content is a string.
*/
title?: string;
};
/**
* App Launcher Link component creates simple links to be used in "All Items" sections
*/
function Component(props: Props): React.ReactNode;
export default Component;
}
44 changes: 44 additions & 0 deletions components/app-launcher/section.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
declare module '@salesforce/design-system-react/components/app-launcher/section' {
import React from 'react';
type Props = {
/**
* **Assistive text for accessibility.**
* This object is merged with the default props object on every render.
* * `collapseSection`: The assistive text for the section collapse icons.
*/

assistiveText?: Partial<{
collapseSection?: string;
}>;
/**
* The title for this section of apps
*/

title: string /*.isRequired*/;
/**
* Allows the user to show/hide the section
*/

toggleable?: boolean;
/**
* An array of applications to display
*/

children: React.ReactNode /*.isRequired*/;
/**
* Controls the open/closed state of the section
*/

isOpen?: boolean;
/**
* Callback for when section is toggled. Passes "isOpen" bool. Forces `toggleable` to true
*/

onToggleClick?: (v: any) => any;
};
/**
* App Launcher Sections allow users to categorize App Tiles as well as toggle their display
*/
function Component(props: Props): React.ReactNode;
export default Component;
}
Loading