@semcore/bulk-textarea 1.4.2-prerelease.0 → 1.5.0-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.
Files changed (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/BulkTextarea.js +35 -38
  3. package/lib/cjs/BulkTextarea.js.map +1 -1
  4. package/lib/cjs/BulkTextarea.types.js.map +1 -1
  5. package/lib/cjs/components/ClearAll.js +2 -2
  6. package/lib/cjs/components/ClearAll.js.map +1 -1
  7. package/lib/cjs/components/Counter.js +5 -5
  8. package/lib/cjs/components/Counter.js.map +1 -1
  9. package/lib/cjs/components/ErrorsNavigation.js +14 -14
  10. package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
  11. package/lib/cjs/components/InputField/InputField.js +219 -167
  12. package/lib/cjs/components/InputField/InputField.js.map +1 -1
  13. package/lib/cjs/components/InputField/InputField.types.js.map +1 -1
  14. package/lib/cjs/components/InputField/inputField.shadow.css +70 -32
  15. package/lib/cjs/index.js +1 -1
  16. package/lib/cjs/index.js.map +1 -1
  17. package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
  18. package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
  19. package/lib/es6/BulkTextarea.js +31 -32
  20. package/lib/es6/BulkTextarea.js.map +1 -1
  21. package/lib/es6/BulkTextarea.types.js.map +1 -1
  22. package/lib/es6/components/ClearAll.js +2 -2
  23. package/lib/es6/components/ClearAll.js.map +1 -1
  24. package/lib/es6/components/Counter.js +2 -2
  25. package/lib/es6/components/Counter.js.map +1 -1
  26. package/lib/es6/components/ErrorsNavigation.js +10 -10
  27. package/lib/es6/components/ErrorsNavigation.js.map +1 -1
  28. package/lib/es6/components/InputField/InputField.js +219 -165
  29. package/lib/es6/components/InputField/InputField.js.map +1 -1
  30. package/lib/es6/components/InputField/InputField.types.js.map +1 -1
  31. package/lib/es6/components/InputField/inputField.shadow.css +70 -32
  32. package/lib/es6/index.js.map +1 -1
  33. package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
  34. package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
  35. package/lib/esm/BulkTextarea.mjs +33 -35
  36. package/lib/esm/components/ClearAll.mjs +1 -1
  37. package/lib/esm/components/Counter.mjs +2 -2
  38. package/lib/esm/components/ErrorsNavigation.mjs +4 -4
  39. package/lib/esm/components/InputField/InputField.mjs +181 -136
  40. package/lib/esm/components/InputField/inputField.shadow.css +70 -32
  41. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
  42. package/lib/types/BulkTextarea.d.ts +1 -1
  43. package/lib/types/BulkTextarea.types.d.ts +113 -8
  44. package/lib/types/components/ClearAll.d.ts +2 -2
  45. package/lib/types/components/Counter.d.ts +4 -4
  46. package/lib/types/components/ErrorsNavigation.d.ts +2 -2
  47. package/lib/types/components/InputField/InputField.d.ts +12 -7
  48. package/lib/types/components/InputField/InputField.types.d.ts +11 -125
  49. package/package.json +10 -10
@@ -1,22 +1,22 @@
1
- SInputField > div {
1
+ SInputField>div {
2
2
  box-sizing: content-box;
3
3
  outline: none;
4
4
  border-radius: var(--intergalactic-control-rounded, 6px);
5
- border-color: var(--intergalactic-border-primary, #c4c7cf);
5
+ border-color: var(--intergalactic-border-primary, oklch(0.137 0.026 175.7 / 0.161));
6
6
  border-style: solid;
7
7
  border-width: 1px;
8
8
  overflow: auto;
9
9
  position: relative;
10
10
 
11
- background-color: var(--intergalactic-bg-primary-neutral, #ffffff);
12
- color: var(--intergalactic-text-primary, #191b23);
11
+ background-color: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
12
+ color: var(--intergalactic-text-primary, oklch(0.1 0.03 137 / 0.899));
13
13
  word-wrap: break-word;
14
14
  word-break: break-word;
15
15
  font-family: inherit;
16
16
 
17
17
  &:empty::before {
18
18
  content: '1. ' attr(placeholder);
19
- color: var(--intergalactic-text-placeholder, #8a8e9b);
19
+ color: var(--intergalactic-text-placeholder, oklch(0.098 0.023 157.4 / 0.457));
20
20
  position: absolute;
21
21
  }
22
22
 
@@ -32,12 +32,12 @@ SInputField > div {
32
32
  display: inline-block;
33
33
  white-space: nowrap;
34
34
  text-align: right;
35
- color: var(--intergalactic-text-secondary, #6c6e79);
35
+ color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
36
36
  margin-right: var(--intergalactic-spacing-1x, 4px);
37
37
  }
38
38
  }
39
39
 
40
- > p {
40
+ >p {
41
41
  counter-increment: row;
42
42
  /*display: inline-block;*/
43
43
  margin: 0 0 var(--intergalactic-spacing-1x, 4px) 0;
@@ -55,7 +55,7 @@ SInputField > div {
55
55
  display: inline-block;
56
56
  white-space: nowrap;
57
57
  text-align: right;
58
- color: var(--intergalactic-text-secondary, #6c6e79);
58
+ color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
59
59
  margin-right: var(--intergalactic-spacing-1x, 4px);
60
60
 
61
61
  position: absolute;
@@ -63,43 +63,65 @@ SInputField > div {
63
63
  }
64
64
 
65
65
  &[data-over-max-rows='true'] {
66
- background-color: var(--intergalactic-bg-secondary-critical, #fff0f7);
66
+ background-color: var(--intergalactic-bg-secondary-critical, oklch(0.958 0.029 5.7));
67
67
  }
68
68
  }
69
69
 
70
70
  &:has(p:nth-child(n + 10)) {
71
- > p {
71
+ >p {
72
72
  padding-left: var(--intergalactic-spacing-6x, 24px);
73
73
  }
74
- > p:nth-child(-n + 9)::before {
74
+
75
+ >p:nth-child(-n + 9)::before {
75
76
  padding-left: var(--intergalactic-spacing-2x, 8px);
76
77
  }
77
78
  }
78
79
 
79
80
  &:has(p:nth-child(n + 100)) {
80
- > p {
81
+ >p {
81
82
  padding-left: var(--intergalactic-spacing-8x, 32px);
82
83
  }
83
- > p:nth-child(-n + 9)::before {
84
+
85
+ >p:nth-child(-n + 9)::before {
84
86
  padding-left: var(--intergalactic-spacing-4x, 16px);
85
87
  }
86
- > p:nth-child(n + 10)::before {
88
+
89
+ >p:nth-child(n + 10)::before {
87
90
  padding-left: var(--intergalactic-spacing-2x, 8px);
88
91
  }
92
+
93
+ >p:nth-child(n + 100)::before {
94
+ padding-left: 0;
95
+ }
96
+ }
97
+
98
+ &:has(p:nth-child(n + 1000)) {
99
+ > p {
100
+ padding-left: calc(var(--intergalactic-spacing-10x, 40px) + var(--intergalactic-spacing-1x, 4px));
101
+ }
102
+ > p:nth-child(-n + 9)::before {
103
+ padding-left: var(--intergalactic-spacing-6x, 24px);
104
+ }
105
+ > p:nth-child(n + 10)::before {
106
+ padding-left: var(--intergalactic-spacing-4x, 16px);
107
+ }
89
108
  > p:nth-child(n + 100)::before {
109
+ padding-left: var(--intergalactic-spacing-2x, 8px);
110
+ }
111
+ > p:nth-child(n + 1000)::before {
90
112
  padding-left: 0;
91
113
  }
92
114
  }
93
115
  }
94
116
 
95
- SInputField[showErrors] > div[aria-invalid] > p[aria-invalid]:after {
117
+ SInputField[showErrors]>div[aria-invalid]>p[aria-invalid]:after {
96
118
  content: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBmaWxsPSIjZDEwMDJmIj48cGF0aCBkPSJNNyA2aDJ2NEg3VjZabTIgN3YtMkg3djJoMloiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMTUyIDEuMTcyYy43MTktMS41NjMgMi45NzctMS41NjMgMy42OTYgMGw2LjA0MyAxMy4xNDFjLjM2My43OTEtLjIyNSAxLjY4Ny0xLjEwOSAxLjY4N0gxLjIxOGMtLjg4NCAwLTEuNDcyLS44OTYtMS4xMDktMS42ODdMNi4xNTIgMS4xNzJabTcuMzc0IDEyLjgzN0w4IDEuOTkgMi40NzQgMTQuMDFoMTEuMDUyWiIvPjwvc3ZnPgo= ");
97
119
  position: absolute;
98
120
  right: 0;
99
121
  top: var(--intergalactic-spacing-05x, 2px);
100
122
  }
101
123
 
102
- SInputField[size='m'] > div {
124
+ SInputField[size='m']>div {
103
125
  padding: var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-4x, 16px);
104
126
  font-size: var(--intergalactic-fs-200, 14px);
105
127
  line-height: var(--intergalactic-lh-200, 142%);
@@ -110,13 +132,14 @@ SInputField[size='m'] > div {
110
132
 
111
133
  &:empty {
112
134
  padding-left: var(--intergalactic-spacing-8x, 32px);
135
+
113
136
  &::before {
114
137
  left: var(--intergalactic-spacing-4x, 16px);
115
138
  }
116
139
  }
117
140
  }
118
141
 
119
- SInputField[size='l'] > div {
142
+ SInputField[size='l']>div {
120
143
  padding: var(--intergalactic-spacing-3x, 12px) var(--intergalactic-spacing-4x, 16px);
121
144
  font-size: var(--intergalactic-fs-300, 16px);
122
145
  line-height: var(--intergalactic-lh-300, 150%);
@@ -126,6 +149,7 @@ SInputField[size='l'] > div {
126
149
 
127
150
  &:empty {
128
151
  padding-left: calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-05x, 2px));
152
+
129
153
  &::before {
130
154
  left: var(--intergalactic-spacing-4x, 16px);
131
155
  }
@@ -133,39 +157,53 @@ SInputField[size='l'] > div {
133
157
  }
134
158
 
135
159
 
136
- SInputField[state='normal']:not([disabled]) > div:focus {
160
+ SInputField[state='normal']:not([disabled])>div {
137
161
  &:focus {
138
- box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));
139
- border-color: var(--intergalactic-border-info-active, #006dca);
162
+ border-color: var(--intergalactic-border-info-active, oklch(0.382 0.248 264.2 / 0.386));
163
+ @mixin focus-outline-mixin {
164
+ outline-offset: 0;
165
+ transition-property: outline-color, outline-width;
166
+ }
140
167
  }
141
168
  }
142
169
 
143
- SInputField[state='valid'] > div {
144
- border-color: var(--intergalactic-border-success-active, #007c65);
170
+ SInputField[state='valid']>div {
171
+ border-color: var(--intergalactic-border-success-active, oklch(0.75 0.153 167.5));
145
172
 
146
173
  &:focus {
147
- box-shadow: var(--intergalactic-keyboard-focus-valid, 0px 0px 0px 3px rgba(0, 159, 129, 0.5));
174
+ border-color: var(--intergalactic-border-success-active, oklch(0.75 0.153 167.5));
175
+ @mixin focus-outline-mixin {
176
+ outline-offset: 0;
177
+ transition-property: outline-color, outline-width;
178
+ }
179
+ outline-color: var(--intergalactic-keyboard-focus-valid-outline, oklch(0.711 0.146 166.9));
148
180
  }
149
181
  }
150
182
 
151
- SInputField[state='invalid'] > div {
152
- border-color: var(--intergalactic-border-critical-active, #d1002f);
183
+ SInputField[state='invalid']>div {
184
+ border-color: var(--intergalactic-border-critical-active, oklch(0.628 0.258 29 / 0.56));
153
185
 
154
186
  &:focus {
155
- box-shadow: var(--intergalactic-keyboard-focus-invalid, 0px 0px 0px 3px rgba(255, 73, 83, 0.5));
187
+ border-color: var(--intergalactic-border-critical-active, oklch(0.628 0.258 29 / 0.56));
188
+ @mixin focus-outline-mixin {
189
+ outline-offset: 0;
190
+ transition-property: outline-color, outline-width;
191
+ }
192
+ outline-color: var(--intergalactic-keyboard-focus-invalid-outline, oklch(0.628 0.257 28.9 / 0.652));
156
193
  }
157
194
 
158
- background-image: var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, rgba(209, 0, 47, 1) 0, rgba(209, 0, 47, 1) 2px, transparent 0, transparent 50%));
195
+ background-image: var(--intergalactic-border-critical-pattern, repeating-linear-gradient(315deg, oklch(0.628 0.258 29 / 0.56) 0, oklch(0.628 0.258 29 / 0.56) 1px, transparent 0, transparent 50%));
159
196
  background-size: 6px 6px;
160
- background-color: var(--intergalactic-bg-primary-neutral, #ffffff);
197
+ background-color: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
161
198
  border-bottom-left-radius: var(--intergalactic-control-rounded, 6px);
162
199
  border-top-left-radius: var(--intergalactic-control-rounded, 6px);
163
200
  background-repeat: repeat-y;
164
201
  }
165
202
 
166
- SInputField[readonly] > div {
167
- background-color: var(--intergalactic-bg-secondary-neutral, #f4f5f9);
203
+ SInputField[readonly]>div {
204
+ background-color: var(--intergalactic-bg-secondary-neutral, oklch(0.98 0.001 180));
168
205
  }
169
- SInputField[disabled] > div {
170
- opacity: var(--intergalactic-disabled-opacity, 0.3);
206
+
207
+ SInputField[disabled]>div {
208
+ opacity: var(--intergalactic-disabled-opacity, 0.4);
171
209
  }
@@ -6,12 +6,12 @@ import it from "./it.json.mjs";
6
6
  import ja from "./ja.json.mjs";
7
7
  import ko from "./ko.json.mjs";
8
8
  import nl from "./nl.json.mjs";
9
+ import pl from "./pl.json.mjs";
9
10
  import pt from "./pt.json.mjs";
11
+ import sv from "./sv.json.mjs";
10
12
  import tr from "./tr.json.mjs";
11
13
  import vi from "./vi.json.mjs";
12
14
  import zh from "./zh.json.mjs";
13
- import pl from "./pl.json.mjs";
14
- import sv from "./sv.json.mjs";
15
15
  var localizedMessages = {
16
16
  de,
17
17
  en,
@@ -1,3 +1,3 @@
1
- import { BulkTextareaType } from './BulkTextarea.types';
1
+ import type { BulkTextareaType } from './BulkTextarea.types';
2
2
  declare const BulkTextarea: BulkTextareaType<string | string[]>;
3
3
  export default BulkTextarea;
@@ -1,33 +1,138 @@
1
- import { Intergalactic } from '@semcore/utils/lib/core';
2
- import { BoxProps } from '@semcore/flex-box';
3
- import Button from '@semcore/button';
4
- import { InputFieldProps } from './components/InputField/InputField';
5
- import { CounterProps } from './components/Counter';
6
- import { ErrorsNavigationProps } from './components/ErrorsNavigation';
1
+ import type { BoxProps } from '@semcore/base-components';
2
+ import type Button from '@semcore/button';
3
+ import type { Intergalactic } from '@semcore/core';
4
+ import type { CounterProps } from './components/Counter';
5
+ import type { ErrorsNavigationProps } from './components/ErrorsNavigation';
6
+ import type { InputFieldProps } from './components/InputField/InputField';
7
+ import type { PasteProps } from './components/InputField/InputField.types';
7
8
  export type BulkTextareaProps<T extends string | string[]> = {
9
+ /** The current value */
8
10
  value?: InputFieldProps<T>['value'];
11
+ /** Callback triggered when the onBlur event is emmited */
9
12
  onChange?: InputFieldProps<T>['onBlur'];
13
+ /** Placeholder text */
10
14
  placeholder?: InputFieldProps<T>['placeholder'];
15
+ /** Component size */
11
16
  size?: InputFieldProps<T>['size'];
17
+ /** State for show errors or valid(green) borders */
12
18
  state?: InputFieldProps<T>['state'];
19
+ /** Defines whether the textarea is disabled */
13
20
  disabled?: InputFieldProps<T>['disabled'];
21
+ /** Defines whether the textarea is readonly */
14
22
  readonly?: InputFieldProps<T>['readonly'];
23
+ /** Minimum number of rows to display */
15
24
  minRows?: InputFieldProps<T>['minRows'];
25
+ /** Maximum number of rows to display */
16
26
  maxRows?: InputFieldProps<T>['maxRows'];
27
+ /** An event when a validation occurs */
17
28
  validateOn?: InputFieldProps<T>['validateOn'];
29
+ /** A function to valide the line */
18
30
  lineValidation?: InputFieldProps<T>['lineValidation'];
31
+ /** Line delimeters */
19
32
  linesDelimiters?: InputFieldProps<T>['linesDelimiters'];
33
+ /** Defines the props for paste action */
20
34
  pasteProps?: InputFieldProps<T>['pasteProps'];
35
+ /** Maximum number of allowed lines/values */
21
36
  maxLines?: InputFieldProps<T>['maxLines'];
37
+ /** Function to process individual lines during input */
22
38
  lineProcessing?: InputFieldProps<T>['lineProcessing'];
39
+ /** List of errors */
23
40
  errors?: InputFieldProps<T>['errors'];
24
- showErrors?: boolean;
41
+ /** Defines whether to show errors or not */
42
+ showErrors?: InputFieldProps<T>['showErrors'];
43
+ /** Internal */
25
44
  onErrorsChange?: InputFieldProps<T>['onErrorsChange'];
45
+ /** Internal */
26
46
  onShowErrorsChange?: InputFieldProps<T>['onShowErrorsChange'];
47
+ /** Internal */
48
+ onImmediatelyChange?: InputFieldProps<T>['onImmediatelyChange'];
27
49
  };
28
50
  type BulkTextareaComponent = (<T extends string | string[]>(props: Intergalactic.InternalTypings.ComponentProps<'div', 'div', BoxProps & BulkTextareaProps<T>>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', {}>;
51
+ export type BulkTextareaInputFieldProps<T extends string | string[] = string | string[]> = BoxProps & {
52
+ /**
53
+ * Unique id
54
+ */
55
+ id?: string;
56
+ /**
57
+ * Placeholder for field
58
+ */
59
+ placeholder?: string;
60
+ /**
61
+ * String to render in textarea. OnChanging value, it will go throw paste pipeline
62
+ */
63
+ value?: T;
64
+ /**
65
+ * This component doesn't have default onChange callback, because we think that you need only the result after every changes/fixes
66
+ */
67
+ onBlur?: (value: T, e: Event) => void;
68
+ /**
69
+ * Size of component
70
+ * @default m
71
+ */
72
+ size?: 'm' | 'l';
73
+ /**
74
+ * State for show errors or valid(green) borders
75
+ * @default normal
76
+ */
77
+ state?: 'normal' | 'valid' | 'invalid';
78
+ /**
79
+ * Flag for disabling field
80
+ * @default false
81
+ */
82
+ disabled?: boolean;
83
+ /**
84
+ * Flag for readonly field
85
+ * @default false
86
+ */
87
+ readonly?: boolean;
88
+ /**
89
+ * Min rows
90
+ * @default 2
91
+ */
92
+ minRows?: number;
93
+ /**
94
+ * Max rows
95
+ * @default 10
96
+ */
97
+ maxRows?: number;
98
+ /**
99
+ * List of available points to validate value
100
+ * @default blur
101
+ */
102
+ validateOn?: ('blur' | 'blurLine' | 'paste')[];
103
+ /**
104
+ * Function to validate line
105
+ */
106
+ lineValidation?: (line: string, lines: string[]) => {
107
+ isValid: boolean;
108
+ errorMessage: string;
109
+ };
110
+ /**
111
+ * Message for display error about whole field, not only one line.
112
+ * If set empty string, field will not have invalid state.
113
+ */
114
+ commonErrorMessage: string;
115
+ /**
116
+ * Delimiters (event.key) for lines
117
+ * @default Enter
118
+ */
119
+ linesDelimiters?: string[];
120
+ /**
121
+ * Count of max lines in badge
122
+ * @default 100
123
+ */
124
+ maxLines?: number;
125
+ /**
126
+ * Paste props
127
+ */
128
+ pasteProps?: PasteProps;
129
+ /**
130
+ * Function for process line after it was blurred
131
+ */
132
+ lineProcessing?: (line: string, lines: string[]) => string;
133
+ };
29
134
  export type BulkTextareaType<T extends string | string[]> = BulkTextareaComponent & {
30
- InputField: Intergalactic.Component<'div', Pick<InputFieldProps<T>, 'commonErrorMessage' | 'id'> & Partial<BulkTextareaProps<T>> & BoxProps>;
135
+ InputField: Intergalactic.Component<'div', BulkTextareaInputFieldProps<T>>;
31
136
  Counter: Intergalactic.Component<'div', Partial<CounterProps>>;
32
137
  ClearAll: typeof Button;
33
138
  ErrorsNavigation: Intergalactic.Component<'div', Partial<ErrorsNavigationProps>>;
@@ -1,6 +1,6 @@
1
+ import { type IRootComponentProps } from '@semcore/core';
2
+ import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
1
3
  import React from 'react';
2
- import { IRootComponentProps } from '@semcore/core';
3
- import { useI18n } from '@semcore/utils/lib/enhances/WithI18n';
4
4
  export declare function ClearAll(props: IRootComponentProps & {
5
5
  isHidden: boolean;
6
6
  getI18nText: ReturnType<typeof useI18n>;
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
2
- import { CounterProps as CounterPropsKit } from '@semcore/counter';
3
- import { useI18n } from '@semcore/utils/lib/enhances/WithI18n';
1
+ import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
2
+ import { type CounterProps as CounterPropsKit } from '@semcore/counter';
3
+ import React from 'react';
4
4
  export type CounterProps = {
5
5
  theme: CounterPropsKit['theme'];
6
6
  linesCount: number;
7
7
  maxLines: number;
8
8
  getI18nText: ReturnType<typeof useI18n>;
9
9
  };
10
- export declare function Counter(props: CounterProps): JSX.Element;
10
+ export declare function Counter(props: CounterProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
+ import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
1
2
  import React from 'react';
2
- import { useI18n } from '@semcore/utils/lib/enhances/WithI18n';
3
3
  export type ErrorsNavigationProps = {
4
4
  errorIndex: number;
5
5
  onPrevError: () => void;
@@ -12,4 +12,4 @@ export type ErrorsNavigationProps = {
12
12
  nextButtonRef: React.RefObject<HTMLButtonElement>;
13
13
  prevButtonRef: React.RefObject<HTMLButtonElement>;
14
14
  };
15
- export declare function ErrorsNavigation(props: ErrorsNavigationProps): JSX.Element;
15
+ export declare function ErrorsNavigation(props: ErrorsNavigationProps): React.JSX.Element;
@@ -1,20 +1,24 @@
1
- import React from 'react';
1
+ import type { PopperContext } from '@semcore/base-components';
2
2
  import { Component } from '@semcore/core';
3
- import { PopperContext } from '@semcore/popper';
4
- import { InputFieldProps, ErrorItem } from './InputField.types';
3
+ import React from 'react';
4
+ import type { InputFieldProps, ErrorItem } from './InputField.types';
5
5
  type IndexKeys = 'keyboardLineIndex' | 'mouseLineIndex';
6
6
  type State = {
7
7
  [key in IndexKeys]: number;
8
8
  } & {
9
9
  visibleErrorPopper: boolean;
10
10
  };
11
- declare class InputField<T extends string | string[]> extends Component<InputFieldProps<T>, {}, State, typeof InputField.enhance> {
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> {
12
16
  static displayName: string;
13
17
  static style: {
14
18
  [key: string]: string;
15
19
  };
16
20
  static enhance: readonly [(props: any) => {
17
- uid: string;
21
+ uid: ReturnType<typeof import("@semcore/core/lib/utils/uniqueID").useUID>;
18
22
  }];
19
23
  static defaultProps: {
20
24
  defaultValue: string;
@@ -41,6 +45,7 @@ declare class InputField<T extends string | string[]> extends Component<InputFie
41
45
  toggleErrorsPopperTimeout: number;
42
46
  isFocusing: boolean;
43
47
  linesCountTimeout: number;
48
+ observer: MutationObserver;
44
49
  state: {
45
50
  visibleErrorPopper: boolean;
46
51
  keyboardLineIndex: number;
@@ -66,10 +71,10 @@ declare class InputField<T extends string | string[]> extends Component<InputFie
66
71
  handleScroll(): void;
67
72
  handleMouseDown(event: MouseEvent): void;
68
73
  handleMouseMove(event: MouseEvent): void;
69
- handleMouseLeave(event: MouseEvent): void;
74
+ handleMouseLeave(): void;
70
75
  handlePaste(event: ClipboardEvent): void;
71
76
  handleChange(event: Event): void;
72
- handleFocus(event: FocusEvent): void;
77
+ handleFocus(): void;
73
78
  handleBlur(event: Event): void;
74
79
  handleKeyDown(event: KeyboardEvent): void;
75
80
  render(): React.ReactNode;
@@ -1,4 +1,5 @@
1
- type PasteProps = {
1
+ import type { BulkTextareaInputFieldProps } from '../../BulkTextarea.types';
2
+ export type PasteProps = {
2
3
  /**
3
4
  * @default '\n'
4
5
  */
@@ -17,142 +18,27 @@ export type ErrorItem = {
17
18
  lineNode?: Node;
18
19
  errorMessage: string;
19
20
  };
20
- export type InputFieldProps<T extends string | string[]> = {
21
- /**
22
- * Unique id
23
- */
24
- id?: string;
25
- /**
26
- * Placeholder for field
27
- */
28
- placeholder?: string;
29
- /**
30
- * String to render in textarea. OnChanging value, it will go throw paste pipeline
31
- */
32
- value: T;
33
- /**
34
- * This component doesn't have default onChange callback, because we think that you need only the result after every changes/fixes
35
- */
36
- onBlur: (value: T, e: Event) => void;
37
- /**
38
- * Size of component
39
- * @default m
40
- */
41
- size: 'm' | 'l';
42
- /**
43
- * State for show errors or valid(green) borders
44
- * @default normal
45
- */
46
- state: 'normal' | 'valid' | 'invalid';
47
- /**
48
- * Flag for disabling field
49
- * @default false
50
- */
51
- disabled?: boolean;
52
- /**
53
- * Flag for readonly field
54
- * @default false
55
- */
56
- readonly?: boolean;
57
- /**
58
- * Min rows
59
- * @default 2
60
- */
61
- minRows: number;
62
- /**
63
- * Max rows
64
- * @default 10
65
- */
66
- maxRows: number;
67
- /**
68
- * List of available points to validate value
69
- * @default blur
70
- */
71
- validateOn: ('blur' | 'blurLine' | 'paste')[];
72
- /**
73
- * Function to validate line
74
- */
75
- lineValidation?: (line: string, lines: string[]) => {
76
- isValid: boolean;
77
- errorMessage: string;
78
- };
79
- /**
80
- * Message for display error about whole field, not only one line.
81
- * If set empty string, field will not have invalid state.
82
- */
83
- commonErrorMessage: string;
84
- /**
85
- * Delimiters (event.key) for lines
86
- * @default Enter
87
- */
88
- linesDelimiters?: string[];
89
- /**
90
- * Count of max lines in badge
91
- * @default 100
92
- */
93
- maxLines: number;
94
- /**
95
- * Paste props
96
- */
97
- pasteProps: PasteProps;
98
- /**
99
- * Function for process line after it was blurred
100
- */
101
- lineProcessing?: (line: string, lines: string[]) => string;
102
- /**
103
- * Internal
104
- */
21
+ export type InputFieldProps<T extends string | string[]> = BulkTextareaInputFieldProps<T> & Required<Pick<BulkTextareaInputFieldProps<T>, 'value' | 'onBlur' | 'size' | 'state' | 'minRows' | 'maxRows' | 'validateOn' | 'maxLines' | 'pasteProps'>> & {
105
22
  prevError: ErrorItem;
106
- /**
107
- * Internal
108
- */
109
23
  currentLineIndex: number;
110
- /**
111
- * Internal
112
- */
113
24
  linesCount: number;
114
- /**
115
- * Internal
116
- */
117
25
  onChangeLineIndex: (newIndex: number) => void;
118
- /**
119
- * Internal
120
- */
121
26
  onChangeLinesCount: (rowsCount: number) => void;
122
- /**
123
- * Internal
124
- */
125
27
  showErrors: boolean;
126
- /**
127
- * Internal
128
- * List of errors in rows
129
- */
28
+ /** List of errors in rows */
130
29
  errors: ErrorItem[];
131
- /**
132
- * Internal
133
- * Select row with error
134
- */
30
+ /** Select row with error */
135
31
  errorIndex: number;
136
- /**
137
- * Internal
138
- * Flag for select all row
139
- */
32
+ /** Flag for select all row */
140
33
  highlightErrorIndex: boolean;
141
- /**
142
- * Internal
143
- */
144
34
  onErrorsChange: (errors: ErrorItem[]) => void;
145
- /**
146
- * Internal
147
- */
148
35
  onShowErrorsChange: (showErrors: boolean) => void;
149
- /**
150
- * Internal
151
- */
152
36
  onErrorIndexChange: (errorIndex: number) => void;
153
37
  /**
154
- * Internal
155
- */
38
+ * Return lines from textarea immediately they changed (uses mutation observer on textarea node under the hood)
39
+ * Throttling may be required during processing this cb
40
+ */
41
+ onImmediatelyChange?: (lines: string[], value: string) => void;
42
+ } & {
156
43
  'aria-describedby'?: string;
157
44
  };
158
- export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/bulk-textarea",
3
3
  "description": "Semrush BulkTextarea Component",
4
- "version": "1.4.2-prerelease.0",
4
+ "version": "1.5.0-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,19 +14,19 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/utils": "4.48.5-prerelease.0",
18
- "@semcore/flex-box": "5.41.4-prerelease.0",
19
- "@semcore/button": "5.43.3-prerelease.0",
20
- "@semcore/typography": "5.53.2-prerelease.0",
21
- "@semcore/counter": "3.38.4-prerelease.0",
22
- "@semcore/icon": "4.62.1-prerelease.0",
23
- "@semcore/popper": "5.46.4-prerelease.0",
24
- "@semcore/tooltip": "6.49.4-prerelease.0",
17
+ "@semcore/utils": "4.49.0-prerelease.0",
18
+ "@semcore/flex-box": "5.42.0-prerelease.0",
19
+ "@semcore/button": "5.44.0-prerelease.0",
20
+ "@semcore/typography": "5.54.0-prerelease.0",
21
+ "@semcore/counter": "3.39.0-prerelease.0",
22
+ "@semcore/icon": "4.63.0-prerelease.0",
23
+ "@semcore/popper": "5.47.0-prerelease.0",
24
+ "@semcore/tooltip": "6.50.0-prerelease.0",
25
25
  "csstype": "3.0.8",
26
26
  "dompurify": "3.2.3"
27
27
  },
28
28
  "peerDependencies": {
29
- "@semcore/core": "^2.39.4-prerelease.0",
29
+ "@semcore/core": "^2.40.0-prerelease.0",
30
30
  "react": "16.8 - 18",
31
31
  "react-dom": "16.8 - 18"
32
32
  },