@fiddle-digital/string-tune 1.1.18 → 1.1.20
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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +37 -42
- package/dist/index.d.ts +37 -42
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -537,47 +537,6 @@ declare class ColorParserTool implements IStringTool<ColorParserInput, StringCol
|
|
537
537
|
private hslToRgb;
|
538
538
|
}
|
539
539
|
|
540
|
-
type ValidationErrorCode = "required" | "invalid-email" | "too-short" | "too-long";
|
541
|
-
type ValidationRule = "required" | "email" | {
|
542
|
-
type: "minLength";
|
543
|
-
value: number;
|
544
|
-
} | {
|
545
|
-
type: "maxLength";
|
546
|
-
value: number;
|
547
|
-
};
|
548
|
-
interface ValidationInput {
|
549
|
-
/** Value to validate. */
|
550
|
-
value: string;
|
551
|
-
/** List of rules to apply. */
|
552
|
-
rules: ValidationRule[];
|
553
|
-
/**
|
554
|
-
* Optional message map: key = errorCode, value = string or function returning a message.
|
555
|
-
*/
|
556
|
-
messages?: Partial<Record<ValidationErrorCode, string | ((args: {
|
557
|
-
value: string;
|
558
|
-
rule: ValidationRule;
|
559
|
-
}) => string)>>;
|
560
|
-
}
|
561
|
-
interface ValidationOutput {
|
562
|
-
/** `true` if valid, `false` if error found. */
|
563
|
-
valid: boolean;
|
564
|
-
/** One of the known error codes (or null if no error). */
|
565
|
-
error: ValidationErrorCode | null;
|
566
|
-
/** Final message (either default or user-defined). */
|
567
|
-
message: string | null;
|
568
|
-
}
|
569
|
-
/**
|
570
|
-
* Tool for validating strings using rules like `required`, `minLength`, etc.
|
571
|
-
* Allows custom error messages (as string or generator function).
|
572
|
-
*/
|
573
|
-
declare class ValidationTool implements IStringTool<ValidationInput, ValidationOutput> {
|
574
|
-
/**
|
575
|
-
* Validates input value and returns error code + message.
|
576
|
-
*/
|
577
|
-
process({ value, rules, messages }: ValidationInput): ValidationOutput;
|
578
|
-
private defaultMessage;
|
579
|
-
}
|
580
|
-
|
581
540
|
/**
|
582
541
|
* Input parameters for EasingFunctionTool.
|
583
542
|
*/
|
@@ -799,6 +758,33 @@ declare class SplitOptionsParserTool implements IStringTool<SplitOptionsParserIn
|
|
799
758
|
private parseParamsArray;
|
800
759
|
}
|
801
760
|
|
761
|
+
interface RuleParserInput {
|
762
|
+
value: string;
|
763
|
+
}
|
764
|
+
interface RuleParserResult {
|
765
|
+
key: string;
|
766
|
+
params?: string[];
|
767
|
+
}
|
768
|
+
declare class RuleParserTool implements IStringTool<RuleParserInput, RuleParserResult[]> {
|
769
|
+
process({ value }: RuleParserInput): RuleParserResult[];
|
770
|
+
}
|
771
|
+
|
772
|
+
interface ValidateInput {
|
773
|
+
rules: RuleParserResult[];
|
774
|
+
value: any;
|
775
|
+
type?: "input" | "beforeinput";
|
776
|
+
}
|
777
|
+
interface ValidationResult {
|
778
|
+
valid: boolean;
|
779
|
+
errors: string[];
|
780
|
+
}
|
781
|
+
declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
|
782
|
+
process({ rules, value, type }: ValidateInput): ValidationResult;
|
783
|
+
inputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
|
784
|
+
beforeInputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
|
785
|
+
getErrorMessage(key: string, params?: string[]): string;
|
786
|
+
}
|
787
|
+
|
802
788
|
/**
|
803
789
|
* Interface describing all available tools used inside modules.
|
804
790
|
*/
|
@@ -860,6 +846,7 @@ interface StringToolsContainer {
|
|
860
846
|
lerpVector: LerpVector2Tool;
|
861
847
|
transformScaleParser: TransformScaleParserTool;
|
862
848
|
optionsParser: SplitOptionsParserTool;
|
849
|
+
ruleParser: RuleParserTool;
|
863
850
|
}
|
864
851
|
|
865
852
|
/**
|
@@ -1773,6 +1760,14 @@ declare class StringSequence extends StringModule {
|
|
1773
1760
|
private setSequenceState;
|
1774
1761
|
}
|
1775
1762
|
|
1763
|
+
declare class StringForm extends StringModule {
|
1764
|
+
constructor(context: StringContext);
|
1765
|
+
initializeObject(globalId: number, object: StringObject, element: HTMLElement, attributes: Record<string, any>): void;
|
1766
|
+
onObjectConnected(object: StringObject): void;
|
1767
|
+
getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
|
1768
|
+
getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
|
1769
|
+
}
|
1770
|
+
|
1776
1771
|
declare class StringTune {
|
1777
1772
|
/** Bound handler for the scroll start event */
|
1778
1773
|
private onScrollStartBind;
|
@@ -2010,4 +2005,4 @@ declare class StringTune {
|
|
2010
2005
|
destroy(): void;
|
2011
2006
|
}
|
2012
2007
|
|
2013
|
-
export { type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringGlide, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringResponsive, StringScrollbar, StringSequence, StringSplit, StringTune, StringVideoAutoplay, StringTune as default };
|
2008
|
+
export { type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringResponsive, StringScrollbar, StringSequence, StringSplit, StringTune, StringVideoAutoplay, StringTune as default };
|
package/dist/index.d.ts
CHANGED
@@ -537,47 +537,6 @@ declare class ColorParserTool implements IStringTool<ColorParserInput, StringCol
|
|
537
537
|
private hslToRgb;
|
538
538
|
}
|
539
539
|
|
540
|
-
type ValidationErrorCode = "required" | "invalid-email" | "too-short" | "too-long";
|
541
|
-
type ValidationRule = "required" | "email" | {
|
542
|
-
type: "minLength";
|
543
|
-
value: number;
|
544
|
-
} | {
|
545
|
-
type: "maxLength";
|
546
|
-
value: number;
|
547
|
-
};
|
548
|
-
interface ValidationInput {
|
549
|
-
/** Value to validate. */
|
550
|
-
value: string;
|
551
|
-
/** List of rules to apply. */
|
552
|
-
rules: ValidationRule[];
|
553
|
-
/**
|
554
|
-
* Optional message map: key = errorCode, value = string or function returning a message.
|
555
|
-
*/
|
556
|
-
messages?: Partial<Record<ValidationErrorCode, string | ((args: {
|
557
|
-
value: string;
|
558
|
-
rule: ValidationRule;
|
559
|
-
}) => string)>>;
|
560
|
-
}
|
561
|
-
interface ValidationOutput {
|
562
|
-
/** `true` if valid, `false` if error found. */
|
563
|
-
valid: boolean;
|
564
|
-
/** One of the known error codes (or null if no error). */
|
565
|
-
error: ValidationErrorCode | null;
|
566
|
-
/** Final message (either default or user-defined). */
|
567
|
-
message: string | null;
|
568
|
-
}
|
569
|
-
/**
|
570
|
-
* Tool for validating strings using rules like `required`, `minLength`, etc.
|
571
|
-
* Allows custom error messages (as string or generator function).
|
572
|
-
*/
|
573
|
-
declare class ValidationTool implements IStringTool<ValidationInput, ValidationOutput> {
|
574
|
-
/**
|
575
|
-
* Validates input value and returns error code + message.
|
576
|
-
*/
|
577
|
-
process({ value, rules, messages }: ValidationInput): ValidationOutput;
|
578
|
-
private defaultMessage;
|
579
|
-
}
|
580
|
-
|
581
540
|
/**
|
582
541
|
* Input parameters for EasingFunctionTool.
|
583
542
|
*/
|
@@ -799,6 +758,33 @@ declare class SplitOptionsParserTool implements IStringTool<SplitOptionsParserIn
|
|
799
758
|
private parseParamsArray;
|
800
759
|
}
|
801
760
|
|
761
|
+
interface RuleParserInput {
|
762
|
+
value: string;
|
763
|
+
}
|
764
|
+
interface RuleParserResult {
|
765
|
+
key: string;
|
766
|
+
params?: string[];
|
767
|
+
}
|
768
|
+
declare class RuleParserTool implements IStringTool<RuleParserInput, RuleParserResult[]> {
|
769
|
+
process({ value }: RuleParserInput): RuleParserResult[];
|
770
|
+
}
|
771
|
+
|
772
|
+
interface ValidateInput {
|
773
|
+
rules: RuleParserResult[];
|
774
|
+
value: any;
|
775
|
+
type?: "input" | "beforeinput";
|
776
|
+
}
|
777
|
+
interface ValidationResult {
|
778
|
+
valid: boolean;
|
779
|
+
errors: string[];
|
780
|
+
}
|
781
|
+
declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
|
782
|
+
process({ rules, value, type }: ValidateInput): ValidationResult;
|
783
|
+
inputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
|
784
|
+
beforeInputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
|
785
|
+
getErrorMessage(key: string, params?: string[]): string;
|
786
|
+
}
|
787
|
+
|
802
788
|
/**
|
803
789
|
* Interface describing all available tools used inside modules.
|
804
790
|
*/
|
@@ -860,6 +846,7 @@ interface StringToolsContainer {
|
|
860
846
|
lerpVector: LerpVector2Tool;
|
861
847
|
transformScaleParser: TransformScaleParserTool;
|
862
848
|
optionsParser: SplitOptionsParserTool;
|
849
|
+
ruleParser: RuleParserTool;
|
863
850
|
}
|
864
851
|
|
865
852
|
/**
|
@@ -1773,6 +1760,14 @@ declare class StringSequence extends StringModule {
|
|
1773
1760
|
private setSequenceState;
|
1774
1761
|
}
|
1775
1762
|
|
1763
|
+
declare class StringForm extends StringModule {
|
1764
|
+
constructor(context: StringContext);
|
1765
|
+
initializeObject(globalId: number, object: StringObject, element: HTMLElement, attributes: Record<string, any>): void;
|
1766
|
+
onObjectConnected(object: StringObject): void;
|
1767
|
+
getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
|
1768
|
+
getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
|
1769
|
+
}
|
1770
|
+
|
1776
1771
|
declare class StringTune {
|
1777
1772
|
/** Bound handler for the scroll start event */
|
1778
1773
|
private onScrollStartBind;
|
@@ -2010,4 +2005,4 @@ declare class StringTune {
|
|
2010
2005
|
destroy(): void;
|
2011
2006
|
}
|
2012
2007
|
|
2013
|
-
export { type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringGlide, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringResponsive, StringScrollbar, StringSequence, StringSplit, StringTune, StringVideoAutoplay, StringTune as default };
|
2008
|
+
export { type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringResponsive, StringScrollbar, StringSequence, StringSplit, StringTune, StringVideoAutoplay, StringTune as default };
|