@nuralyui/form 0.1.0

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/form.style.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { css } from 'lit';
7
+ export const styles = css `
8
+ :host {
9
+ display: block;
10
+ width: 100%;
11
+ }
12
+
13
+ :host([disabled]) {
14
+ opacity: 0.6;
15
+ pointer-events: none;
16
+ }
17
+
18
+ .form-wrapper {
19
+ width: 100%;
20
+ display: flex;
21
+ flex-direction: column;
22
+ gap: var(--nuraly-form-gap, 16px);
23
+ }
24
+
25
+ .form-wrapper[disabled] {
26
+ opacity: 0.6;
27
+ pointer-events: none;
28
+ }
29
+
30
+ /* Form validation states */
31
+ :host([data-validation-state="pristine"]) {
32
+ border-left: 3px solid transparent;
33
+ }
34
+
35
+ :host([data-validation-state="valid"]) {
36
+ border-left: 3px solid #52c41a;
37
+ }
38
+
39
+ :host([data-validation-state="invalid"]) {
40
+ border-left: 3px solid #ff4d4f;
41
+ }
42
+
43
+ :host([data-validation-state="pending"]) {
44
+ border-left: 3px solid #1890ff;
45
+ }
46
+
47
+ /* Form submission states */
48
+ :host([data-submission-state="submitting"]) {
49
+ opacity: 0.8;
50
+ pointer-events: none;
51
+ }
52
+
53
+ :host([data-submission-state="success"]) {
54
+ border-left: 3px solid #52c41a;
55
+ }
56
+
57
+ :host([data-submission-state="error"]) {
58
+ border-left: 3px solid #ff4d4f;
59
+ }
60
+
61
+ /* Responsive design */
62
+ @media (max-width: 768px) {
63
+ .form-wrapper {
64
+ gap: var(--nuraly-form-gap-mobile, 12px);
65
+ }
66
+ }
67
+ `;
68
+ //# sourceMappingURL=form.style.js.map
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { ValidatableComponent, FormFieldInfo } from '../../shared/validation.types.js';
7
+ /**
8
+ * Form validation states that can be applied to the form and its children
9
+ */
10
+ export declare enum FormValidationState {
11
+ Pristine = "pristine",
12
+ Pending = "pending",
13
+ Valid = "valid",
14
+ Invalid = "invalid",
15
+ Submitted = "submitted"
16
+ }
17
+ /**
18
+ * Form submission states
19
+ */
20
+ export declare enum FormSubmissionState {
21
+ Idle = "idle",
22
+ Submitting = "submitting",
23
+ Success = "success",
24
+ Error = "error"
25
+ }
26
+ /**
27
+ * Form configuration options
28
+ */
29
+ export interface FormConfig {
30
+ /** Enable real-time validation */
31
+ validateOnChange?: boolean;
32
+ /** Validate fields on blur */
33
+ validateOnBlur?: boolean;
34
+ /** Show validation errors immediately */
35
+ showErrorsImmediately?: boolean;
36
+ /** Prevent submission if invalid */
37
+ preventInvalidSubmission?: boolean;
38
+ /** Reset form after successful submission */
39
+ resetOnSuccess?: boolean;
40
+ /** Custom validation debounce delay (ms) */
41
+ validationDelay?: number;
42
+ }
43
+ /**
44
+ * Form field information
45
+ */
46
+ export interface FormField extends FormFieldInfo {
47
+ }
48
+ /**
49
+ * Form validation result
50
+ */
51
+ export interface FormValidationResult {
52
+ isValid: boolean;
53
+ invalidFields: FormField[];
54
+ validationErrors: Record<string, string>;
55
+ summary: string;
56
+ }
57
+ /**
58
+ * Form submission data
59
+ */
60
+ export interface FormSubmissionData {
61
+ formData: FormData;
62
+ jsonData: Record<string, any>;
63
+ fields: Record<string, any>;
64
+ }
65
+ /**
66
+ * Interface that form field components must implement
67
+ * @deprecated Use ValidatableComponent from shared/validation.types.js instead
68
+ */
69
+ export interface FormFieldCapable extends ValidatableComponent {
70
+ }
71
+ /**
72
+ * Form event details
73
+ */
74
+ export interface FormEventDetail {
75
+ formData?: FormSubmissionData;
76
+ validationResult?: FormValidationResult;
77
+ field?: FormField;
78
+ error?: Error;
79
+ }
80
+ /**
81
+ * Custom form events
82
+ */
83
+ export declare const FORM_EVENTS: {
84
+ readonly VALIDATION_CHANGED: "nr-form-validation-changed";
85
+ readonly FIELD_CHANGED: "nr-form-field-changed";
86
+ readonly SUBMIT_ATTEMPT: "nr-form-submit-attempt";
87
+ readonly SUBMIT_SUCCESS: "nr-form-submit-success";
88
+ readonly SUBMIT_ERROR: "nr-form-submit-error";
89
+ readonly RESET: "nr-form-reset";
90
+ };
91
+ export declare type FormEventType = typeof FORM_EVENTS[keyof typeof FORM_EVENTS];
92
+ //# sourceMappingURL=form.types.d.ts.map
package/form.types.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ /**
7
+ * Form validation states that can be applied to the form and its children
8
+ */
9
+ export var FormValidationState;
10
+ (function (FormValidationState) {
11
+ FormValidationState["Pristine"] = "pristine";
12
+ FormValidationState["Pending"] = "pending";
13
+ FormValidationState["Valid"] = "valid";
14
+ FormValidationState["Invalid"] = "invalid";
15
+ FormValidationState["Submitted"] = "submitted"; // Form has been submitted
16
+ })(FormValidationState || (FormValidationState = {}));
17
+ /**
18
+ * Form submission states
19
+ */
20
+ export var FormSubmissionState;
21
+ (function (FormSubmissionState) {
22
+ FormSubmissionState["Idle"] = "idle";
23
+ FormSubmissionState["Submitting"] = "submitting";
24
+ FormSubmissionState["Success"] = "success";
25
+ FormSubmissionState["Error"] = "error";
26
+ })(FormSubmissionState || (FormSubmissionState = {}));
27
+ /**
28
+ * Custom form events
29
+ */
30
+ export const FORM_EVENTS = {
31
+ VALIDATION_CHANGED: 'nr-form-validation-changed',
32
+ FIELD_CHANGED: 'nr-form-field-changed',
33
+ SUBMIT_ATTEMPT: 'nr-form-submit-attempt',
34
+ SUBMIT_SUCCESS: 'nr-form-submit-success',
35
+ SUBMIT_ERROR: 'nr-form-submit-error',
36
+ RESET: 'nr-form-reset',
37
+ };
38
+ //# sourceMappingURL=form.types.js.map
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ export { NrFormElement } from './form.component.js';
7
+ export * from './form.types.js';
8
+ export { FormValidationController } from './controllers/validation.controller.js';
9
+ export { FormSubmissionController } from './controllers/submission.controller.js';
10
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ // Main component
7
+ export { NrFormElement } from './form.component.js';
8
+ // Types and interfaces
9
+ export * from './form.types.js';
10
+ // Controllers
11
+ export { FormValidationController } from './controllers/validation.controller.js';
12
+ export { FormSubmissionController } from './controllers/submission.controller.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ /**
7
+ * Standard interface that all form-compatible components should implement
8
+ * This ensures consistent validation API across all form field components
9
+ */
10
+ export interface FormFieldValidation {
11
+ /** Component name for form submission */
12
+ name?: string;
13
+ /** Current field value */
14
+ value: any;
15
+ /** Required field indicator */
16
+ required?: boolean;
17
+ /** Disabled state */
18
+ disabled?: boolean;
19
+ /** Readonly state */
20
+ readonly?: boolean;
21
+ /** Current validation message */
22
+ validationMessage?: string;
23
+ /**
24
+ * Validate the field and return true if valid
25
+ */
26
+ validate?(): boolean;
27
+ /**
28
+ * Check if the field satisfies HTML5 constraints
29
+ */
30
+ checkValidity?(): boolean;
31
+ /**
32
+ * Report validation state (shows validation UI)
33
+ */
34
+ reportValidity?(): boolean;
35
+ /**
36
+ * Set custom validation message
37
+ */
38
+ setCustomValidity?(message: string): void;
39
+ /**
40
+ * Reset field to initial state
41
+ */
42
+ reset?(): void;
43
+ /**
44
+ * Focus the field
45
+ */
46
+ focus?(): void;
47
+ }
48
+ /**
49
+ * Enhanced validation interface for components with advanced validation features
50
+ */
51
+ export interface AdvancedFormFieldValidation extends FormFieldValidation {
52
+ /** Validation state details */
53
+ isValid?: boolean;
54
+ isTouched?: boolean;
55
+ isDirty?: boolean;
56
+ /** Validation rules */
57
+ validationRules?: ValidationRule[];
58
+ /** Custom validators */
59
+ customValidators?: CustomValidator[];
60
+ /**
61
+ * Get detailed validation result
62
+ */
63
+ getValidationResult?(): {
64
+ isValid: boolean;
65
+ errors: string[];
66
+ warnings: string[];
67
+ };
68
+ /**
69
+ * Add custom validation rule
70
+ */
71
+ addValidationRule?(rule: ValidationRule): void;
72
+ /**
73
+ * Remove validation rule
74
+ */
75
+ removeValidationRule?(ruleId: string): void;
76
+ }
77
+ /**
78
+ * Validation rule definition
79
+ */
80
+ export interface ValidationRule {
81
+ id: string;
82
+ message: string;
83
+ validator: (value: any) => boolean;
84
+ severity?: 'error' | 'warning';
85
+ }
86
+ /**
87
+ * Custom validator function
88
+ */
89
+ export interface CustomValidator {
90
+ id: string;
91
+ validate: (value: any, element: any) => {
92
+ isValid: boolean;
93
+ message: string;
94
+ };
95
+ }
96
+ /**
97
+ * Validation event details
98
+ */
99
+ export interface ValidationEventDetail {
100
+ isValid: boolean;
101
+ value: any;
102
+ message: string;
103
+ errors: string[];
104
+ warnings?: string[];
105
+ field?: string;
106
+ timestamp: number;
107
+ }
108
+ /**
109
+ * Form field registration info
110
+ */
111
+ export interface FormFieldRegistration {
112
+ element: HTMLElement & FormFieldValidation;
113
+ name: string;
114
+ type: string;
115
+ initialValue: any;
116
+ registrationTime: number;
117
+ }
118
+ //# sourceMappingURL=validation.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.interface.d.ts","sourceRoot":"","sources":["../../../../src/components/form/interfaces/validation.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,KAAK,EAAE,GAAG,CAAC;IAEX,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,IAAI,OAAO,CAAC;IAErB;;OAEG;IACH,aAAa,CAAC,IAAI,OAAO,CAAC;IAE1B;;OAEG;IACH,cAAc,CAAC,IAAI,OAAO,CAAC;IAE3B;;OAEG;IACH,iBAAiB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,KAAK,CAAC,IAAI,IAAI,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,uBAAuB;IACvB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAEnC,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IAErC;;OAEG;IACH,mBAAmB,CAAC,IAAI;QACtB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IAEF;;OAEG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAE/C;;OAEG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK;QACtC,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,WAAW,GAAG,mBAAmB,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,GAAG,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=validation.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.interface.js","sourceRoot":"","sources":["../../../../src/components/form/interfaces/validation.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * Standard interface that all form-compatible components should implement\n * This ensures consistent validation API across all form field components\n */\nexport interface FormFieldValidation {\n /** Component name for form submission */\n name?: string;\n \n /** Current field value */\n value: any;\n \n /** Required field indicator */\n required?: boolean;\n \n /** Disabled state */\n disabled?: boolean;\n \n /** Readonly state */\n readonly?: boolean;\n \n /** Current validation message */\n validationMessage?: string;\n \n /**\n * Validate the field and return true if valid\n */\n validate?(): boolean;\n \n /**\n * Check if the field satisfies HTML5 constraints\n */\n checkValidity?(): boolean;\n \n /**\n * Report validation state (shows validation UI)\n */\n reportValidity?(): boolean;\n \n /**\n * Set custom validation message\n */\n setCustomValidity?(message: string): void;\n \n /**\n * Reset field to initial state\n */\n reset?(): void;\n \n /**\n * Focus the field\n */\n focus?(): void;\n}\n\n/**\n * Enhanced validation interface for components with advanced validation features\n */\nexport interface AdvancedFormFieldValidation extends FormFieldValidation {\n /** Validation state details */\n isValid?: boolean;\n isTouched?: boolean;\n isDirty?: boolean;\n \n /** Validation rules */\n validationRules?: ValidationRule[];\n \n /** Custom validators */\n customValidators?: CustomValidator[];\n \n /**\n * Get detailed validation result\n */\n getValidationResult?(): {\n isValid: boolean;\n errors: string[];\n warnings: string[];\n };\n \n /**\n * Add custom validation rule\n */\n addValidationRule?(rule: ValidationRule): void;\n \n /**\n * Remove validation rule\n */\n removeValidationRule?(ruleId: string): void;\n}\n\n/**\n * Validation rule definition\n */\nexport interface ValidationRule {\n id: string;\n message: string;\n validator: (value: any) => boolean;\n severity?: 'error' | 'warning';\n}\n\n/**\n * Custom validator function\n */\nexport interface CustomValidator {\n id: string;\n validate: (value: any, element: any) => {\n isValid: boolean;\n message: string;\n };\n}\n\n/**\n * Validation event details\n */\nexport interface ValidationEventDetail {\n isValid: boolean;\n value: any;\n message: string;\n errors: string[];\n warnings?: string[];\n field?: string;\n timestamp: number;\n}\n\n/**\n * Form field registration info\n */\nexport interface FormFieldRegistration {\n element: HTMLElement & FormFieldValidation;\n name: string;\n type: string;\n initialValue: any;\n registrationTime: number;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { LitElement } from 'lit';
7
+ import { FormFieldCapable } from '../form.types.js';
8
+ declare type Constructor<T = {}> = new (...args: any[]) => T;
9
+ /**
10
+ * Lightweight mixin that provides only form integration capabilities
11
+ * This replaces the heavier FormFieldValidationMixin for components that have their own validation
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * export class InputComponent extends FormFieldIntegrationMixin(NuralyUIBaseMixin(LitElement)) {
16
+ * // Component manages its own validation via controllers
17
+ * }
18
+ * ```
19
+ */
20
+ export declare const FormFieldIntegrationMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<FormFieldCapable> & T;
21
+ export {};
22
+ //# sourceMappingURL=form-field-integration.mixin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-field-integration.mixin.d.ts","sourceRoot":"","sources":["../../../../src/components/form/mixins/form-field-integration.mixin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,aAAK,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,yFA+GrC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ };
12
+ import { property } from 'lit/decorators.js';
13
+ /**
14
+ * Lightweight mixin that provides only form integration capabilities
15
+ * This replaces the heavier FormFieldValidationMixin for components that have their own validation
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * export class InputComponent extends FormFieldIntegrationMixin(NuralyUIBaseMixin(LitElement)) {
20
+ * // Component manages its own validation via controllers
21
+ * }
22
+ * ```
23
+ */
24
+ export const FormFieldIntegrationMixin = (superClass) => {
25
+ class FormFieldIntegrationMixinClass extends superClass {
26
+ constructor() {
27
+ super(...arguments);
28
+ /** Disabled state */
29
+ this.disabled = false;
30
+ /** Readonly state */
31
+ this.readonly = false;
32
+ }
33
+ /**
34
+ * Dispatch a standardized field change event for form integration
35
+ */
36
+ dispatchFieldChangeEvent() {
37
+ var _a, _b;
38
+ this.dispatchEvent(new CustomEvent('nr-field-change', {
39
+ detail: {
40
+ name: this.name,
41
+ value: this.value,
42
+ isValid: (_b = (_a = this.checkValidity) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : true
43
+ },
44
+ bubbles: true,
45
+ composed: true
46
+ }));
47
+ }
48
+ /**
49
+ * Dispatch a standardized validation event for form integration
50
+ */
51
+ dispatchValidationEvent(isValid, message) {
52
+ this.dispatchEvent(new CustomEvent('nr-validation', {
53
+ detail: {
54
+ name: this.name,
55
+ isValid,
56
+ message: message || '',
57
+ value: this.value
58
+ },
59
+ bubbles: true,
60
+ composed: true
61
+ }));
62
+ }
63
+ }
64
+ __decorate([
65
+ property({ type: String })
66
+ ], FormFieldIntegrationMixinClass.prototype, "name", void 0);
67
+ __decorate([
68
+ property({ type: Boolean })
69
+ ], FormFieldIntegrationMixinClass.prototype, "required", void 0);
70
+ __decorate([
71
+ property({ type: Boolean, reflect: true })
72
+ ], FormFieldIntegrationMixinClass.prototype, "disabled", void 0);
73
+ __decorate([
74
+ property({ type: Boolean, reflect: true })
75
+ ], FormFieldIntegrationMixinClass.prototype, "readonly", void 0);
76
+ return FormFieldIntegrationMixinClass;
77
+ };
78
+ //# sourceMappingURL=form-field-integration.mixin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-field-integration.mixin.js","sourceRoot":"","sources":["../../../../src/components/form/mixins/form-field-integration.mixin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAoC,UAAa,EAAE,EAAE;IAC5F,MAAM,8BAA+B,SAAQ,UAAU;QAAvD;;YAUE,qBAAqB;YAErB,aAAQ,GAAG,KAAK,CAAC;YAEjB,qBAAqB;YAErB,aAAQ,GAAG,KAAK,CAAC;QA2FnB,CAAC;QA9BC;;WAEG;QACO,wBAAwB;;YAChC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,iBAAiB,EAAE;gBACpD,MAAM,EAAE;oBACN,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,aAAa,oDAAI,mCAAI,IAAI;iBACxC;gBACD,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC,CAAC;QACN,CAAC;QAED;;WAEG;QACO,uBAAuB,CAAC,OAAgB,EAAE,OAAgB;YAClE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,eAAe,EAAE;gBAClD,MAAM,EAAE;oBACN,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO;oBACP,OAAO,EAAE,OAAO,IAAI,EAAE;oBACtB,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB;gBACD,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC,CAAC;QACN,CAAC;KACF;IAvGC;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEACb;IAId;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oEACT;IAInB;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oEAC1B;IAIjB;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oEAC1B;IA6FnB,OAAO,8BAAmE,CAAC;AAC7E,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { FormFieldCapable } from '../form.types.js';\n\ntype Constructor<T = {}> = new (...args: any[]) => T;\n\n/**\n * Lightweight mixin that provides only form integration capabilities\n * This replaces the heavier FormFieldValidationMixin for components that have their own validation\n * \n * @example\n * ```typescript\n * export class InputComponent extends FormFieldIntegrationMixin(NuralyUIBaseMixin(LitElement)) {\n * // Component manages its own validation via controllers\n * }\n * ```\n */\nexport const FormFieldIntegrationMixin = <T extends Constructor<LitElement>>(superClass: T) => {\n class FormFieldIntegrationMixinClass extends superClass implements FormFieldCapable {\n \n /** Field name for form submission */\n @property({ type: String })\n name?: string;\n \n /** Required field indicator */\n @property({ type: Boolean })\n required?: boolean;\n \n /** Disabled state */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Readonly state */\n @property({ type: Boolean, reflect: true })\n readonly = false;\n \n /** Field value - must be implemented by component */\n declare value: any;\n \n /** Validation message - should be managed by component's validation system */\n declare validationMessage?: string;\n\n // These methods should be implemented by the component using this mixin\n // They are declared here to satisfy the FormFieldCapable interface\n \n /**\n * Validate the field - should be implemented by component\n */\n validate?(): boolean | Promise<boolean>;\n \n /**\n * HTML5 checkValidity - should be implemented by component\n */\n checkValidity?(): boolean;\n \n /**\n * HTML5 reportValidity - should be implemented by component\n */\n reportValidity?(): boolean;\n \n /**\n * Set custom validity message - should be implemented by component\n */\n setCustomValidity?(message: string): void;\n \n /**\n * Reset field - should be implemented by component\n */\n reset?(): void;\n \n /**\n * Get current value - should be implemented by component\n */\n getValue?(): any;\n \n /**\n * Set field value - should be implemented by component\n */\n setValue?(value: any): void;\n \n /**\n * Get validation error - should be implemented by component\n */\n getError?(): string | null;\n \n /**\n * Clear validation - should be implemented by component\n */\n clearValidation?(): void;\n \n /**\n * Check if touched - should be implemented by component\n */\n isTouched?(): boolean;\n\n /**\n * Dispatch a standardized field change event for form integration\n */\n protected dispatchFieldChangeEvent(): void {\n this.dispatchEvent(new CustomEvent('nr-field-change', {\n detail: {\n name: this.name,\n value: this.value,\n isValid: this.checkValidity?.() ?? true\n },\n bubbles: true,\n composed: true\n }));\n }\n\n /**\n * Dispatch a standardized validation event for form integration\n */\n protected dispatchValidationEvent(isValid: boolean, message?: string): void {\n this.dispatchEvent(new CustomEvent('nr-validation', {\n detail: {\n name: this.name,\n isValid,\n message: message || '',\n value: this.value\n },\n bubbles: true,\n composed: true\n }));\n }\n }\n \n return FormFieldIntegrationMixinClass as Constructor<FormFieldCapable> & T;\n};\n"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ /**
7
+ * @deprecated This mixin is deprecated and no longer used.
8
+ *
9
+ * Form field validation is now handled by individual component validation controllers:
10
+ * - Input validation: InputValidationController
11
+ * - Form coordination: FormValidationController (listens to validation events)
12
+ *
13
+ * This approach eliminates duplication and provides better separation of concerns.
14
+ * Components handle their own validation, and forms coordinate/listen to validation events.
15
+ */
16
+ import { LitElement } from 'lit';
17
+ import { FormFieldValidation } from '../interfaces/validation.interface.js';
18
+ declare type Constructor<T = {}> = new (...args: any[]) => T;
19
+ /**
20
+ * Mixin that provides standardized form field validation capabilities
21
+ * This should be used by input components that need to participate in forms
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * export class InputComponent extends FormFieldValidationMixin(NuralyUIBaseMixin(LitElement)) {
26
+ * // Component-specific validation logic
27
+ * protected validateValue(value: string): boolean {
28
+ * return value.length >= this.minLength;
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export declare const FormFieldValidationMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<FormFieldValidation> & T;
34
+ export {};
35
+ //# sourceMappingURL=form-field-validation.mixin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-field-validation.mixin.d.ts","sourceRoot":"","sources":["../../../../src/components/form/mixins/form-field-validation.mixin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAyB,MAAM,uCAAuC,CAAC;AAEnG,aAAK,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,4FAqTpC,CAAC"}