@semcore/bulk-textarea 17.2.1 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/cjs/BulkTextarea.js +18 -12
  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.map +1 -1
  6. package/lib/cjs/components/Counter.js.map +1 -1
  7. package/lib/cjs/components/ErrorsNavigation.js +5 -2
  8. package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
  9. package/lib/cjs/components/InputField/History.js +46 -0
  10. package/lib/cjs/components/InputField/History.js.map +1 -0
  11. package/lib/cjs/components/InputField/InputField.js +494 -361
  12. package/lib/cjs/components/InputField/InputField.js.map +1 -1
  13. package/lib/cjs/components/InputField/inputField.shadow.css +42 -51
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/es6/BulkTextarea.js +18 -12
  16. package/lib/es6/BulkTextarea.js.map +1 -1
  17. package/lib/es6/BulkTextarea.types.js.map +1 -1
  18. package/lib/es6/components/ClearAll.js.map +1 -1
  19. package/lib/es6/components/Counter.js.map +1 -1
  20. package/lib/es6/components/ErrorsNavigation.js +5 -2
  21. package/lib/es6/components/ErrorsNavigation.js.map +1 -1
  22. package/lib/es6/components/InputField/History.js +38 -0
  23. package/lib/es6/components/InputField/History.js.map +1 -0
  24. package/lib/es6/components/InputField/InputField.js +494 -361
  25. package/lib/es6/components/InputField/InputField.js.map +1 -1
  26. package/lib/es6/components/InputField/inputField.shadow.css +42 -51
  27. package/lib/es6/index.js.map +1 -1
  28. package/lib/esm/BulkTextarea.mjs +12 -5
  29. package/lib/esm/components/ErrorsNavigation.mjs +5 -2
  30. package/lib/esm/components/InputField/History.mjs +40 -0
  31. package/lib/esm/components/InputField/InputField.mjs +481 -358
  32. package/lib/esm/components/InputField/inputField.shadow.css +42 -51
  33. package/lib/types/BulkTextarea.d.ts +108 -2
  34. package/lib/types/BulkTextarea.types.d.ts +245 -147
  35. package/lib/types/components/ClearAll.d.ts +4 -6
  36. package/lib/types/components/Counter.d.ts +4 -9
  37. package/lib/types/components/ErrorsNavigation.d.ts +4 -14
  38. package/lib/types/components/InputField/History.d.ts +20 -0
  39. package/lib/types/components/InputField/InputField.d.ts +30 -24
  40. package/lib/types/index.d.ts +1 -2
  41. package/package.json +3 -3
  42. package/lib/cjs/components/InputField/InputField.types.js +0 -2
  43. package/lib/cjs/components/InputField/InputField.types.js.map +0 -1
  44. package/lib/es6/components/InputField/InputField.types.js +0 -2
  45. package/lib/es6/components/InputField/InputField.types.js.map +0 -1
  46. package/lib/types/components/InputField/InputField.types.d.ts +0 -44
