@raycast/api 1.26.2 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/arm64/ray +0 -0
- package/bin/x86/ray +0 -0
- package/package.json +3 -3
- package/types/api/app/app.d.ts +171 -0
- package/types/api/app/clipboard.d.ts +47 -0
- package/types/api/app/index.d.ts +4 -0
- package/types/api/app/keyboard.d.ts +56 -0
- package/types/api/app/localStorage.d.ts +117 -0
- package/types/api/components/ActionPanel.d.ts +297 -0
- package/types/api/components/Detail.d.ts +40 -0
- package/types/api/components/Form.d.ts +992 -0
- package/types/api/components/List.d.ts +275 -0
- package/types/api/components/actions/Action.d.ts +396 -0
- package/types/api/components/actions/CopyToClipboardAction.d.ts +39 -0
- package/types/api/components/actions/OpenAction.d.ts +47 -0
- package/types/api/components/actions/OpenInBrowserAction.d.ts +42 -0
- package/types/api/components/actions/OpenWithAction.d.ts +40 -0
- package/types/api/components/actions/PasteAction.d.ts +39 -0
- package/types/api/components/actions/PushAction.d.ts +38 -0
- package/types/api/components/actions/ShowInFinderAction.d.ts +42 -0
- package/types/api/components/actions/SubmitFormAction.d.ts +34 -0
- package/types/api/components/actions/TrashAction.d.ts +43 -0
- package/types/api/components/actions/index.d.ts +1 -0
- package/types/api/components/index.d.ts +5 -0
- package/types/api/components/propTypes.d.ts +1 -0
- package/types/api/components/types.d.ts +30 -0
- package/types/api/deprecated.d.ts +410 -0
- package/types/api/environment/environment.d.ts +48 -0
- package/types/api/environment/index.d.ts +3 -0
- package/types/api/environment/preferences.d.ts +31 -0
- package/types/api/environment/workspace.d.ts +62 -0
- package/types/api/hooks/index.d.ts +1 -0
- package/types/api/hooks/useNavigation.d.ts +66 -0
- package/types/api/index.d.ts +6 -0
- package/types/api/internal/comm/index.d.ts +1 -0
- package/types/api/internal/components/ErrorBoundary.d.ts +1 -0
- package/types/api/internal/components/Navigation.d.ts +1 -0
- package/types/api/internal/components/Root.d.ts +1 -0
- package/types/api/internal/components/index.d.ts +4 -0
- package/types/api/internal/components/portal/components/portal/Portal.d.ts +4 -0
- package/types/api/internal/components/portal/components/portal/index.d.ts +1 -0
- package/types/api/internal/components/portal/components/portalHost/PortalHost.d.ts +4 -0
- package/types/api/internal/components/portal/components/portalHost/index.d.ts +1 -0
- package/types/api/internal/components/portal/components/portalProvider/PortalProvider.d.ts +4 -0
- package/types/api/internal/components/portal/components/portalProvider/index.d.ts +1 -0
- package/types/api/internal/components/portal/contexts/index.d.ts +1 -0
- package/types/api/internal/components/portal/contexts/portal.d.ts +5 -0
- package/types/api/internal/components/portal/hooks/index.d.ts +2 -0
- package/types/api/internal/components/portal/hooks/usePortal.d.ts +8 -0
- package/types/api/internal/components/portal/hooks/usePortalState.d.ts +1 -0
- package/types/api/internal/components/portal/index.d.ts +5 -0
- package/types/api/internal/components/portal/state/constants.d.ts +9 -0
- package/types/api/internal/components/portal/state/index.d.ts +3 -0
- package/types/api/internal/components/portal/state/reducer.d.ts +3 -0
- package/types/api/internal/components/portal/utilities/logger.d.ts +9 -0
- package/types/api/internal/devtools/index.d.ts +1 -0
- package/types/api/internal/devtools/react.d.ts +1 -0
- package/types/api/internal/hooks/index.d.ts +2 -0
- package/types/api/internal/hooks/useActionPanel.d.ts +1 -0
- package/types/api/internal/hooks/useId.d.ts +1 -0
- package/types/api/internal/index.d.ts +6 -0
- package/types/api/internal/rendering/callbacks.d.ts +1 -0
- package/types/api/internal/rendering/index.d.ts +5 -0
- package/types/api/internal/rendering/node-builders/actions.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/detail.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/forms.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/keyboard.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/list.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/navigationStack.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/root.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/types.d.ts +1 -0
- package/types/api/internal/rendering/node-builders/utils.d.ts +1 -0
- package/types/api/internal/rendering/reconciler.d.ts +1 -0
- package/types/api/internal/rendering/renderer.d.ts +1 -0
- package/types/api/internal/utils/ids.d.ts +1 -0
- package/types/api/internal/utils/index.d.ts +1 -0
- package/types/api/ui/color.d.ts +115 -0
- package/types/api/ui/errors.d.ts +1 -0
- package/types/api/ui/feedback/alert.d.ts +97 -0
- package/types/api/ui/feedback/hud.d.ts +16 -0
- package/types/api/ui/feedback/index.d.ts +3 -0
- package/types/api/ui/feedback/toast.d.ts +171 -0
- package/types/api/ui/icon.d.ts +88 -0
- package/types/api/ui/image.d.ts +161 -0
- package/types/api/ui/index.d.ts +5 -0
- package/types/core/message-types.d.ts +17 -0
- package/types/core/preferences.d.ts +69 -0
- package/types/index.d.ts +2814 -2139
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare const usePortal: (hostName?: string) => {
|
|
3
|
+
registerHost: () => void;
|
|
4
|
+
deregisterHost: () => void;
|
|
5
|
+
addPortal: (name: string, node: ReactNode) => void;
|
|
6
|
+
updatePortal: (name: string, node: ReactNode) => void;
|
|
7
|
+
removePortal: (name: string) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePortalState: (hostName: string) => import("../types").PortalType[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Portal } from './components/portal';
|
|
2
|
+
export { default as PortalHost } from './components/portalHost';
|
|
3
|
+
export { default as PortalProvider } from './components/portalProvider';
|
|
4
|
+
export { usePortal } from './hooks/usePortal';
|
|
5
|
+
export { enableLogging } from './utilities/logger';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface PrintOptions {
|
|
2
|
+
component?: string;
|
|
3
|
+
method?: string;
|
|
4
|
+
params?: Record<string, any> | string | number | boolean;
|
|
5
|
+
}
|
|
6
|
+
declare type Print = (options: PrintOptions) => void;
|
|
7
|
+
declare const enableLogging: () => void;
|
|
8
|
+
declare let print: Print;
|
|
9
|
+
export { print, enableLogging };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ids";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The standard colors. Use those colors for consistency.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The colors automatically adapt to the Raycast theme (light or dark).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { Color, Icon, List } from "@raycast/api";
|
|
10
|
+
*
|
|
11
|
+
* export default function Command() {
|
|
12
|
+
* return (
|
|
13
|
+
* <List>
|
|
14
|
+
* <List.Item title="Blue" icon={{ source: Icon.Circle, tintColor: Color.Blue }} />
|
|
15
|
+
* <List.Item title="Green" icon={{ source: Icon.Circle, tintColor: Color.Green }} />
|
|
16
|
+
* <List.Item title="Brown" icon={{ source: Icon.Circle, tintColor: Color.Brown }} />
|
|
17
|
+
* <List.Item title="Magenta" icon={{ source: Icon.Circle, tintColor: Color.Magenta }} />
|
|
18
|
+
* <List.Item title="Orange" icon={{ source: Icon.Circle, tintColor: Color.Orange }} />
|
|
19
|
+
* <List.Item title="Purple" icon={{ source: Icon.Circle, tintColor: Color.Purple }} />
|
|
20
|
+
* <List.Item title="Red" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
|
|
21
|
+
* <List.Item title="Yellow" icon={{ source: Icon.Circle, tintColor: Color.Yellow }} />
|
|
22
|
+
* <List.Item title="PrimaryText" icon={{ source: Icon.Circle, tintColor: Color.PrimaryText }} />
|
|
23
|
+
* <List.Item title="SecondaryText" icon={{ source: Icon.Circle, tintColor: Color.SecondaryText }} />
|
|
24
|
+
* </List>
|
|
25
|
+
* );
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare enum Color {
|
|
30
|
+
Blue = "raycast-blue",
|
|
31
|
+
Brown = "raycast-brown",
|
|
32
|
+
Green = "raycast-green",
|
|
33
|
+
Magenta = "raycast-magenta",
|
|
34
|
+
Orange = "raycast-orange",
|
|
35
|
+
Purple = "raycast-purple",
|
|
36
|
+
Red = "raycast-red",
|
|
37
|
+
Yellow = "raycast-yellow",
|
|
38
|
+
PrimaryText = "raycast-primary-text",
|
|
39
|
+
SecondaryText = "raycast-secondary-text"
|
|
40
|
+
}
|
|
41
|
+
export declare namespace Color {
|
|
42
|
+
/**
|
|
43
|
+
* Union type for the supported color types.
|
|
44
|
+
*
|
|
45
|
+
* {@link Color.Raw} will be dynamically adjusted to achieve high contrast with the Raycast user interface.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { Color, Icon, List } from "@raycast/api";
|
|
50
|
+
*
|
|
51
|
+
* export default function Command() {
|
|
52
|
+
* return (
|
|
53
|
+
* <List>
|
|
54
|
+
* <List.Item title="Built-in color" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
|
|
55
|
+
* <List.Item title="HEX" icon={{ source: Icon.Circle, tintColor: "#FF0000" }} />
|
|
56
|
+
* <List.Item title="Short HEX" icon={{ source: Icon.Circle, tintColor: "#F00" }} />
|
|
57
|
+
* <List.Item title="RGBA" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0)" }} />
|
|
58
|
+
* <List.Item title="RGBA Percentage" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0, 1.0)" }} />
|
|
59
|
+
* <List.Item title="HSL" icon={{ source: Icon.Circle, tintColor: "hsla(200, 20%, 33%, 0.2)" }} />
|
|
60
|
+
* <List.Item title="Keywords" icon={{ source: Icon.Circle, tintColor: "red" }} />
|
|
61
|
+
* </List>
|
|
62
|
+
* );
|
|
63
|
+
* };
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
type ColorLike = Color | Color.Dynamic | Color.Raw;
|
|
67
|
+
/**
|
|
68
|
+
* A dynamic color applies different colors depending on the active Raycast theme.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { Color, Icon, List } from "@raycast/api";
|
|
73
|
+
*
|
|
74
|
+
* export default function Command() {
|
|
75
|
+
* return (
|
|
76
|
+
* <List>
|
|
77
|
+
* <List.Item title="Dynamic Tint Color" icon={{ source: Icon.Circle, tintColor: { light: "#FF01FF", dark: "#FFFF50", adjustContrast: true } }} />
|
|
78
|
+
* <List.Item title="Dynamic Tint Color" icon={{ source: Icon.Circle, tintColor: { light: "#FF01FF", dark: "#FFFF50" } }} />
|
|
79
|
+
* </List>
|
|
80
|
+
* );
|
|
81
|
+
* };
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
interface Dynamic {
|
|
85
|
+
/**
|
|
86
|
+
* The color which is used in light theme.
|
|
87
|
+
*/
|
|
88
|
+
light: Color.Raw;
|
|
89
|
+
/**
|
|
90
|
+
* The color which is used in dark theme.
|
|
91
|
+
*/
|
|
92
|
+
dark: Color.Raw;
|
|
93
|
+
/**
|
|
94
|
+
* Enables dynamic contrast adjustment for light and dark theme color.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Colors different to the built-in {@link Color} can be dynamically adjusted to achieve high contrast with the
|
|
98
|
+
* Raycast user interface. This makes it easy to guarantee a good look and feel when you aren't in control of the
|
|
99
|
+
* color, e.g. get it via a network request.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue false
|
|
102
|
+
*/
|
|
103
|
+
adjustContrast?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* You can use any of the following color formats:
|
|
107
|
+
* - HEX, e.g `#FF0000`
|
|
108
|
+
* - Short HEX, e.g. `#F00`
|
|
109
|
+
* - RGBA, e.g. `rgb(255, 0, 0)`
|
|
110
|
+
* - RGBA Percentage, e.g. `rgb(255, 0, 0, 1.0)`
|
|
111
|
+
* - HSL, e.g. `hsla(200, 20%, 33%, 0.2)`
|
|
112
|
+
* - Keywords, e.g. `red`
|
|
113
|
+
*/
|
|
114
|
+
type Raw = string;
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Image } from "../image";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and shows a confirmation Alert with the given options.
|
|
4
|
+
*
|
|
5
|
+
* @param options - The options used to create the Alert.
|
|
6
|
+
* @returns A Promise that resolves to a boolean when the user takes an action.
|
|
7
|
+
* It will be `true` for the primary Action, `false` for the dismiss Action.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { confirmAlert } from "@raycast/api";
|
|
12
|
+
*
|
|
13
|
+
* export default async () => {
|
|
14
|
+
* if (await confirmAlert({ title: "Are you sure?" })) {
|
|
15
|
+
* // do something
|
|
16
|
+
* }
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function confirmAlert(options: Alert.Options): Promise<boolean>;
|
|
21
|
+
export declare namespace Alert {
|
|
22
|
+
/**
|
|
23
|
+
* The options to create an {@link Alert}.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { confimrAlert, Alert } from "@raycast/api";
|
|
28
|
+
*
|
|
29
|
+
* export default async () => {
|
|
30
|
+
* const options: Alert.Options = {
|
|
31
|
+
* title: "Finished cooking",
|
|
32
|
+
* message: "Delicious pasta for lunch",
|
|
33
|
+
* primaryAction: {
|
|
34
|
+
* title: 'Do something',
|
|
35
|
+
* onAction: () => {
|
|
36
|
+
* // while you can register a handler for an action, it's more elegant
|
|
37
|
+
* // to use the `if (await confirmAlert(...)) { ... }` pattern
|
|
38
|
+
* console.log("The alert action has been triggered")
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* };
|
|
42
|
+
* await confirmAlert(options);
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
interface Options {
|
|
47
|
+
/**
|
|
48
|
+
* The icon of an alert to illustrate the action. Displayed on the top.
|
|
49
|
+
*/
|
|
50
|
+
icon?: Image.ImageLike;
|
|
51
|
+
/**
|
|
52
|
+
* The title of an alert. Displayed below the icon.
|
|
53
|
+
*/
|
|
54
|
+
title: string;
|
|
55
|
+
/**
|
|
56
|
+
* An additional message for an Alert. Useful to show more information, e.g. a confirmation message for a destructive action.
|
|
57
|
+
*/
|
|
58
|
+
message?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The primary Action the user can take.
|
|
61
|
+
*/
|
|
62
|
+
primaryAction?: ActionOptions;
|
|
63
|
+
/**
|
|
64
|
+
* The Action to dismiss the alert. There usually shouldn't be any side effects when the user takes this action.
|
|
65
|
+
*/
|
|
66
|
+
dismissAction?: ActionOptions;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The options to create an {@link Alert} Action.
|
|
70
|
+
*/
|
|
71
|
+
interface ActionOptions {
|
|
72
|
+
/**
|
|
73
|
+
* The title of the action.
|
|
74
|
+
*/
|
|
75
|
+
title: string;
|
|
76
|
+
/**
|
|
77
|
+
* The style of the action.
|
|
78
|
+
*/
|
|
79
|
+
style?: ActionStyle;
|
|
80
|
+
/**
|
|
81
|
+
* A callback called when the action is triggered.
|
|
82
|
+
*/
|
|
83
|
+
onAction?: () => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Defines the visual style of an Action of the Alert.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Use {@link Alert.ActionStyle.Default} for confirmations of a positive action.
|
|
90
|
+
* Use {@link Alert.ActionStyle.Destructive} for confirmations of a destructive action (eg. deleting a file).
|
|
91
|
+
*/
|
|
92
|
+
enum ActionStyle {
|
|
93
|
+
Default = "DEFAULT",
|
|
94
|
+
Cancel = "CANCEL",
|
|
95
|
+
Destructive = "DESTRUCTIVE"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A HUD will automatically hide the main window and show a compact message at the bottom of the screen.
|
|
3
|
+
*
|
|
4
|
+
* @param title - The title that will be displayed for the HUD.
|
|
5
|
+
* @returns A Promise that resolves when the HUD is shown.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { showHUD } from "@raycast/api";
|
|
10
|
+
*
|
|
11
|
+
* export default async () => {
|
|
12
|
+
* await showHUD("Hey there 👋");
|
|
13
|
+
* };
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function showHUD(title: string): Promise<void>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Keyboard } from "../../app";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and shows a Toast with the given {@link Toast.Options}.
|
|
4
|
+
*
|
|
5
|
+
* @param options - The options to customize the Toast.
|
|
6
|
+
* @returns A Promise that resolves with the shown Toast. The Toast can be used to change or hide it.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
11
|
+
*
|
|
12
|
+
* export default async () => {
|
|
13
|
+
* const success = false;
|
|
14
|
+
*
|
|
15
|
+
* if (success) {
|
|
16
|
+
* await showToast({ title: "Dinner is ready", message: "Pizza margherita" });
|
|
17
|
+
* } else {
|
|
18
|
+
* await showToast({ style: Toast.Style.Failure, title: "Dinner isn't ready", message: "Pizza dropped on the floor" });
|
|
19
|
+
* }
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* When showing an animated Toast, you can later on update it:
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
27
|
+
* import { setTimeout } from "timers/promises";
|
|
28
|
+
*
|
|
29
|
+
* export default async () => {
|
|
30
|
+
* const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
|
|
31
|
+
*
|
|
32
|
+
* await setTimeout(1000);
|
|
33
|
+
*
|
|
34
|
+
* toast.style = ToastStyle.Success;
|
|
35
|
+
* toast.title = "Uploaded image";
|
|
36
|
+
*
|
|
37
|
+
* await setTimeout(500);
|
|
38
|
+
*
|
|
39
|
+
* await toast.hide()
|
|
40
|
+
* };
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function showToast(options: Toast.Options): Promise<Toast>;
|
|
44
|
+
export declare function showToast(style: Toast.Style, title: string, message?: string): Promise<Toast>;
|
|
45
|
+
/**
|
|
46
|
+
* A Toast with a certain style, title, and message.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
51
|
+
* import { setTimeout } from "timers/promises";
|
|
52
|
+
*
|
|
53
|
+
* export default async () => {
|
|
54
|
+
* const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
|
|
55
|
+
*
|
|
56
|
+
* await setTimeout(1000);
|
|
57
|
+
*
|
|
58
|
+
* toast.style = Toast.Style.Success;
|
|
59
|
+
* toast.title = "Uploaded image";
|
|
60
|
+
* };
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class Toast {
|
|
64
|
+
private options;
|
|
65
|
+
private id;
|
|
66
|
+
private callbacks;
|
|
67
|
+
/**
|
|
68
|
+
* Deprecated - Use `showToast` instead
|
|
69
|
+
*/
|
|
70
|
+
constructor(props: Toast.Options);
|
|
71
|
+
get style(): Toast.Style;
|
|
72
|
+
set style(style: Toast.Style);
|
|
73
|
+
get title(): string;
|
|
74
|
+
set title(title: string);
|
|
75
|
+
get message(): string | undefined;
|
|
76
|
+
set message(message: string | undefined);
|
|
77
|
+
get primaryAction(): Toast.ActionOptions | undefined;
|
|
78
|
+
set primaryAction(action: Toast.ActionOptions | undefined);
|
|
79
|
+
get secondaryAction(): Toast.ActionOptions | undefined;
|
|
80
|
+
set secondaryAction(action: Toast.ActionOptions | undefined);
|
|
81
|
+
/**
|
|
82
|
+
* Shows the Toast.
|
|
83
|
+
*
|
|
84
|
+
* @returns A Promise that resolves when the toast is shown.
|
|
85
|
+
*/
|
|
86
|
+
show(): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Hides the Toast.
|
|
89
|
+
*
|
|
90
|
+
* @returns A Promise that resolves when toast is hidden.
|
|
91
|
+
*/
|
|
92
|
+
hide(): Promise<void>;
|
|
93
|
+
private update;
|
|
94
|
+
}
|
|
95
|
+
export declare namespace Toast {
|
|
96
|
+
/**
|
|
97
|
+
* The options to create a {@link Toast}.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
102
|
+
*
|
|
103
|
+
* export default async () => {
|
|
104
|
+
* const options: Toast.Options = {
|
|
105
|
+
* style: Toast.Style.Success,
|
|
106
|
+
* title: "Finished cooking",
|
|
107
|
+
* message: "Delicious pasta for lunch",
|
|
108
|
+
* primaryAction: {
|
|
109
|
+
* title: 'Do something',
|
|
110
|
+
* onAction: () => {
|
|
111
|
+
* console.log("The toast action has been triggered")
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* };
|
|
115
|
+
* await showToast(options);
|
|
116
|
+
* };
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
interface Options {
|
|
120
|
+
/**
|
|
121
|
+
* The title of a Toast. Displayed on the top.
|
|
122
|
+
*/
|
|
123
|
+
title: string;
|
|
124
|
+
/**
|
|
125
|
+
* An additional message for the Toast. Useful to show more information, e.g. an identifier of a newly created asset.
|
|
126
|
+
*/
|
|
127
|
+
message?: string;
|
|
128
|
+
/**
|
|
129
|
+
* The style of a Toast.
|
|
130
|
+
*/
|
|
131
|
+
style?: Style;
|
|
132
|
+
/**
|
|
133
|
+
* The primary Action the user can take when hovering on the Toast.
|
|
134
|
+
*/
|
|
135
|
+
primaryAction?: ActionOptions;
|
|
136
|
+
/**
|
|
137
|
+
* The secondary Action the user can take when hovering on the Toast.
|
|
138
|
+
*/
|
|
139
|
+
secondaryAction?: ActionOptions;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The options to create a {@link Toast} Action.
|
|
143
|
+
*/
|
|
144
|
+
interface ActionOptions {
|
|
145
|
+
/**
|
|
146
|
+
* The title of the action.
|
|
147
|
+
*/
|
|
148
|
+
title: string;
|
|
149
|
+
/**
|
|
150
|
+
* The keyboard shortcut for the action.
|
|
151
|
+
*/
|
|
152
|
+
shortcut?: Keyboard.Shortcut;
|
|
153
|
+
/**
|
|
154
|
+
* A callback called when the action is triggered.
|
|
155
|
+
*/
|
|
156
|
+
onAction: (toast: Toast) => void;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Defines the visual style of the Toast.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Use {@link Toast.Style.Success} for confirmations and {@link Toast.Style.Failure} for displaying errors.
|
|
163
|
+
* Use {@link Toast.Style.Animated} when your Toast should be shown until a process is completed.
|
|
164
|
+
* You can hide it later by using {@link Toast.hide} or update the properties of an existing Toast.
|
|
165
|
+
*/
|
|
166
|
+
enum Style {
|
|
167
|
+
Success = "SUCCESS",
|
|
168
|
+
Failure = "FAILURE",
|
|
169
|
+
Animated = "ANIMATED"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of built-in icons that can be used for actions or list items.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { Icon, List } from "@raycast/api";
|
|
7
|
+
*
|
|
8
|
+
* export default function Command() {
|
|
9
|
+
* return (
|
|
10
|
+
* <List>
|
|
11
|
+
* <List.Item title="Icon" icon={Icon.Circle} />
|
|
12
|
+
* </List>
|
|
13
|
+
* );
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare enum Icon {
|
|
18
|
+
ArrowClockwise = "arrow-clockwise-16",
|
|
19
|
+
ArrowRight = "arrow-right-16",
|
|
20
|
+
Binoculars = "binoculars-16",
|
|
21
|
+
Bubble = "bubble-left-16",
|
|
22
|
+
Calendar = "calendar-16",
|
|
23
|
+
Checkmark = "checkmark-circle-16",
|
|
24
|
+
ChevronDown = "chevron-down-16",
|
|
25
|
+
ChevronUp = "chevron-up-16",
|
|
26
|
+
Circle = "circle-16",
|
|
27
|
+
Clipboard = "doc-on-clipboard-16",
|
|
28
|
+
Clock = "clock-16",
|
|
29
|
+
Desktop = "desktopcomputer-16",
|
|
30
|
+
Document = "doc-16",
|
|
31
|
+
Dot = "dot-16",
|
|
32
|
+
Download = "square-and-arrow-down-16",
|
|
33
|
+
Envelope = "envelope-16",
|
|
34
|
+
ExclamationMark = "exclamation-mark-triangle-16",
|
|
35
|
+
Eye = "eye-16",
|
|
36
|
+
EyeSlash = "eye-slash-16",
|
|
37
|
+
Finder = "finder-16",
|
|
38
|
+
Gear = "gearshape-16",
|
|
39
|
+
Globe = "globe-16",
|
|
40
|
+
Hammer = "hammer-16",
|
|
41
|
+
LevelMeter = "level-meter-16",
|
|
42
|
+
Link = "link-16",
|
|
43
|
+
List = "main-list-view-16",
|
|
44
|
+
MagnifyingGlass = "magnifyingglass-16",
|
|
45
|
+
MemoryChip = "memorychip-16",
|
|
46
|
+
Message = "message-16",
|
|
47
|
+
Pencil = "pencil-16",
|
|
48
|
+
Person = "person-crop-circle-16",
|
|
49
|
+
Phone = "phone-16",
|
|
50
|
+
Pin = "pin-16",
|
|
51
|
+
Plus = "plus-16",
|
|
52
|
+
Sidebar = "sidebar-right-16",
|
|
53
|
+
SpeakerArrowDown = "speaker-arrow-down-16",
|
|
54
|
+
SpeakerArrowUp = "speaker-arrow-up-16",
|
|
55
|
+
SpeakerSlash = "speaker-slash-16",
|
|
56
|
+
Star = "star-16",
|
|
57
|
+
Text = "text-alignleft-16",
|
|
58
|
+
TextDocument = "doc-plaintext-16",
|
|
59
|
+
QuestionMark = "questionmark-circle-16",
|
|
60
|
+
Terminal = "terminal-16",
|
|
61
|
+
Trash = "trash-16",
|
|
62
|
+
Upload = "square-and-arrow-up-16",
|
|
63
|
+
Video = "video-16",
|
|
64
|
+
Window = "macwindow-16",
|
|
65
|
+
XmarkCircle = "xmark-circle-16"
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An icon as it's used in the Finder.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { List } from "@raycast/api";
|
|
73
|
+
*
|
|
74
|
+
* export default function Command() {
|
|
75
|
+
* return (
|
|
76
|
+
* <List>
|
|
77
|
+
* <List.Item title="File icon" icon={{ fileIcon: __filename }} />
|
|
78
|
+
* </List>
|
|
79
|
+
* );
|
|
80
|
+
* };
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export interface FileIcon {
|
|
84
|
+
/**
|
|
85
|
+
* The path to a file or folder to get its icon from.
|
|
86
|
+
*/
|
|
87
|
+
fileIcon: string;
|
|
88
|
+
}
|