@uniquedj95/vform 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ export type FormValue = string | number | boolean | Option | Array<Option>;
2
+ export type FormValidator = (value: FormValue, schema?: FormSchema) => Promise<Array<string> | null> | Array<string> | null;
3
+ export type ComputedValueHandler = (value: FormValue, schema: FormSchema) => Promise<any> | any;
4
+ export type FormOptions = Array<Option> | (() => Promise<Array<Option>>);
5
+ export type FormData = Record<string, FormValue | undefined>;
6
+ export type ComputedData = Record<string, any>;
7
+ export type FormSchema = Record<string, FormField>;
8
+ export interface GridSize {
9
+ xs?: string;
10
+ sm?: string;
11
+ md?: string;
12
+ lg?: string;
13
+ xl?: string;
14
+ }
15
+ export interface FormField {
16
+ value?: FormValue;
17
+ type: InputType;
18
+ label?: string;
19
+ required?: boolean;
20
+ options?: FormOptions;
21
+ multiple?: boolean;
22
+ min?: number | string;
23
+ max?: number | string;
24
+ counter?: boolean;
25
+ minLength?: number;
26
+ maxLength?: number;
27
+ disabled?: boolean;
28
+ hidden?: boolean;
29
+ grid?: GridSize;
30
+ placeholder?: string;
31
+ icon?: string;
32
+ prefix?: string;
33
+ suffix?: string;
34
+ error?: string;
35
+ pattern?: string;
36
+ allowUnknown?: boolean;
37
+ allowCustom?: boolean;
38
+ autoFocus?: boolean;
39
+ fill?: "solid" | "outline";
40
+ labelPlacement?: "stacked" | "start" | "end" | "fixed" | "floating";
41
+ validation?: FormValidator;
42
+ onChange?: (value: FormValue) => FormValue;
43
+ computedValue?: ComputedValueHandler;
44
+ condition?: (data: FormData, computedData: ComputedData) => boolean;
45
+ }
46
+ export interface OptionDescription {
47
+ color: "primary" | "warning" | "danger" | "secondary" | "light";
48
+ show?: "onChecked" | "always";
49
+ text: string;
50
+ }
51
+ export interface Option {
52
+ label: string;
53
+ value: string | number;
54
+ other?: any;
55
+ isChecked?: boolean;
56
+ disabled?: boolean;
57
+ description?: OptionDescription;
58
+ }
59
+ export type InputType = "TextInput" | "DateInput" | "NumberInput" | "EmailInput" | "PasswordInput";
60
+ export type BaseFieldTypes = "text" | "password" | "email" | "number" | "tel" | "url" | "search" | "time" | "month" | "week";
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,SAAS,EAChB,MAAM,CAAC,EAAE,UAAU,KAChB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAC1D,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,UAAU,KACf,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxB,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;AAC7D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,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E,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC;CACrE;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;IAChE,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,MAAM,MAAM,SAAS,GACjB,WAAW,GACX,WAAW,GACX,aAAa,GACb,YAAY,GACZ,eAAe,CAAA;AAEnB,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,UAAU,GACV,OAAO,GACP,QAAQ,GACR,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,MAAM,CAAA"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Form Builder Utility functions.
3
+ *
4
+ * @packageDocumentation
5
+ * @module utils
6
+ * @preferred
7
+ * @author Daniel Justin.
8
+ **/
9
+ /**
10
+ * Full month names.
11
+ **/
12
+ export declare const monthNames: string[];
13
+ /**
14
+ * Checks if a value is "empty".
15
+ *
16
+ * @param value - The value to check for emptiness.
17
+ * @returns `true` if the value is `null` or `undefined`, an empty string, an empty array, or an empty object.
18
+ * Returns `false` otherwise.
19
+ */
20
+ export declare function isEmpty(value: any): boolean;
21
+ /**
22
+ * Format a date string according to a given pattern.
23
+ *
24
+ * @param date - The date string to format.
25
+ * @param pattern - The pattern to format the date string with. default is 'DD/MMM/2024'.
26
+ * @returns The formatted date string.
27
+ */
28
+ export declare function formatDate(date: string, pattern?: string): string;
29
+ /**
30
+ * Append a zero to a number if it is less than 10.
31
+ *
32
+ * @param num - The number to append a zero to.
33
+ * @returns The number as a string with a zero appended if it is less than 10.
34
+ */
35
+ export declare function zeroPad(num: number): string;
36
+ /**
37
+ * Get the month name or number.
38
+ *
39
+ * @param month - The month number or name.
40
+ * @param part - The part of the month to get. Either 'MMMM', 'MMM', or 'MM'.
41
+ * @returns The month name or number.
42
+ */
43
+ export declare function getMonth(month: number | string, part: string): string;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;IAOI;AAEJ;;IAEI;AACJ,eAAO,MAAM,UAAU,UAatB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAQ3C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,MAAM,CAuChF;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,UAO5D"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@uniquedj95/vform",
3
+ "version": "1.2.0",
4
+ "description": "A simplified ionic vue desktop form builder",
5
+ "type": "module",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.es.js",
15
+ "require": "./dist/index.umd.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "vite build",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "Vue",
24
+ "ionic",
25
+ "typescript",
26
+ "Form builder"
27
+ ],
28
+ "author": "Daniel Justin <danieljmuleke@gamil.com>",
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "@ionic/vue": "^8.2.5",
32
+ "@vitejs/plugin-vue": "^5.0.5",
33
+ "ionicons": "^7.4.0",
34
+ "typescript": "^5.5.3",
35
+ "vite": "^5.3.3",
36
+ "vite-plugin-dts": "^3.9.1",
37
+ "vue": "^3.4.31"
38
+ },
39
+ "peerDependencies": {
40
+ "vue": "^3.4.31"
41
+ },
42
+ "dependencies": {
43
+ "@vuepic/vue-datepicker": "^9.0.1"
44
+ }
45
+ }