
Security News
Rspack Introduces Rslint, a TypeScript-First Linter Written in Go
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
A Rails port of conversational-form inspired by SPACE10
Add this line to your application's Gemfile:
gem 'conversation_forms'
And then execute:
$ bundle
Or install it yourself as:
$ gem install conversation_forms
require the js:
//= require conversation_forms
and require the css:
*= require conversation_forms
on any pages that you want to use a conversation form, simply set the form's ID to convo-form
conversation forms will automatically detect your form's method and action
<form id="my-form-element" cf-form-element ...
with form_for add "cf-form-elemt" => true:
<%= form_for @user, html: { "cf-form-element" => true } do |f| %>
``
That's It!
# DOM Element attributes
### cf-questions
* to map questions directly to a tag.
* seperate by | to allow for more questions, app will shuffle.
```html
<input type="text" cf-questions="What is your name?|Please tell me your name." ..
For cui-questions, add {previous-answer} to insert the value from the previous user-answer.
<input type="text" cf-questions="Hello {previous-answer}" ..
previous input could be firstname.
<input type="text" cf-questions="So you want to travel to {previous-answer}" ..
previous input could be a select:option list with countries.
<input type="radio" cf-label="Subscribe to newsletter" ..
<input type="text" cf-error="Text is wrong wrong|Input is not right" ..
<input type="text" pattern="^[0-9a-zA-Z-']*$" ..
<input type="text" cf-validation-contains="a|b|c|d" ..
<input type="text" cf-validation-email ..
<input type="text" pattern="^[0-9a-zA-Z-']*$" ..
<input type="text" cf-validation-matches="^[0-9a-zA-Z-']*$" ..
<input type="number" max=9 ..
<input type="text" cf-validation-max=9 ..
<input type="number" min=1 ..
<input type="text" cf-validation-min=1 ..
<input type="text" required ..
<input type="text" required="true" ..
<input type="text" required="required" ..
<input type="text" cf-validation-custom="window.validateFunction" ..
cf-context
If you want to have the ConversationalForm appended to a certain element (when auto-instantiating) then add attribute cf-context
to an element, otherwise the ConversationalForm will be appended to the form's parent element.
<div cf-context ...>
cf-prevent-autofocus
If you don't want to have the UserInput to auto focus.
<form id="my-form-element" cf-form-element cf-prevent-autofocus>
For more control over the output exclude the attribute cf-form-element
from the form element and instantiate either with vanilla JS or jQuery:
new cf.ConversationalForm({
formEl: <HTMLFormElement>,
// dictionaryData?: {}, // empty will throw error, see Dictionaty.ts for values
// dictionaryAI?: {}, // empty will throw error, see Dictionaty.ts for values
// context?: // context of where to append the ConversationalForm (see also cf-context attribute)
// tags?: tags, // pass in custom tags (when prevent the auto-instantiation of ConversationalForm)
// submitCallback?: () => void | HTMLButtonElement // custom submit callback if button[type=submit] || form.submit() is not wanted..
// userImage: "..." //base64 || image url
});
$("form").conversationalForm();
The Conversational Form automatically detects the accepted tags in the passed in form element. If this is not desired then you are able to define your own tags, and pass them into the constructor.:
var fields = [].slice.call(formEl.querySelectorAll("input, select, button"), 0);
for (var i = 0; i < fields.length; i++) {
var element = fields[i];
tags.push(cf.Tag.createTag(element));
}
Tags can then be set in the instantiation object, see ConversationalFormOptions
When instantiating ConversationalForm a reference to the instance will be available in window scope.
window.ConversationalForm
using this reference you are able to remove the ConversationalForm by calling:
window.ConversationalForm.remove();
You can overwrite the UI with your own styles. Please see the source styles files for more info.
We welcome contributions in the form of bug reports, pull requests, or thoughtful discussions in the GitHub issue tracker.
ConversationalForm is a concept originally by SPACE10. Brought to life by Felix Nielsen, RWATGG. Designed by Charlie Isslander.
Ported By Sampson Crowley
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that conversation_forms demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.