-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept variables from Omnibar in workflow steps (#97)
Bump to v1 🎉 - potential breaking changes below! ## Features - Add arguments support for workflows ## Updates - Update autocomplete-js to 1.7.4 - Refactor creation of Autocomplete - Changed the Autocomplete component to use @algolia/core for more control - Added styling for inputs and buttons in core components - Updated workflow-source, settings-source and math-source to work with the new autocomplete component, added descriptions
- Loading branch information
Showing
21 changed files
with
2,067 additions
and
517 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
|
||
export type Workflow = { | ||
name: string; | ||
arguments?: string[]; | ||
steps: { | ||
value: string; | ||
}[]; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { createAutocomplete } from "@algolia/autocomplete-core"; | ||
import { useState, useMemo } from "react"; | ||
import { appWindow } from "@tauri-apps/api/window"; | ||
|
||
function Autocomplete({ getSources }) { | ||
// (1) Create a React state. | ||
const [autocompleteState, setAutocompleteState] = useState(); | ||
const autocomplete = useMemo( | ||
() => | ||
createAutocomplete({ | ||
placeholder: "", | ||
openOnFocus: true, | ||
autoFocus: true, | ||
defaultActiveItemId: 0, | ||
onStateChange({ state }) { | ||
// (2) Synchronize the Autocomplete state with the state. | ||
setAutocompleteState(state); | ||
}, | ||
getSources({ ...props }) { | ||
return getSources({ ...props }); | ||
}, | ||
}), | ||
[getSources] | ||
); | ||
|
||
return ( | ||
<form | ||
onSubmit={(e) => { | ||
e.preventDefault(); | ||
const argKey = autocompleteState?.context?.searchPrefix ?? ""; | ||
const argValue = { | ||
[argKey]: autocompleteState?.query, | ||
}; | ||
console.log("argValue", argValue); | ||
autocompleteState?.context.onComplete && | ||
autocompleteState.context.onComplete(argValue); | ||
}} | ||
> | ||
<div | ||
style={{ | ||
backgroundColor: "white", | ||
padding: "0.5rem 1rem", | ||
borderRadius: "4px", | ||
boxShadow: "rgb(0 0 0 / 9%) 0px 3px 12px", | ||
}} | ||
onKeyDown={(e) => { | ||
if (e.key === "Escape") { | ||
autocomplete.setContext({ searchPrefix: null }); | ||
appWindow.hide(); | ||
} | ||
}} | ||
> | ||
<div className="aa-Autocomplete" {...autocomplete.getRootProps({})}> | ||
<div style={{ display: "flex", gap: "8px", alignItems: "center" }}> | ||
{autocompleteState?.context?.searchPrefix && ( | ||
<span style={{ fontWeight: 900 }}> | ||
{autocompleteState?.context?.searchPrefix}: | ||
</span> | ||
)} | ||
<input className="aa-Input" {...autocomplete.getInputProps({})} /> | ||
</div> | ||
|
||
<div | ||
style={{ | ||
padding: "1rem", | ||
boxShadow: "rgb(0 0 0 / 9%) 0px 3px 12px", | ||
width: "100%", | ||
left: 0, | ||
transform: "translateY(20px)", | ||
}} | ||
className="aa-Panel" | ||
{...autocomplete.getPanelProps({})} | ||
> | ||
{autocompleteState?.isOpen && | ||
autocompleteState?.collections.map((collection, index) => { | ||
const { source, items } = collection; | ||
console.log({ source }); | ||
return ( | ||
<div key={`source-${index}`} className="aa-Source"> | ||
{/* <h2>{source}</h2> */} | ||
{source.templates.header && source.templates.header()} | ||
{items.length > 0 && ( | ||
<ul className="aa-List" {...autocomplete.getListProps()}> | ||
{items.map((item) => { | ||
return ( | ||
<li | ||
className="aa-Item" | ||
{...autocomplete.getItemProps({ | ||
item, | ||
source, | ||
})} | ||
> | ||
{source.templates.item({ item })} | ||
</li> | ||
); | ||
// <li | ||
// key={item.objectID} | ||
// className="aa-Item" | ||
// {...autocomplete.getItemProps({ | ||
// item, | ||
// source, | ||
// })} | ||
// > | ||
// {item.label} | ||
// </li> | ||
})} | ||
</ul> | ||
)} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
); | ||
|
||
// ... | ||
} | ||
|
||
export default Autocomplete; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ReactNode } from "react" | ||
|
||
|
||
type Props = { | ||
hit: { | ||
label: string | ||
description?: ReactNode | ||
} | ||
} | ||
export const Action = ({ hit }: Props) => { | ||
// Component to display the items | ||
return ( | ||
<div className="aa-ItemWrapper"> | ||
<div className="aa-ItemContent"> | ||
{/* <div className="aa-ItemIcon"></div> */} | ||
<div className="aa-ItemContentBody"> | ||
<div className="aa-ItemContentTitle"> | ||
<span>{hit.label}</span> | ||
{hit.description && <div style={{ fontSize: '0.8rem', paddingRight: '1rem' }}>{hit.description}</div>} | ||
|
||
</div> | ||
</div> | ||
</div> | ||
<div className="aa-ItemActions"> | ||
<button | ||
className="aa-ItemActionButton aa-DesktopOnly aa-ActiveOnly" | ||
type="button" | ||
title="Select" | ||
> | ||
<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor"> | ||
<path d="M18.984 6.984h2.016v6h-15.188l3.609 3.609-1.406 1.406-6-6 6-6 1.406 1.406-3.609 3.609h13.172v-4.031z" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.