Skip to content

Commit

Permalink
Deprecate IHotkeyProps, IDocumentationProps, IExampleMap (#6223)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jun 14, 2023
1 parent 96966bb commit 228847c
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 24 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/components/hotkeys/hotkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ import { AbstractPureComponent2, Classes, DISPLAYNAME_PREFIX, Props } from "../.
import { HotkeyConfig } from "../../hooks";
import { KeyComboTag } from "./keyComboTag";

/** @deprecated */
export type IHotkeyProps = Props & HotkeyConfig;
// eslint-disable-next-line deprecation/deprecation
export type HotkeyProps = IHotkeyProps;

/**
* Hotkey component.
*
* @see https://blueprintjs.com/docs/#core/components/hotkeys
*/
export class Hotkey extends AbstractPureComponent2<IHotkeyProps> {
export class Hotkey extends AbstractPureComponent2<HotkeyProps> {
public static displayName = `${DISPLAYNAME_PREFIX}.Hotkey`;

public static defaultProps = {
Expand All @@ -51,7 +54,7 @@ export class Hotkey extends AbstractPureComponent2<IHotkeyProps> {
);
}

protected validateProps(props: IHotkeyProps) {
protected validateProps(props: HotkeyProps) {
if (props.global !== true && props.group == null) {
console.error("non-global <Hotkey>s must define a group");
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/hotkeys/hotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { AbstractPureComponent2, Classes, DISPLAYNAME_PREFIX } from "../../commo
import { HOTKEYS_HOTKEY_CHILDREN } from "../../common/errors";
import { isElementOfType, isReactChildrenElementOrElements } from "../../common/utils";
import { H4 } from "../html/html";
import { Hotkey, IHotkeyProps } from "./hotkey";
import { Hotkey, HotkeyProps } from "./hotkey";
import { IHotkeysProps } from "./hotkeysTypes";

/**
Expand All @@ -43,7 +43,7 @@ export class Hotkeys extends AbstractPureComponent2<IHotkeysProps> {

const hotkeys = React.Children.map(
this.props.children,
(child: React.ReactElement<IHotkeyProps>) => child.props,
(child: React.ReactElement<HotkeyProps>) => child.props,
);

// sort by group label alphabetically, prioritize globals
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/components/hotkeys/hotkeysDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as ReactDOM from "react-dom";

import { Classes } from "../../common";
import { Dialog, DialogBody, DialogProps } from "../../components";
import { Hotkey, IHotkeyProps } from "./hotkey";
import { Hotkey, HotkeyProps } from "./hotkey";
import { Hotkeys } from "./hotkeys";

export interface IHotkeysDialogProps extends DialogProps {
Expand All @@ -44,7 +44,7 @@ class HotkeysDialog {

private container: HTMLElement | null = null;

private hotkeysQueue = [] as IHotkeyProps[][];
private hotkeysQueue = [] as HotkeyProps[][];

private isDialogShowing = false;

Expand Down Expand Up @@ -75,7 +75,7 @@ class HotkeysDialog {
* 10msec after the last listener adds their hotkeys, we render the dialog
* and clear the queue.
*/
public enqueueHotkeysForDisplay(hotkeys: IHotkeyProps[]) {
public enqueueHotkeysForDisplay(hotkeys: HotkeyProps[]) {
this.hotkeysQueue.push(hotkeys);

// reset timeout for debounce
Expand Down Expand Up @@ -159,7 +159,7 @@ export function setHotkeysDialogProps(props: Partial<IHotkeysDialogProps>) {
}
}

export function showHotkeysDialog(hotkeys: IHotkeyProps[]) {
export function showHotkeysDialog(hotkeys: HotkeyProps[]) {
HOTKEYS_DIALOG.enqueueHotkeysForDisplay(hotkeys);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/components/hotkeys/hotkeysEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Children, ReactNode } from "react";

import { isElementOfType } from "../../common/utils";
import { Hotkey, IHotkeyProps } from "./hotkey";
import { Hotkey, HotkeyProps } from "./hotkey";
import { comboMatches, getKeyCombo, IKeyCombo, parseKeyCombo } from "./hotkeyParser";
import { hideHotkeysDialogAfterDelay, isHotkeysDialogShowing, showHotkeysDialog } from "./hotkeysDialog";
import { IHotkeysProps } from "./hotkeysTypes";
Expand All @@ -31,7 +31,7 @@ export enum HotkeyScope {

export interface IHotkeyAction {
combo: IKeyCombo;
props: IHotkeyProps;
props: HotkeyProps;
}

export class HotkeysEvents {
Expand Down Expand Up @@ -107,7 +107,7 @@ export class HotkeysEvents {
}
}

private isScope(props: IHotkeyProps) {
private isScope(props: HotkeyProps) {
return (props.global ? HotkeyScope.GLOBAL : HotkeyScope.LOCAL) === this.scope;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/hotkeys/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

export * from "./hotkeysTypes";
export * from "./hotkeys";
export { Hotkey, IHotkeyProps } from "./hotkey";
export { Hotkey, HotkeyProps, IHotkeyProps } from "./hotkey";
export { KeyCombo, KeyComboTag, KeyComboTagProps, IKeyComboProps } from "./keyComboTag";
// eslint-disable-next-line import/no-cycle
export { HotkeysTarget, IHotkeysTargetComponent } from "./hotkeysTarget";
Expand Down
6 changes: 3 additions & 3 deletions packages/docs-app/src/components/blueprintDocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as React from "react";

import { AnchorButton, Classes, HotkeysProvider, Tag } from "@blueprintjs/core";
import { IDocsCompleteData } from "@blueprintjs/docs-data";
import { Banner, Documentation, IDocumentationProps, NavMenuItem, NavMenuItemProps } from "@blueprintjs/docs-theme";
import { Banner, Documentation, DocumentationProps, NavMenuItem, NavMenuItemProps } from "@blueprintjs/docs-theme";

import { highlightCodeBlocks } from "../styles/syntaxHighlighting";
import { NavHeader } from "./navHeader";
Expand Down Expand Up @@ -57,8 +57,8 @@ export function setTheme(themeName: string) {

export interface IBlueprintDocsProps {
docs: IDocsCompleteData;
defaultPageId: IDocumentationProps["defaultPageId"];
tagRenderers: IDocumentationProps["tagRenderers"];
defaultPageId: DocumentationProps["defaultPageId"];
tagRenderers: DocumentationProps["tagRenderers"];
/** Whether to use `next` versions for packages (as opposed to `latest`). */
useNextVersion: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as React from "react";

import { HotkeysTarget2, IHotkeyProps } from "@blueprintjs/core";
import { HotkeyProps, HotkeysTarget2 } from "@blueprintjs/core";
import { Example, ExampleProps } from "@blueprintjs/docs-theme";

import { PianoKey } from "./audio";
Expand Down Expand Up @@ -57,7 +57,7 @@ export class HotkeysTarget2Example extends React.PureComponent<ExampleProps, IHo
};
};

private hotkeys: IHotkeyProps[] = [
private hotkeys: HotkeyProps[] = [
{
combo: "shift + P",
global: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/docs-app/src/tags/reactExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as React from "react";

import { ExampleProps, IExampleMap } from "@blueprintjs/docs-theme";
import { ExampleMap, ExampleProps } from "@blueprintjs/docs-theme";

import { getTheme } from "../components/blueprintDocs";
import * as CoreExamples from "../examples/core-examples";
Expand All @@ -34,7 +34,7 @@ function getPackageExamples(
packageName: string,
packageExamples: { [name: string]: React.ComponentClass<ExampleProps<IBlueprintExampleData>> },
) {
const ret: IExampleMap = {};
const ret: ExampleMap = {};
for (const exampleName of Object.keys(packageExamples)) {
const example = packageExamples[exampleName];
const fileName = exampleName.charAt(0).toLowerCase() + exampleName.slice(1) + ".tsx";
Expand All @@ -46,7 +46,7 @@ function getPackageExamples(
return ret;
}

export const reactExamples: IExampleMap = (() => {
export const reactExamples: ExampleMap = (() => {
return {
...getPackageExamples("core", CoreExamples as any),
...getPackageExamples("datetime", DateExamples as any),
Expand Down
10 changes: 7 additions & 3 deletions packages/docs-theme/src/components/documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { Page } from "./page";
import { addScrollbarStyle } from "./scrollbar";
import { ApiLink } from "./typescript/apiLink";

/** @deprecated use DocumentationProps */
export interface IDocumentationProps extends Props {
/**
* An element to place above the documentation, along the top of the viewport.
Expand Down Expand Up @@ -108,6 +109,9 @@ export interface IDocumentationProps extends Props {
tagRenderers: TagRendererMap;
}

// eslint-disable-next-line deprecation/deprecation
export type DocumentationProps = IDocumentationProps;

export interface IDocumentationState {
activeApiMember: string;
activePageId: string;
Expand All @@ -116,7 +120,7 @@ export interface IDocumentationState {
isNavigatorOpen: boolean;
}

export class Documentation extends React.PureComponent<IDocumentationProps, IDocumentationState> {
export class Documentation extends React.PureComponent<DocumentationProps, IDocumentationState> {
public static childContextTypes = DocumentationContextTypes;

/** Map of section route to containing page reference. */
Expand All @@ -131,7 +135,7 @@ export class Documentation extends React.PureComponent<IDocumentationProps, IDoc
nav: (ref: HTMLElement) => (this.navElement = ref),
};

public constructor(props: IDocumentationProps) {
public constructor(props: DocumentationProps) {
super(props);
this.state = {
activeApiMember: "",
Expand Down Expand Up @@ -271,7 +275,7 @@ export class Documentation extends React.PureComponent<IDocumentationProps, IDoc
document.removeEventListener("scroll", this.handleScroll);
}

public componentDidUpdate(_prevProps: IDocumentationProps, prevState: IDocumentationState) {
public componentDidUpdate(_prevProps: DocumentationProps, prevState: IDocumentationState) {
const { activePageId } = this.state;

// only scroll to heading when switching pages, but always check if nav item needs scrolling.
Expand Down
5 changes: 4 additions & 1 deletion packages/docs-theme/src/tags/reactExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ export interface IExample {

// construct a map of package name to all examples defined in that package.
// packageName must match directory name as it is used to generate sourceUrl.
/** @deprecated use ExampleMap */
export interface IExampleMap {
[componentName: string]: IExample;
}
// eslint-disable-next-line deprecation/deprecation
export type ExampleMap = IExampleMap;

export class ReactExampleTagRenderer {
constructor(private examples: IExampleMap) {}
constructor(private examples: ExampleMap) {}

/**
* Given the name of an example component, like `"AlertExample"`, attempts to resolve
Expand Down

1 comment on commit 228847c

@adidahiya
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate IHotkeyProps, IDocumentationProps, IExampleMap (#6223)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.