Skip to content

Commit

Permalink
Merge pull request #446 from aXenDeveloper/fix/auto-form-path
Browse files Browse the repository at this point in the history
fix(frontend): Invalid path for Auto Form
  • Loading branch information
aXenDeveloper authored Aug 12, 2024
2 parents b6a250d + 803f1b9 commit c8ba189
Show file tree
Hide file tree
Showing 58 changed files with 220 additions and 193 deletions.
4 changes: 4 additions & 0 deletions apps/docs/content/docs/dev/lint.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Lint
description: Lint your code with ESLint and Prettier.
---
3 changes: 2 additions & 1 deletion apps/docs/content/docs/dev/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"---Introduction ---",
"index",
"contribution",
"--- Plugins ---",
"--- Plugins in AdminCP ---",
"plugins",
"lint",
"plugins-nav-admin",
"plugins-permissions-admin",
"--- GraphQL ---",
Expand Down
46 changes: 37 additions & 9 deletions apps/docs/content/docs/dev/pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,47 @@ title: Pages
description: Create pages in VitNode.
---

Some folders in `apps/frontend/app` are in `.gitignore` and are not included in the repository. All files from these folders are copied when you are using `npm run config:init` to initialize your workspace.

<Callout title="Default pages from VitNode" type="error">
Do not put any files inside `(vitnode)` folders! They are automatically
generated by VitNode and can be overwritten.
</Callout>

Below is guide how to create own pages in VitNode using own `plugin`. If your `workspace` is `private` and you don't plan to share your `workspace` with others, you can create pages without `{your_plugin}` folder.

## Default Page

VitNode handle automaticly default page for you. You need to create a file `themes/1/{your_plugin}/default-page.tsx` in your plugin template.
VitNode automaticly create default page for you in your plugin.

Use `export default` for your template.
import { File, Folder, Files } from 'fumadocs-ui/components/files';

```tsx
export default async function DefaultPage() {
const data = await getData();
const t = await getTranslations('core');
<Files>
<Folder name="app" defaultOpen>
<Folder name="frontend" defaultOpen>
<Folder name="plugins" defaultOpen>
<Folder name="{your_plugin}" defaultOpen>
<Folder name="templates" defaultOpen>
<File name="default-page.tsx" />
</Folder>
</Folder>
</Folder>
</Folder>
</Folder>
</Files>

return <div>{t('info', { data })}</div>;
}
```
<Callout title="export default">
The default page is exported as `default`.
</Callout>

Test it by set your plugin as default in `AdminCP` and go to your website.

You can also delete this file if you don't need it, then VitNode after export your plugin will block your plugin to be default.

## Create Pages

