@nuralyui/textarea 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/bundle.js +782 -0
- package/index.d.ts +8 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/package.json +34 -0
- package/react.d.ts +9 -0
- package/react.js +16 -0
- package/react.js.map +1 -0
- package/textarea.component.d.ts +204 -0
- package/textarea.component.js +670 -0
- package/textarea.component.js.map +1 -0
- package/textarea.style.d.ts +59 -0
- package/textarea.style.js +386 -0
- package/textarea.style.js.map +1 -0
- package/textarea.types.d.ts +102 -0
- package/textarea.types.js +14 -0
- package/textarea.types.js.map +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
export { NrTextareaElement } from './textarea.component.js';
|
|
7
|
+
export type { TEXTAREA_STATE, TEXTAREA_SIZE, TEXTAREA_VARIANT, TEXTAREA_RESIZE, ValidationRule, TextareaValidationResult, TextareaChangeEvent, TextareaResizeEvent, FocusOptions, BlurOptions } from './textarea.types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/textarea/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nexport { NrTextareaElement } from './textarea.component.js';\nexport type {\n TEXTAREA_STATE,\n TEXTAREA_SIZE,\n TEXTAREA_VARIANT,\n TEXTAREA_RESIZE,\n ValidationRule,\n TextareaValidationResult,\n TextareaChangeEvent,\n TextareaResizeEvent,\n FocusOptions,\n BlurOptions\n} from './textarea.types.js';"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuralyui/textarea",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Textarea component for Nuraly UI Library with validation, resize options, and interactive features",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"author": "Labidi Aymen",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./index.js"
|
|
15
|
+
},
|
|
16
|
+
"./bundle": {
|
|
17
|
+
"import": "./bundle.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bundle.js",
|
|
22
|
+
"*.js",
|
|
23
|
+
"*.d.ts",
|
|
24
|
+
"*.js.map"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"textarea",
|
|
28
|
+
"web-components",
|
|
29
|
+
"lit-element",
|
|
30
|
+
"ui-library",
|
|
31
|
+
"validation",
|
|
32
|
+
"form-control"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/react.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NrTextareaElement } from './textarea.component.js';
|
|
2
|
+
export declare const NrTextarea: import("@lit-labs/react").ReactWebComponent<NrTextareaElement, {
|
|
3
|
+
nrTextareaChange: string;
|
|
4
|
+
nrFocus: string;
|
|
5
|
+
nrBlur: string;
|
|
6
|
+
nrClear: string;
|
|
7
|
+
nrResize: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=react.d.ts.map
|
package/react.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createComponent } from '@lit-labs/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { NrTextareaElement } from './textarea.component.js';
|
|
4
|
+
export const NrTextarea = createComponent({
|
|
5
|
+
tagName: 'nr-textarea',
|
|
6
|
+
elementClass: NrTextareaElement,
|
|
7
|
+
react: React,
|
|
8
|
+
events: {
|
|
9
|
+
nrTextareaChange: 'nr-textarea-change',
|
|
10
|
+
nrFocus: 'nr-focus',
|
|
11
|
+
nrBlur: 'nr-blur',
|
|
12
|
+
nrClear: 'nr-clear',
|
|
13
|
+
nrResize: 'nr-resize'
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=react.js.map
|
package/react.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/components/textarea/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,iBAAiB;IAC/B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,gBAAgB,EAAE,oBAAoB;QACtC,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,UAAU;QACnB,QAAQ,EAAE,WAAW;KACtB;CACF,CAAC,CAAC","sourcesContent":["import { createComponent } from '@lit-labs/react';\nimport * as React from 'react';\nimport { NrTextareaElement } from './textarea.component.js';\n\nexport const NrTextarea = createComponent({\n tagName: 'nr-textarea',\n elementClass: NrTextareaElement,\n react: React,\n events: {\n nrTextareaChange: 'nr-textarea-change',\n nrFocus: 'nr-focus',\n nrBlur: 'nr-blur',\n nrClear: 'nr-clear',\n nrResize: 'nr-resize'\n },\n});"]}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
7
|
+
import '../icon/icon.component.js';
|
|
8
|
+
import { TEXTAREA_STATE, TEXTAREA_SIZE, TEXTAREA_VARIANT, TEXTAREA_RESIZE, ValidationRule, TextareaValidationResult, FocusOptions } from './textarea.types.js';
|
|
9
|
+
import { ValidatableComponent, ValidationStatus } from '../../shared/validation.types.js';
|
|
10
|
+
import { type TextareaValidationHost, type TextareaEventHost } from './controllers/index.js';
|
|
11
|
+
declare const NrTextareaElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
|
|
12
|
+
/**
|
|
13
|
+
* Versatile textarea component with validation, resize options, and interactive features.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <nr-textarea placeholder="Enter your message"></nr-textarea>
|
|
18
|
+
* <nr-textarea rows="5" resize="vertical"></nr-textarea>
|
|
19
|
+
* <nr-textarea max-length="500" show-count></nr-textarea>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @fires nr-textarea-change - Value changes
|
|
23
|
+
* @fires nr-focus - Textarea focused
|
|
24
|
+
* @fires nr-blur - Textarea blurred
|
|
25
|
+
* @fires nr-clear - Clear button clicked
|
|
26
|
+
* @fires nr-resize - Textarea resized
|
|
27
|
+
*
|
|
28
|
+
* @slot label - Textarea label
|
|
29
|
+
* @slot helper-text - Helper text
|
|
30
|
+
* @slot addon-before - Content before textarea
|
|
31
|
+
* @slot addon-after - Content after textarea
|
|
32
|
+
*/
|
|
33
|
+
export declare class NrTextareaElement extends NrTextareaElement_base implements TextareaValidationHost, TextareaEventHost, ValidatableComponent {
|
|
34
|
+
static styles: import("lit").CSSResult;
|
|
35
|
+
private textareaElement;
|
|
36
|
+
private validationController;
|
|
37
|
+
private eventController;
|
|
38
|
+
/** Disables the textarea */
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
/** Makes the textarea read-only */
|
|
41
|
+
readonly: boolean;
|
|
42
|
+
/** Visual state (default, success, warning, error) */
|
|
43
|
+
state: TEXTAREA_STATE;
|
|
44
|
+
/** Current textarea value */
|
|
45
|
+
value: string;
|
|
46
|
+
/** Textarea size (small, medium, large) */
|
|
47
|
+
size: TEXTAREA_SIZE;
|
|
48
|
+
/** Visual variant (outlined, underlined, filled) */
|
|
49
|
+
variant: TEXTAREA_VARIANT;
|
|
50
|
+
/** Resize behavior (none, vertical, horizontal, both) */
|
|
51
|
+
resize: TEXTAREA_RESIZE;
|
|
52
|
+
/** Number of visible text lines */
|
|
53
|
+
rows: 3;
|
|
54
|
+
/** Number of visible character columns */
|
|
55
|
+
cols: 50;
|
|
56
|
+
/** Placeholder text */
|
|
57
|
+
placeholder: string;
|
|
58
|
+
/** HTML autocomplete attribute */
|
|
59
|
+
autocomplete: string;
|
|
60
|
+
/** Field name for form submission */
|
|
61
|
+
name?: string;
|
|
62
|
+
/** Required field indicator */
|
|
63
|
+
required?: boolean;
|
|
64
|
+
/** Shows clear button */
|
|
65
|
+
allowClear: boolean;
|
|
66
|
+
/** Clearable alias for controller interface compatibility */
|
|
67
|
+
get clearable(): boolean;
|
|
68
|
+
/** Shows character counter */
|
|
69
|
+
showCount: boolean;
|
|
70
|
+
/** Maximum character limit */
|
|
71
|
+
maxLength?: number;
|
|
72
|
+
/** Minimum height for auto-resize */
|
|
73
|
+
minHeight?: number;
|
|
74
|
+
/** Maximum height for auto-resize */
|
|
75
|
+
maxHeight?: number;
|
|
76
|
+
/** Auto-resize textarea based on content */
|
|
77
|
+
autoResize: boolean;
|
|
78
|
+
/** Array of validation rules */
|
|
79
|
+
rules: ValidationRule[];
|
|
80
|
+
/** Validate on change */
|
|
81
|
+
validateOnChange: boolean;
|
|
82
|
+
/** Validate on blur */
|
|
83
|
+
validateOnBlur: boolean;
|
|
84
|
+
/** Show validation status icon */
|
|
85
|
+
hasFeedback: boolean;
|
|
86
|
+
/** Custom validation message */
|
|
87
|
+
validationMessage?: string;
|
|
88
|
+
private isFocused;
|
|
89
|
+
private validationResult?;
|
|
90
|
+
private characterCount;
|
|
91
|
+
private resizeObserver?;
|
|
92
|
+
constructor();
|
|
93
|
+
/**
|
|
94
|
+
* Setup controller event listeners
|
|
95
|
+
*/
|
|
96
|
+
private setupControllerListeners;
|
|
97
|
+
/**
|
|
98
|
+
* Handle input from controller
|
|
99
|
+
*/
|
|
100
|
+
private handleControllerInput;
|
|
101
|
+
/**
|
|
102
|
+
* Handle clear from controller
|
|
103
|
+
*/
|
|
104
|
+
private handleControllerClear;
|
|
105
|
+
connectedCallback(): void;
|
|
106
|
+
disconnectedCallback(): void;
|
|
107
|
+
firstUpdated(changedProperties: PropertyValues): void;
|
|
108
|
+
updated(changedProperties: PropertyValues): void;
|
|
109
|
+
private setupResizeObserver;
|
|
110
|
+
private cleanupResizeObserver;
|
|
111
|
+
private updateTextareaValue;
|
|
112
|
+
private autoResizeIfNeeded;
|
|
113
|
+
/**
|
|
114
|
+
* Handle input event (now delegated to event controller via addEventListener)
|
|
115
|
+
*/
|
|
116
|
+
private handleInput;
|
|
117
|
+
/**
|
|
118
|
+
* Handle focus event (now delegated to event controller)
|
|
119
|
+
*/
|
|
120
|
+
private handleFocus;
|
|
121
|
+
/**
|
|
122
|
+
* Handle blur event (now delegated to event controller)
|
|
123
|
+
*/
|
|
124
|
+
private handleBlur;
|
|
125
|
+
/**
|
|
126
|
+
* Handle clear event (now delegated to event controller)
|
|
127
|
+
*/
|
|
128
|
+
private handleClear;
|
|
129
|
+
private dispatchChangeEvent;
|
|
130
|
+
private dispatchResizeEvent;
|
|
131
|
+
/**
|
|
132
|
+
* Focus the textarea with optional configuration
|
|
133
|
+
*/
|
|
134
|
+
focus(options?: FocusOptions): void;
|
|
135
|
+
/**
|
|
136
|
+
* Blur the textarea
|
|
137
|
+
*/
|
|
138
|
+
blur(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Get validation status
|
|
141
|
+
*/
|
|
142
|
+
getValidationResult(): TextareaValidationResult | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Trigger validation manually (ValidatableComponent interface)
|
|
145
|
+
*/
|
|
146
|
+
validate(): Promise<boolean>;
|
|
147
|
+
/**
|
|
148
|
+
* Clear validation state
|
|
149
|
+
*/
|
|
150
|
+
clearValidation(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Clear the textarea value
|
|
153
|
+
*/
|
|
154
|
+
clear(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Add a validation rule (ValidatableComponent interface)
|
|
157
|
+
*/
|
|
158
|
+
addRule(rule: ValidationRule): void;
|
|
159
|
+
/**
|
|
160
|
+
* Remove validation rules matching predicate (ValidatableComponent interface)
|
|
161
|
+
*/
|
|
162
|
+
removeRule(predicate: (rule: ValidationRule) => boolean): void;
|
|
163
|
+
/**
|
|
164
|
+
* Clear all validation rules (ValidatableComponent interface)
|
|
165
|
+
*/
|
|
166
|
+
clearRules(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Get current validation status (ValidatableComponent interface)
|
|
169
|
+
*/
|
|
170
|
+
getValidationStatus(): ValidationStatus;
|
|
171
|
+
/**
|
|
172
|
+
* Check if the textarea value is valid
|
|
173
|
+
*/
|
|
174
|
+
isValid(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Check validity (HTML form API compatibility)
|
|
177
|
+
*/
|
|
178
|
+
checkValidity(): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Report validity (HTML form API compatibility)
|
|
181
|
+
*/
|
|
182
|
+
reportValidity(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Set custom validity message (HTML form API compatibility)
|
|
185
|
+
*/
|
|
186
|
+
setCustomValidity(message: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Trigger validation manually (enhanced version)
|
|
189
|
+
*/
|
|
190
|
+
validateTextarea(): Promise<boolean>;
|
|
191
|
+
/**
|
|
192
|
+
* Set validation state externally (for form integration)
|
|
193
|
+
*/
|
|
194
|
+
setValidationStatus(result: TextareaValidationResult): void;
|
|
195
|
+
private renderLabel;
|
|
196
|
+
private renderTextarea;
|
|
197
|
+
private renderValidationIcon;
|
|
198
|
+
private renderClearButton;
|
|
199
|
+
private renderCharacterCount;
|
|
200
|
+
private renderHelperText;
|
|
201
|
+
render(): import("lit").TemplateResult<1>;
|
|
202
|
+
}
|
|
203
|
+
export {};
|
|
204
|
+
//# sourceMappingURL=textarea.component.d.ts.map
|