@vicinae/api 0.9.4 → 0.9.5
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode, Ref } from "react";
|
|
2
|
+
import { ImageLike } from "../image";
|
|
2
3
|
type FormProps = {
|
|
3
4
|
actions?: React.ReactNode;
|
|
4
5
|
children?: React.ReactNode;
|
|
@@ -70,12 +71,44 @@ interface DropdownProps extends FormItemProps<string>, WithFormRef<Form.Dropdown
|
|
|
70
71
|
throttle?: boolean;
|
|
71
72
|
onSearchTextChange?: (text: string) => void;
|
|
72
73
|
}
|
|
74
|
+
interface TagPickerProps extends FormItemProps<string[]>, WithFormRef<Form.TagPicker> {
|
|
75
|
+
children?: ReactNode;
|
|
76
|
+
}
|
|
77
|
+
interface TextAreaProps extends FormItemProps<string>, WithFormRef<Form.TagPicker> {
|
|
78
|
+
}
|
|
79
|
+
interface FilePickerProps extends FormItemProps<string[]>, WithFormRef<Form.FilePicker> {
|
|
80
|
+
}
|
|
81
|
+
type DescriptionProps = {
|
|
82
|
+
text: string;
|
|
83
|
+
title?: string;
|
|
84
|
+
};
|
|
73
85
|
export declare const Form: import("react").FC<FormProps> & {
|
|
74
86
|
TextField: import("react").FC<TextFieldProps>;
|
|
75
87
|
PasswordField: import("react").FC<PasswordFieldProps>;
|
|
76
88
|
DatePicker: import("react").FC<DatePickerProps>;
|
|
77
89
|
Checkbox: import("react").FC<CheckboxProps>;
|
|
78
|
-
|
|
90
|
+
TextArea: import("react").FC<TextAreaProps>;
|
|
91
|
+
Dropdown: import("react").FC<DropdownProps> & {
|
|
92
|
+
Item: import("react").FC<{
|
|
93
|
+
title: string;
|
|
94
|
+
value: string;
|
|
95
|
+
icon?: import("../image").Image.ImageLike;
|
|
96
|
+
keywords?: string[];
|
|
97
|
+
}>;
|
|
98
|
+
Section: import("react").FC<{
|
|
99
|
+
title?: string;
|
|
100
|
+
children?: ReactNode;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
Description: import("react").FC<DescriptionProps>;
|
|
104
|
+
TagPicker: import("react").FC<TagPickerProps> & {
|
|
105
|
+
Item: import("react").FC<{
|
|
106
|
+
title: string;
|
|
107
|
+
value: string;
|
|
108
|
+
icon: ImageLike;
|
|
109
|
+
}>;
|
|
110
|
+
};
|
|
111
|
+
FilePicker: import("react").FC<FilePickerProps>;
|
|
79
112
|
Separator: () => import("react/jsx-runtime").JSX.Element;
|
|
80
113
|
};
|
|
81
114
|
export {};
|
|
@@ -3,12 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Form = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const use_imperative_form_handle_1 = require("../hooks/use-imperative-form-handle");
|
|
6
|
+
const image_1 = require("../image");
|
|
7
|
+
const dropdown_1 = require("./dropdown");
|
|
8
|
+
const wrapFormItemProps = (props) => {
|
|
9
|
+
// TODO: pass the current value in the event
|
|
10
|
+
return {
|
|
11
|
+
...props,
|
|
12
|
+
onFocus: () => props.onFocus?.({ type: 'focus', target: { id: props.id } }),
|
|
13
|
+
onBlur: () => props.onBlur?.({ type: 'blur', target: { id: props.id } })
|
|
14
|
+
};
|
|
15
|
+
};
|
|
6
16
|
const FormRoot = ({ enableDrafts = false, actions, children, isLoading = false, navigationTitle, searchBarAccessory, }) => {
|
|
7
17
|
return ((0, jsx_runtime_1.jsxs)("form", { enableDrafts: enableDrafts, isLoading: isLoading, navigationTitle: navigationTitle, children: [searchBarAccessory, children, actions] }));
|
|
8
18
|
};
|
|
9
19
|
const TextField = ({ ref, ...props }) => {
|
|
10
20
|
(0, use_imperative_form_handle_1.useImperativeFormHandle)(ref);
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)("text-field", { ...props }));
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)("text-field", { ...wrapFormItemProps(props) }));
|
|
12
22
|
};
|
|
13
23
|
const PasswordField = ({ ...props }) => {
|
|
14
24
|
return (0, jsx_runtime_1.jsx)("password-field", { ...props });
|
|
@@ -18,16 +28,45 @@ const DatePicker = ({ ...props }) => {
|
|
|
18
28
|
};
|
|
19
29
|
const Checkbox = ({ ref, ...props }) => {
|
|
20
30
|
(0, use_imperative_form_handle_1.useImperativeFormHandle)(ref);
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("checkbox-field", { ...props }));
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)("checkbox-field", { ...wrapFormItemProps(props) }));
|
|
32
|
+
};
|
|
33
|
+
//FIXME: we probably need to reuse the existing dropdown in
|
|
34
|
+
// a smarter way.
|
|
35
|
+
const DropdownRoot = ({ children, ...props }) => {
|
|
36
|
+
// FIXME: testing stuff, we need to generalize this to all form items
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)("dropdown-field", { ...wrapFormItemProps(props), children: children }));
|
|
38
|
+
};
|
|
39
|
+
const Dropdown = Object.assign(DropdownRoot, {
|
|
40
|
+
Item: dropdown_1.Dropdown.Item,
|
|
41
|
+
Section: dropdown_1.Dropdown.Section
|
|
42
|
+
});
|
|
43
|
+
const TagPickerRoot = ({ children, ...props }) => {
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)("tag-picker-field", { ...wrapFormItemProps(props), children: children }));
|
|
45
|
+
};
|
|
46
|
+
const TagPickerItem = ({ icon, ...props }) => {
|
|
47
|
+
return (0, jsx_runtime_1.jsx)("tag-picker-item", { ...props, icon: icon && (0, image_1.serializeImageLike)(icon) });
|
|
48
|
+
};
|
|
49
|
+
const TagPicker = Object.assign(TagPickerRoot, {
|
|
50
|
+
Item: TagPickerItem
|
|
51
|
+
});
|
|
52
|
+
const TextArea = (props) => {
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)("text-area-field", { ...wrapFormItemProps(props) }));
|
|
54
|
+
};
|
|
55
|
+
const FilePicker = (props) => {
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)("file-picker-field", { ...wrapFormItemProps(props) }));
|
|
22
57
|
};
|
|
23
|
-
const
|
|
24
|
-
return (
|
|
58
|
+
const Description = (props) => {
|
|
59
|
+
return (0, jsx_runtime_1.jsx)("form-description", { ...props });
|
|
25
60
|
};
|
|
26
61
|
exports.Form = Object.assign(FormRoot, {
|
|
27
62
|
TextField,
|
|
28
63
|
PasswordField,
|
|
29
64
|
DatePicker,
|
|
30
65
|
Checkbox,
|
|
66
|
+
TextArea,
|
|
31
67
|
Dropdown,
|
|
68
|
+
Description,
|
|
69
|
+
TagPicker,
|
|
70
|
+
FilePicker,
|
|
32
71
|
Separator: () => (0, jsx_runtime_1.jsx)("separator", {}),
|
|
33
72
|
});
|
package/dist/api/proto/ui.d.ts
CHANGED
|
@@ -80,8 +80,8 @@ export interface ConfirmAlertRequest {
|
|
|
80
80
|
description: string;
|
|
81
81
|
/** TODO: replace with proper ImageLike message */
|
|
82
82
|
icon?: string | undefined;
|
|
83
|
-
dismissAction
|
|
84
|
-
primaryAction
|
|
83
|
+
dismissAction: ConfirmAlertAction | undefined;
|
|
84
|
+
primaryAction: ConfirmAlertAction | undefined;
|
|
85
85
|
rememberUserChoice: boolean;
|
|
86
86
|
}
|
|
87
87
|
export interface ConfirmAlertResponse {
|
|
@@ -106,7 +106,7 @@ class Build extends core_1.Command {
|
|
|
106
106
|
return esbuild.build({
|
|
107
107
|
bundle: true,
|
|
108
108
|
entryPoints: [source],
|
|
109
|
-
external: ["react", "@vicinae/api"],
|
|
109
|
+
external: ["react", "@vicinae/api", "@raycast/api"],
|
|
110
110
|
format: "cjs",
|
|
111
111
|
outfile: (0, node_path_1.join)(outDir, `${cmd.name}.js`),
|
|
112
112
|
platform: "node",
|
|
@@ -125,7 +125,7 @@ class Develop extends core_1.Command {
|
|
|
125
125
|
return esbuild.build({
|
|
126
126
|
bundle: true,
|
|
127
127
|
entryPoints: [source],
|
|
128
|
-
external: ["react", "@vicinae/api"],
|
|
128
|
+
external: ["react", "@vicinae/api", "@raycast/api"],
|
|
129
129
|
format: "cjs",
|
|
130
130
|
outfile: (0, node_path_1.join)(outDir, `${cmd.name}.js`),
|
|
131
131
|
platform: "node",
|
package/package.json
CHANGED
package/types/jsx.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ import { Grid } from "../api/components/grid";
|
|
|
8
8
|
|
|
9
9
|
import 'react';
|
|
10
10
|
|
|
11
|
+
type BaseFormField = {
|
|
12
|
+
onBlur?: Function;
|
|
13
|
+
onFocus?: Function;
|
|
14
|
+
onChange?: Function;
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
declare module "react" {
|
|
12
18
|
namespace JSX {
|
|
13
19
|
interface IntrinsicElements {
|
|
@@ -132,23 +138,22 @@ declare module "react" {
|
|
|
132
138
|
navigationTitle?: string;
|
|
133
139
|
children?: React.ReactNode;
|
|
134
140
|
};
|
|
135
|
-
"text-field": {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
"text-field": BaseFormField & {};
|
|
142
|
+
"tag-picker-field": BaseFormField & {},
|
|
143
|
+
"tag-picker-item": {
|
|
144
|
+
title: string;
|
|
145
|
+
value: string;
|
|
146
|
+
icon?: SerializedImageLike;
|
|
147
|
+
},
|
|
148
|
+
"text-area-field": BaseFormField & {
|
|
149
|
+
}
|
|
150
|
+
"file-picker-field": BaseFormField & {
|
|
151
|
+
}
|
|
152
|
+
"dropdown-field": BaseFormField & {
|
|
144
153
|
children?: ReactNode;
|
|
145
154
|
};
|
|
146
155
|
"date-picker-field": {};
|
|
147
|
-
"checkbox-field": {
|
|
148
|
-
onBlur?: Function;
|
|
149
|
-
onFocus?: Function;
|
|
150
|
-
onChange?: Function;
|
|
151
|
-
};
|
|
156
|
+
"checkbox-field": BaseFormField & {};
|
|
152
157
|
"password-field": {};
|
|
153
158
|
"textarea-field": {};
|
|
154
159
|
|
|
@@ -168,6 +173,11 @@ declare module "react" {
|
|
|
168
173
|
keywords?: string[];
|
|
169
174
|
};
|
|
170
175
|
|
|
176
|
+
"form-description": {
|
|
177
|
+
title?: string;
|
|
178
|
+
text: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
171
181
|
separator: {};
|
|
172
182
|
"menu-bar": {};
|
|
173
183
|
"menu-bar-item": {};
|