Vitnode using [NextJS](https://nextjs.org/docs/app/building-your-application/routing) in app directory. All features about `routing` from `NextJS` are available in VitNode for example [Parallel Routes](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes), [Dynamic Routes](https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes), [Error Handling](https://nextjs.org/docs/app/building-your-application/routing/error-handling), [Metadata](https://nextjs.org/docs/app/building-your-application/optimizing/metadata) etc.

You need to remember only where to put your pages if you are creating plugin for VitNode.

### Frontend
8 changes: 4 additions & 4 deletions apps/docs/content/docs/ui/forms/auto-form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ npm i react-hook-form zod

```tsx
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoForm } from 'vitnode-frontend/form/auto-form';

// for input
import { AutoFormInput } from 'vitnode-frontend/components/ui/auto-form/fields/input';
import { AutoFormInput } from 'vitnode-frontend/form/fields/input';
```

```ts
Expand Down Expand Up @@ -150,7 +150,7 @@ You can set a label for a field by using the `label` method.
You can nest objects to create accordion sections. Here is an example:

```ts
import { AutoFormInputComponentProps } from 'vitnode-frontend/components/ui/auto-form/type';
import { AutoFormInputComponentProps } from 'vitnode-frontend/form/type';
```

```ts
Expand Down Expand Up @@ -324,7 +324,7 @@ const [values, setValues] = useState<Partial<z.infer<typeof formSchema>>>({});
AutoForm allow to create dependencies between fields. For example allowing one field's visibility or behavior to be controlled based on the value of another. Pass `dependencies` prop with an array of objects.

```ts
import { DependencyType } from 'vitnode-frontend/components/ui/auto-form/type';
import { DependencyType } from 'vitnode-frontend/form/type';
```

### Hides
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/checkbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormCheckbox } from 'vitnode-frontend/components/ui/auto-form/fields/checkbox';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormCheckbox } from 'vitnode-frontend/form/fields/checkbox';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/color-picker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormColor } from 'vitnode-frontend/components/ui/auto-form/fields/color';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormColor } from 'vitnode-frontend/form/fields/color';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/combobox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormCombobox } from 'vitnode-frontend/components/ui/auto-form/fields/combobox';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormCombobox } from 'vitnode-frontend/form/fields/combobox';
```

```ts
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/docs/ui/forms/file-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormFile } from 'vitnode-frontend/components/ui/auto-form/fields/file';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormFile } from 'vitnode-frontend/form/fields/file';
import { zodFile } from 'vitnode-frontend/helpers/zod';
```

Expand Down Expand Up @@ -62,7 +62,7 @@ import { FileInput } from 'vitnode-frontend/components/ui/file-input';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { zodFile } from 'vitnode-frontend/helpers/zod';
```

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/icon-picker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormIcon } from 'vitnode-frontend/components/ui/auto-form/fields/icon';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormIcon } from 'vitnode-frontend/form/fields/icon';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormInput } from 'vitnode-frontend/components/ui/auto-form/fields/input';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormInput } from 'vitnode-frontend/form/fields/input';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/radio-group.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormRadioGroup } from 'vitnode-frontend/components/ui/auto-form/fields/radio-group';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormRadioGroup } from 'vitnode-frontend/form/fields/radio-group';
````

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormSelect } from 'vitnode-frontend/components/ui/auto-form/fields/select';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormSelect } from 'vitnode-frontend/form/fields/select';
```

```ts
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/ui/forms/switch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/tags-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormTags } from 'vitnode-frontend/components/ui/auto-form/fields/tags';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormTags } from 'vitnode-frontend/form/fields/tags';
import { zodTag } from 'vitnode-frontend/helpers/zod';
```

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/text-language-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
```ts
import * as z from 'zod';
import { zodLanguageInput } from 'vitnode-frontend/helpers/zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoFormTextLanguageInput } from 'vitnode-frontend/components/ui/auto-form/fields/text-language-input';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
import { AutoFormTextLanguageInput } from 'vitnode-frontend/form/fields/text-language-input';
```

```ts
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/ui/forms/textarea.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
```

```ts
Expand Down Expand Up @@ -58,7 +58,7 @@ import { Textarea } from 'vitnode-frontend/components/ui/textarea';
<Tab value="Auto Form">
```ts
import * as z from 'zod';
import { AutoForm } from 'vitnode-frontend/components/ui/auto-form';
import { AutoForm } from 'vitnode-frontend/form/auto-form';
```

