@semcore/bulk-textarea 17.2.1 → 17.2.2-prerelease.1
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 +12 -0
- 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 +3 -3
- 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,4 +1,4 @@
|
|
|
1
|
-
SInputField>
|
|
1
|
+
SInputField>ol {
|
|
2
2
|
box-sizing: content-box;
|
|
3
3
|
outline-color: transparent;
|
|
4
4
|
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
@@ -13,33 +13,22 @@ SInputField>div {
|
|
|
13
13
|
word-wrap: break-word;
|
|
14
14
|
word-break: break-word;
|
|
15
15
|
font-family: inherit;
|
|
16
|
+
margin: 0;
|
|
17
|
+
|
|
18
|
+
list-style-type: none;
|
|
19
|
+
counter-reset: list-counter;
|
|
16
20
|
|
|
17
21
|
&:empty::before {
|
|
18
|
-
content: '1. ' attr(placeholder);
|
|
22
|
+
content: '1. ' attr(data-placeholder);
|
|
19
23
|
color: var(--intergalactic-text-placeholder, oklch(0.098 0.023 157.4 / 0.457));
|
|
20
24
|
position: absolute;
|
|
25
|
+
white-space: pre-wrap;
|
|
26
|
+
padding-left: var(--intergalactic-spacing-4x, 16px);
|
|
27
|
+
text-indent: calc(-1 * var(--intergalactic-spacing-4x, 16px));
|
|
21
28
|
}
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
counter-increment: row;
|
|
26
|
-
margin-bottom: var(--intergalactic-spacing-1x, 4px);
|
|
27
|
-
position: relative;
|
|
28
|
-
word-break: break-all;
|
|
29
|
-
|
|
30
|
-
&::before {
|
|
31
|
-
content: counter(row) '.';
|
|
32
|
-
display: inline-block;
|
|
33
|
-
white-space: nowrap;
|
|
34
|
-
text-align: right;
|
|
35
|
-
color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
|
|
36
|
-
margin-right: var(--intergalactic-spacing-1x, 4px);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
>p {
|
|
41
|
-
counter-increment: row;
|
|
42
|
-
/*display: inline-block;*/
|
|
30
|
+
>li {
|
|
31
|
+
counter-increment: list-counter;
|
|
43
32
|
margin: 0 0 var(--intergalactic-spacing-1x, 4px) 0;
|
|
44
33
|
position: relative;
|
|
45
34
|
word-break: break-all;
|
|
@@ -50,16 +39,18 @@ SInputField>div {
|
|
|
50
39
|
margin-bottom: 0;
|
|
51
40
|
}
|
|
52
41
|
|
|
53
|
-
|
|
54
|
-
content: counter(
|
|
55
|
-
|
|
42
|
+
&::before {
|
|
43
|
+
content: counter(list-counter) ".";
|
|
44
|
+
position: absolute;
|
|
45
|
+
left: 0;
|
|
56
46
|
white-space: nowrap;
|
|
47
|
+
display: inline-block;
|
|
48
|
+
|
|
57
49
|
text-align: right;
|
|
58
50
|
color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
|
|
59
51
|
margin-right: var(--intergalactic-spacing-1x, 4px);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
left: 0;
|
|
52
|
+
font-variant-numeric: normal;
|
|
53
|
+
font-weight: 300;
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
&[data-over-max-rows='true'] {
|
|
@@ -67,61 +58,61 @@ SInputField>div {
|
|
|
67
58
|
}
|
|
68
59
|
}
|
|
69
60
|
|
|
70
|
-
&:has(
|
|
71
|
-
>
|
|
61
|
+
&:has(li:nth-child(n + 10)) {
|
|
62
|
+
>li {
|
|
72
63
|
padding-left: var(--intergalactic-spacing-6x, 24px);
|
|
73
64
|
}
|
|
74
65
|
|
|
75
|
-
>
|
|
66
|
+
>li:nth-child(-n + 9)::before {
|
|
76
67
|
padding-left: var(--intergalactic-spacing-2x, 8px);
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
70
|
|
|
80
|
-
&:has(
|
|
81
|
-
>
|
|
71
|
+
&:has(li:nth-child(n + 100)) {
|
|
72
|
+
>li {
|
|
82
73
|
padding-left: var(--intergalactic-spacing-8x, 32px);
|
|
83
74
|
}
|
|
84
75
|
|
|
85
|
-
>
|
|
76
|
+
>li:nth-child(-n + 9)::before {
|
|
86
77
|
padding-left: var(--intergalactic-spacing-4x, 16px);
|
|
87
78
|
}
|
|
88
79
|
|
|
89
|
-
>
|
|
80
|
+
>li:nth-child(n + 10)::before {
|
|
90
81
|
padding-left: var(--intergalactic-spacing-2x, 8px);
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
>
|
|
84
|
+
>li:nth-child(n + 100)::before {
|
|
94
85
|
padding-left: 0;
|
|
95
86
|
}
|
|
96
87
|
}
|
|
97
88
|
|
|
98
|
-
&:has(
|
|
99
|
-
>
|
|
89
|
+
&:has(li:nth-child(n + 1000)) {
|
|
90
|
+
> li {
|
|
100
91
|
padding-left: calc(var(--intergalactic-spacing-10x, 40px) + var(--intergalactic-spacing-1x, 4px));
|
|
101
92
|
}
|
|
102
|
-
>
|
|
93
|
+
> li:nth-child(-n + 9)::before {
|
|
103
94
|
padding-left: var(--intergalactic-spacing-6x, 24px);
|
|
104
95
|
}
|
|
105
|
-
>
|
|
96
|
+
> li:nth-child(n + 10)::before {
|
|
106
97
|
padding-left: var(--intergalactic-spacing-4x, 16px);
|
|
107
98
|
}
|
|
108
|
-
>
|
|
99
|
+
> li:nth-child(n + 100)::before {
|
|
109
100
|
padding-left: var(--intergalactic-spacing-2x, 8px);
|
|
110
101
|
}
|
|
111
|
-
>
|
|
102
|
+
> li:nth-child(n + 1000)::before {
|
|
112
103
|
padding-left: 0;
|
|
113
104
|
}
|
|
114
105
|
}
|
|
115
106
|
}
|
|
116
107
|
|
|
117
|
-
SInputField[showErrors]>
|
|
108
|
+
SInputField[showErrors]>ol[aria-invalid]>li[aria-invalid]:after {
|
|
118
109
|
content: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBmaWxsPSIjZDEwMDJmIj48cGF0aCBkPSJNNyA2aDJ2NEg3VjZabTIgN3YtMkg3djJoMloiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMTUyIDEuMTcyYy43MTktMS41NjMgMi45NzctMS41NjMgMy42OTYgMGw2LjA0MyAxMy4xNDFjLjM2My43OTEtLjIyNSAxLjY4Ny0xLjEwOSAxLjY4N0gxLjIxOGMtLjg4NCAwLTEuNDcyLS44OTYtMS4xMDktMS42ODdMNi4xNTIgMS4xNzJabTcuMzc0IDEyLjgzN0w4IDEuOTkgMi40NzQgMTQuMDFoMTEuMDUyWiIvPjwvc3ZnPgo=");
|
|
119
110
|
position: absolute;
|
|
120
111
|
right: 0;
|
|
121
112
|
top: var(--intergalactic-spacing-05x, 2px);
|
|
122
113
|
}
|
|
123
114
|
|
|
124
|
-
SInputField[size='m']>
|
|
115
|
+
SInputField[size='m']>ol {
|
|
125
116
|
padding: var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-4x, 16px);
|
|
126
117
|
font-size: var(--intergalactic-fs-200, 14px);
|
|
127
118
|
line-height: var(--intergalactic-lh-200, 142%);
|
|
@@ -134,12 +125,12 @@ SInputField[size='m']>div {
|
|
|
134
125
|
padding-left: var(--intergalactic-spacing-8x, 32px);
|
|
135
126
|
|
|
136
127
|
&::before {
|
|
137
|
-
left: var(--intergalactic-spacing-4x, 16px);
|
|
128
|
+
left: calc(var(--intergalactic-spacing-4x, 16px) + 1px);
|
|
138
129
|
}
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
|
|
142
|
-
SInputField[size='l']>
|
|
133
|
+
SInputField[size='l']>ol {
|
|
143
134
|
padding: var(--intergalactic-spacing-3x, 12px) var(--intergalactic-spacing-4x, 16px);
|
|
144
135
|
font-size: var(--intergalactic-fs-300, 16px);
|
|
145
136
|
line-height: var(--intergalactic-lh-300, 150%);
|
|
@@ -157,7 +148,7 @@ SInputField[size='l']>div {
|
|
|
157
148
|
}
|
|
158
149
|
|
|
159
150
|
|
|
160
|
-
SInputField[state='normal']:not([disabled])>
|
|
151
|
+
SInputField[state='normal']:not([disabled])>ol {
|
|
161
152
|
&:focus {
|
|
162
153
|
border-color: var(--intergalactic-border-info-active, oklch(0.7 0.131 275.2));
|
|
163
154
|
@mixin focus-outline-mixin {
|
|
@@ -167,7 +158,7 @@ SInputField[state='normal']:not([disabled])>div {
|
|
|
167
158
|
}
|
|
168
159
|
}
|
|
169
160
|
|
|
170
|
-
SInputField[state='valid']>
|
|
161
|
+
SInputField[state='valid']>ol {
|
|
171
162
|
border-color: var(--intergalactic-border-success-active, oklch(0.7 0.166 170));
|
|
172
163
|
|
|
173
164
|
&:focus {
|
|
@@ -180,7 +171,7 @@ SInputField[state='valid']>div {
|
|
|
180
171
|
}
|
|
181
172
|
}
|
|
182
173
|
|
|
183
|
-
SInputField[state='invalid']>
|
|
174
|
+
SInputField[state='invalid']>ol {
|
|
184
175
|
border-color: var(--intergalactic-border-critical-active, oklch(0.7 0.21 23));
|
|
185
176
|
|
|
186
177
|
&:focus {
|
|
@@ -200,10 +191,10 @@ SInputField[state='invalid']>div {
|
|
|
200
191
|
background-repeat: repeat-y;
|
|
201
192
|
}
|
|
202
193
|
|
|
203
|
-
SInputField[readonly]>
|
|
194
|
+
SInputField[readonly]>ol {
|
|
204
195
|
background-color: var(--intergalactic-bg-secondary-neutral, oklch(0.98 0.001 180));
|
|
205
196
|
}
|
|
206
197
|
|
|
207
|
-
SInputField[disabled]>
|
|
198
|
+
SInputField[disabled]>ol {
|
|
208
199
|
opacity: var(--intergalactic-disabled-opacity, 0.4);
|
|
209
200
|
}
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_BulkTextarea","_interopRequireDefault","require"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './BulkTextarea';\nexport type { BulkTextareaProps
|
|
1
|
+
{"version":3,"file":"index.js","names":["_BulkTextarea","_interopRequireDefault","require"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './BulkTextarea';\nexport type { BulkTextareaProps, NSBulktextarea, ErrorItem } from './BulkTextarea.types';\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
package/lib/es6/BulkTextarea.js
CHANGED
|
@@ -34,6 +34,12 @@ class BulkTextareaRoot extends Component {
|
|
|
34
34
|
this.handlers.showErrors(false);
|
|
35
35
|
this.handlers.errors([]);
|
|
36
36
|
this.handlers.state('normal');
|
|
37
|
+
if (document.activeElement === this.clearAllButtonRef.current) {
|
|
38
|
+
const textarea = this.inputFieldRef.current?.querySelector('[contenteditable="true"]');
|
|
39
|
+
if (textarea instanceof HTMLOListElement) {
|
|
40
|
+
textarea.focus();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
});
|
|
39
45
|
_defineProperty(this, "handleClickClearAll", e => {
|
|
@@ -42,13 +48,9 @@ class BulkTextareaRoot extends Component {
|
|
|
42
48
|
this.setState({
|
|
43
49
|
errorIndex: -1
|
|
44
50
|
});
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
this.handlers.value('', e);
|
|
51
|
+
// @ts-ignore (we should set right type of value depending on the type of value passed)
|
|
52
|
+
this.handlers.value(typeof this.asProps.value === 'string' ? '' : [], e);
|
|
47
53
|
this.handlers.state('normal');
|
|
48
|
-
const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]');
|
|
49
|
-
if (textarea instanceof HTMLDivElement) {
|
|
50
|
-
textarea.focus();
|
|
51
|
-
}
|
|
52
54
|
});
|
|
53
55
|
_defineProperty(this, "handleChangeErrorIndex", amount => () => {
|
|
54
56
|
const {
|
|
@@ -148,6 +150,11 @@ class BulkTextareaRoot extends Component {
|
|
|
148
150
|
}
|
|
149
151
|
this.handlers.value?.(value, event);
|
|
150
152
|
},
|
|
153
|
+
onPaste: () => {
|
|
154
|
+
if (validateOn?.includes('paste')) {
|
|
155
|
+
this.handlers.showErrors(true);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
151
158
|
showErrors,
|
|
152
159
|
validateOn,
|
|
153
160
|
lineValidation: lineValidation,
|
|
@@ -267,12 +274,6 @@ class BulkTextareaRoot extends Component {
|
|
|
267
274
|
}, _ref));
|
|
268
275
|
}
|
|
269
276
|
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* BulkTextarea
|
|
273
|
-
*
|
|
274
|
-
* {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-api/|API} | {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-code/|Examples}
|
|
275
|
-
*/
|
|
276
277
|
_defineProperty(BulkTextareaRoot, "displayName", 'BulkTextarea');
|
|
277
278
|
_defineProperty(BulkTextareaRoot, "defaultProps", {
|
|
278
279
|
defaultValue: '',
|
|
@@ -287,6 +288,11 @@ _defineProperty(BulkTextareaRoot, "defaultProps", {
|
|
|
287
288
|
defaultShowErrors: false
|
|
288
289
|
});
|
|
289
290
|
_defineProperty(BulkTextareaRoot, "enhance", [i18nEnhance(localizedMessages), uniqueIdEnhance()]);
|
|
291
|
+
/**
|
|
292
|
+
* BulkTextarea
|
|
293
|
+
*
|
|
294
|
+
* {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-api/|API} | {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-code/|Examples}
|
|
295
|
+
*/
|
|
290
296
|
const BulkTextarea = (() => createComponent(BulkTextareaRoot, {
|
|
291
297
|
InputField,
|
|
292
298
|
Counter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkTextarea.js","names":["Box","createComponent","Component","Root","lastInteraction","i18nEnhance","uniqueIdEnhance","React","ClearAll","Counter","ErrorsNavigation","InputField","localizedMessages","BulkTextareaRoot","constructor","args","_defineProperty","createRef","linesCount","isEmptyText","errorIndex","highlightErrorIndex","isEmpty","setState","handlers","showErrors","errors","state","e","value","textarea","inputFieldRef","current","querySelector","HTMLDivElement","focus","amount","asProps","itemsIndex","length","newIndex","handleChangeErrorIndex","setTimeout","uncontrolledProps","counterId","uid","getInputFieldProps","size","minRows","maxRows","lineValidation","placeholder","validateOn","linesDelimiters","maxLines","disabled","readonly","pasteProps","lineProcessing","onImmediatelyChange","prevError","onChangeLinesCount","handleChangeLinesCount","onChangeLineIndex","includes","onBlur","event","isKeyboard","FocusEvent","relatedTarget","clearAllButtonRef","nextButtonRef","onErrorsChange","newErrors","undefined","newState","onErrorIndexChange","newErrorIndex","ref","getCounterProps","getI18nText","counterTheme","id","counterRef","theme","getClearAllProps","onClick","handleClickClearAll","isHidden","getErrorsNavigationProps","onPrevError","onNextError","errorsCount","map","Boolean","prevButtonRef","render","_ref","createElement","_assignProps","defaultValue","defaultState","locale","defaultErrors","defaultShowErrors","BulkTextarea"],"sources":["../../src/BulkTextarea.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport { createComponent, Component, Root, lastInteraction } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport uniqueIdEnhance from '@semcore/core/lib/utils/uniqueID';\nimport React from 'react';\n\nimport type { BulkTextareaType, BulkTextareaProps, BulkTextareaDefaultProps } from './BulkTextarea.types';\nimport { ClearAll } from './components/ClearAll';\nimport { Counter } from './components/Counter';\nimport { ErrorsNavigation } from './components/ErrorsNavigation';\nimport { InputField, type InputFieldProps } from './components/InputField/InputField';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\n\ntype State<T extends string | string[]> = {\n linesCount: number;\n isEmptyText: boolean;\n errorIndex: number;\n highlightErrorIndex: boolean;\n prevError?: InputFieldProps<T>['errors'][number];\n};\n\nclass BulkTextareaRoot<T extends string | string[]> extends Component<\n BulkTextareaProps<T>,\n typeof BulkTextareaRoot.enhance,\n {\n value: null;\n state: null;\n showErrors: null;\n errors: null;\n },\n WithI18nEnhanceProps,\n State<T>,\n BulkTextareaDefaultProps<T>\n> {\n static displayName = 'BulkTextarea';\n static defaultProps: BulkTextareaDefaultProps<string | string[]> = {\n defaultValue: '',\n size: 'm',\n defaultState: 'normal',\n minRows: 2,\n maxRows: 10,\n maxLines: 100,\n validateOn: ['blur'],\n locale: 'en',\n defaultErrors: [],\n defaultShowErrors: false,\n };\n\n static enhance = [i18nEnhance(localizedMessages), uniqueIdEnhance()] as const;\n\n inputFieldRef = React.createRef<HTMLDivElement>();\n clearAllButtonRef = React.createRef<HTMLButtonElement>();\n nextButtonRef = React.createRef<HTMLButtonElement>();\n prevButtonRef = React.createRef<HTMLButtonElement>();\n counterRef = React.createRef<HTMLDivElement>();\n\n state: State<T> = {\n linesCount: 0,\n isEmptyText: true,\n errorIndex: -1,\n highlightErrorIndex: false,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n state: null,\n showErrors: null,\n errors: null,\n };\n }\n\n get counterId() {\n return `${this.asProps.uid}_counter`;\n }\n\n getInputFieldProps() {\n const {\n value,\n size,\n minRows,\n maxRows,\n lineValidation,\n placeholder,\n validateOn,\n linesDelimiters,\n maxLines,\n disabled,\n readonly,\n pasteProps,\n lineProcessing,\n errors = [],\n showErrors,\n onImmediatelyChange,\n } = this.asProps;\n const { errorIndex, prevError, linesCount, highlightErrorIndex } = this.state;\n\n return {\n value,\n size,\n state: showErrors && errors?.length > 0 ? 'invalid' : 'normal',\n disabled,\n readonly,\n minRows,\n maxRows,\n maxLines,\n placeholder,\n prevError,\n pasteProps,\n linesCount,\n lineProcessing,\n onChangeLinesCount: this.handleChangeLinesCount,\n onChangeLineIndex: () => {\n if (validateOn?.includes('blurLine')) {\n this.handlers.showErrors(true);\n }\n },\n onBlur: (value: T, event: Event) => {\n if (\n validateOn?.includes('blur') &&\n (lastInteraction.isKeyboard() ||\n (event instanceof FocusEvent && event.relatedTarget !== this.clearAllButtonRef.current))\n ) {\n this.handlers.showErrors(true);\n }\n\n if (\n this.asProps.showErrors === false &&\n (validateOn?.includes('blur') || validateOn?.includes('blurLine'))\n ) {\n setTimeout(() => {\n this.nextButtonRef.current?.focus();\n }, 250);\n }\n\n this.handlers.value?.(value, event);\n },\n showErrors,\n validateOn,\n lineValidation: lineValidation,\n errors,\n onErrorsChange: (newErrors: InputFieldProps<T>['errors']) => {\n const prevError = newErrors.length === 0 ? errors[0] : undefined;\n this.handlers.errors(newErrors);\n this.setState({ prevError });\n setTimeout(() => {\n const { showErrors, errors } = this.asProps;\n if (showErrors) {\n const newState = newErrors.length === 0 ? 'normal' : 'invalid';\n this.handlers.state(newState);\n }\n if (errors?.length === 0) {\n this.handlers.showErrors(false);\n\n setTimeout(() => {\n this.setState({ prevError: undefined });\n }, 150);\n }\n }, 10); // this timeout to be sure that code will be after state change\n },\n highlightErrorIndex,\n errorIndex,\n onErrorIndexChange: (newErrorIndex: number) => {\n const prevError = errors[errorIndex];\n\n this.setState({ errorIndex: newErrorIndex, prevError, highlightErrorIndex: false });\n },\n linesDelimiters,\n ref: this.inputFieldRef,\n ['aria-describedby']: this.counterId,\n onImmediatelyChange,\n };\n }\n\n getCounterProps() {\n const { maxLines, getI18nText, size } = this.asProps;\n const { linesCount, isEmptyText } = this.state;\n\n let counterTheme = '';\n\n if (linesCount === maxLines) {\n counterTheme = 'warning';\n } else if (linesCount > maxLines!) {\n counterTheme = 'danger';\n }\n\n return {\n id: this.counterId,\n ref: this.counterRef,\n getI18nText,\n theme: counterTheme,\n linesCount: isEmptyText ? 0 : linesCount,\n maxLines,\n size,\n };\n }\n\n getClearAllProps() {\n const { size, getI18nText, disabled, readonly } = this.asProps;\n\n return {\n onClick: this.handleClickClearAll,\n isHidden: this.state.isEmptyText,\n size,\n getI18nText,\n ref: this.clearAllButtonRef,\n disabled: disabled || readonly,\n };\n }\n\n getErrorsNavigationProps() {\n const { size, getI18nText, disabled, readonly, errors = [], showErrors } = this.asProps;\n const { errorIndex } = this.state;\n return {\n size,\n getI18nText,\n errorIndex: errorIndex,\n onPrevError: this.handleChangeErrorIndex(-1),\n onNextError: this.handleChangeErrorIndex(1),\n errorsCount: errors.map(Boolean).length,\n showErrors,\n disabled: disabled || readonly || false,\n nextButtonRef: this.nextButtonRef,\n prevButtonRef: this.prevButtonRef,\n };\n }\n\n handleChangeLinesCount = (linesCount: number) => {\n const isEmpty = !linesCount;\n this.setState({ linesCount, isEmptyText: isEmpty });\n\n if (isEmpty) {\n this.handlers.showErrors(false);\n this.handlers.errors([]);\n this.handlers.state('normal');\n }\n };\n\n handleClickClearAll = (e: Event) => {\n this.handlers.showErrors(false);\n this.handlers.errors([]);\n this.setState({ errorIndex: -1 });\n // @ts-ignore\n this.handlers.value('', e);\n this.handlers.state('normal');\n\n const textarea = this.inputFieldRef.current?.querySelector('[role=\"textbox\"]');\n\n if (textarea instanceof HTMLDivElement) {\n textarea.focus();\n }\n };\n\n handleChangeErrorIndex = (amount: number) => () => {\n const { errors = [] } = this.asProps;\n const { errorIndex } = this.state;\n const itemsIndex = errors.length - 1;\n let newIndex = errorIndex + amount;\n\n if (newIndex < 0) {\n newIndex = amount + itemsIndex + 1;\n } else if (newIndex > itemsIndex) {\n newIndex = newIndex - itemsIndex - 1;\n }\n\n if (!errors[newIndex]) {\n this.handleChangeErrorIndex(amount < 0 ? amount - 1 : amount + 1)();\n } else {\n this.handlers.showErrors(false);\n this.setState({ errorIndex: -1 });\n\n setTimeout(() => {\n this.handlers.showErrors(true);\n this.setState({ errorIndex: newIndex, highlightErrorIndex: true });\n });\n }\n };\n\n render() {\n return <Root render={Box} __excludeProps={['onBlur', 'value', 'placeholder']} />;\n }\n}\n\n/**\n * BulkTextarea\n *\n * {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-api/|API} | {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-code/|Examples}\n */\nconst BulkTextarea = (<T extends string | string[]>() =>\n createComponent<BulkTextareaType<T>, typeof BulkTextareaRoot>(BulkTextareaRoot, {\n InputField,\n Counter,\n ClearAll,\n ErrorsNavigation,\n }))();\n\nexport default BulkTextarea;\n"],"mappings":";;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,SAAS,EAAEC,IAAI,EAAEC,eAAe,QAAQ,eAAe;AAEjF,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,UAAU,QAA8B,oCAAoC;AACrF,SAASC,iBAAiB,QAAQ,gDAAgD;AAUlF,MAAMC,gBAAgB,SAAsCX,SAAS,CAYnE;EAAAY,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,qCAiBgBT,KAAK,CAACU,SAAS,CAAiB,CAAC;IAAAD,eAAA,yCAC7BT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,qCACxCT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,qCACpCT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,kCACvCT,KAAK,CAACU,SAAS,CAAiB,CAAC;IAAAD,eAAA,gBAE5B;MAChBE,UAAU,EAAE,CAAC;MACbC,WAAW,EAAE,IAAI;MACjBC,UAAU,EAAE,CAAC,CAAC;MACdC,mBAAmB,EAAE;IACvB,CAAC;IAAAL,eAAA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C,CAAC,EAAE,CAAC;AAEP,eAAe+F,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BulkTextarea.js","names":["Box","createComponent","Component","Root","lastInteraction","i18nEnhance","uniqueIdEnhance","React","ClearAll","Counter","ErrorsNavigation","InputField","localizedMessages","BulkTextareaRoot","constructor","args","_defineProperty","createRef","linesCount","isEmptyText","errorIndex","highlightErrorIndex","isEmpty","setState","handlers","showErrors","errors","state","document","activeElement","clearAllButtonRef","current","textarea","inputFieldRef","querySelector","HTMLOListElement","focus","e","value","asProps","amount","itemsIndex","length","newIndex","handleChangeErrorIndex","setTimeout","uncontrolledProps","counterId","uid","getInputFieldProps","size","minRows","maxRows","lineValidation","placeholder","validateOn","linesDelimiters","maxLines","disabled","readonly","pasteProps","lineProcessing","onImmediatelyChange","prevError","onChangeLinesCount","handleChangeLinesCount","onChangeLineIndex","includes","onBlur","event","isKeyboard","FocusEvent","relatedTarget","nextButtonRef","onPaste","onErrorsChange","newErrors","undefined","newState","onErrorIndexChange","newErrorIndex","ref","getCounterProps","getI18nText","counterTheme","id","counterRef","theme","getClearAllProps","onClick","handleClickClearAll","isHidden","getErrorsNavigationProps","onPrevError","onNextError","errorsCount","map","Boolean","prevButtonRef","render","_ref","createElement","_assignProps","defaultValue","defaultState","locale","defaultErrors","defaultShowErrors","BulkTextarea"],"sources":["../../src/BulkTextarea.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, Root, lastInteraction } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport uniqueIdEnhance from '@semcore/core/lib/utils/uniqueID';\nimport React from 'react';\n\nimport type { NSBulktextarea } from './BulkTextarea.types';\nimport { ClearAll } from './components/ClearAll';\nimport { Counter } from './components/Counter';\nimport { ErrorsNavigation } from './components/ErrorsNavigation';\nimport { InputField } from './components/InputField/InputField';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\n\nclass BulkTextareaRoot<T extends string | string[]> extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSBulktextarea.Component<T>>,\n typeof BulkTextareaRoot.enhance,\n NSBulktextarea.Handlers,\n WithI18nEnhanceProps,\n NSBulktextarea.State,\n NSBulktextarea.DefaultProps<T>\n> {\n static displayName = 'BulkTextarea';\n static defaultProps: NSBulktextarea.DefaultProps<string | string[]> = {\n defaultValue: '',\n size: 'm',\n defaultState: 'normal',\n minRows: 2,\n maxRows: 10,\n maxLines: 100,\n validateOn: ['blur'],\n locale: 'en',\n defaultErrors: [],\n defaultShowErrors: false,\n };\n\n static enhance = [i18nEnhance(localizedMessages), uniqueIdEnhance()] as const;\n\n inputFieldRef = React.createRef<HTMLOListElement>();\n clearAllButtonRef = React.createRef<HTMLButtonElement>();\n nextButtonRef = React.createRef<HTMLButtonElement>();\n prevButtonRef = React.createRef<HTMLButtonElement>();\n counterRef = React.createRef<HTMLOListElement>();\n\n state: NSBulktextarea.State = {\n linesCount: 0,\n isEmptyText: true,\n errorIndex: -1,\n highlightErrorIndex: false,\n };\n\n uncontrolledProps() {\n return {\n value: null,\n state: null,\n showErrors: null,\n errors: null,\n };\n }\n\n get counterId() {\n return `${this.asProps.uid}_counter`;\n }\n\n getInputFieldProps() {\n const {\n value,\n size,\n minRows,\n maxRows,\n lineValidation,\n placeholder,\n validateOn,\n linesDelimiters,\n maxLines,\n disabled,\n readonly,\n pasteProps,\n lineProcessing,\n errors = [],\n showErrors,\n onImmediatelyChange,\n } = this.asProps;\n const { errorIndex, prevError, linesCount, highlightErrorIndex } = this.state;\n\n return {\n value,\n size,\n state: showErrors && errors?.length > 0 ? 'invalid' : 'normal',\n disabled,\n readonly,\n minRows,\n maxRows,\n maxLines,\n placeholder,\n prevError,\n pasteProps,\n linesCount,\n lineProcessing,\n onChangeLinesCount: this.handleChangeLinesCount,\n onChangeLineIndex: () => {\n if (validateOn?.includes('blurLine')) {\n this.handlers.showErrors(true);\n }\n },\n onBlur: (value: T, event: Event) => {\n if (\n validateOn?.includes('blur') &&\n (lastInteraction.isKeyboard() ||\n (event instanceof FocusEvent && event.relatedTarget !== this.clearAllButtonRef.current))\n ) {\n this.handlers.showErrors(true);\n }\n\n if (\n this.asProps.showErrors === false &&\n (validateOn?.includes('blur') || validateOn?.includes('blurLine'))\n ) {\n setTimeout(() => {\n this.nextButtonRef.current?.focus();\n }, 250);\n }\n\n this.handlers.value?.(value, event);\n },\n onPaste: () => {\n if (validateOn?.includes('paste')) {\n this.handlers.showErrors(true);\n }\n },\n showErrors,\n validateOn,\n lineValidation: lineValidation,\n errors,\n onErrorsChange: (newErrors: NSBulktextarea.ErrorItem[]) => {\n const prevError = newErrors.length === 0 ? errors[0] : undefined;\n this.handlers.errors(newErrors);\n this.setState({ prevError });\n setTimeout(() => {\n const { showErrors, errors } = this.asProps;\n if (showErrors) {\n const newState = newErrors.length === 0 ? 'normal' : 'invalid';\n this.handlers.state(newState);\n }\n if (errors?.length === 0) {\n this.handlers.showErrors(false);\n\n setTimeout(() => {\n this.setState({ prevError: undefined });\n }, 150);\n }\n }, 10); // this timeout to be sure that code will be after state change\n },\n highlightErrorIndex,\n errorIndex,\n onErrorIndexChange: (newErrorIndex: number) => {\n const prevError = errors[errorIndex];\n\n this.setState({ errorIndex: newErrorIndex, prevError, highlightErrorIndex: false });\n },\n linesDelimiters,\n ref: this.inputFieldRef,\n ['aria-describedby']: this.counterId,\n onImmediatelyChange,\n };\n }\n\n getCounterProps() {\n const { maxLines, getI18nText, size } = this.asProps;\n const { linesCount, isEmptyText } = this.state;\n\n let counterTheme = '';\n\n if (linesCount === maxLines) {\n counterTheme = 'warning';\n } else if (linesCount > maxLines!) {\n counterTheme = 'danger';\n }\n\n return {\n id: this.counterId,\n ref: this.counterRef,\n getI18nText,\n theme: counterTheme,\n linesCount: isEmptyText ? 0 : linesCount,\n maxLines,\n size,\n };\n }\n\n getClearAllProps() {\n const { size, getI18nText, disabled, readonly } = this.asProps;\n\n return {\n onClick: this.handleClickClearAll,\n isHidden: this.state.isEmptyText,\n size,\n getI18nText,\n ref: this.clearAllButtonRef,\n disabled: disabled || readonly,\n };\n }\n\n getErrorsNavigationProps() {\n const { size, getI18nText, disabled, readonly, errors = [], showErrors } = this.asProps;\n const { errorIndex } = this.state;\n return {\n size,\n getI18nText,\n errorIndex: errorIndex,\n onPrevError: this.handleChangeErrorIndex(-1),\n onNextError: this.handleChangeErrorIndex(1),\n errorsCount: errors.map(Boolean).length,\n showErrors,\n disabled: disabled || readonly || false,\n nextButtonRef: this.nextButtonRef,\n prevButtonRef: this.prevButtonRef,\n };\n }\n\n handleChangeLinesCount = (linesCount: number) => {\n const isEmpty = !linesCount;\n this.setState({ linesCount, isEmptyText: isEmpty });\n\n if (isEmpty) {\n this.handlers.showErrors(false);\n this.handlers.errors([]);\n this.handlers.state('normal');\n\n if (document.activeElement === this.clearAllButtonRef.current) {\n const textarea = this.inputFieldRef.current?.querySelector('[contenteditable=\"true\"]');\n\n if (textarea instanceof HTMLOListElement) {\n textarea.focus();\n }\n }\n }\n };\n\n handleClickClearAll = (e: Event) => {\n this.handlers.showErrors(false);\n this.handlers.errors([]);\n this.setState({ errorIndex: -1 });\n // @ts-ignore (we should set right type of value depending on the type of value passed)\n this.handlers.value(typeof this.asProps.value === 'string' ? '' : [], e);\n this.handlers.state('normal');\n };\n\n handleChangeErrorIndex = (amount: number) => () => {\n const { errors = [] } = this.asProps;\n const { errorIndex } = this.state;\n const itemsIndex = errors.length - 1;\n let newIndex = errorIndex + amount;\n\n if (newIndex < 0) {\n newIndex = amount + itemsIndex + 1;\n } else if (newIndex > itemsIndex) {\n newIndex = newIndex - itemsIndex - 1;\n }\n\n if (!errors[newIndex]) {\n this.handleChangeErrorIndex(amount < 0 ? amount - 1 : amount + 1)();\n } else {\n this.handlers.showErrors(false);\n this.setState({ errorIndex: -1 });\n\n setTimeout(() => {\n this.handlers.showErrors(true);\n this.setState({ errorIndex: newIndex, highlightErrorIndex: true });\n });\n }\n };\n\n render() {\n return <Root render={Box} __excludeProps={['onBlur', 'value', 'placeholder']} />;\n }\n}\n\nexport type BulkTextareaRootType = typeof BulkTextareaRoot;\n\n/**\n * BulkTextarea\n *\n * {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-api/|API} | {@link https://developer.semrush.com/intergalactic/components/bulk-textarea/bulk-textarea-code/|Examples}\n */\nconst BulkTextarea = (<T extends string | string[]>() =>\n createComponent<NSBulktextarea.Component<T>, BulkTextareaRootType>(BulkTextareaRoot, {\n InputField,\n Counter,\n ClearAll,\n ErrorsNavigation,\n }))();\n\nexport default BulkTextarea;\n"],"mappings":";;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAE9C,SAASC,eAAe,EAAEC,SAAS,EAAEC,IAAI,EAAEC,eAAe,QAAQ,eAAe;AAEjF,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,UAAU,QAAQ,oCAAoC;AAC/D,SAASC,iBAAiB,QAAQ,gDAAgD;AAElF,MAAMC,gBAAgB,SAAsCX,SAAS,CAOnE;EAAAY,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,qCAiBgBT,KAAK,CAACU,SAAS,CAAmB,CAAC;IAAAD,eAAA,yCAC/BT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,qCACxCT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,qCACpCT,KAAK,CAACU,SAAS,CAAoB,CAAC;IAAAD,eAAA,kCACvCT,KAAK,CAACU,SAAS,CAAmB,CAAC;IAAAD,eAAA,gBAElB;MAC5BE,UAAU,EAA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O,EAAE,EAAE;EACXK,QAAQ,EAAE,GAAG;EACbF,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBkD,MAAM,EAAE,IAAI;EACZC,aAAa,EAAE,EAAE;EACjBC,iBAAiB,EAAE;AACrB,CAAC;AAAA3F,eAAA,CApBGH,gBAAgB,aAsBH,CAACR,WAAW,CAACO,iBAAiB,CAAC,EAAEN,eAAe,CAAC,CAAC,CAAC;AAoPtE;AACA;AACA;AACA;AACA;AACA,MAAMsG,YAAY,GAAG,CAAC,MACpB3G,eAAe,CAAoDY,gBAAgB,EAAE;EACnFF,UAAU;EACVF,OAAO;EACPD,QAAQ;EACRE;AACF,CAAC,CAAC,EAAE,CAAC;AAEP,eAAekG,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkTextarea.types.js","names":[],"sources":["../../src/BulkTextarea.types.ts"],"sourcesContent":["import type { BoxProps } from '@semcore/base-components';\nimport type Button from '@semcore/button';\nimport type { Intergalactic } from '@semcore/core';\
|
|
1
|
+
{"version":3,"file":"BulkTextarea.types.js","names":[],"sources":["../../src/BulkTextarea.types.ts"],"sourcesContent":["import type { BoxProps } from '@semcore/base-components';\nimport type Button from '@semcore/button';\nimport type { Intergalactic } from '@semcore/core';\nimport type { NSCounter } from '@semcore/counter';\n\ndeclare namespace NSBulktextarea {\n type Props<T extends string | string[]> = {\n /** The current value */\n value?: NSBulktextarea.InputField.Props<T>['value'];\n /** Callback triggered when the onBlur event is emmited */\n onChange?: NSBulktextarea.InputField.Props<T>['onBlur'];\n /** Placeholder text */\n placeholder?: NSBulktextarea.InputField.Props<T>['placeholder'];\n /** Component size */\n size?: NSBulktextarea.InputField.Props<T>['size'];\n /** State for show errors or valid(green) borders */\n state?: NSBulktextarea.InputField.Props<T>['state'];\n /** Defines whether the textarea is disabled */\n disabled?: NSBulktextarea.InputField.Props<T>['disabled'];\n /** Defines whether the textarea is readonly */\n readonly?: NSBulktextarea.InputField.Props<T>['readonly'];\n /** Minimum number of rows to display */\n minRows?: NSBulktextarea.InputField.Props<T>['minRows'];\n /** Maximum number of rows to display */\n maxRows?: NSBulktextarea.InputField.Props<T>['maxRows'];\n /** An event when a validation occurs */\n validateOn?: NSBulktextarea.InputField.Props<T>['validateOn'];\n /** A function to valide the line */\n lineValidation?: NSBulktextarea.InputField.Props<T>['lineValidation'];\n /** Line delimeters */\n linesDelimiters?: NSBulktextarea.InputField.Props<T>['linesDelimiters'];\n /** Defines the props for paste action */\n pasteProps?: NSBulktextarea.InputField.Props<T>['pasteProps'];\n /** Maximum number of allowed lines/values */\n maxLines?: NSBulktextarea.InputField.Props<T>['maxLines'];\n /** Function to process individual lines during input */\n lineProcessing?: NSBulktextarea.InputField.Props<T>['lineProcessing'];\n /** List of errors */\n errors?: Array<NSBulktextarea.ErrorItem>;\n /** Defines whether to show errors or not */\n showErrors?: boolean;\n /** Internal */\n onErrorsChange?: (errors: NSBulktextarea.ErrorItem[]) => void;\n /** Internal */\n onShowErrorsChange?: (showErrors: boolean) => void;\n /** Internal */\n onImmediatelyChange?: (lines: string[], value: string) => void;\n };\n type DefaultProps<T extends string | string[]> = {\n defaultValue: T;\n size: 'm';\n defaultState: 'normal';\n minRows: 2;\n maxRows: 10;\n maxLines: 100;\n validateOn: NSBulktextarea.Props<T>['validateOn'];\n locale: 'en';\n defaultErrors: NSBulktextarea.Props<T>['errors'];\n defaultShowErrors: false;\n };\n type State = {\n linesCount: number;\n isEmptyText: boolean;\n errorIndex: number;\n highlightErrorIndex: boolean;\n prevError?: NSBulktextarea.ErrorItem;\n };\n type Handlers = {\n value: null;\n state: null;\n showErrors: null;\n errors: null;\n };\n type ErrorItem = {\n lineIndex: number;\n lineNode?: Node;\n errorMessage: string;\n };\n\n namespace InputField {\n type Props<T extends string | string[] = string | string[]> = BoxProps & {\n /**\n * Unique id\n */\n id?: string;\n /**\n * Placeholder for field. For multiline placeholder use an array of strings\n */\n placeholder?: string | string[];\n /**\n * String to render in textarea. OnChanging value, it will go throw paste pipeline\n */\n value?: T;\n /**\n * This component doesn't have default onChange callback, because we think that you need only the result after every changes/fixes\n */\n onBlur?: (value: T, e: Event) => void;\n\n /**\n * Callback to enable display errors after pasting for `on-paste` validation.\n * @internal\n */\n onPaste?: () => void;\n /**\n * Size of component\n * @default m\n */\n size?: 'm' | 'l';\n /**\n * State for show errors or valid(green) borders\n * @default normal\n */\n state?: 'normal' | 'valid' | 'invalid';\n /**\n * Flag for disabling field\n * @default false\n */\n disabled?: boolean;\n /**\n * Flag for readonly field\n * @default false\n */\n readonly?: boolean;\n /**\n * Min rows\n * @default 2\n */\n minRows?: number;\n /**\n * Max rows\n * @default 10\n */\n maxRows?: number;\n /**\n * List of available points to validate value\n * @default blur\n */\n validateOn?: ('blur' | 'blurLine' | 'paste')[];\n /**\n * Function to validate line\n */\n lineValidation?: (line: string, lines: string[]) => { isValid: boolean; errorMessage: string };\n /**\n * Message for display error about whole field, not only one line.\n * If set empty string, field will not have invalid state.\n */\n commonErrorMessage: string;\n /**\n * Delimiters (event.key) for lines\n * @default Enter\n */\n linesDelimiters?: string[];\n /**\n * Count of max lines in badge\n * @default 100\n */\n maxLines?: number;\n /**\n * Paste props\n */\n 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 /**\n * Function for process line after it was blurred\n */\n lineProcessing?: (line: string, lines: string[]) => string;\n };\n type DefaultProps = {\n defaultValue: '';\n size: 'm';\n state: 'normal';\n minRows: 2;\n maxRows: 10;\n defaultShowErrors: false;\n defaultErrorIndex: -1;\n defaultLinesCount: 0;\n };\n type Handlers = {\n value: null;\n linesCount: null;\n errorIndex: null;\n };\n type State = {\n keyboardLineIndex: number;\n mouseLineIndex: number;\n visibleErrorPopper: boolean;\n };\n interface Instance {\n focus(): void;\n focus(node: HTMLLIElement, offset: number | [number, number]): void;\n addLine(value: string): Promise<HTMLLIElement>;\n }\n\n type Component<T extends string | string[] = string | string[]> = Intergalactic.Component<'div', Props<T>, {}, [], Instance>;\n }\n\n namespace Counter {\n type Props = {\n theme?: NSCounter.Props['theme'];\n linesCount?: number;\n maxLines?: number;\n };\n\n type Component = Intergalactic.Component<'div', Props>;\n }\n\n namespace ClearAll {\n type Component = typeof Button;\n }\n\n namespace ErrorsNavigation {\n type Props = {\n errorIndex?: number;\n onPrevError?: () => void;\n onNextError?: () => void;\n errorsCount?: number;\n size?: 'm' | 'l';\n showErrors?: boolean;\n disabled?: boolean;\n nextButtonRef?: React.RefObject<HTMLButtonElement>;\n prevButtonRef?: React.RefObject<HTMLButtonElement>;\n };\n\n type Component = Intergalactic.Component<'div', Props>;\n }\n\n type RootComponent = (<T extends string | string[]>(\n props: Intergalactic.InternalTypings.ComponentProps<'div', 'div', BoxProps & NSBulktextarea.Props<T>>,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', {}>;\n\n type Component<T extends string | string[]> = RootComponent & {\n InputField: InputField.Component<T>;\n Counter: Counter.Component;\n ClearAll: ClearAll.Component;\n ErrorsNavigation: ErrorsNavigation.Component;\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type BulkTextareaProps<T extends string | string[]> = NSBulktextarea.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type BulkTextareaDefaultProps<T extends string | string[]> = NSBulktextarea.DefaultProps<T>;\n/** @deprecated It will be removed in v18. */\nexport type BulkTextareaInputFieldProps<T extends string | string[] = string | string[]> =\n NSBulktextarea.InputField.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type BulkTextareaType<T extends string | string[]> = NSBulktextarea.Component<T>;\n/** @deprecated It will be removed in v18. */\nexport type ErrorItem = NSBulktextarea.ErrorItem;\n\nexport type { NSBulktextarea };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClearAll.js","names":["Button","Root","sstyled","CloseM","React","ClearAll","props","_ref","arguments[0]","_ref2","SButton","isHidden","styles","createElement","cn","_assignProps","getI18nText"],"sources":["../../../src/components/ClearAll.tsx"],"sourcesContent":["import Button from '@semcore/button';\nimport
|
|
1
|
+
{"version":3,"file":"ClearAll.js","names":["Button","Root","sstyled","CloseM","React","ClearAll","props","_ref","arguments[0]","_ref2","SButton","isHidden","styles","createElement","cn","_assignProps","getI18nText"],"sources":["../../../src/components/ClearAll.tsx"],"sourcesContent":["import Button from '@semcore/button';\nimport type { Intergalactic } from '@semcore/core';\nimport { Root, sstyled } from '@semcore/core';\nimport CloseM from '@semcore/icon/Close/m';\nimport React from 'react';\n\nimport type { BulkTextareaRootType } from '../BulkTextarea';\nimport type { NSBulktextarea } from '../BulkTextarea.types';\n\nexport function ClearAll(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSBulktextarea.ClearAll.Component,\n BulkTextareaRootType,\n 'ClearAll'\n >,\n) {\n const SButton = Root;\n return (\n !props.isHidden &&\n sstyled(props.styles)(\n <SButton render={Button} theme='muted' use='tertiary' addonLeft={CloseM}>\n {props.getI18nText('BulkTextarea.ClearAllButton.buttonText')}\n </SButton>,\n )\n );\n}\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,SAASC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAC7C,OAAOC,MAAM,MAAM,uBAAuB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AAKzB,OAAO,SAASC,QAAQA,CACtBC,KAIC,EACD;EAAA,IAAAC,IAAA,GAAAC,YAAA;IAAAC,KAAA;EACA,MAAMC,OAAO,GAIQV,MAAM;EAH3B,OACE,CAACM,KAAK,CAACK,QAAQ,KAAAF,KAAA,GACfP,OAAO,CAACI,KAAK,CAACM,MAAM,CAAC,eACnBR,KAAA,CAAAS,aAAA,CAACH,OAAO,EAAAD,KAAA,CAAAK,EAAA;IAAA,GAAAC,YAAA;MAAA,SAAuB,OAAO;MAAA,OAAK,UAAU;MAAA,aAAYZ;IAAM,GAAAI,IAAA;EAAA,IACpED,KAAK,CAACU,WAAW,CAAC,wCAAwC,CACpD,CAAC,CACX;AAEL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Counter.js","names":["ScreenReaderOnly","Root","CounterKit","React","Counter","props","_ref","arguments[0]","theme","linesCount","maxLines","getI18nText","createElement","_assignProps","rowsNumber"],"sources":["../../../src/components/Counter.tsx"],"sourcesContent":["import { ScreenReaderOnly } from '@semcore/base-components';\nimport {
|
|
1
|
+
{"version":3,"file":"Counter.js","names":["ScreenReaderOnly","Root","CounterKit","React","Counter","props","_ref","arguments[0]","theme","linesCount","maxLines","getI18nText","createElement","_assignProps","rowsNumber"],"sources":["../../../src/components/Counter.tsx"],"sourcesContent":["import { ScreenReaderOnly } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { Root } from '@semcore/core';\nimport CounterKit from '@semcore/counter';\nimport React from 'react';\n\nimport type { BulkTextareaRootType } from '../BulkTextarea';\nimport type { NSBulktextarea } from '../BulkTextarea.types';\n\nexport function Counter(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSBulktextarea.Counter.Component,\n BulkTextareaRootType,\n 'Counter'\n >,\n) {\n const { theme, linesCount, maxLines, getI18nText } = props;\n\n return (\n <Root render={CounterKit} ml={1} theme={theme}>\n {linesCount}\n <span aria-hidden='true'>\n /\n {maxLines}\n </span>\n <ScreenReaderOnly>\n {getI18nText('BulkTextarea.Counter.ofAllowedRows:sr-message', { rowsNumber: maxLines })}\n </ScreenReaderOnly>\n {theme === 'warning' && (\n <ScreenReaderOnly>\n {getI18nText('BulkTextarea.Counter.limitReached:sr-message')}\n </ScreenReaderOnly>\n )}\n {theme === 'danger' && (\n <ScreenReaderOnly>\n {getI18nText('BulkTextarea.Counter.limitExceeded:sr-message')}\n </ScreenReaderOnly>\n )}\n </Root>\n );\n}\n"],"mappings":";AAAA,SAASA,gBAAgB,QAAQ,0BAA0B;AAE3D,SAASC,IAAI,QAAQ,eAAe;AACpC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,KAAK,MAAM,OAAO;AAKzB,OAAO,SAASC,OAAOA,CACrBC,KAIC,EACD;EAAA,IAAAC,IAAA,GAAAC,YAAA;EACA,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC,QAAQ;IAAEC;EAAY,CAAC,GAAGN,KAAK;EAE1D,oBACEF,KAAA,CAAAS,aAAA,CAAcV,UAAU,EAAAW,YAAA;IAAA,MAAM,CAAC;IAAA,SAASL;EAAK,GAAAF,IAAA,GAC1CG,UAAU,eACXN,KAAA,CAAAS,aAAA;IAAM,eAAY;EAAM,GAAC,GAEvB,EAACF,QACG,CAAC,eACPP,KAAA,CAAAS,aAAA,CAACZ,gBAAgB,QACdW,WAAW,CAAC,+CAA+C,EAAE;IAAEG,UAAU,EAAEJ;EAAS,CAAC,CACtE,CAAC,EAClBF,KAAK,KAAK,SAAS,iBAClBL,KAAA,CAAAS,aAAA,CAACZ,gBAAgB,QACdW,WAAW,CAAC,8CAA8C,CAC3C,CACnB,EACAH,KAAK,KAAK,QAAQ,iBACjBL,KAAA,CAAAS,aAAA,CAACZ,gBAAgB,QACdW,WAAW,CAAC,+CAA+C,CAC5C,CAEhB,CAAC;AAEX","ignoreList":[]}
|
|
@@ -27,7 +27,8 @@ export function ErrorsNavigation(props) {
|
|
|
27
27
|
"aria-label": getI18nText('BulkTextarea.ErrorsNavigation.nextError:aria-label'),
|
|
28
28
|
hintPlacement: "bottom",
|
|
29
29
|
disabled: disabled,
|
|
30
|
-
ref: nextButtonRef
|
|
30
|
+
ref: nextButtonRef,
|
|
31
|
+
size: size
|
|
31
32
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
32
33
|
onClick: onPrevError,
|
|
33
34
|
addonLeft: ChevronUpM,
|
|
@@ -36,7 +37,9 @@ export function ErrorsNavigation(props) {
|
|
|
36
37
|
"aria-label": getI18nText('BulkTextarea.ErrorsNavigation.previousError:aria-label'),
|
|
37
38
|
hintPlacement: "bottom",
|
|
38
39
|
disabled: disabled,
|
|
39
|
-
ref: prevButtonRef
|
|
40
|
+
ref: prevButtonRef,
|
|
41
|
+
size: size,
|
|
42
|
+
ml: 1
|
|
40
43
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
41
44
|
size: size === 'l' ? 300 : 200,
|
|
42
45
|
color: "text-critical",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsNavigation.js","names":["Flex","Button","ChevronDownM","ChevronUpM","Text","React","ErrorsNavigation","props","errorIndex","errorsCount","onPrevError","onNextError","size","showErrors","getI18nText","disabled","nextButtonRef","prevButtonRef","createElement","alignItems","Fragment","onClick","addonLeft","use","theme","hintPlacement","ref","
|
|
1
|
+
{"version":3,"file":"ErrorsNavigation.js","names":["Flex","Button","ChevronDownM","ChevronUpM","Text","React","ErrorsNavigation","props","errorIndex","errorsCount","onPrevError","onNextError","size","showErrors","getI18nText","disabled","nextButtonRef","prevButtonRef","createElement","alignItems","Fragment","onClick","addonLeft","use","theme","hintPlacement","ref","ml","color"],"sources":["../../../src/components/ErrorsNavigation.tsx"],"sourcesContent":["import { Flex } from '@semcore/base-components';\nimport Button from '@semcore/button';\nimport type { Intergalactic } from '@semcore/core';\nimport ChevronDownM from '@semcore/icon/ChevronDown/m';\nimport ChevronUpM from '@semcore/icon/ChevronUp/m';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport type { BulkTextareaRootType } from '../BulkTextarea';\nimport type { NSBulktextarea } from '../BulkTextarea.types';\n\nexport function ErrorsNavigation(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n NSBulktextarea.ErrorsNavigation.Component,\n BulkTextareaRootType,\n 'ErrorsNavigation'\n >,\n) {\n const {\n errorIndex,\n errorsCount,\n onPrevError,\n onNextError,\n size,\n showErrors,\n getI18nText,\n disabled,\n nextButtonRef,\n prevButtonRef,\n } = props;\n return (\n <Flex alignItems='center'>\n {errorsCount > 0 && showErrors && (\n <>\n <Button\n onClick={onNextError}\n addonLeft={ChevronDownM}\n use='tertiary'\n theme='muted'\n aria-label={getI18nText('BulkTextarea.ErrorsNavigation.nextError:aria-label')}\n hintPlacement='bottom'\n disabled={disabled}\n ref={nextButtonRef}\n size={size}\n />\n <Button\n onClick={onPrevError}\n addonLeft={ChevronUpM}\n use='tertiary'\n theme='muted'\n aria-label={getI18nText('BulkTextarea.ErrorsNavigation.previousError:aria-label')}\n hintPlacement='bottom'\n disabled={disabled}\n ref={prevButtonRef}\n size={size}\n ml={1}\n />\n <Text size={size === 'l' ? 300 : 200} color='text-critical' ml={1} disabled={disabled}>\n {errorIndex === -1\n ? getI18nText('BulkTextarea.ErrorsNavigation.totalErrors', { errorsCount })\n : getI18nText('BulkTextarea.ErrorsNavigation.selectedError', {\n errorIndex: errorIndex + 1,\n errorsCount,\n })}\n </Text>\n </>\n )}\n </Flex>\n );\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,0BAA0B;AAC/C,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,UAAU,MAAM,2BAA2B;AAClD,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AAKzB,OAAO,SAASC,gBAAgBA,CAC9BC,KAIC,EACD;EACA,MAAM;IACJC,UAAU;IACVC,WAAW;IACXC,WAAW;IACXC,WAAW;IACXC,IAAI;IACJC,UAAU;IACVC,WAAW;IACXC,QAAQ;IACRC,aAAa;IACbC;EACF,CAAC,GAAGV,KAAK;EACT,oBACEF,KAAA,CAAAa,aAAA,CAAClB,IAAI;IAACmB,UAAU,EAAC;EAAQ,GACtBV,WAAW,GAAG,CAAC,IAAII,UAAU,iBAC5BR,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAe,QAAA,qBACEf,KAAA,CAAAa,aAAA,CAACjB,MAAM;IACLoB,OAAO,EAAEV,WAAY;IACrBW,SAAS,EAAEpB,YAAa;IACxBqB,GAAG,EAAC,UAAU;IACdC,KAAK,EAAC,OAAO;IACb,cAAYV,WAAW,CAAC,oDAAoD,CAAE;IAC9EW,aAAa,EAAC,QAAQ;IACtBV,QAAQ,EAAEA,QAAS;IACnBW,GAAG,EAAEV,aAAc;IACnBJ,IAAI,EAAEA;EAAK,CACZ,CAAC,eACFP,KAAA,CAAAa,aAAA,CAACjB,MAAM;IACLoB,OAAO,EAAEX,WAAY;IACrBY,SAAS,EAAEnB,UAAW;IACtBoB,GAAG,EAAC,UAAU;IACdC,KAAK,EAAC,OAAO;IACb,cAAYV,WAAW,CAAC,wDAAwD,CAAE;IAClFW,aAAa,EAAC,QAAQ;IACtBV,QAAQ,EAAEA,QAAS;IACnBW,GAAG,EAAET,aAAc;IACnBL,IAAI,EAAEA,IAAK;IACXe,EAAE,EAAE;EAAE,CACP,CAAC,eACFtB,KAAA,CAAAa,aAAA,CAACd,IAAI;IAACQ,IAAI,EAAEA,IAAI,KAAK,GAAG,GAAG,GAAG,GAAG,GAAI;IAACgB,KAAK,EAAC,eAAe;IAACD,EAAE,EAAE,CAAE;IAACZ,QAAQ,EAAEA;EAAS,GACnFP,UAAU,KAAK,CAAC,CAAC,GACdM,WAAW,CAAC,2CAA2C,EAAE;IAAEL;EAAY,CAAC,CAAC,GACzEK,WAAW,CAAC,6CAA6C,EAAE;IACzDN,UAAU,EAAEA,UAAU,GAAG,CAAC;IAC1BC;EACF,CAAC,CACD,CACN,CAEA,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
const DEFAULT_MAX_LENGTH = 100;
|
|
3
|
+
export class History {
|
|
4
|
+
constructor(maxLength = DEFAULT_MAX_LENGTH) {
|
|
5
|
+
_defineProperty(this, "undoStack", []);
|
|
6
|
+
_defineProperty(this, "redoStack", []);
|
|
7
|
+
_defineProperty(this, "maxLength", void 0);
|
|
8
|
+
this.maxLength = maxLength;
|
|
9
|
+
}
|
|
10
|
+
push(state) {
|
|
11
|
+
this.undoStack.push(state);
|
|
12
|
+
this.trimUndoStack();
|
|
13
|
+
this.redoStack = [];
|
|
14
|
+
}
|
|
15
|
+
undo(currentState) {
|
|
16
|
+
const previousState = this.undoStack.pop();
|
|
17
|
+
if (!previousState) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
this.redoStack.push(currentState);
|
|
21
|
+
return previousState;
|
|
22
|
+
}
|
|
23
|
+
redo(currentState) {
|
|
24
|
+
const nextState = this.redoStack.pop();
|
|
25
|
+
if (!nextState) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
this.undoStack.push(currentState);
|
|
29
|
+
this.trimUndoStack();
|
|
30
|
+
return nextState;
|
|
31
|
+
}
|
|
32
|
+
trimUndoStack() {
|
|
33
|
+
if (this.undoStack.length > this.maxLength) {
|
|
34
|
+
this.undoStack.shift();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=History.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"History.js","names":["DEFAULT_MAX_LENGTH","History","constructor","maxLength","_defineProperty","push","state","undoStack","trimUndoStack","redoStack","undo","currentState","previousState","pop","redo","nextState","length","shift"],"sources":["../../../../src/components/InputField/History.ts"],"sourcesContent":["export type HistorySelection = {\n startLine: number;\n startOffset: number;\n endLine: number;\n endOffset: number;\n};\n\nexport type HistoryState = {\n lines: string[];\n selection: HistorySelection;\n};\n\nconst DEFAULT_MAX_LENGTH = 100;\n\nexport class History {\n private undoStack: HistoryState[] = [];\n private redoStack: HistoryState[] = [];\n private readonly maxLength: number;\n\n constructor(maxLength = DEFAULT_MAX_LENGTH) {\n this.maxLength = maxLength;\n }\n\n public push(state: HistoryState): void {\n this.undoStack.push(state);\n this.trimUndoStack();\n\n this.redoStack = [];\n }\n\n public undo(currentState: HistoryState): HistoryState | null {\n const previousState = this.undoStack.pop();\n\n if (!previousState) {\n return null;\n }\n\n this.redoStack.push(currentState);\n\n return previousState;\n }\n\n public redo(currentState: HistoryState): HistoryState | null {\n const nextState = this.redoStack.pop();\n\n if (!nextState) {\n return null;\n }\n\n this.undoStack.push(currentState);\n this.trimUndoStack();\n\n return nextState;\n }\n\n private trimUndoStack(): void {\n if (this.undoStack.length > this.maxLength) {\n this.undoStack.shift();\n }\n }\n}\n"],"mappings":";AAYA,MAAMA,kBAAkB,GAAG,GAAG;AAE9B,OAAO,MAAMC,OAAO,CAAC;EAKnBC,WAAWA,CAACC,SAAS,GAAGH,kBAAkB,EAAE;IAAAI,eAAA,oBAJR,EAAE;IAAAA,eAAA,oBACF,EAAE;IAAAA,eAAA;IAIpC,IAAI,CAACD,SAAS,GAAGA,SAAS;EAC5B;EAEOE,IAAIA,CAACC,KAAmB,EAAQ;IACrC,IAAI,CAACC,SAAS,CAACF,IAAI,CAACC,KAAK,CAAC;IAC1B,IAAI,CAACE,aAAa,CAAC,CAAC;IAEpB,IAAI,CAACC,SAAS,GAAG,EAAE;EACrB;EAEOC,IAAIA,CAACC,YAA0B,EAAuB;IAC3D,MAAMC,aAAa,GAAG,IAAI,CAACL,SAAS,CAACM,GAAG,CAAC,CAAC;IAE1C,IAAI,CAACD,aAAa,EAAE;MAClB,OAAO,IAAI;IACb;IAEA,IAAI,CAACH,SAAS,CAACJ,IAAI,CAACM,YAAY,CAAC;IAEjC,OAAOC,aAAa;EACtB;EAEOE,IAAIA,CAACH,YAA0B,EAAuB;IAC3D,MAAMI,SAAS,GAAG,IAAI,CAACN,SAAS,CAACI,GAAG,CAAC,CAAC;IAEtC,IAAI,CAACE,SAAS,EAAE;MACd,OAAO,IAAI;IACb;IAEA,IAAI,CAACR,SAAS,CAACF,IAAI,CAACM,YAAY,CAAC;IACjC,IAAI,CAACH,aAAa,CAAC,CAAC;IAEpB,OAAOO,SAAS;EAClB;EAEQP,aAAaA,CAAA,EAAS;IAC5B,IAAI,IAAI,CAACD,SAAS,CAACS,MAAM,GAAG,IAAI,CAACb,SAAS,EAAE;MAC1C,IAAI,CAACI,SAAS,CAACU,KAAK,CAAC,CAAC;IACxB;EACF;AACF","ignoreList":[]}
|