@frontile/forms 0.18.0-alpha.10 → 0.18.0-alpha.12

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,69 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { type FormControlSharedArgs } from './form-control';
3
- import { type TextareaSlots, type TextareaVariants, type SlotsToClasses } from '@frontile/theme';
4
- interface Args extends FormControlSharedArgs {
5
- id?: string;
6
- value?: string | number | boolean;
7
- name?: string;
8
- size?: TextareaVariants['size'];
9
- classes?: SlotsToClasses<TextareaSlots>;
10
- onInput?: (value: string, event: InputEvent) => void;
11
- onChange?: (value: string, event: InputEvent) => void;
12
- onBlur?: () => void;
13
- }
14
- interface TextareaSignature {
15
- Args: Args;
16
- Element: HTMLTextAreaElement;
17
- }
18
- declare class Textarea extends Component<TextareaSignature> {
19
- handleOnInput(event: Event): void;
20
- handleOnChange(event: Event): void;
21
- handleOnBlur(): void;
22
- get classes(): {
23
- base: (slotProps?: ({
24
- size?: "sm" | "md" | "lg" | undefined;
25
- startContentPointerEvents?: "none" | "auto" | undefined;
26
- endContentPointerEvents?: "none" | "auto" | undefined;
27
- hasStartContent?: boolean | undefined;
28
- hasEndContent?: boolean | undefined;
29
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
30
- innerContainer: (slotProps?: ({
31
- size?: "sm" | "md" | "lg" | undefined;
32
- startContentPointerEvents?: "none" | "auto" | undefined;
33
- endContentPointerEvents?: "none" | "auto" | undefined;
34
- hasStartContent?: boolean | undefined;
35
- hasEndContent?: boolean | undefined;
36
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
37
- startContent: (slotProps?: ({
38
- size?: "sm" | "md" | "lg" | undefined;
39
- startContentPointerEvents?: "none" | "auto" | undefined;
40
- endContentPointerEvents?: "none" | "auto" | undefined;
41
- hasStartContent?: boolean | undefined;
42
- hasEndContent?: boolean | undefined;
43
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
44
- endContent: (slotProps?: ({
45
- size?: "sm" | "md" | "lg" | undefined;
46
- startContentPointerEvents?: "none" | "auto" | undefined;
47
- endContentPointerEvents?: "none" | "auto" | undefined;
48
- hasStartContent?: boolean | undefined;
49
- hasEndContent?: boolean | undefined;
50
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
51
- input: (slotProps?: ({
52
- size?: "sm" | "md" | "lg" | undefined;
53
- startContentPointerEvents?: "none" | "auto" | undefined;
54
- endContentPointerEvents?: "none" | "auto" | undefined;
55
- hasStartContent?: boolean | undefined;
56
- hasEndContent?: boolean | undefined;
57
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
58
- } & {
59
- input: (slotProps?: ({
60
- size?: "sm" | "md" | "lg" | undefined;
61
- startContentPointerEvents?: "none" | "auto" | undefined;
62
- endContentPointerEvents?: "none" | "auto" | undefined;
63
- hasStartContent?: boolean | undefined;
64
- hasEndContent?: boolean | undefined;
65
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
66
- } & {};
67
- }
68
- export { Textarea, type TextareaSignature };
69
- export default Textarea;
@@ -1,3 +0,0 @@
1
- declare function triggerFormInputEvent(element?: HTMLElement | null): void;
2
- export { triggerFormInputEvent };
3
- export { flattenData, unflattenData, hasNestedData, deepEqual } from './nested-data';
@@ -1,44 +0,0 @@
1
- /**
2
- * Utility functions for working with nested data structures in forms.
3
- * These functions convert between nested objects and flat dotted-path notation.
4
- */
5
- /**
6
- * Flattens a nested object into a flat object with dotted-path keys.
7
- *
8
- * @example
9
- * flattenData({name: {first: 'John', last: 'Doe'}, email: 'john@example.com'})
10
- * // Returns: {'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'}
11
- *
12
- * @param data - The nested data object to flatten
13
- * @param prefix - Internal parameter for recursion (parent path)
14
- * @returns A flat object with dotted-path keys
15
- */
16
- export declare function flattenData<T = unknown>(data: Record<string, unknown>, prefix?: string): Record<string, T>;
17
- /**
18
- * Unflattens a flat object with dotted-path keys into a nested object structure.
19
- *
20
- * @example
21
- * unflattenData({'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'})
22
- * // Returns: {name: {first: 'John', last: 'Doe'}, email: 'john@example.com'}
23
- *
24
- * @param data - The flat data object with dotted-path keys
25
- * @returns A nested object structure
26
- */
27
- export declare function unflattenData<T = unknown>(data: Record<string, unknown>): Record<string, T>;
28
- /**
29
- * Checks if the data structure contains any nested objects.
30
- * If true, we need to handle it as nested data.
31
- *
32
- * @param data - The data object to check
33
- * @returns True if the data contains nested plain objects
34
- */
35
- export declare function hasNestedData(data: Record<string, unknown>): boolean;
36
- /**
37
- * Deep equality comparison for nested objects.
38
- * Handles primitives, arrays, and nested objects.
39
- *
40
- * @param a - First value to compare
41
- * @param b - Second value to compare
42
- * @returns True if values are deeply equal
43
- */
44
- export declare function deepEqual(a: unknown, b: unknown): boolean;
@@ -1,151 +0,0 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- /**
3
- * The issues collection returned by a Standard Schema validation failure.
4
- */
5
- export type Issues = readonly StandardSchemaV1.Issue[];
6
- /**
7
- * The return type of a validator function.
8
- * Resolves to the issues (when validation fails) or undefined
9
- * (when it succeeds).
10
- */
11
- export type ValidatorReturn = Promise<Issues | undefined>;
12
- /**
13
- * StandardSchemaV1 issues as either a promise or synchronous. If there are
14
- * no issues, `undefined` is returned.
15
- */
16
- export type CustomValidatorReturn = ValidatorReturn | Issues | undefined;
17
- /**
18
- * A custom validator function.
19
- * If there are errors, they are returned by the validator as
20
- * StandardSchemaV1 issues. If there are no errors, nothing is returned.
21
- */
22
- export type CustomValidatorFn<Input = unknown> = (input: Input) => CustomValidatorReturn;
23
- /**
24
- * Provides convenience methods for validating data using Standard Schema.
25
- * Also supports custom validator functions that return issues in the
26
- * Standard Schema format.
27
- *
28
- * Most of the time you should use `validateAll` or `validateFieldAll` to
29
- * validate data. Schema and custom validation are optional arguments
30
- * to these methods. This is useful because schema and custom validation
31
- * must both be optional in the form component, which is the primary use
32
- * case for this class.
33
- *
34
- * Note: all methods are static, so you do not need to instantiate
35
- * this class.
36
- *
37
- * @see https://standardschema.dev/
38
- */
39
- declare class StandardValidator {
40
- private constructor();
41
- /**
42
- * Validates data against the provided standard schema.
43
- * If there are errors, they are returned. Otherwise, nothing is returned.
44
- * This provides a boolean indication of outcome: if there is a return
45
- * value, validation failed. Otherwise, validation succeeded.
46
- * @see https://standardschema.dev/
47
- *
48
- * @example
49
- * const input = …; // your data to validate
50
- * const schema = …; // your standard schema
51
- * const issues = await StandardValidator.validate(input, schema);
52
- *
53
- * @param input The input to validate.
54
- * @param schema The standard schema to validate against.
55
- * @return The issues if validation failed, otherwise undefined.
56
- */
57
- static validate<I, O>(input: I, schema: StandardSchemaV1<I, O>): ValidatorReturn;
58
- /**
59
- * Validates a single field within the input data using the provided
60
- * standard schema. If there are issues related to the specified field,
61
- * they are returned. Otherwise, nothing is returned.
62
- *
63
- * Note: because standard schema does not provide a way to validate
64
- * individual fields, this method filters the issues returned by the
65
- * schema validation to find those related to the specified field.
66
- * @see https://standardschema.dev/
67
- *
68
- * @param input The input data to validate.
69
- * @param fieldName The name of the field to validate.
70
- * @param schema The standard schema to validate against.
71
- * @returns The issues related to the specified field if validation failed,
72
- * otherwise undefined.
73
- */
74
- static validateField<I, O>(input: I, fieldName: string, schema: StandardSchemaV1<I, O>): ValidatorReturn;
75
- /**
76
- * Validates input using a custom validator function.
77
- * If there are errors, they are returned by the validator as
78
- * StandardSchemaV1 issues. If there are no errors, nothing is returned.
79
- * @see https://standardschema.dev/
80
- *
81
- * @param input The input data to validate.
82
- * @param customValidator The custom validator function to use.
83
- * @returns The issues if validation failed, otherwise undefined.
84
- */
85
- static validateCustom<I>(input: I, customValidator: CustomValidatorFn<I>): ValidatorReturn;
86
- /**
87
- * Validates a single field within the input data using a custom validator
88
- * function. If there are issues related to the specified field, they are
89
- * returned. Otherwise, nothing is returned.
90
- *
91
- * Note: because custom validators may return issues for multiple fields,
92
- * this method filters the issues returned by the custom validator to find
93
- * those related to the specified field.
94
- * @see https://standardschema.dev/
95
- *
96
- * @param input The input data to validate.
97
- * @param fieldName The name of the field to validate.
98
- * @param customValidator The custom validator function to use.
99
- * @returns The issues related to the specified field if validation failed,
100
- * otherwise undefined.
101
- */
102
- static validateFieldCustom<I>(input: I, fieldName: string, customValidator: CustomValidatorFn<I>): ValidatorReturn;
103
- /**
104
- * Validates input data using both a standard schema and a custom validator
105
- * function, merging any issues found by either method. If there are issues,
106
- * they are returned. Otherwise, nothing is returned. This method runs both
107
- * validations in parallel.
108
- *
109
- * Note: `schema` and `customValidator` are both optional. If either the
110
- * schema or custom validator is not provided, that validation is skipped.
111
- * @see https://standardschema.dev/
112
- *
113
- * @param input The input data to validate.
114
- * @param schema Optional standard schema to validate against.
115
- * @param customValidator Optional custom validator function to use.
116
- * @returns issues if validation failed, otherwise undefined.
117
- */
118
- static validateAll<I, O>(input: I, schema?: StandardSchemaV1<I, O>, customValidator?: CustomValidatorFn<I>): ValidatorReturn;
119
- /**
120
- * Validates a single field within the input data using both a standard
121
- * schema and a custom validator function, merging any issues found by
122
- * either method. If there are issues related to the specified field,
123
- * they are returned. Otherwise, nothing is returned. This method runs
124
- * both validations in parallel.
125
- *
126
- * Note: `schema` and `customValidator` are both optional. If either the
127
- * schema or custom validator is not provided, that validation is skipped.
128
- * @see https://standardschema.dev/
129
- *
130
- * @param input The input data to validate.
131
- * @param fieldName The name of the field to validate.
132
- * @param schema Optional standard schema to validate against.
133
- * @param customValidator Optional custom validator function to use.
134
- * @returns The issues related to the specified field if validation failed,
135
- * otherwise undefined.
136
- */
137
- static validateFieldAll<I, O>(input: I, fieldName: string, schema?: StandardSchemaV1<I, O>, customValidator?: CustomValidatorFn<I>): ValidatorReturn;
138
- /**
139
- * Filters issues to those related to the specified field name.
140
- * Supports both simple field names and dotted notation for nested fields.
141
- *
142
- * @param issues The issues to filter.
143
- * @param fieldName The name of the field to filter by (e.g., "email" or
144
- * "profile.contact.email").
145
- * @returns The issues related to the specified field, or undefined if
146
- * there are none.
147
- */
148
- static filterFieldIssues(issues: Issues, fieldName: string): Issues | undefined;
149
- }
150
- export { StandardValidator };
151
- export default StandardValidator;