```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import React from 'react';
import { zodResolver } from '@hookform/resolvers/zod';
import { useTranslations } from 'next-intl';

import { Dependency, FieldConfig, ZodObjectOrWrapped } from './type';
import { getDefaultValues, getObjectFormSchema } from './utils';
import { Form } from '../form';
import { AutoFormObject } from './object';
import { Button } from '../button';
import { Form } from '../ui/form';
import { Button } from '../ui/button';
import { cn } from '@/helpers/classnames';
import { AutoFormObject } from '@/components/form/object';
import { getDefaultValues, getObjectFormSchema } from './utils';
import { Dependency, FieldConfig, ZodObjectOrWrapped } from './type';

export function AutoForm<T extends ZodObjectOrWrapped>({
formSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AutoFormInputComponentProps } from '../type';
import { AutoFormLabel } from './common/label';
import { AutoFormTooltip } from './common/tooltip';
import { cn } from '@/helpers/classnames';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';
import { AutoFormLabel } from './common/label';
import { AutoFormTooltip } from './common/tooltip';

import { FormControl, FormMessage } from '../../form';
import { Checkbox } from '../../checkbox';
import { Checkbox } from '../../ui/checkbox';
import { FormControl, FormMessage } from '../../ui/form';

export const AutoFormCheckbox = ({
autoFormProps: { isRequired, fieldConfigItem, field, theme, isDisabled },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ColorPicker } from '@/components/ui/color-picker';
import { AutoFormInputComponentProps } from '../type';
import { DefaultParent } from './common/children';
import { AutoFormWrapper } from './common/wrapper';
import { AutoFormLabel } from './common/label';
import { FormControl, FormMessage } from '@/components/ui/form';
import { AutoFormTooltip } from './common/tooltip';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';

import { FormControl, FormMessage } from '../../form';
import { ColorPicker } from '../../color-picker';

export const AutoFormColor = ({
autoFormProps: { isRequired, fieldConfigItem, field, theme, isDisabled },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import React from 'react';
import { useTranslations } from 'next-intl';
import { Check, ChevronsUpDown } from 'lucide-react';

import { cn } from '@/helpers/classnames';
import { getBaseSchema } from '../utils';
import { AutoFormInputComponentProps } from '../type';
import { DefaultParent } from './common/children';
import { AutoFormWrapper } from './common/wrapper';
import { AutoFormLabel } from './common/label';
import { AutoFormTooltip } from './common/tooltip';
import { getBaseSchema } from '../utils';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';
import { cn } from '@/helpers/classnames';

import { FormControl, FormMessage } from '../../form';
import { Popover, PopoverContent, PopoverTrigger } from '../../popover';
import { Button } from '../../button';
import { FormControl, FormMessage } from '../../ui/form';
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover';
import { Button } from '../../ui/button';
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from '../../command';
} from '../../ui/command';

export const AutoFormCombobox = ({
autoFormProps: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { FileInput } from '@/components/ui/file-input';
import { AutoFormInputComponentProps } from '../type';
import { DefaultParent } from './common/children';
import { AutoFormLabel } from './common/label';
import { AutoFormTooltip } from './common/tooltip';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';

import { FormControl, FormMessage } from '../../form';
import { FileInput } from '../../file-input';
import { FormControl, FormMessage } from '@/components/ui/form';
import { AutoFormTooltip } from './common/tooltip';

export const AutoFormFile = ({
autoFormProps: { isRequired, fieldConfigItem, field, theme, isDisabled },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { IconPicker } from '@/components/icon/picker/icon-picker';
import { AutoFormInputComponentProps } from '../type';
import { DefaultParent } from './common/children';
import { AutoFormWrapper } from './common/wrapper';
import { AutoFormLabel } from './common/label';
import { FormControl, FormMessage } from '@/components/ui/form';
import { AutoFormTooltip } from './common/tooltip';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';
import { IconPicker } from '@/components/icon/picker/icon-picker';

import { FormControl, FormMessage } from '../../form';

export const AutoFormIcon = ({
autoFormProps: { isRequired, fieldConfigItem, field, theme, isDisabled },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DefaultParent } from './common/children';
import { AutoFormInputComponentProps } from '../type';
import { AutoFormWrapper } from './common/wrapper';
import { AutoFormLabel } from './common/label';
import { FormControl, FormMessage } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { AutoFormTooltip } from './common/tooltip';
import { AutoFormWrapper } from './common/wrapper';
import { DefaultParent } from './common/children';

import { FormControl, FormMessage } from '../../form';
import { Input } from '../../input';

export const AutoFormInput = ({
autoFormProps: { isRequired, fieldConfigItem, field, theme, isDisabled },
Expand Down
Loading

0 comments on commit c8ba189

Please sign in to comment.