foorm 0.0.2-alpha.0 → 0.0.2-alpha.10

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.
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ class Foorm {
20
20
  this.entries = (opts === null || opts === void 0 ? void 0 : opts.entries) || [];
21
21
  this.submit = opts === null || opts === void 0 ? void 0 : opts.submit;
22
22
  this.title = (opts === null || opts === void 0 ? void 0 : opts.title) || '';
23
+ this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {};
23
24
  }
24
25
  addEntry(entry) {
25
26
  this.entries.push(entry);
@@ -30,17 +31,33 @@ class Foorm {
30
31
  setSubmit(submit) {
31
32
  this.submit = submit;
32
33
  }
33
- transportable() {
34
+ setContext(context) {
35
+ this.context = context;
36
+ }
37
+ /**
38
+ * Normalizes form metadata and removes all the functions
39
+ * from validators.
40
+ *
41
+ * @param replaceContext a context to be transported along with metadata
42
+ * @returns form metadata without functions
43
+ */
44
+ transportable(replaceContext) {
34
45
  var _a, _b;
35
46
  return {
36
47
  title: (_a = this.title) !== null && _a !== void 0 ? _a : '',
37
48
  submit: (_b = this.submit) !== null && _b !== void 0 ? _b : { text: 'Submit' },
38
- entries: this.entries.map((e) => (Object.assign(Object.assign({}, this.normalizeEntry(e)), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
49
+ context: replaceContext || this.context,
50
+ entries: this.entries.map((e) => (Object.assign(Object.assign({}, e), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
39
51
  };
40
52
  }
41
53
  normalizeEntry(e) {
42
54
  return Object.assign(Object.assign({}, e), { name: e.name || e.field, label: e.label || e.field, type: e.type || 'text' });
43
55
  }
56
+ /**
57
+ * Evaluates all the ftrings into functions, makes it ready for execution
58
+ *
59
+ * @returns form metadata with functions
60
+ */
44
61
  executable() {
45
62
  var _a, _b;
46
63
  if (!this.fns)
@@ -51,6 +68,7 @@ class Foorm {
51
68
  text: transformFtrings(((_a = this.submit) === null || _a === void 0 ? void 0 : _a.text) || 'Submit', this.fns),
52
69
  disabled: transformFtrings((_b = this.submit) === null || _b === void 0 ? void 0 : _b.disabled, this.fns),
53
70
  },
71
+ context: this.context,
54
72
  entries: this.entries
55
73
  .map((e) => this.normalizeEntry(e))
56
74
  .map((e) => (Object.assign(Object.assign({}, e), {
@@ -59,10 +77,28 @@ class Foorm {
59
77
  // strings || objects
60
78
  classes: transformFtringsInObj(e.classes, this.fns), styles: transformFtringsInObj(e.styles, this.fns),
61
79
  // booleans
62
- optional: transformFtrings(e.optional, this.fns), disabled: transformFtrings(e.disabled, this.fns), hidden: transformFtrings(e.hidden, this.fns) }))),
80
+ optional: transformFtrings(e.optional, this.fns), disabled: transformFtrings(e.disabled, this.fns), hidden: transformFtrings(e.hidden, this.fns), validators: this.prepareValidators(e.validators) }))),
63
81
  };
64
82
  }
65
- getValidator() {
83
+ createFormData() {
84
+ const data = {};
85
+ for (const entry of this.entries) {
86
+ if (entry.type !== 'action') {
87
+ data[entry.field] = (entry.value ||
88
+ undefined);
89
+ }
90
+ }
91
+ return data;
92
+ }
93
+ prepareValidators(_validators) {
94
+ const validators = (_validators || []).map((v) => isFtring(v) ? this.fns.getFn(v.v) : v);
95
+ validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
96
+ return validators;
97
+ }
98
+ supportsAltAction(altAction) {
99
+ return !!this.entries.find((e) => e.altAction === altAction);
100
+ }
101
+ getFormValidator() {
66
102
  if (!this.fns)
67
103
  this.fns = new ftring$1.FtringsPool();
68
104
  const entries = this.executable().entries;
@@ -71,7 +107,7 @@ class Foorm {
71
107
  if (entry.field) {
72
108
  fields[entry.field] = {
73
109
  entry,
74
- validators: (entry.validators || []).map((v) => isFtring(v) ? this.fns.getFn(v.v) : v),
110
+ validators: this.prepareValidators(entry.validators),
75
111
  };
76
112
  }
77
113
  fields[entry.field].validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
@@ -80,25 +116,48 @@ class Foorm {
80
116
  let passed = true;
81
117
  const errors = {};
82
118
  for (const [key, value] of Object.entries(fields)) {
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
119
  const evalEntry = Object.assign({}, value.entry);
85
- const ctx = {
120
+ const scope = {
86
121
  v: data[key],
87
- validators: value.validators,
88
- entry: value.entry,
122
+ context: this.context,
123
+ entry: {
124
+ field: evalEntry.field,
125
+ type: evalEntry.type,
126
+ component: evalEntry.component,
127
+ name: evalEntry.name,
128
+ length: evalEntry.length,
129
+ },
89
130
  data,
90
131
  };
91
- if (typeof evalEntry.optional === 'function') {
92
- evalEntry.optional = evalEntry.optional(ctx);
93
- }
94
- if (typeof evalEntry.disabled === 'function') {
95
- evalEntry.disabled = evalEntry.disabled(ctx);
132
+ if (scope.entry) {
133
+ if (typeof evalEntry.disabled === 'function') {
134
+ scope.entry.disabled = evalEntry.disabled =
135
+ evalEntry.disabled(scope);
136
+ }
137
+ else {
138
+ scope.entry.disabled = evalEntry.disabled;
139
+ }
140
+ if (typeof evalEntry.optional === 'function') {
141
+ scope.entry.optional = evalEntry.optional =
142
+ evalEntry.optional(scope);
143
+ }
144
+ else {
145
+ scope.entry.optional = evalEntry.optional;
146
+ }
147
+ if (typeof evalEntry.hidden === 'function') {
148
+ scope.entry.hidden = evalEntry.hidden =
149
+ evalEntry.hidden(scope);
150
+ }
151
+ else {
152
+ scope.entry.hidden = evalEntry.hidden;
153
+ }
96
154
  }
97
155
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
156
  const result = validate({
99
157
  v: data[key],
158
+ context: this.context,
100
159
  validators: value.validators,
101
- entry: evalEntry,
160
+ entry: scope.entry,
102
161
  data,
103
162
  });
104
163
  if (!result.passed) {
@@ -119,6 +178,7 @@ function validate(opts) {
119
178
  for (const validator of opts.validators || []) {
120
179
  const result = validator({
121
180
  v: opts.v,
181
+ context: opts.context,
122
182
  data: opts.data,
123
183
  entry: opts.entry,
124
184
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,122 @@
1
- export * from './foorm';
2
- export * from './utils';
3
- export * from './types';
1
+ type TFtring = {
2
+ __is_ftring__: true;
3
+ v: string;
4
+ __type__?: 'boolean' | 'string' | 'number';
5
+ };
6
+ type StringOrFtring = string | TFtring;
7
+ type ObjSOF = Record<string, StringOrFtring>;
8
+ type TFoormFnScope<T = string> = {
9
+ v?: T;
10
+ data: Record<string, unknown>;
11
+ context: Record<string, unknown>;
12
+ entry?: Pick<TFoormEntry<T, unknown, string, boolean>, TRelevantFields> & {
13
+ optional?: boolean;
14
+ disabled?: boolean;
15
+ hidden?: boolean;
16
+ };
17
+ action?: string;
18
+ };
19
+ type TFoormValidatorFn<T = string> = (ctx: TFoormFnScope<T>) => string | boolean;
20
+ type TFoormFn<T = string, R = string | boolean> = (ctx: TFoormFnScope<T>) => R;
21
+ type TRelevantFields = 'field' | 'type' | 'component' | 'name' | 'attrs' | 'length';
22
+ interface TFoormEntry<T = string, O = string, SFTR = TFtring, BFTR = TFtring, FNFTR = TFtring> {
23
+ field: string;
24
+ altAction?: string;
25
+ label?: string | SFTR;
26
+ description?: string | SFTR;
27
+ hint?: string | SFTR;
28
+ placeholder?: string | SFTR;
29
+ classes?: (string | SFTR) | Record<string, boolean | BFTR>;
30
+ styles?: (string | SFTR) | Record<string, string | SFTR>;
31
+ type?: string;
32
+ component?: string;
33
+ autocomplete?: string;
34
+ name?: string;
35
+ value?: T;
36
+ options?: O[];
37
+ attrs?: Record<string, unknown>;
38
+ optional?: boolean | BFTR;
39
+ disabled?: boolean | BFTR;
40
+ hidden?: boolean | BFTR;
41
+ length?: number;
42
+ validators?: (FNFTR | TFoormValidatorFn<T>)[];
43
+ }
44
+ type TFoormEntryExecutable<T = unknown, O = string> = TFoormEntry<T, O, TFoormFn<T, string>, TFoormFn<T, boolean>, TFoormValidatorFn<T>> & {
45
+ name: string;
46
+ label: string | TFoormFn<T, string>;
47
+ type: string;
48
+ };
49
+ type TFoormMetaExecutable = {
50
+ title: string | TFoormFn<undefined, string>;
51
+ submit: {
52
+ text: string | TFoormFn<undefined, string>;
53
+ disabled: boolean | TFoormFn<undefined, boolean>;
54
+ };
55
+ context: Record<string, unknown>;
56
+ entries: TFoormEntryExecutable[];
57
+ };
58
+
59
+ interface TFoormSubmit<S = TFtring, B = TFtring> {
60
+ text: string | S;
61
+ disabled?: boolean | B;
62
+ }
63
+ interface TFoormOptions {
64
+ title?: StringOrFtring;
65
+ entries: TFoormEntry[];
66
+ submit?: TFoormSubmit;
67
+ context?: Record<string, unknown>;
68
+ }
69
+ declare class Foorm {
70
+ protected entries: TFoormEntry[];
71
+ protected submit?: TFoormSubmit;
72
+ protected title?: StringOrFtring;
73
+ protected context: Record<string, unknown>;
74
+ private fns;
75
+ constructor(opts?: TFoormOptions);
76
+ addEntry(entry: TFoormEntry): void;
77
+ setTitle(title: string): void;
78
+ setSubmit(submit: TFoormSubmit): void;
79
+ setContext<T extends Record<string, unknown>>(context: T): void;
80
+ /**
81
+ * Normalizes form metadata and removes all the functions
82
+ * from validators.
83
+ *
84
+ * @param replaceContext a context to be transported along with metadata
85
+ * @returns form metadata without functions
86
+ */
87
+ transportable<T extends Record<string, unknown>>(replaceContext?: T): Required<TFoormOptions> & {
88
+ context?: Record<string, unknown>;
89
+ };
90
+ protected normalizeEntry<T, O>(e: TFoormEntry<T, O>): TFoormEntry<T, O> & {
91
+ name: string;
92
+ label: string | TFtring;
93
+ type: string;
94
+ };
95
+ /**
96
+ * Evaluates all the ftrings into functions, makes it ready for execution
97
+ *
98
+ * @returns form metadata with functions
99
+ */
100
+ executable(): TFoormMetaExecutable;
101
+ createFormData<T extends Record<string, unknown>>(): T;
102
+ prepareValidators(_validators: TFoormEntry['validators']): TFoormValidatorFn<string>[];
103
+ supportsAltAction(altAction: string): boolean;
104
+ getFormValidator(): (inputs: Record<string, unknown>) => {
105
+ passed: boolean;
106
+ errors: Record<string, string>;
107
+ };
108
+ }
109
+ declare function validate<T = string>(opts: TFoormFnScope<T> & {
110
+ validators: TFoormValidatorFn<T>[];
111
+ }): {
112
+ passed: boolean;
113
+ error: string;
114
+ } | {
115
+ passed: boolean;
116
+ error?: undefined;
117
+ };
118
+
119
+ declare function isFtring(input: unknown): input is TFtring;
120
+ declare function ftring(strings: TemplateStringsArray, __type__?: TFtring['__type__']): TFtring;
121
+
122
+ export { Foorm, type ObjSOF, type StringOrFtring, type TFoormEntry, type TFoormEntryExecutable, type TFoormFn, type TFoormFnScope, type TFoormMetaExecutable, type TFoormOptions, type TFoormSubmit, type TFoormValidatorFn, type TFtring, ftring, isFtring, validate };
package/dist/index.mjs CHANGED
@@ -18,6 +18,7 @@ class Foorm {
18
18
  this.entries = (opts === null || opts === void 0 ? void 0 : opts.entries) || [];
19
19
  this.submit = opts === null || opts === void 0 ? void 0 : opts.submit;
20
20
  this.title = (opts === null || opts === void 0 ? void 0 : opts.title) || '';
21
+ this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {};
21
22
  }
22
23
  addEntry(entry) {
23
24
  this.entries.push(entry);
@@ -28,17 +29,33 @@ class Foorm {
28
29
  setSubmit(submit) {
29
30
  this.submit = submit;
30
31
  }
31
- transportable() {
32
+ setContext(context) {
33
+ this.context = context;
34
+ }
35
+ /**
36
+ * Normalizes form metadata and removes all the functions
37
+ * from validators.
38
+ *
39
+ * @param replaceContext a context to be transported along with metadata
40
+ * @returns form metadata without functions
41
+ */
42
+ transportable(replaceContext) {
32
43
  var _a, _b;
33
44
  return {
34
45
  title: (_a = this.title) !== null && _a !== void 0 ? _a : '',
35
46
  submit: (_b = this.submit) !== null && _b !== void 0 ? _b : { text: 'Submit' },
36
- entries: this.entries.map((e) => (Object.assign(Object.assign({}, this.normalizeEntry(e)), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
47
+ context: replaceContext || this.context,
48
+ entries: this.entries.map((e) => (Object.assign(Object.assign({}, e), { validators: (e.validators || []).filter((v) => isFtring(v)) }))),
37
49
  };
38
50
  }
39
51
  normalizeEntry(e) {
40
52
  return Object.assign(Object.assign({}, e), { name: e.name || e.field, label: e.label || e.field, type: e.type || 'text' });
41
53
  }
54
+ /**
55
+ * Evaluates all the ftrings into functions, makes it ready for execution
56
+ *
57
+ * @returns form metadata with functions
58
+ */
42
59
  executable() {
43
60
  var _a, _b;
44
61
  if (!this.fns)
@@ -49,6 +66,7 @@ class Foorm {
49
66
  text: transformFtrings(((_a = this.submit) === null || _a === void 0 ? void 0 : _a.text) || 'Submit', this.fns),
50
67
  disabled: transformFtrings((_b = this.submit) === null || _b === void 0 ? void 0 : _b.disabled, this.fns),
51
68
  },
69
+ context: this.context,
52
70
  entries: this.entries
53
71
  .map((e) => this.normalizeEntry(e))
54
72
  .map((e) => (Object.assign(Object.assign({}, e), {
@@ -57,10 +75,28 @@ class Foorm {
57
75
  // strings || objects
58
76
  classes: transformFtringsInObj(e.classes, this.fns), styles: transformFtringsInObj(e.styles, this.fns),
59
77
  // booleans
60
- optional: transformFtrings(e.optional, this.fns), disabled: transformFtrings(e.disabled, this.fns), hidden: transformFtrings(e.hidden, this.fns) }))),
78
+ optional: transformFtrings(e.optional, this.fns), disabled: transformFtrings(e.disabled, this.fns), hidden: transformFtrings(e.hidden, this.fns), validators: this.prepareValidators(e.validators) }))),
61
79
  };
62
80
  }
63
- getValidator() {
81
+ createFormData() {
82
+ const data = {};
83
+ for (const entry of this.entries) {
84
+ if (entry.type !== 'action') {
85
+ data[entry.field] = (entry.value ||
86
+ undefined);
87
+ }
88
+ }
89
+ return data;
90
+ }
91
+ prepareValidators(_validators) {
92
+ const validators = (_validators || []).map((v) => isFtring(v) ? this.fns.getFn(v.v) : v);
93
+ validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
94
+ return validators;
95
+ }
96
+ supportsAltAction(altAction) {
97
+ return !!this.entries.find((e) => e.altAction === altAction);
98
+ }
99
+ getFormValidator() {
64
100
  if (!this.fns)
65
101
  this.fns = new FtringsPool();
66
102
  const entries = this.executable().entries;
@@ -69,7 +105,7 @@ class Foorm {
69
105
  if (entry.field) {
70
106
  fields[entry.field] = {
71
107
  entry,
72
- validators: (entry.validators || []).map((v) => isFtring(v) ? this.fns.getFn(v.v) : v),
108
+ validators: this.prepareValidators(entry.validators),
73
109
  };
74
110
  }
75
111
  fields[entry.field].validators.unshift(this.fns.getFn('entry.optional || !!v || "Required"'));
@@ -78,25 +114,48 @@ class Foorm {
78
114
  let passed = true;
79
115
  const errors = {};
80
116
  for (const [key, value] of Object.entries(fields)) {
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
117
  const evalEntry = Object.assign({}, value.entry);
83
- const ctx = {
118
+ const scope = {
84
119
  v: data[key],
85
- validators: value.validators,
86
- entry: value.entry,
120
+ context: this.context,
121
+ entry: {
122
+ field: evalEntry.field,
123
+ type: evalEntry.type,
124
+ component: evalEntry.component,
125
+ name: evalEntry.name,
126
+ length: evalEntry.length,
127
+ },
87
128
  data,
88
129
  };
89
- if (typeof evalEntry.optional === 'function') {
90
- evalEntry.optional = evalEntry.optional(ctx);
91
- }
92
- if (typeof evalEntry.disabled === 'function') {
93
- evalEntry.disabled = evalEntry.disabled(ctx);
130
+ if (scope.entry) {
131
+ if (typeof evalEntry.disabled === 'function') {
132
+ scope.entry.disabled = evalEntry.disabled =
133
+ evalEntry.disabled(scope);
134
+ }
135
+ else {
136
+ scope.entry.disabled = evalEntry.disabled;
137
+ }
138
+ if (typeof evalEntry.optional === 'function') {
139
+ scope.entry.optional = evalEntry.optional =
140
+ evalEntry.optional(scope);
141
+ }
142
+ else {
143
+ scope.entry.optional = evalEntry.optional;
144
+ }
145
+ if (typeof evalEntry.hidden === 'function') {
146
+ scope.entry.hidden = evalEntry.hidden =
147
+ evalEntry.hidden(scope);
148
+ }
149
+ else {
150
+ scope.entry.hidden = evalEntry.hidden;
151
+ }
94
152
  }
95
153
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
154
  const result = validate({
97
155
  v: data[key],
156
+ context: this.context,
98
157
  validators: value.validators,
99
- entry: evalEntry,
158
+ entry: scope.entry,
100
159
  data,
101
160
  });
102
161
  if (!result.passed) {
@@ -117,6 +176,7 @@ function validate(opts) {
117
176
  for (const validator of opts.validators || []) {
118
177
  const result = validator({
119
178
  v: opts.v,
179
+ context: opts.context,
120
180
  data: opts.data,
121
181
  entry: opts.entry,
122
182
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foorm",
3
- "version": "0.0.2-alpha.0",
3
+ "version": "0.0.2-alpha.10",
4
4
  "description": "foorm",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
package/dist/foorm.d.ts DELETED
@@ -1,85 +0,0 @@
1
- import { StringOrFtring, TFoormEntry, TFoormValidatorFn, TFoormFn, TFtring } from './types';
2
- export interface TFoormSubmit<S = TFtring, B = TFtring> {
3
- text: string | S;
4
- disabled?: boolean | B;
5
- }
6
- export interface TFoormOptions {
7
- title?: StringOrFtring;
8
- entries: TFoormEntry[];
9
- submit?: TFoormSubmit;
10
- }
11
- export declare class Foorm {
12
- protected entries: TFoormEntry[];
13
- protected submit?: TFoormSubmit;
14
- protected title?: StringOrFtring;
15
- private fns;
16
- constructor(opts?: TFoormOptions);
17
- addEntry(entry: TFoormEntry): void;
18
- setTitle(title: string): void;
19
- setSubmit(submit: TFoormSubmit): void;
20
- transportable(): Required<TFoormOptions>;
21
- protected normalizeEntry(e: TFoormEntry): {
22
- name: string;
23
- label: string | TFtring;
24
- type: string;
25
- description?: string | TFtring | undefined;
26
- hint?: string | TFtring | undefined;
27
- placeholder?: string | TFtring | undefined;
28
- classes?: string | TFtring | Record<string, boolean | TFtring> | undefined;
29
- styles?: string | TFtring | Record<string, string | TFtring> | undefined;
30
- component?: string | undefined;
31
- field: string;
32
- value?: string | undefined;
33
- options?: string[] | undefined;
34
- attrs?: Record<string, unknown> | undefined;
35
- optional?: boolean | TFtring | undefined;
36
- disabled?: boolean | TFtring | undefined;
37
- hidden?: boolean | TFtring | undefined;
38
- length?: number | undefined;
39
- validators?: (TFtring | TFoormValidatorFn<string>)[] | undefined;
40
- };
41
- executable(): {
42
- title: string | TFoormFn<undefined, string>;
43
- submit: {
44
- text: string | TFoormFn<undefined, string>;
45
- disabled: boolean | TFoormFn<undefined, boolean>;
46
- };
47
- entries: {
48
- label: string | TFoormFn<unknown, string>;
49
- description: string | TFoormFn<unknown, string>;
50
- hint: unknown;
51
- placeholder: string | TFoormFn<unknown, string>;
52
- classes: string | TFoormFn<unknown, string> | Record<string, boolean | TFoormFn<unknown, boolean>>;
53
- styles: string | TFoormFn<unknown, string> | Record<string, string | TFoormFn<unknown, string>>;
54
- optional: boolean | TFoormFn<unknown, boolean>;
55
- disabled: boolean | TFoormFn<unknown, boolean>;
56
- hidden: boolean | TFoormFn<unknown, boolean>;
57
- name: string;
58
- type: string;
59
- component?: string | undefined;
60
- field: string;
61
- value?: string | undefined;
62
- options?: string[] | undefined;
63
- attrs?: Record<string, unknown> | undefined;
64
- length?: number | undefined;
65
- validators?: (TFtring | TFoormValidatorFn<string>)[] | undefined;
66
- }[];
67
- };
68
- getValidator(): (inputs: Record<string, unknown>) => {
69
- passed: boolean;
70
- errors: Record<string, string>;
71
- };
72
- }
73
- export type TFoormExecutableMeta = ReturnType<Foorm['executable']>;
74
- export declare function validate<T = string>(opts: {
75
- v: T;
76
- data: Record<string, unknown>;
77
- entry?: TFoormEntry<T>;
78
- validators: TFoormValidatorFn<T>[];
79
- }): {
80
- passed: boolean;
81
- error: string;
82
- } | {
83
- passed: boolean;
84
- error?: undefined;
85
- };
@@ -1 +0,0 @@
1
- export {};
package/dist/types.d.ts DELETED
@@ -1,35 +0,0 @@
1
- export type TFtring = {
2
- __is_ftring__: true;
3
- v: string;
4
- __type__?: 'boolean' | 'string' | 'number';
5
- };
6
- export type StringOrFtring = string | TFtring;
7
- export type ObjSOF = Record<string, StringOrFtring>;
8
- export type TFoormFnCtx<T = string> = {
9
- v?: T;
10
- data: Record<string, unknown>;
11
- entry?: TFoormEntry<T>;
12
- action?: string;
13
- };
14
- export type TFoormValidatorFn<T = string> = (ctx: TFoormFnCtx<T>) => string | boolean;
15
- export type TFoormFn<T = string, R = string | boolean> = (ctx: TFoormFnCtx<T>) => R;
16
- export interface TFoormEntry<T = string, O = string, SFTR = TFtring, BFTR = TFtring, FNFTR = TFtring> {
17
- label?: string | SFTR;
18
- description?: string | SFTR;
19
- hint?: string | SFTR;
20
- placeholder?: string | SFTR;
21
- classes?: (string | SFTR) | Record<string, boolean | BFTR>;
22
- styles?: (string | SFTR) | Record<string, string | SFTR>;
23
- type?: string;
24
- component?: string;
25
- name?: string;
26
- field: string;
27
- value?: T;
28
- options?: O[];
29
- attrs?: Record<string, unknown>;
30
- optional?: boolean | BFTR;
31
- disabled?: boolean | BFTR;
32
- hidden?: boolean | BFTR;
33
- length?: number;
34
- validators?: (FNFTR | TFoormValidatorFn<T>)[];
35
- }
package/dist/utils.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { TFtring } from './types';
2
- export declare function isFtring(input: unknown): input is TFtring;
3
- export declare function ftring(strings: TemplateStringsArray, __type__?: TFtring['__type__']): TFtring;
@@ -1 +0,0 @@
1
- export {};