From 83b5dbadfe3196aa6853bdc32e6adadefefd7b45 Mon Sep 17 00:00:00 2001 From: Avior Date: Tue, 27 Aug 2019 12:50:57 +0200 Subject: [PATCH] Small changes --- README.md | 137 +++++++++++++++++++++++++++++++++++++ modules/FMDatalistInput.ts | 2 +- package.json | 5 +- 3 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..68c2378 --- /dev/null +++ b/README.md @@ -0,0 +1,137 @@ +# FormManager + +A powerfull Manager for all your forms + + +## Table of Content + +- [FormManager](#formmanager) + - [Base](#base) + - [modules](#modules) + - [datalist changes](#datalist-changes) + - [date changes](#date-changes) + - [Repeat Element](#repeat-element) + - [TODO LIST](#todo-list) + +## Base + +to have the basic system just import `FormManager` + +```ts +import FormManager from '@dzeio/form-manager'; + +const fm = new FormManager(docuement.getElementById("formId")) +``` + +from now on you can get datas by using `fm.getJSON()` fill by using `fm.fillFromJSON()` or `fm.fillFromURI()` verify datas with `fm.verify()` + +## modules + +Actually there is 3 modules included in the system _non of them are loaded_ +each modules add new functionality to the form (see later) + +to load a module: +```ts +//the three modules availables +import { FMRepeatInputAssignment } from '@dzeio/form-manager/modules/FMRepeatInput' +import { FMDatalistAssignement } from '@dzeio/form-manager/modules/FMDatalistInput' +import { FMDateInputAssignement } from '@dzeio/form-manager/modules/FMDateInput' + +// add the modules to the Form +fm.assign(FMRepeatInputAssignment) +fm.assign(FMDateInputAssignement) +fm.assign(FMDatalistAssignement) + +// reload the manager to use the new modules +fm.setupInputs() + +``` + +you can customise how the module assign himself to an element by doing this: +```ts +/* + input: typeof FMInput + classes?: string[] | string + attributes?: string[] | string + type?: string + tagName?: string +*/ +fm.assign({ + input: FMRepeatInput, + classes: "custom-class", + attributes: "data-custom", + type: "number", //for input + tagName: "div" +}) +``` + +### datalist changes + +the values for the datalist will not be the `value` attribute anymore but a `data-value` so the end user will see wht you wnt and not the value you want to send + +even if you set `data-strict` the result value will only be set if it's from one of the option +if not set the value will stay set by what the user wrote +***ATTENTION if multiple `option` has the same `value` attribute the final value will be the `data-value` of the first `value`*** + +ex: +```html + + + + + + + +``` + +### date changes + +`FMDateInput` change the result type from a string to a `Date` object +and if `data-default` is set the current date will be set + +ex: +```html + +``` + +### Repeat Element + +the Repeat element allow to add/delete multiple time the sames input(s) + +***NOTE***_: actually the filling don't work but the rest work just fine_ + +Organisation +```html +
+
+ + + +
+ +
+
+ + + +
+ +
+
+``` + +## TODO LIST + +more Listing [here](https://git.delta-wings.net/dzeio/FormManager/issues) + +- [ ] add `data-autoset` to autofill the input with data from another one _with `readonly` and `disabled`_ +- [ ] allow filling of `FMRepeatInput` +- [ ] add `data-regex` for verification +- [ ] add `data-ignore` mainly for `data-autoset` diff --git a/modules/FMDatalistInput.ts b/modules/FMDatalistInput.ts index 5e2a8ff..33dbd95 100644 --- a/modules/FMDatalistInput.ts +++ b/modules/FMDatalistInput.ts @@ -1,4 +1,4 @@ -import { FMAssignInterface } from './../Interfaces'; +import { FMAssignInterface } from '../Interfaces'; import FormManager from "../FormManager" import FMInput from "../FMInput" diff --git a/package.json b/package.json index 500b9f8..dc2f405 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { - "name": "form-manager", - "version": "1.0.0", + "name": "@dzeio/form-manager", + "version": "0.1.1", + "main": "./FormManager.ts", "description": "A powerfull Form Manager", "repository": { "type": "git",