-
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 Color component
- Loading branch information
1 parent
d24ac8e
commit bde0567
Showing
3 changed files
with
95 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { type FormKitTypeDefinition } from '@formkit/core' | ||
import { | ||
outer, | ||
inner, | ||
wrapper, | ||
label, | ||
prefix, | ||
suffix, | ||
casts, | ||
createSection | ||
} from '@formkit/inputs' | ||
import { icon, messages, message, help } from './sections' | ||
|
||
|
||
const colorInput = createSection('input', () => ({ | ||
$cmp: 'VaColorInput', | ||
bind: '$attrs', | ||
props: { | ||
type: '$type', | ||
disabled: '$disabled', | ||
name: '$node.name', | ||
onChange: '$handlers.DOMInput', | ||
[`onUpdate:modelValue`]: '$handlers.DOMInput', | ||
onBlur: '$handlers.blur', | ||
modelValue: '$_value', | ||
id: '$id', | ||
'aria-describedby': '$describedBy', | ||
'aria-required': '$state.required || undefined', | ||
}, | ||
})) | ||
|
||
/** | ||
* Input definition for a text. | ||
* @public | ||
*/ | ||
export const color: FormKitTypeDefinition = { | ||
/** | ||
* The actual schema of the input, or a function that returns the schema. | ||
*/ | ||
schema: outer( | ||
wrapper( | ||
label('$label'), | ||
inner( | ||
icon('prefix', 'label'), | ||
prefix(), | ||
colorInput(), | ||
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()}`, | ||
} |
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