mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-08-31 11:17:27 +00:00
feat(preferences): update checkbox schema and UI handling
This commit updates the preference handling to align with the documentation for preferences. The `PreferenceSchema` now mandates a `label` property for all preferences of type `checkbox`. In the `SettingsView`, the rendering logic has been adjusted to use the `title` as an optional section header, enabling the grouping of related checkboxes. The `label` is now used for the text directly next to the checkbox input.
This commit is contained in:
parent
1bdb0f534e
commit
e9dbcf3a57
2 changed files with 97 additions and 74 deletions
|
@ -117,11 +117,10 @@ const LogMessageSchema = z.object({
|
|||
export const SidecarMessageSchema = z.union([BatchUpdateSchema, CommandSchema, LogMessageSchema]);
|
||||
export type SidecarMessage = z.infer<typeof SidecarMessageSchema>;
|
||||
|
||||
export const PreferenceSchema = z.object({
|
||||
const BasePreferenceSchema = z.object({
|
||||
name: z.string(),
|
||||
title: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
type: z.enum(['textfield', 'password', 'checkbox', 'dropdown', 'appPicker', 'file', 'directory']),
|
||||
required: z.boolean().optional(),
|
||||
default: z.union([z.string(), z.boolean()]).optional(),
|
||||
data: z
|
||||
|
@ -133,6 +132,16 @@ export const PreferenceSchema = z.object({
|
|||
)
|
||||
.optional()
|
||||
});
|
||||
|
||||
export const PreferenceSchema = z.discriminatedUnion('type', [
|
||||
BasePreferenceSchema.extend({
|
||||
type: z.literal('checkbox'),
|
||||
label: z.string()
|
||||
}),
|
||||
BasePreferenceSchema.extend({
|
||||
type: z.enum(['textfield', 'password', 'dropdown', 'appPicker', 'file', 'directory'])
|
||||
})
|
||||
]);
|
||||
export type Preference = z.infer<typeof PreferenceSchema>;
|
||||
|
||||
export const PluginInfoSchema = z.object({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue