@dmsi/wedgekit-react 0.0.46 → 0.0.47

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.
@@ -1246,7 +1246,11 @@ var DateInput = (_a) => {
1246
1246
  setInputValue(formattedValue);
1247
1247
  requestAnimationFrame(() => {
1248
1248
  if (triggerRef.current) {
1249
- const newPosition = calculateCursorPosition(rawValue, formattedValue, cursorPosition);
1249
+ const newPosition = calculateCursorPosition(
1250
+ rawValue,
1251
+ formattedValue,
1252
+ cursorPosition
1253
+ );
1250
1254
  triggerRef.current.setSelectionRange(newPosition, newPosition);
1251
1255
  }
1252
1256
  });
@@ -135,7 +135,11 @@ var DateInput = (_a) => {
135
135
  setInputValue(formattedValue);
136
136
  requestAnimationFrame(() => {
137
137
  if (triggerRef.current) {
138
- const newPosition = calculateCursorPosition(rawValue, formattedValue, cursorPosition);
138
+ const newPosition = calculateCursorPosition(
139
+ rawValue,
140
+ formattedValue,
141
+ cursorPosition
142
+ );
139
143
  triggerRef.current.setSelectionRange(newPosition, newPosition);
140
144
  }
141
145
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.46",
4
+ "version": "0.0.47",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -75,7 +75,7 @@ export const DateInput = ({
75
75
  if (visible) {
76
76
  updatePosition();
77
77
  }
78
- }, [visible])
78
+ }, [visible]);
79
79
 
80
80
  const updatePosition = () => {
81
81
  if (triggerRef.current) {
@@ -148,27 +148,31 @@ export const DateInput = ({
148
148
 
149
149
  const handleClick = () => {
150
150
  handleFocus();
151
- }
151
+ };
152
152
 
153
153
  const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
154
154
  if (readOnly) return;
155
-
155
+
156
156
  const rawValue = event.target.value;
157
157
  const cursorPosition = event.target.selectionStart || 0;
158
158
  setIsTyping(true);
159
-
159
+
160
160
  // Format the input as user types (add slashes automatically)
161
161
  const formattedValue = formatInputValue(rawValue);
162
162
  setInputValue(formattedValue);
163
-
163
+
164
164
  // Restore cursor position after formatting
165
165
  requestAnimationFrame(() => {
166
166
  if (triggerRef.current) {
167
- const newPosition = calculateCursorPosition(rawValue, formattedValue, cursorPosition);
167
+ const newPosition = calculateCursorPosition(
168
+ rawValue,
169
+ formattedValue,
170
+ cursorPosition,
171
+ );
168
172
  triggerRef.current.setSelectionRange(newPosition, newPosition);
169
173
  }
170
174
  });
171
-
175
+
172
176
  // Try to parse and validate the date
173
177
  const parsedDate = parseInputDate(formattedValue);
174
178
  if (parsedDate && isValidDate(parsedDate)) {
@@ -190,14 +194,15 @@ export const DateInput = ({
190
194
  const input = event.target as HTMLInputElement;
191
195
  const cursorPosition = input.selectionStart || 0;
192
196
  const value = input.value;
193
-
197
+
194
198
  // If cursor is right after a slash, move it before the slash
195
199
  if (cursorPosition > 0 && value[cursorPosition - 1] === "/") {
196
200
  event.preventDefault();
197
- const newValue = value.slice(0, cursorPosition - 2) + value.slice(cursorPosition);
201
+ const newValue =
202
+ value.slice(0, cursorPosition - 2) + value.slice(cursorPosition);
198
203
  const formattedValue = formatInputValue(newValue);
199
204
  setInputValue(formattedValue);
200
-
205
+
201
206
  // Set cursor position after the deletion
202
207
  requestAnimationFrame(() => {
203
208
  if (triggerRef.current) {
@@ -205,12 +210,12 @@ export const DateInput = ({
205
210
  triggerRef.current.setSelectionRange(newPosition, newPosition);
206
211
  }
207
212
  });
208
-
213
+
209
214
  setIsTyping(true);
210
215
  return;
211
216
  }
212
217
  }
213
-
218
+
214
219
  if (event.key === "Enter") {
215
220
  const parsedDate = parseInputDate(inputValue);
216
221
  if (parsedDate && isValidDate(parsedDate)) {
@@ -280,6 +285,6 @@ function formatDisplayValue(from?: string): string {
280
285
  if (!isValidDate(from)) {
281
286
  return "";
282
287
  }
283
-
288
+
284
289
  return formatDate(from);
285
- }
290
+ }