@regle/core 1.19.11 → 1.19.13
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/regle-core.d.ts +24 -9
- package/dist/regle-core.js +2554 -2460
- package/dist/regle-core.min.js +2 -2
- package/package.json +1 -1
package/dist/regle-core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @regle/core v1.19.
|
|
2
|
+
* @regle/core v1.19.13
|
|
3
3
|
* (c) 2026 Victor Garcia
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -67,6 +67,11 @@ interface RegleBehaviourOptions {
|
|
|
67
67
|
* @default false
|
|
68
68
|
*/
|
|
69
69
|
immediateDirty?: boolean | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Disable all the computation
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
disabled?: boolean | undefined;
|
|
70
75
|
}
|
|
71
76
|
interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<TState>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
|
|
72
77
|
/**
|
|
@@ -96,6 +101,17 @@ interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules
|
|
|
96
101
|
*/
|
|
97
102
|
id?: string | undefined;
|
|
98
103
|
}
|
|
104
|
+
type FieldOnlyRegleBehaviourOptions = {
|
|
105
|
+
/**
|
|
106
|
+
* Set external errors for the field.
|
|
107
|
+
*/
|
|
108
|
+
externalErrors?: Ref<string[]>;
|
|
109
|
+
/**
|
|
110
|
+
* A unique identifier for the Regle instance in the devtools.
|
|
111
|
+
* @default undefined
|
|
112
|
+
*/
|
|
113
|
+
id?: string | undefined;
|
|
114
|
+
};
|
|
99
115
|
type RegleValidationGroupEntry = RegleFieldStatus<any, any> | undefined;
|
|
100
116
|
interface RegleValidationGroupOutput {
|
|
101
117
|
/** Indicates whether any field in the validation group is invalid. */
|
|
@@ -391,9 +407,10 @@ type UnwrapSimple<T extends MaybeRef<Record<string, any>>> = T extends MaybeComp
|
|
|
391
407
|
type ExtractFromGetter<T extends MaybeGetter<any, any, any>> = T extends ((value: Ref<any>, index: number) => infer U extends Record<string, any>) ? U : T;
|
|
392
408
|
type ExtendOnlyRealRecord<T extends unknown> = NonNullable<T> extends File | Date | RegleStatic<{}> | RegleStaticImpl<{}> ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
393
409
|
type OmitByType<T extends Record<string, any>, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] };
|
|
394
|
-
type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]:
|
|
410
|
+
type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]: MaybeRefOrGetter<T[K]> };
|
|
395
411
|
type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K] };
|
|
396
412
|
type PrimitiveTypes = string | number | boolean | bigint | Date | File;
|
|
413
|
+
type WidenPrimitiveLiterals<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T;
|
|
397
414
|
type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File | RegleStatic<unknown> | RegleStaticImpl<unknown> ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
398
415
|
type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
399
416
|
/**
|
|
@@ -683,9 +700,9 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<ExtendedRule
|
|
|
683
700
|
* @see {@link https://reglejs.dev/advanced-usage/global-config Documentation}
|
|
684
701
|
*/
|
|
685
702
|
declare function defineRegleOptions<T extends GlobalConfigOptions<Partial<ExtendedRulesDeclarationsOverrides>, RegleShortcutDefinition<any>>>(options: T): T;
|
|
686
|
-
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<NonNullable<JoinDiscriminatedUnions<TState>>, CustomRulesDeclarationTree>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends Record<string, any> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState>, TRules, TValidationGroups> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions;
|
|
703
|
+
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<NonNullable<JoinDiscriminatedUnions<TState>>, CustomRulesDeclarationTree>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends Record<string, any> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState>, TRules, TValidationGroups> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions & FieldOnlyRegleBehaviourOptions>> & TAdditionalOptions;
|
|
687
704
|
interface useRegleFn<TCustomRules extends Partial<ExtendedRulesDeclarationsOverrides>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
688
|
-
<TState extends MaybeRef<Record<string, any> | MaybeInput<PrimitiveTypes>>, TRules extends ReglePartialRuleTree<JoinDiscriminatedUnions<Unwrap<TState>>, Partial<ExtendedRulesDeclarations & Omit<TCustomRules, keyof DefaultValidatorsTree>>>, TDecl extends RegleRuleDecl<NonNullable<Unwrap<TState
|
|
705
|
+
<TState extends MaybeRef<Record<string, any> | MaybeInput<PrimitiveTypes>>, TRules extends ReglePartialRuleTree<JoinDiscriminatedUnions<Unwrap<TState>>, Partial<ExtendedRulesDeclarations & Omit<TCustomRules, keyof DefaultValidatorsTree>>>, TDecl extends RegleRuleDecl<WidenPrimitiveLiterals<NonNullable<Unwrap<TState>>>, Partial<ExtendedRulesDeclarations & TCustomRules>>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<TState> | DeepReactiveState<TState>, rulesFactory: Unwrap<TState> extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : Unwrap<TState> extends Record<string, any> ? MaybeComputedOrGetter<TRules> : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<Unwrap<TState>, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<Unwrap<NoInferLegacy<TState>>, TRules, TAdditionalOptions, TValidationGroups>])]): NonNullable<Unwrap<TState>> extends PrimitiveTypes ? RegleSingleField<WidenPrimitiveLiterals<NonNullable<Unwrap<TState>>>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<Unwrap<TState> extends Record<string, any> ? Unwrap<TState> : {}, UnwrapSimple<TRules> extends Record<string, any> ? UnwrapSimple<TRules> : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
|
|
689
706
|
__config?: GlobalConfigOptions<TCustomRules, TShortcuts>;
|
|
690
707
|
}
|
|
691
708
|
/**
|
|
@@ -751,9 +768,7 @@ declare function useRootStorage({
|
|
|
751
768
|
schemaMode?: boolean;
|
|
752
769
|
onValidate?: () => Promise<$InternalRegleResult>;
|
|
753
770
|
overrides: GlobalConfigOverrides | undefined;
|
|
754
|
-
}):
|
|
755
|
-
regle: $InternalRegleStatusType | undefined;
|
|
756
|
-
};
|
|
771
|
+
}): Ref<$InternalRegleStatusType | undefined, $InternalRegleStatusType | undefined>;
|
|
757
772
|
/**
|
|
758
773
|
* Converts a nested `$errors` object to a flat array of error strings.
|
|
759
774
|
* Useful for displaying a complete list of form errors or counting total errors.
|
|
@@ -828,7 +843,7 @@ declare function flatErrors(errors: $InternalRegleErrors, options?: {
|
|
|
828
843
|
*
|
|
829
844
|
* @see {@link https://reglejs.dev/core-concepts/displaying-errors#get-errors-by-path Documentation}
|
|
830
845
|
*/
|
|
831
|
-
declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$errors']> | (string & {})>(r$:
|
|
846
|
+
declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$errors']> | (string & {})>(r$: MaybeRefOrGetter<TRegle>, path: TPath): IsStringLiteral<TPath> extends true ? Get<TRegle['$errors'], TPath & string> : string[] | undefined;
|
|
832
847
|
/**
|
|
833
848
|
* Retrieves detailed validation issues for a specific field using a dot-notation path.
|
|
834
849
|
* Issues contain more information than errors, including the rule name, property, and metadata.
|
|
@@ -866,7 +881,7 @@ declare function getErrors<TRegle extends SuperCompatibleRegleRoot | SuperCompat
|
|
|
866
881
|
*
|
|
867
882
|
* @see {@link https://reglejs.dev/core-concepts/displaying-errors#get-issues-by-path Documentation}
|
|
868
883
|
*/
|
|
869
|
-
declare function getIssues<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$issues']>>(r$:
|
|
884
|
+
declare function getIssues<TRegle extends SuperCompatibleRegleRoot | SuperCompatibleRegleStatus, TPath extends Paths<TRegle['$issues']>>(r$: MaybeRefOrGetter<TRegle>, path: TPath | (string & {})): IsStringLiteral<TPath> extends true ? Get<TRegle['$issues'], TPath & string> : RegleFieldIssue[] | undefined;
|
|
870
885
|
type useRulesFnOptions<TRules extends RegleUnknownRulesTree | RegleRuleDecl, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState = InferInput<TRules>> = Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? (TRules extends Record<string, any> ? TRules : {}) : {}, TValidationGroups>;
|
|
871
886
|
interface useRulesFn<TCustomRules extends Partial<ExtendedRulesDeclarationsOverrides>, TShortcuts extends RegleShortcutDefinition<any> = never> {
|
|
872
887
|
<TRules extends RegleUnknownRulesTree | RegleRuleDecl, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<ExtendedRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState extends Record<string, any> = InferInput<TRules>>(rulesFactory: TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {}, options?: useRulesFnOptions<TRules, TValidationGroups, TState>): NonNullable<TState> extends PrimitiveTypes ? Raw<RegleFieldStatus<NonNullable<TState>, TDecl, TShortcuts>> & StandardSchemaV1<TState> : Raw<RegleRoot<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules extends Record<string, any> ? TRules : {}, TValidationGroups, TShortcuts>> & StandardSchemaV1<TState>;
|