@@ -1,4 +1,4 @@
1
- SInputField>div {
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
- &:nth-child(even) {
24
- color: red;
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
- &:not(:empty)::before {
54
- content: counter(row) '.';
55
- display: inline-block;
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
- position: absolute;
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(p:nth-child(n + 10)) {
71
- >p {
61
+ &:has(li:nth-child(n + 10)) {
62
+ >li {
72
63
  padding-left: var(--intergalactic-spacing-6x, 24px);
73
64
  }
74
65
 
75
- >p:nth-child(-n + 9)::before {
66
+ >li:nth-child(-n + 9)::before {
76
67
  padding-left: var(--intergalactic-spacing-2x, 8px);
77
68
  }
78
69
  }
79
70
 
80
- &:has(p:nth-child(n + 100)) {
81
- >p {
71
+ &:has(li:nth-child(n + 100)) {
72
+ >li {
82
73
  padding-left: var(--intergalactic-spacing-8x, 32px);
83
74
  }
84
75
 
85
- >p:nth-child(-n + 9)::before {
76
+ >li:nth-child(-n + 9)::before {
86
77
  padding-left: var(--intergalactic-spacing-4x, 16px);
87
78
  }
88
79
 
89
- >p:nth-child(n + 10)::before {
80
+ >li:nth-child(n + 10)::before {
90
81
  padding-left: var(--intergalactic-spacing-2x, 8px);
91
82
  }
92
83
 
93
- >p:nth-child(n + 100)::before {
84
+ >li:nth-child(n + 100)::before {
94
85
  padding-left: 0;
95
86
  }
96
87
  }
97
88
 
98
- &:has(p:nth-child(n + 1000)) {
99
- > p {
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
- > p:nth-child(-n + 9)::before {
93
+ > li:nth-child(-n + 9)::before {
103
94
  padding-left: var(--intergalactic-spacing-6x, 24px);
104
95
  }
105
- > p:nth-child(n + 10)::before {
96
+ > li:nth-child(n + 10)::before {
106
97
  padding-left: var(--intergalactic-spacing-4x, 16px);
107
98
  }
108
- > p:nth-child(n + 100)::before {
99
+ > li:nth-child(n + 100)::before {
109
100
  padding-left: var(--intergalactic-spacing-2x, 8px);
110
101
  }
111
- > p:nth-child(n + 1000)::before {
102
+ > li:nth-child(n + 1000)::before {
112
103
  padding-left: 0;
113
104
  }
114
105
  }
115
106
  }
116
107
 
117
- SInputField[showErrors]>div[aria-invalid]>p[aria-invalid]:after {
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']>div {
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']>div {
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])>div {
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']>div {
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']>div {
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]>div {
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]>div {
198
+ SInputField[disabled]>ol {
208
199
  opacity: var(--intergalactic-disabled-opacity, 0.4);
209
200
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './BulkTextarea';\nexport type { BulkTextareaProps } from './BulkTextarea.types';\nexport type { ErrorItem } from './components/InputField/InputField.types';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './BulkTextarea';\nexport type { BulkTextareaProps, NSBulktextarea, ErrorItem } from './BulkTextarea.types';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,gBAAgB","ignoreList":[]}
@@ -33,6 +33,12 @@ class BulkTextareaRoot extends Component {
33
33
  this.handlers.showErrors(false);
34
34
  this.handlers.errors([]);
35
35
  this.handlers.state("normal");
36
+ if (document.activeElement === this.clearAllButtonRef.current) {
37
+ const textarea = this.inputFieldRef.current?.querySelector('[contenteditable="true"]');
38
+ if (textarea instanceof HTMLOListElement) {
39
+ textarea.focus();
40
+ }
41
+ }
36
42
  }
37
43
  });
38
44
  _defineProperty(this, "handleClickClearAll", (e) => {
@@ -41,12 +47,8 @@ class BulkTextareaRoot extends Component {
41
47
  this.setState({
42
48
  errorIndex: -1
43
49
  });
44
- this.handlers.value("", e);
50
+ this.handlers.value(typeof this.asProps.value === "string" ? "" : [], e);
45
51
  this.handlers.state("normal");
46
- const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]');
47
- if (textarea instanceof HTMLDivElement) {
48
- textarea.focus();
49
- }
50
52
  });
51
53
  _defineProperty(this, "handleChangeErrorIndex", (amount) => () => {
52
54
  const {
@@ -146,6 +148,11 @@ class BulkTextareaRoot extends Component {
146
148
  }
147
149
  this.handlers.value?.(value2, event);
148
150
  },
151
+ onPaste: () => {
152
+ if (validateOn?.includes("paste")) {
153
+ this.handlers.showErrors(true);
154
+ }
155
+ },
149
156
  showErrors,
150
157
  validateOn,
151
158
  lineValidation,
@@ -27,7 +27,8 @@ function ErrorsNavigation(props) {
27
27
  "aria-label": getI18nText("BulkTextarea.ErrorsNavigation.nextError:aria-label"),
28
28
  hintPlacement: "bottom",
29
29
  disabled,
30
- ref: nextButtonRef
30
+ ref: nextButtonRef,
31
+ size
31
32
  }), /* @__PURE__ */ React.createElement(Button, {
32
33
  onClick: onPrevError,
33
34
  addonLeft: ChevronUpM,
@@ -36,7 +37,9 @@ function ErrorsNavigation(props) {
36
37
  "aria-label": getI18nText("BulkTextarea.ErrorsNavigation.previousError:aria-label"),
37
38
  hintPlacement: "bottom",
38
39
  disabled,
39
- ref: prevButtonRef
40
+ ref: prevButtonRef,
41
+ size,
42
+ ml: 1
40
43
  }), /* @__PURE__ */ React.createElement(Text, {
41
44
  size: size === "l" ? 300 : 200,
42
45
  color: "text-critical",
@@ -0,0 +1,40 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ const DEFAULT_MAX_LENGTH = 100;
3
+ 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
+ export {
39
+ History
40
+ };