Eney
Widgets

Actions

Use actions to perform tasks within your widget, such as submitting data, opening files, or copying text to the clipboard.

Actions

Properties

PropertyDescriptionTypeDefault
titleButton labelstringvaries
styleButton style variation"primary" | "secondary""secondary"
isLoadingShow a loading indicatorboolean
isDisabledDisable the buttonboolean

Action

A custom action button. Use this when the built-in action types don't cover your use case.

Properties

PropertyDescriptionTypeDefaultRequired
titleButton labelstringYes
onActionCallback triggered when the button is clicked() => voidYes
styleButton style variation"primary" | "secondary""secondary"No
isLoadingShow a loading indicatorbooleanNo
isDisabledDisable the buttonbooleanNo

Usage

import { Action, ActionPanel } from "@eney/api";

function MyWidget() {
  function handleRefresh() {
    // custom action logic
  }

  return (
    <ActionPanel>
      <Action title="Refresh" onAction={handleRefresh} />
    </ActionPanel>
  );
}

Action.SubmitForm

Triggers a form submission handler. Typically used inside an ActionPanel that is passed to a Form.

Properties

PropertyDescriptionTypeDefaultRequired
titleButton labelstringYes
onSubmitCallback triggered on form submit() => voidYes
styleButton style variation"primary" | "secondary""secondary"No
isLoadingShow a loading indicatorbooleanNo
isDisabledDisable the buttonbooleanNo

Usage

import { useState } from "react";
import { Form, Action, ActionPanel } from "@eney/api";

function MyWidget() {
  const [name, setName] = useState("");
  const [loading, setLoading] = useState(false);

  async function onSubmit() {
    setLoading(true);
    // process the form data
    setLoading(false);
  }

  return (
    <Form
      actions={
        <ActionPanel>
          <Action.SubmitForm
            title="Save"
            onSubmit={onSubmit}
            style="primary"
            isLoading={loading}
          />
        </ActionPanel>
      }
    >
      <Form.TextField
        name="name"
        label="Name"
        value={name}
        onChange={setName}
      />
    </Form>
  );
}

Action.ShowInFinder

Opens a file or folder in macOS Finder.

Properties

PropertyDescriptionTypeDefaultRequired
pathThe file path to reveal in FinderstringYes
titleButton labelstring"Show in Finder"No
styleButton style variation"primary" | "secondary""secondary"No
isDisabledDisable the buttonbooleanNo

Usage

Provide a direct link for the user to locate a generated file on their Mac:

import { Action, ActionPanel } from "@eney/api";

<ActionPanel>
  <Action.ShowInFinder path="/Users/me/Documents/report.pdf" />
</ActionPanel>;

Action.CopyToClipboard

Copies text content to the system clipboard.

Properties

PropertyDescriptionTypeDefaultRequired
contentText to be copiedstringYes
titleButton labelstring"Copy"No
styleButton style variation"primary" | "secondary""secondary"No
isDisabledDisable the buttonbooleanNo

Usage

import { Action, ActionPanel, Paper } from "@eney/api";

function ResultView(props: { result: string }) {
  return (
    <Paper
      markdown={props.result}
      actions={
        <ActionPanel>
          <Action.CopyToClipboard content={props.result} />
        </ActionPanel>
      }
    />
  );
}