@aerogel/core 0.1.1-next.ad50ec0af53abadac36a5f25261330a0b5d77f4b → 0.1.1-next.b342b522bd4e8a154c68962bb545cd8ae66010c3

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.
@@ -1,6 +1,9 @@
1
1
  import type { FormFieldDefinition } from './FormController';
2
2
 
3
- export function booleanInput(defaultValue?: boolean, options: { rules?: string } = {}): FormFieldDefinition<'boolean'> {
3
+ export function booleanInput(
4
+ defaultValue?: boolean,
5
+ options: { rules?: string[] } = {},
6
+ ): FormFieldDefinition<'boolean'> {
4
7
  return {
5
8
  default: defaultValue,
6
9
  type: 'boolean',
@@ -8,7 +11,7 @@ export function booleanInput(defaultValue?: boolean, options: { rules?: string }
8
11
  };
9
12
  }
10
13
 
11
- export function dateInput(defaultValue?: Date, options: { rules?: string } = {}): FormFieldDefinition<'date'> {
14
+ export function dateInput(defaultValue?: Date, options: { rules?: string[] } = {}): FormFieldDefinition<'date'> {
12
15
  return {
13
16
  default: defaultValue,
14
17
  type: 'date',
@@ -19,7 +22,7 @@ export function dateInput(defaultValue?: Date, options: { rules?: string } = {})
19
22
  export function enumInput<const T extends string>(
20
23
  values: readonly T[],
21
24
  defaultValue?: T,
22
- options: { rules?: string } = {},
25
+ options: { rules?: string[] } = {},
23
26
  ): FormFieldDefinition<'enum', string, T> {
24
27
  return {
25
28
  default: defaultValue,
@@ -29,59 +32,75 @@ export function enumInput<const T extends string>(
29
32
  };
30
33
  }
31
34
 
32
- export function requiredBooleanInput(defaultValue?: boolean): FormFieldDefinition<'boolean', 'required'> {
35
+ export function requiredBooleanInput(
36
+ defaultValue?: boolean,
37
+ options: { rules?: string[] } = {},
38
+ ): FormFieldDefinition<'boolean', 'required'> {
33
39
  return {
34
40
  default: defaultValue,
35
41
  type: 'boolean',
36
- rules: 'required',
42
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
37
43
  };
38
44
  }
39
45
 
40
- export function requiredDateInput(defaultValue?: Date): FormFieldDefinition<'date', 'required'> {
46
+ export function requiredDateInput(
47
+ defaultValue?: Date,
48
+ options: { rules?: string[] } = {},
49
+ ): FormFieldDefinition<'date', 'required'> {
41
50
  return {
42
51
  default: defaultValue,
43
52
  type: 'date',
44
- rules: 'required',
53
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
45
54
  };
46
55
  }
47
56
 
48
57
  export function requiredEnumInput<const T extends string>(
49
58
  values: readonly T[],
50
59
  defaultValue?: T,
60
+ options: { rules?: string[] } = {},
51
61
  ): FormFieldDefinition<'enum', 'required', T> {
52
62
  return {
53
63
  default: defaultValue,
54
64
  type: 'enum',
55
- rules: 'required',
65
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
56
66
  values,
57
67
  };
58
68
  }
59
69
 
60
- export function requiredNumberInput(defaultValue?: number): FormFieldDefinition<'number', 'required'> {
70
+ export function requiredNumberInput(
71
+ defaultValue?: number,
72
+ options: { rules?: string[] } = {},
73
+ ): FormFieldDefinition<'number', 'required'> {
61
74
  return {
62
75
  default: defaultValue,
63
76
  type: 'number',
64
- rules: 'required',
77
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
65
78
  };
66
79
  }
67
80
 
68
- export function requiredObjectInput<T extends object>(defaultValue?: T): FormFieldDefinition<'object', 'required', T> {
81
+ export function requiredObjectInput<T extends object>(
82
+ defaultValue?: T,
83
+ options: { rules?: string[] } = {},
84
+ ): FormFieldDefinition<'object', 'required', T> {
69
85
  return {
70
86
  default: defaultValue,
71
87
  type: 'object',
72
- rules: 'required',
88
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
73
89
  };
74
90
  }
75
91
 
76
- export function requiredStringInput(defaultValue?: string): FormFieldDefinition<'string', 'required'> {
92
+ export function requiredStringInput(
93
+ defaultValue?: string,
94
+ options: { rules?: string[] } = {},
95
+ ): FormFieldDefinition<'string', 'required'> {
77
96
  return {
78
97
  default: defaultValue,
79
98
  type: 'string',
80
- rules: 'required',
99
+ rules: ['required', ...((options.rules as 'required'[]) ?? [])],
81
100
  };
82
101
  }
83
102
 
84
- export function numberInput(defaultValue?: number, options: { rules?: string } = {}): FormFieldDefinition<'number'> {
103
+ export function numberInput(defaultValue?: number, options: { rules?: string[] } = {}): FormFieldDefinition<'number'> {
85
104
  return {
86
105
  default: defaultValue,
87
106
  type: 'number',
@@ -91,7 +110,7 @@ export function numberInput(defaultValue?: number, options: { rules?: string } =
91
110
 
92
111
  export function objectInput<T extends object>(
93
112
  defaultValue?: T,
94
- options: { rules?: string } = {},
113
+ options: { rules?: string[] } = {},
95
114
  ): FormFieldDefinition<'object', string, T> {
96
115
  return {
97
116
  default: defaultValue,
@@ -100,7 +119,7 @@ export function objectInput<T extends object>(
100
119
  };
101
120
  }
102
121
 
103
- export function stringInput(defaultValue?: string, options: { rules?: string } = {}): FormFieldDefinition<'string'> {
122
+ export function stringInput(defaultValue?: string, options: { rules?: string[] } = {}): FormFieldDefinition<'string'> {
104
123
  return {
105
124
  default: defaultValue,
106
125
  type: 'string',
@@ -31,10 +31,14 @@ export type FormFieldValidator<T = unknown> = (value: T) => string | string[] |
31
31
 
32
32
  export const validators: Record<string, FormFieldValidator> = { ...builtInRules };
33
33
 
34
- export function defineFormValidationRule<T>(rule: string, validator: FormFieldValidator<T>): void {
34
+ export function registerFormValidationRule<T>(rule: string, validator: FormFieldValidator<T>): void {
35
35
  validators[rule] = validator as FormFieldValidator;
36
36
  }
37
37
 
38
+ export function defineFormValidationRules<T extends Record<string, FormFieldValidator>>(rules: T): T {
39
+ return rules;
40
+ }
41
+
38
42
  export function validateType(value: unknown, definition: FormFieldDefinition): string[] {
39
43
  if (isValidType(value, definition)) {
40
44
  return [];
package/src/jobs/Job.ts CHANGED
@@ -115,7 +115,7 @@ export default abstract class Job<
115
115
  return 1;
116
116
  }
117
117
 
118
- if (!status.children) {
118
+ if (!status.children || status.children.length === 0) {
119
119
  return 0;
120
120
  }
121
121
 
@@ -10,6 +10,7 @@ import Service from './Service';
10
10
  import Storage from './Storage';
11
11
  import { getPiniaStore } from './store';
12
12
  import type { AppSetting } from './App.state';
13
+ import type { FormFieldValidator } from '@aerogel/core/forms';
13
14
 
14
15
  export * from './App';
15
16
  export * from './Cache';
@@ -68,6 +69,7 @@ declare module '@aerogel/core/bootstrap/options' {
68
69
  export interface AerogelOptions {
69
70
  services?: Record<string, Service>;
70
71
  settings?: AppSetting[];
72
+ formValidationRules?: Record<string, FormFieldValidator>;
71
73
  settingsFullscreenOnMobile?: boolean;
72
74
  }
73
75
  }
@@ -1,12 +0,0 @@
1
- <template>
2
- <slot />
3
- </template>
4
-
5
- <script setup lang="ts">
6
- import { provide } from 'vue';
7
-
8
- const { name } = defineProps<{ name: string }>();
9
- const model = defineModel<unknown>();
10
-
11
- provide(name, model);
12
- </script>