@semcore/bulk-textarea 17.2.1-prerelease.0 → 17.2.2-prerelease.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/CHANGELOG.md +13 -1
- package/lib/cjs/BulkTextarea.js +18 -12
- package/lib/cjs/BulkTextarea.js.map +1 -1
- package/lib/cjs/BulkTextarea.types.js.map +1 -1
- package/lib/cjs/components/ClearAll.js.map +1 -1
- package/lib/cjs/components/Counter.js.map +1 -1
- package/lib/cjs/components/ErrorsNavigation.js +5 -2
- package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
- package/lib/cjs/components/InputField/History.js +46 -0
- package/lib/cjs/components/InputField/History.js.map +1 -0
- package/lib/cjs/components/InputField/InputField.js +494 -361
- package/lib/cjs/components/InputField/InputField.js.map +1 -1
- package/lib/cjs/components/InputField/inputField.shadow.css +42 -51
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/BulkTextarea.js +18 -12
- package/lib/es6/BulkTextarea.js.map +1 -1
- package/lib/es6/BulkTextarea.types.js.map +1 -1
- package/lib/es6/components/ClearAll.js.map +1 -1
- package/lib/es6/components/Counter.js.map +1 -1
- package/lib/es6/components/ErrorsNavigation.js +5 -2
- package/lib/es6/components/ErrorsNavigation.js.map +1 -1
- package/lib/es6/components/InputField/History.js +38 -0
- package/lib/es6/components/InputField/History.js.map +1 -0
- package/lib/es6/components/InputField/InputField.js +494 -361
- package/lib/es6/components/InputField/InputField.js.map +1 -1
- package/lib/es6/components/InputField/inputField.shadow.css +42 -51
- package/lib/es6/index.js.map +1 -1
- package/lib/esm/BulkTextarea.mjs +12 -5
- package/lib/esm/components/ErrorsNavigation.mjs +5 -2
- package/lib/esm/components/InputField/History.mjs +40 -0
- package/lib/esm/components/InputField/InputField.mjs +481 -358
- package/lib/esm/components/InputField/inputField.shadow.css +42 -51
- package/lib/types/BulkTextarea.d.ts +108 -2
- package/lib/types/BulkTextarea.types.d.ts +245 -147
- package/lib/types/components/ClearAll.d.ts +4 -6
- package/lib/types/components/Counter.d.ts +4 -9
- package/lib/types/components/ErrorsNavigation.d.ts +4 -14
- package/lib/types/components/InputField/History.d.ts +20 -0
- package/lib/types/components/InputField/InputField.d.ts +30 -24
- package/lib/types/index.d.ts +1 -2
- package/package.json +9 -9
- package/lib/cjs/components/InputField/InputField.types.js +0 -2
- package/lib/cjs/components/InputField/InputField.types.js.map +0 -1
- package/lib/es6/components/InputField/InputField.types.js +0 -2
- package/lib/es6/components/InputField/InputField.types.js.map +0 -1
- package/lib/types/components/InputField/InputField.types.d.ts +0 -44
|
@@ -1,152 +1,250 @@
|
|
|
1
1
|
import type { BoxProps } from '@semcore/base-components';
|
|
2
2
|
import type Button from '@semcore/button';
|
|
3
3
|
import type { Intergalactic } from '@semcore/core';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* This component doesn't have default onChange callback, because we think that you need only the result after every changes/fixes
|
|
78
|
-
*/
|
|
79
|
-
onBlur?: (value: T, e: Event) => void;
|
|
80
|
-
/**
|
|
81
|
-
* Size of component
|
|
82
|
-
* @default m
|
|
83
|
-
*/
|
|
84
|
-
size?: 'm' | 'l';
|
|
85
|
-
/**
|
|
86
|
-
* State for show errors or valid(green) borders
|
|
87
|
-
* @default normal
|
|
88
|
-
*/
|
|
89
|
-
state?: 'normal' | 'valid' | 'invalid';
|
|
90
|
-
/**
|
|
91
|
-
* Flag for disabling field
|
|
92
|
-
* @default false
|
|
93
|
-
*/
|
|
94
|
-
disabled?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Flag for readonly field
|
|
97
|
-
* @default false
|
|
98
|
-
*/
|
|
99
|
-
readonly?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Min rows
|
|
102
|
-
* @default 2
|
|
103
|
-
*/
|
|
104
|
-
minRows?: number;
|
|
105
|
-
/**
|
|
106
|
-
* Max rows
|
|
107
|
-
* @default 10
|
|
108
|
-
*/
|
|
109
|
-
maxRows?: number;
|
|
110
|
-
/**
|
|
111
|
-
* List of available points to validate value
|
|
112
|
-
* @default blur
|
|
113
|
-
*/
|
|
114
|
-
validateOn?: ('blur' | 'blurLine' | 'paste')[];
|
|
115
|
-
/**
|
|
116
|
-
* Function to validate line
|
|
117
|
-
*/
|
|
118
|
-
lineValidation?: (line: string, lines: string[]) => {
|
|
119
|
-
isValid: boolean;
|
|
4
|
+
import type { NSCounter } from '@semcore/counter';
|
|
5
|
+
declare namespace NSBulktextarea {
|
|
6
|
+
type Props<T extends string | string[]> = {
|
|
7
|
+
/** The current value */
|
|
8
|
+
value?: NSBulktextarea.InputField.Props<T>['value'];
|
|
9
|
+
/** Callback triggered when the onBlur event is emmited */
|
|
10
|
+
onChange?: NSBulktextarea.InputField.Props<T>['onBlur'];
|
|
11
|
+
/** Placeholder text */
|
|
12
|
+
placeholder?: NSBulktextarea.InputField.Props<T>['placeholder'];
|
|
13
|
+
/** Component size */
|
|
14
|
+
size?: NSBulktextarea.InputField.Props<T>['size'];
|
|
15
|
+
/** State for show errors or valid(green) borders */
|
|
16
|
+
state?: NSBulktextarea.InputField.Props<T>['state'];
|
|
17
|
+
/** Defines whether the textarea is disabled */
|
|
18
|
+
disabled?: NSBulktextarea.InputField.Props<T>['disabled'];
|
|
19
|
+
/** Defines whether the textarea is readonly */
|
|
20
|
+
readonly?: NSBulktextarea.InputField.Props<T>['readonly'];
|
|
21
|
+
/** Minimum number of rows to display */
|
|
22
|
+
minRows?: NSBulktextarea.InputField.Props<T>['minRows'];
|
|
23
|
+
/** Maximum number of rows to display */
|
|
24
|
+
maxRows?: NSBulktextarea.InputField.Props<T>['maxRows'];
|
|
25
|
+
/** An event when a validation occurs */
|
|
26
|
+
validateOn?: NSBulktextarea.InputField.Props<T>['validateOn'];
|
|
27
|
+
/** A function to valide the line */
|
|
28
|
+
lineValidation?: NSBulktextarea.InputField.Props<T>['lineValidation'];
|
|
29
|
+
/** Line delimeters */
|
|
30
|
+
linesDelimiters?: NSBulktextarea.InputField.Props<T>['linesDelimiters'];
|
|
31
|
+
/** Defines the props for paste action */
|
|
32
|
+
pasteProps?: NSBulktextarea.InputField.Props<T>['pasteProps'];
|
|
33
|
+
/** Maximum number of allowed lines/values */
|
|
34
|
+
maxLines?: NSBulktextarea.InputField.Props<T>['maxLines'];
|
|
35
|
+
/** Function to process individual lines during input */
|
|
36
|
+
lineProcessing?: NSBulktextarea.InputField.Props<T>['lineProcessing'];
|
|
37
|
+
/** List of errors */
|
|
38
|
+
errors?: Array<NSBulktextarea.ErrorItem>;
|
|
39
|
+
/** Defines whether to show errors or not */
|
|
40
|
+
showErrors?: boolean;
|
|
41
|
+
/** Internal */
|
|
42
|
+
onErrorsChange?: (errors: NSBulktextarea.ErrorItem[]) => void;
|
|
43
|
+
/** Internal */
|
|
44
|
+
onShowErrorsChange?: (showErrors: boolean) => void;
|
|
45
|
+
/** Internal */
|
|
46
|
+
onImmediatelyChange?: (lines: string[], value: string) => void;
|
|
47
|
+
};
|
|
48
|
+
type DefaultProps<T extends string | string[]> = {
|
|
49
|
+
defaultValue: T;
|
|
50
|
+
size: 'm';
|
|
51
|
+
defaultState: 'normal';
|
|
52
|
+
minRows: 2;
|
|
53
|
+
maxRows: 10;
|
|
54
|
+
maxLines: 100;
|
|
55
|
+
validateOn: NSBulktextarea.Props<T>['validateOn'];
|
|
56
|
+
locale: 'en';
|
|
57
|
+
defaultErrors: NSBulktextarea.Props<T>['errors'];
|
|
58
|
+
defaultShowErrors: false;
|
|
59
|
+
};
|
|
60
|
+
type State = {
|
|
61
|
+
linesCount: number;
|
|
62
|
+
isEmptyText: boolean;
|
|
63
|
+
errorIndex: number;
|
|
64
|
+
highlightErrorIndex: boolean;
|
|
65
|
+
prevError?: NSBulktextarea.ErrorItem;
|
|
66
|
+
};
|
|
67
|
+
type Handlers = {
|
|
68
|
+
value: null;
|
|
69
|
+
state: null;
|
|
70
|
+
showErrors: null;
|
|
71
|
+
errors: null;
|
|
72
|
+
};
|
|
73
|
+
type ErrorItem = {
|
|
74
|
+
lineIndex: number;
|
|
75
|
+
lineNode?: Node;
|
|
120
76
|
errorMessage: string;
|
|
121
77
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
78
|
+
namespace InputField {
|
|
79
|
+
type Props<T extends string | string[] = string | string[]> = BoxProps & {
|
|
80
|
+
/**
|
|
81
|
+
* Unique id
|
|
82
|
+
*/
|
|
83
|
+
id?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Placeholder for field. For multiline placeholder use an array of strings
|
|
86
|
+
*/
|
|
87
|
+
placeholder?: string | string[];
|
|
88
|
+
/**
|
|
89
|
+
* String to render in textarea. OnChanging value, it will go throw paste pipeline
|
|
90
|
+
*/
|
|
91
|
+
value?: T;
|
|
92
|
+
/**
|
|
93
|
+
* This component doesn't have default onChange callback, because we think that you need only the result after every changes/fixes
|
|
94
|
+
*/
|
|
95
|
+
onBlur?: (value: T, e: Event) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Callback to enable display errors after pasting for `on-paste` validation.
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
onPaste?: () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Size of component
|
|
103
|
+
* @default m
|
|
104
|
+
*/
|
|
105
|
+
size?: 'm' | 'l';
|
|
106
|
+
/**
|
|
107
|
+
* State for show errors or valid(green) borders
|
|
108
|
+
* @default normal
|
|
109
|
+
*/
|
|
110
|
+
state?: 'normal' | 'valid' | 'invalid';
|
|
111
|
+
/**
|
|
112
|
+
* Flag for disabling field
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
disabled?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Flag for readonly field
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
readonly?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Min rows
|
|
123
|
+
* @default 2
|
|
124
|
+
*/
|
|
125
|
+
minRows?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Max rows
|
|
128
|
+
* @default 10
|
|
129
|
+
*/
|
|
130
|
+
maxRows?: number;
|
|
131
|
+
/**
|
|
132
|
+
* List of available points to validate value
|
|
133
|
+
* @default blur
|
|
134
|
+
*/
|
|
135
|
+
validateOn?: ('blur' | 'blurLine' | 'paste')[];
|
|
136
|
+
/**
|
|
137
|
+
* Function to validate line
|
|
138
|
+
*/
|
|
139
|
+
lineValidation?: (line: string, lines: string[]) => {
|
|
140
|
+
isValid: boolean;
|
|
141
|
+
errorMessage: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Message for display error about whole field, not only one line.
|
|
145
|
+
* If set empty string, field will not have invalid state.
|
|
146
|
+
*/
|
|
147
|
+
commonErrorMessage: string;
|
|
148
|
+
/**
|
|
149
|
+
* Delimiters (event.key) for lines
|
|
150
|
+
* @default Enter
|
|
151
|
+
*/
|
|
152
|
+
linesDelimiters?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* Count of max lines in badge
|
|
155
|
+
* @default 100
|
|
156
|
+
*/
|
|
157
|
+
maxLines?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Paste props
|
|
160
|
+
*/
|
|
161
|
+
pasteProps?: {
|
|
162
|
+
/**
|
|
163
|
+
* @default '\n'
|
|
164
|
+
*/
|
|
165
|
+
delimiter?: string | RegExp;
|
|
166
|
+
/**
|
|
167
|
+
* @default row.trim();
|
|
168
|
+
*/
|
|
169
|
+
lineProcessing?: (line: string, lineIndex: number, totalLinesCount: number) => string;
|
|
170
|
+
/**
|
|
171
|
+
* @default true
|
|
172
|
+
*/
|
|
173
|
+
skipEmptyLines?: boolean;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Function for process line after it was blurred
|
|
177
|
+
*/
|
|
178
|
+
lineProcessing?: (line: string, lines: string[]) => string;
|
|
179
|
+
};
|
|
180
|
+
type DefaultProps = {
|
|
181
|
+
defaultValue: '';
|
|
182
|
+
size: 'm';
|
|
183
|
+
state: 'normal';
|
|
184
|
+
minRows: 2;
|
|
185
|
+
maxRows: 10;
|
|
186
|
+
defaultShowErrors: false;
|
|
187
|
+
defaultErrorIndex: -1;
|
|
188
|
+
defaultLinesCount: 0;
|
|
189
|
+
};
|
|
190
|
+
type Handlers = {
|
|
191
|
+
value: null;
|
|
192
|
+
linesCount: null;
|
|
193
|
+
errorIndex: null;
|
|
194
|
+
};
|
|
195
|
+
type State = {
|
|
196
|
+
keyboardLineIndex: number;
|
|
197
|
+
mouseLineIndex: number;
|
|
198
|
+
visibleErrorPopper: boolean;
|
|
199
|
+
};
|
|
200
|
+
interface Instance {
|
|
201
|
+
focus(): void;
|
|
202
|
+
focus(node: HTMLLIElement, offset: number | [number, number]): void;
|
|
203
|
+
addLine(value: string): Promise<HTMLLIElement>;
|
|
204
|
+
}
|
|
205
|
+
type Component<T extends string | string[] = string | string[]> = Intergalactic.Component<'div', Props<T>, {}, [], Instance>;
|
|
206
|
+
}
|
|
207
|
+
namespace Counter {
|
|
208
|
+
type Props = {
|
|
209
|
+
theme?: NSCounter.Props['theme'];
|
|
210
|
+
linesCount?: number;
|
|
211
|
+
maxLines?: number;
|
|
212
|
+
};
|
|
213
|
+
type Component = Intergalactic.Component<'div', Props>;
|
|
214
|
+
}
|
|
215
|
+
namespace ClearAll {
|
|
216
|
+
type Component = typeof Button;
|
|
217
|
+
}
|
|
218
|
+
namespace ErrorsNavigation {
|
|
219
|
+
type Props = {
|
|
220
|
+
errorIndex?: number;
|
|
221
|
+
onPrevError?: () => void;
|
|
222
|
+
onNextError?: () => void;
|
|
223
|
+
errorsCount?: number;
|
|
224
|
+
size?: 'm' | 'l';
|
|
225
|
+
showErrors?: boolean;
|
|
226
|
+
disabled?: boolean;
|
|
227
|
+
nextButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
228
|
+
prevButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
229
|
+
};
|
|
230
|
+
type Component = Intergalactic.Component<'div', Props>;
|
|
231
|
+
}
|
|
232
|
+
type RootComponent = (<T extends string | string[]>(props: Intergalactic.InternalTypings.ComponentProps<'div', 'div', BoxProps & NSBulktextarea.Props<T>>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', {}>;
|
|
233
|
+
type Component<T extends string | string[]> = RootComponent & {
|
|
234
|
+
InputField: InputField.Component<T>;
|
|
235
|
+
Counter: Counter.Component;
|
|
236
|
+
ClearAll: ClearAll.Component;
|
|
237
|
+
ErrorsNavigation: ErrorsNavigation.Component;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/** @deprecated It will be removed in v18. */
|
|
241
|
+
export type BulkTextareaProps<T extends string | string[]> = NSBulktextarea.Props<T>;
|
|
242
|
+
/** @deprecated It will be removed in v18. */
|
|
243
|
+
export type BulkTextareaDefaultProps<T extends string | string[]> = NSBulktextarea.DefaultProps<T>;
|
|
244
|
+
/** @deprecated It will be removed in v18. */
|
|
245
|
+
export type BulkTextareaInputFieldProps<T extends string | string[] = string | string[]> = NSBulktextarea.InputField.Props<T>;
|
|
246
|
+
/** @deprecated It will be removed in v18. */
|
|
247
|
+
export type BulkTextareaType<T extends string | string[]> = NSBulktextarea.Component<T>;
|
|
248
|
+
/** @deprecated It will be removed in v18. */
|
|
249
|
+
export type ErrorItem = NSBulktextarea.ErrorItem;
|
|
250
|
+
export type { NSBulktextarea };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}): React.ReactNode;
|
|
3
|
+
import type { BulkTextareaRootType } from '../BulkTextarea';
|
|
4
|
+
import type { NSBulktextarea } from '../BulkTextarea.types';
|
|
5
|
+
export declare function ClearAll(props: Intergalactic.InternalTypings.InferChildComponentProps<NSBulktextarea.ClearAll.Component, BulkTextareaRootType, 'ClearAll'>): React.ReactNode;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type NSCounter } from '@semcore/counter';
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
maxLines: number;
|
|
8
|
-
getI18nText: ReturnType<typeof useI18n>;
|
|
9
|
-
};
|
|
10
|
-
export declare function Counter(props: CounterProps): React.JSX.Element;
|
|
3
|
+
import type { BulkTextareaRootType } from '../BulkTextarea';
|
|
4
|
+
import type { NSBulktextarea } from '../BulkTextarea.types';
|
|
5
|
+
export declare function Counter(props: Intergalactic.InternalTypings.InferChildComponentProps<NSBulktextarea.Counter.Component, BulkTextareaRootType, 'Counter'>): React.JSX.Element;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Intergalactic } from '@semcore/core';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onNextError: () => void;
|
|
7
|
-
errorsCount: number;
|
|
8
|
-
size: 'm' | 'l';
|
|
9
|
-
showErrors: boolean;
|
|
10
|
-
getI18nText: ReturnType<typeof useI18n>;
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
nextButtonRef: React.RefObject<HTMLButtonElement>;
|
|
13
|
-
prevButtonRef: React.RefObject<HTMLButtonElement>;
|
|
14
|
-
};
|
|
15
|
-
export declare function ErrorsNavigation(props: ErrorsNavigationProps): React.JSX.Element;
|
|
3
|
+
import type { BulkTextareaRootType } from '../BulkTextarea';
|
|
4
|
+
import type { NSBulktextarea } from '../BulkTextarea.types';
|
|
5
|
+
export declare function ErrorsNavigation(props: Intergalactic.InternalTypings.InferChildComponentProps<NSBulktextarea.ErrorsNavigation.Component, BulkTextareaRootType, 'ErrorsNavigation'>): React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type HistorySelection = {
|
|
2
|
+
startLine: number;
|
|
3
|
+
startOffset: number;
|
|
4
|
+
endLine: number;
|
|
5
|
+
endOffset: number;
|
|
6
|
+
};
|
|
7
|
+
export type HistoryState = {
|
|
8
|
+
lines: string[];
|
|
9
|
+
selection: HistorySelection;
|
|
10
|
+
};
|
|
11
|
+
export declare class History {
|
|
12
|
+
private undoStack;
|
|
13
|
+
private redoStack;
|
|
14
|
+
private readonly maxLength;
|
|
15
|
+
constructor(maxLength?: number);
|
|
16
|
+
push(state: HistoryState): void;
|
|
17
|
+
undo(currentState: HistoryState): HistoryState | null;
|
|
18
|
+
redo(currentState: HistoryState): HistoryState | null;
|
|
19
|
+
private trimUndoStack;
|
|
20
|
+
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { PopperContext } from '@semcore/base-components';
|
|
2
|
+
import type { Intergalactic } from '@semcore/core';
|
|
2
3
|
import { Component } from '@semcore/core';
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
visibleErrorPopper: boolean;
|
|
10
|
-
};
|
|
11
|
-
declare class InputField<T extends string | string[]> extends Component<InputFieldProps<T>, typeof InputField.enhance, {
|
|
12
|
-
value: null;
|
|
13
|
-
linesCount: null;
|
|
14
|
-
errorIndex: null;
|
|
15
|
-
}, {}, State> {
|
|
5
|
+
import { History } from './History';
|
|
6
|
+
import type { BulkTextareaRootType } from '../../BulkTextarea';
|
|
7
|
+
import type { NSBulktextarea } from '../../BulkTextarea.types';
|
|
8
|
+
type Props<T extends string | string[]> = Intergalactic.InternalTypings.InferChildComponentProps<NSBulktextarea.InputField.Component<T>, BulkTextareaRootType, 'InputField'>;
|
|
9
|
+
declare class InputField<T extends string | string[]> extends Component<Props<T>, typeof InputField.enhance, NSBulktextarea.InputField.Handlers, {}, NSBulktextarea.InputField.State, NSBulktextarea.InputField.DefaultProps> implements NSBulktextarea.InputField.Instance {
|
|
16
10
|
static displayName: string;
|
|
17
11
|
static style: {
|
|
18
12
|
[key: string]: string;
|
|
@@ -33,9 +27,10 @@ declare class InputField<T extends string | string[]> extends Component<InputFie
|
|
|
33
27
|
delimiter: string;
|
|
34
28
|
skipEmptyLines: boolean;
|
|
35
29
|
emptyLineValue: string;
|
|
30
|
+
emptyLineValueJs: string;
|
|
36
31
|
spaceLineValue: string;
|
|
37
|
-
containerRef: React.RefObject<
|
|
38
|
-
textarea:
|
|
32
|
+
containerRef: React.RefObject<HTMLOListElement>;
|
|
33
|
+
textarea: HTMLOListElement;
|
|
39
34
|
popper: PopperContext['popper'] | null;
|
|
40
35
|
setPopperTrigger: PopperContext['setTrigger'] | null;
|
|
41
36
|
errorByInteraction: 'keyboard' | 'mouse' | null;
|
|
@@ -46,38 +41,53 @@ declare class InputField<T extends string | string[]> extends Component<InputFie
|
|
|
46
41
|
isFocusing: boolean;
|
|
47
42
|
linesCountTimeout: number;
|
|
48
43
|
observer: MutationObserver;
|
|
44
|
+
history: History;
|
|
49
45
|
state: {
|
|
50
46
|
visibleErrorPopper: boolean;
|
|
51
47
|
keyboardLineIndex: number;
|
|
52
48
|
mouseLineIndex: number;
|
|
53
49
|
};
|
|
54
|
-
constructor(props:
|
|
50
|
+
constructor(props: Props<T>);
|
|
55
51
|
uncontrolledProps(): {
|
|
56
52
|
value: null;
|
|
57
53
|
linesCount: null;
|
|
58
54
|
errorIndex: null;
|
|
59
55
|
};
|
|
60
56
|
componentDidMount(): void;
|
|
61
|
-
componentDidUpdate(prevProps:
|
|
57
|
+
componentDidUpdate(prevProps: typeof this.asProps, prevState: typeof this.state): void;
|
|
62
58
|
componentWillUnmount(): void;
|
|
63
59
|
get isDisabled(): boolean;
|
|
64
60
|
get popperDescribedId(): string;
|
|
65
61
|
get errorMessage(): {
|
|
66
|
-
errorMessage: string | null;
|
|
62
|
+
errorMessage: string | null | undefined;
|
|
67
63
|
isCommonError: boolean;
|
|
68
64
|
};
|
|
69
|
-
createContentEditableElement(props:
|
|
70
|
-
|
|
65
|
+
createContentEditableElement(props: Props<T>): HTMLOListElement;
|
|
66
|
+
focus(node?: HTMLLIElement, offset?: number | [number, number]): void;
|
|
67
|
+
addLine(value: string): Promise<HTMLLIElement>;
|
|
68
|
+
handleValueOutChange(value?: string | string[]): void;
|
|
71
69
|
handleScroll(): void;
|
|
72
70
|
handleMouseDown(event: MouseEvent): void;
|
|
73
71
|
handleMouseMove(event: MouseEvent): void;
|
|
74
72
|
handleMouseLeave(): void;
|
|
75
73
|
handlePaste(event: ClipboardEvent): void;
|
|
76
|
-
|
|
74
|
+
handleCompositionTextStart(): void;
|
|
75
|
+
handleCompositionTextEnd(event: CompositionEvent): void;
|
|
76
|
+
handleChange(event: InputEvent): void;
|
|
77
77
|
handleFocus(): void;
|
|
78
78
|
handleBlur(event: Event): void;
|
|
79
79
|
handleKeyDown(event: KeyboardEvent): void;
|
|
80
80
|
render(): React.ReactNode;
|
|
81
|
+
private insertText;
|
|
82
|
+
private insertParagraph;
|
|
83
|
+
private deleteText;
|
|
84
|
+
private clearNodes;
|
|
85
|
+
private insertFromPaste;
|
|
86
|
+
private getRangeTextNodes;
|
|
87
|
+
private getTextNodeAndOffset;
|
|
88
|
+
private getNode;
|
|
89
|
+
private createHistoryState;
|
|
90
|
+
private restoreHistoryState;
|
|
81
91
|
private prepareNodesForPaste;
|
|
82
92
|
private recalculateErrors;
|
|
83
93
|
private recalculateLinesCount;
|
|
@@ -92,13 +102,9 @@ declare class InputField<T extends string | string[]> extends Component<InputFie
|
|
|
92
102
|
private getNodeFromSelection;
|
|
93
103
|
private handleCursorMovement;
|
|
94
104
|
private setErrorIndex;
|
|
95
|
-
private isDeleteKey;
|
|
96
|
-
private getEmptyParagraph;
|
|
97
105
|
private addEventListeners;
|
|
98
106
|
private removeEventListeners;
|
|
99
107
|
private handleSelectAll;
|
|
100
|
-
private isRangeSelection;
|
|
101
108
|
private getSelectionDirection;
|
|
102
109
|
}
|
|
103
110
|
export { InputField };
|
|
104
|
-
export type { InputFieldProps, ErrorItem };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { default } from './BulkTextarea';
|
|
2
|
-
export type { BulkTextareaProps } from './BulkTextarea.types';
|
|
3
|
-
export type { ErrorItem } from './components/InputField/InputField.types';
|
|
2
|
+
export type { BulkTextareaProps, NSBulktextarea, ErrorItem } from './BulkTextarea.types';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/bulk-textarea",
|
|
3
3
|
"description": "Semrush BulkTextarea Component",
|
|
4
|
-
"version": "17.2.
|
|
4
|
+
"version": "17.2.2-prerelease.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"require": "./lib/cjs/index.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/button": "^17.2.1
|
|
18
|
-
"@semcore/typography": "^17.2.1
|
|
19
|
-
"@semcore/counter": "^17.2.1
|
|
20
|
-
"@semcore/tooltip": "^17.2.1
|
|
17
|
+
"@semcore/button": "^17.2.1",
|
|
18
|
+
"@semcore/typography": "^17.2.1",
|
|
19
|
+
"@semcore/counter": "^17.2.1",
|
|
20
|
+
"@semcore/tooltip": "^17.2.1",
|
|
21
21
|
"dompurify": "3.4.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@semcore/base-components": "^17.2.1",
|
|
25
|
-
"@semcore/icon": "^17.2.
|
|
25
|
+
"@semcore/icon": "^17.2.0"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/dompurify": "3.2.0",
|
|
34
|
-
"@semcore/
|
|
35
|
-
"@semcore/
|
|
34
|
+
"@semcore/base-components": "17.2.1",
|
|
35
|
+
"@semcore/core": "17.2.1",
|
|
36
36
|
"@semcore/testing-utils": "1.0.0",
|
|
37
|
-
"@semcore/icon": "17.2.
|
|
37
|
+
"@semcore/icon": "17.2.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "pnpm semcore-builder --source=ts && pnpm vite build"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InputField.types.js","names":[],"sources":["../../../../src/components/InputField/InputField.types.ts"],"sourcesContent":["import type { BulkTextareaInputFieldProps } from '../../BulkTextarea.types';\n\nexport type PasteProps = {\n /**\n * @default '\\n'\n */\n delimiter?: string | RegExp;\n /**\n * @default row.trim();\n */\n lineProcessing?: (line: string, lineIndex: number, totalLinesCount: number) => string;\n /**\n * @default true\n */\n skipEmptyLines?: boolean;\n};\n\nexport type ErrorItem = {\n lineIndex: number;\n lineNode?: Node;\n errorMessage: string;\n};\n\nexport type InputFieldProps<T extends string | string[]> =\n BulkTextareaInputFieldProps<T>\n & Required<\n Pick<\n BulkTextareaInputFieldProps<T>,\n 'value' | 'onBlur' | 'size' | 'state' | 'minRows' | 'maxRows' | 'validateOn' | 'maxLines' | 'pasteProps'\n >\n >\n & {\n prevError: ErrorItem;\n currentLineIndex: number;\n linesCount: number;\n onChangeLineIndex: (newIndex: number) => void;\n onChangeLinesCount: (rowsCount: number) => void;\n showErrors: boolean;\n /** List of errors in rows */\n errors: ErrorItem[];\n /** Select row with error */\n errorIndex: number;\n /** Flag for select all row */\n highlightErrorIndex: boolean;\n onErrorsChange: (errors: ErrorItem[]) => void;\n onShowErrorsChange: (showErrors: boolean) => void;\n onErrorIndexChange: (errorIndex: number) => void;\n /**\n * Return lines from textarea immediately they changed (uses mutation observer on textarea node under the hood)\n * Throttling may be required during processing this cb\n */\n onImmediatelyChange?: (lines: string[], value: string) => void;\n }\n & { 'aria-describedby'?: string };\n"],"mappings":"","ignoreList":[]}
|