@fiddle-digital/string-tune 1.1.17 → 1.1.19

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.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,31 @@ 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
+ }
776
+ interface ValidationResult {
777
+ valid: boolean;
778
+ errors: string[];
779
+ }
780
+ declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
781
+ process({ rules, value }: ValidateInput): ValidationResult;
782
+ validators: Record<string, (value: any, ...params: string[]) => boolean>;
783
+ getErrorMessage(key: string, params?: string[]): string;
784
+ }
785
+
802
786
  /**
803
787
  * Interface describing all available tools used inside modules.
804
788
  */
@@ -860,6 +844,7 @@ interface StringToolsContainer {
860
844
  lerpVector: LerpVector2Tool;
861
845
  transformScaleParser: TransformScaleParserTool;
862
846
  optionsParser: SplitOptionsParserTool;
847
+ ruleParser: RuleParserTool;
863
848
  }
864
849
 
865
850
  /**
@@ -1773,6 +1758,13 @@ declare class StringSequence extends StringModule {
1773
1758
  private setSequenceState;
1774
1759
  }
1775
1760
 
1761
+ declare class StringForm extends StringModule {
1762
+ constructor(context: StringContext);
1763
+ onObjectConnected(object: StringObject): void;
1764
+ getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
1765
+ getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
1766
+ }
1767
+
1776
1768
  declare class StringTune {
1777
1769
  /** Bound handler for the scroll start event */
1778
1770
  private onScrollStartBind;
@@ -2010,4 +2002,4 @@ declare class StringTune {
2010
2002
  destroy(): void;
2011
2003
  }
2012
2004
 
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 };
2005
+ 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,31 @@ 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
+ }
776
+ interface ValidationResult {
777
+ valid: boolean;
778
+ errors: string[];
779
+ }
780
+ declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
781
+ process({ rules, value }: ValidateInput): ValidationResult;
782
+ validators: Record<string, (value: any, ...params: string[]) => boolean>;
783
+ getErrorMessage(key: string, params?: string[]): string;
784
+ }
785
+
802
786
  /**
803
787
  * Interface describing all available tools used inside modules.
804
788
  */
@@ -860,6 +844,7 @@ interface StringToolsContainer {
860
844
  lerpVector: LerpVector2Tool;
861
845
  transformScaleParser: TransformScaleParserTool;
862
846
  optionsParser: SplitOptionsParserTool;
847
+ ruleParser: RuleParserTool;
863
848
  }
864
849
 
865
850
  /**
@@ -1773,6 +1758,13 @@ declare class StringSequence extends StringModule {
1773
1758
  private setSequenceState;
1774
1759
  }
1775
1760
 
1761
+ declare class StringForm extends StringModule {
1762
+ constructor(context: StringContext);
1763
+ onObjectConnected(object: StringObject): void;
1764
+ getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
1765
+ getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
1766
+ }
1767
+
1776
1768
  declare class StringTune {
1777
1769
  /** Bound handler for the scroll start event */
1778
1770
  private onScrollStartBind;
@@ -2010,4 +2002,4 @@ declare class StringTune {
2010
2002
  destroy(): void;
2011
2003
  }
2012
2004
 
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 };
2005
+ 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 };