-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FormKit): work on Text component
- Loading branch information
1 parent
fec6bf9
commit d24ac8e
Showing
9 changed files
with
952 additions
and
82 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
import UnoCSS from 'unocss/vite' | ||
|
||
// https://vite.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
plugins: [UnoCSS(), vue()], | ||
}) |
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
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,55 @@ | ||
import { createSection, type FormKitSchemaExtendableSection } from "@formkit/inputs"; | ||
|
||
|
||
export const icon = ( | ||
sectionKey: string, | ||
el?: string | ||
): FormKitSchemaExtendableSection => { | ||
return createSection(`${sectionKey}Icon`, () => { | ||
return { | ||
if: `$${sectionKey}Icon`, | ||
$cmp: 'VaIcon', | ||
props: { | ||
tag: el, | ||
for: { | ||
if: `${el === 'label'}`, | ||
then: '$id', | ||
}, | ||
class: 'material-icons', | ||
onClick: `$handlers.iconClick(${sectionKey})`, | ||
role: `$fns.iconRole(${sectionKey})`, | ||
tabindex: `$fns.iconRole(${sectionKey}) === "button" && "0" || undefined`, | ||
}, | ||
children: '$prefixIcon' | ||
} | ||
})() | ||
} | ||
|
||
export const help = createSection('help', () => ({ | ||
$cmp: 'VaMessageList', | ||
if: '$help', | ||
props: { | ||
id: '$: "help-" + $id', | ||
modelValue: '$help' | ||
} | ||
})) | ||
|
||
export const message = createSection('message', () => ({ | ||
$el: 'li', | ||
for: ['message', '$messages'], | ||
attrs: { | ||
key: '$message.key', | ||
id: `$id + '-' + $message.key`, | ||
'data-message-type': '$message.type', | ||
}, | ||
})) | ||
|
||
export const messages = createSection('messages', () => ({ | ||
$cmp: 'VaMessageList', | ||
if: '$defaultMessagePlacement && $fns.length($messages)', | ||
props: { | ||
key: '$message.key', | ||
id: `$id + '-' + $message.key`, | ||
'data-message-type': '$message.type', | ||
}, | ||
})) |
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,61 @@ | ||
import { type FormKitTypeDefinition } from '@formkit/core' | ||
import { | ||
outer, | ||
inner, | ||
wrapper, | ||
label, | ||
prefix, | ||
suffix, | ||
textInput, | ||
casts, | ||
} from '@formkit/inputs' | ||
import { icon, messages, message, help } from './sections' | ||
|
||
/** | ||
* Input definition for a text. | ||
* @public | ||
*/ | ||
export const text: FormKitTypeDefinition = { | ||
/** | ||
* The actual schema of the input, or a function that returns the schema. | ||
*/ | ||
schema: outer( | ||
wrapper( | ||
label('$label'), | ||
inner( | ||
icon('prefix', 'label'), | ||
prefix(), | ||
textInput(), | ||
suffix(), | ||
icon('suffix') | ||
) | ||
), | ||
help('$help'), | ||
messages(message('$message.value')) | ||
), | ||
/** | ||
* The type of node, can be a list, group, or input. | ||
*/ | ||
type: 'input', | ||
/** | ||
* The family of inputs this one belongs too. For example "text" and "email" | ||
* are both part of the "text" family. This is primary used for styling. | ||
*/ | ||
family: 'text', | ||
/** | ||
* An array of extra props to accept for this input. | ||
*/ | ||
props: [], | ||
/** | ||
* Forces node.props.type to be this explicit value. | ||
*/ | ||
forceTypeProp: 'text', | ||
/** | ||
* Additional features that should be added to your input | ||
*/ | ||
features: [casts], | ||
/** | ||
* The key used to memoize the schema. | ||
*/ | ||
schemaMemoKey: `${Math.random()}`, | ||
} |