@xsolla/xui-input-edit 0.176.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.
@@ -0,0 +1,952 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ InputEdit: () => InputEdit
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/InputEdit.tsx
38
+ var import_react3 = __toESM(require("react"));
39
+
40
+ // ../../foundation/primitives-native/src/Box.tsx
41
+ var import_react_native = require("react-native");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var Box = ({
44
+ children,
45
+ onPress,
46
+ onLayout,
47
+ onMoveShouldSetResponder,
48
+ onResponderGrant,
49
+ onResponderMove,
50
+ onResponderRelease,
51
+ onResponderTerminate,
52
+ backgroundColor,
53
+ borderColor,
54
+ borderWidth,
55
+ borderBottomWidth,
56
+ borderBottomColor,
57
+ borderTopWidth,
58
+ borderTopColor,
59
+ borderLeftWidth,
60
+ borderLeftColor,
61
+ borderRightWidth,
62
+ borderRightColor,
63
+ borderRadius,
64
+ borderStyle,
65
+ height,
66
+ padding,
67
+ paddingHorizontal,
68
+ paddingVertical,
69
+ margin,
70
+ marginTop,
71
+ marginBottom,
72
+ marginLeft,
73
+ marginRight,
74
+ flexDirection,
75
+ alignItems,
76
+ justifyContent,
77
+ position,
78
+ top,
79
+ bottom,
80
+ left,
81
+ right,
82
+ width,
83
+ minWidth,
84
+ minHeight,
85
+ maxWidth,
86
+ maxHeight,
87
+ flex,
88
+ overflow,
89
+ zIndex,
90
+ hoverStyle,
91
+ pressStyle,
92
+ style,
93
+ "data-testid": dataTestId,
94
+ testID,
95
+ as,
96
+ src,
97
+ alt,
98
+ ...rest
99
+ }) => {
100
+ const getContainerStyle = (pressed) => ({
101
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
102
+ borderColor,
103
+ borderWidth,
104
+ borderBottomWidth,
105
+ borderBottomColor,
106
+ borderTopWidth,
107
+ borderTopColor,
108
+ borderLeftWidth,
109
+ borderLeftColor,
110
+ borderRightWidth,
111
+ borderRightColor,
112
+ borderRadius,
113
+ borderStyle,
114
+ overflow,
115
+ zIndex,
116
+ height,
117
+ width,
118
+ minWidth,
119
+ minHeight,
120
+ maxWidth,
121
+ maxHeight,
122
+ padding,
123
+ paddingHorizontal,
124
+ paddingVertical,
125
+ margin,
126
+ marginTop,
127
+ marginBottom,
128
+ marginLeft,
129
+ marginRight,
130
+ flexDirection,
131
+ alignItems,
132
+ justifyContent,
133
+ position,
134
+ top,
135
+ bottom,
136
+ left,
137
+ right,
138
+ flex,
139
+ ...style
140
+ });
141
+ const finalTestID = dataTestId || testID;
142
+ const {
143
+ role,
144
+ tabIndex,
145
+ onKeyDown,
146
+ onKeyUp,
147
+ "aria-label": _ariaLabel,
148
+ "aria-labelledby": _ariaLabelledBy,
149
+ "aria-current": _ariaCurrent,
150
+ "aria-disabled": _ariaDisabled,
151
+ "aria-live": _ariaLive,
152
+ className,
153
+ "data-testid": _dataTestId,
154
+ ...nativeRest
155
+ } = rest;
156
+ if (as === "img" && src) {
157
+ const imageStyle = {
158
+ width,
159
+ height,
160
+ borderRadius,
161
+ position,
162
+ top,
163
+ bottom,
164
+ left,
165
+ right,
166
+ ...style
167
+ };
168
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
+ import_react_native.Image,
170
+ {
171
+ source: { uri: src },
172
+ style: imageStyle,
173
+ testID: finalTestID,
174
+ resizeMode: "cover",
175
+ ...nativeRest
176
+ }
177
+ );
178
+ }
179
+ if (onPress) {
180
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
+ import_react_native.Pressable,
182
+ {
183
+ onPress,
184
+ onLayout,
185
+ onMoveShouldSetResponder,
186
+ onResponderGrant,
187
+ onResponderMove,
188
+ onResponderRelease,
189
+ onResponderTerminate,
190
+ style: ({ pressed }) => getContainerStyle(pressed),
191
+ testID: finalTestID,
192
+ ...nativeRest,
193
+ children
194
+ }
195
+ );
196
+ }
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
+ import_react_native.View,
199
+ {
200
+ style: getContainerStyle(),
201
+ testID: finalTestID,
202
+ onLayout,
203
+ onMoveShouldSetResponder,
204
+ onResponderGrant,
205
+ onResponderMove,
206
+ onResponderRelease,
207
+ onResponderTerminate,
208
+ ...nativeRest,
209
+ children
210
+ }
211
+ );
212
+ };
213
+
214
+ // ../../foundation/primitives-native/src/Text.tsx
215
+ var import_react_native2 = require("react-native");
216
+ var import_jsx_runtime2 = require("react/jsx-runtime");
217
+ var roleMap = {
218
+ alert: "alert",
219
+ heading: "header",
220
+ button: "button",
221
+ link: "link",
222
+ text: "text"
223
+ };
224
+ var parseNumericValue = (value) => {
225
+ if (value === void 0) return void 0;
226
+ if (typeof value === "number") return value;
227
+ const parsed = parseFloat(value);
228
+ return isNaN(parsed) ? void 0 : parsed;
229
+ };
230
+ var Text = ({
231
+ children,
232
+ color,
233
+ fontSize,
234
+ fontWeight,
235
+ fontFamily,
236
+ textAlign,
237
+ lineHeight,
238
+ numberOfLines,
239
+ id,
240
+ role,
241
+ testID,
242
+ "data-testid": dataTestId,
243
+ style: styleProp,
244
+ ...props
245
+ }) => {
246
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
247
+ if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
248
+ resolvedFontFamily = void 0;
249
+ }
250
+ const incomingStyle = import_react_native2.StyleSheet.flatten(styleProp);
251
+ const baseStyle = {
252
+ color: color ?? incomingStyle?.color,
253
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
254
+ fontWeight,
255
+ fontFamily: resolvedFontFamily,
256
+ textDecorationLine: props.textDecoration,
257
+ textAlign: textAlign ?? incomingStyle?.textAlign,
258
+ lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),
259
+ marginTop: parseNumericValue(
260
+ incomingStyle?.marginTop
261
+ ),
262
+ marginBottom: parseNumericValue(
263
+ incomingStyle?.marginBottom
264
+ )
265
+ };
266
+ const accessibilityRole = role ? roleMap[role] : void 0;
267
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
268
+ import_react_native2.Text,
269
+ {
270
+ style: baseStyle,
271
+ numberOfLines,
272
+ testID: dataTestId || testID || id,
273
+ accessibilityRole,
274
+ children
275
+ }
276
+ );
277
+ };
278
+
279
+ // ../../foundation/primitives-native/src/Icon.tsx
280
+ var import_react = __toESM(require("react"));
281
+ var import_react_native3 = require("react-native");
282
+ var import_jsx_runtime3 = require("react/jsx-runtime");
283
+ var Icon = ({
284
+ children,
285
+ color,
286
+ size,
287
+ testID,
288
+ "data-testid": dataTestId
289
+ }) => {
290
+ const style = {
291
+ width: typeof size === "number" ? size : void 0,
292
+ height: typeof size === "number" ? size : void 0,
293
+ alignItems: "center",
294
+ justifyContent: "center"
295
+ };
296
+ const childrenWithProps = import_react.default.Children.map(children, (child) => {
297
+ if (import_react.default.isValidElement(child)) {
298
+ return import_react.default.cloneElement(child, {
299
+ color: child.props.color || color,
300
+ // Also pass size if child seems to be an icon that needs it
301
+ size: child.props.size || size
302
+ });
303
+ }
304
+ return child;
305
+ });
306
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style, testID: dataTestId || testID, children: childrenWithProps });
307
+ };
308
+
309
+ // ../../foundation/primitives-native/src/TextArea.tsx
310
+ var import_react2 = require("react");
311
+ var import_react_native4 = require("react-native");
312
+ var import_jsx_runtime4 = require("react/jsx-runtime");
313
+ var TextAreaPrimitive = (0, import_react2.forwardRef)(
314
+ ({
315
+ value,
316
+ placeholder,
317
+ onChange,
318
+ onChangeText,
319
+ onFocus,
320
+ onBlur,
321
+ onKeyDown,
322
+ disabled,
323
+ style,
324
+ color,
325
+ fontSize,
326
+ fontFamily,
327
+ placeholderTextColor,
328
+ maxLength,
329
+ rows,
330
+ id,
331
+ "aria-describedby": ariaDescribedBy,
332
+ "aria-label": ariaLabel,
333
+ "aria-disabled": ariaDisabled,
334
+ "data-testid": dataTestId,
335
+ testID
336
+ }, ref) => {
337
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
338
+ if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
339
+ resolvedFontFamily = void 0;
340
+ }
341
+ const handleChangeText = (text) => {
342
+ onChangeText?.(text);
343
+ if (onChange) {
344
+ const syntheticEvent = {
345
+ target: { value: text },
346
+ currentTarget: { value: text },
347
+ type: "change",
348
+ nativeEvent: { text },
349
+ preventDefault: () => {
350
+ },
351
+ stopPropagation: () => {
352
+ },
353
+ isTrusted: false
354
+ };
355
+ onChange(syntheticEvent);
356
+ }
357
+ };
358
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
359
+ import_react_native4.TextInput,
360
+ {
361
+ ref,
362
+ value,
363
+ placeholder,
364
+ onChangeText: handleChangeText,
365
+ onFocus,
366
+ onBlur,
367
+ onKeyPress: (e) => {
368
+ if (onKeyDown) {
369
+ onKeyDown({
370
+ key: e.nativeEvent.key,
371
+ preventDefault: () => {
372
+ }
373
+ });
374
+ }
375
+ },
376
+ editable: !disabled,
377
+ multiline: true,
378
+ numberOfLines: rows || 4,
379
+ style: [
380
+ {
381
+ color,
382
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
383
+ fontFamily: resolvedFontFamily,
384
+ flex: 1,
385
+ padding: 0,
386
+ textAlignVertical: "top",
387
+ textAlign: style?.textAlign || "left"
388
+ },
389
+ style
390
+ ],
391
+ placeholderTextColor,
392
+ maxLength,
393
+ testID: dataTestId || testID || id,
394
+ accessibilityLabel: ariaLabel,
395
+ accessibilityHint: ariaDescribedBy,
396
+ accessibilityState: {
397
+ disabled: disabled || ariaDisabled
398
+ },
399
+ accessible: true
400
+ }
401
+ );
402
+ }
403
+ );
404
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
405
+
406
+ // ../../foundation/primitives-native/src/index.tsx
407
+ var isWeb = false;
408
+
409
+ // src/InputEdit.tsx
410
+ var import_xui_core = require("@xsolla/xui-core");
411
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
412
+ var import_jsx_runtime5 = (
413
+ // Rich-text editor (web): a contenteditable surface holding HTML.
414
+ require("react/jsx-runtime")
415
+ );
416
+ var FIELD = {
417
+ fontSize: 16,
418
+ lineHeight: 18,
419
+ framePadding: 11,
420
+ iconSize: 16
421
+ };
422
+ var stripHtml = (html) => html.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ");
423
+ var CONTROL_ICON_SIZE = 18;
424
+ var POPOVER_SHADOW = "0px 6px 10px 4px rgba(7, 7, 8, 0.1), 0px 2px 3px 0px rgba(7, 7, 8, 0.2)";
425
+ var POPOVER_DROP_SHADOW = "drop-shadow(0 6px 10px rgba(7, 7, 8, 0.1)) drop-shadow(0 2px 3px rgba(7, 7, 8, 0.2))";
426
+ var InputEdit = (0, import_react3.forwardRef)(
427
+ ({
428
+ value,
429
+ defaultValue,
430
+ placeholder = "Placeholder",
431
+ onChangeText,
432
+ onConfirm,
433
+ onCancel,
434
+ onKeyDown,
435
+ editControl = true,
436
+ icon = true,
437
+ editIcon,
438
+ tools,
439
+ rows,
440
+ mode = "inline",
441
+ textStyle,
442
+ richText = false,
443
+ disabled = false,
444
+ error = false,
445
+ errorMessage,
446
+ id: providedId,
447
+ "aria-label": ariaLabel,
448
+ "aria-labelledby": ariaLabelledBy,
449
+ testID,
450
+ className,
451
+ themeMode,
452
+ themeProductContext,
453
+ ...rest
454
+ }, ref) => {
455
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
456
+ const isControlled = value !== void 0;
457
+ const [internalValue, setInternalValue] = (0, import_react3.useState)(
458
+ value ?? defaultValue ?? ""
459
+ );
460
+ const currentValue = isControlled ? value : internalValue;
461
+ const isFormMode = mode === "form";
462
+ const [isEditing, setIsEditing] = (0, import_react3.useState)(false);
463
+ const editing = isFormMode || isEditing;
464
+ const [focused, setFocused] = (0, import_react3.useState)(false);
465
+ const active = isFormMode ? focused : isEditing;
466
+ const richEnabled = richText && isWeb;
467
+ const inputRef = (0, import_react3.useRef)(null);
468
+ const editableRef = (0, import_react3.useRef)(null);
469
+ const focusField = () => {
470
+ if (richEnabled) editableRef.current?.focus();
471
+ else inputRef.current?.focus();
472
+ };
473
+ const committedValue = (0, import_react3.useRef)(currentValue);
474
+ const [fieldHeight, setFieldHeight] = (0, import_react3.useState)(null);
475
+ const rawId = (0, import_xui_core.useId)();
476
+ const safeId = rawId.replace(/:/g, "");
477
+ const inputId = providedId || `input-edit-${safeId}`;
478
+ const errorId = `${inputId}-error`;
479
+ const triggerId = `${inputId}-trigger`;
480
+ const focusTrigger = () => {
481
+ if (isWeb) {
482
+ setTimeout(() => document.getElementById(triggerId)?.focus(), 0);
483
+ }
484
+ };
485
+ import_react3.default.useImperativeHandle(
486
+ ref,
487
+ () => richEnabled ? editableRef.current : inputRef.current,
488
+ [richEnabled]
489
+ );
490
+ (0, import_react3.useEffect)(() => {
491
+ if (value !== void 0) {
492
+ setInternalValue(value);
493
+ committedValue.current = value;
494
+ }
495
+ }, [value]);
496
+ const autoSize = () => {
497
+ if (!isWeb) return;
498
+ if (richEnabled) {
499
+ requestAnimationFrame(() => {
500
+ const el2 = editableRef.current;
501
+ if (el2) setFieldHeight(el2.offsetHeight + FIELD.framePadding * 2);
502
+ });
503
+ return;
504
+ }
505
+ const el = inputRef.current;
506
+ if (!el) return;
507
+ el.style.height = "auto";
508
+ el.style.height = `${el.scrollHeight}px`;
509
+ setFieldHeight(el.scrollHeight + FIELD.framePadding * 2);
510
+ };
511
+ (0, import_react3.useEffect)(() => {
512
+ if (!editing) return;
513
+ if (richEnabled) {
514
+ const el = editableRef.current;
515
+ if (el && el.innerHTML !== currentValue) el.innerHTML = currentValue;
516
+ }
517
+ autoSize();
518
+ }, [editing, currentValue, richEnabled]);
519
+ const isError = !!(error || errorMessage);
520
+ const isFilled = richText ? stripHtml(currentValue).trim().length > 0 : currentValue.length > 0;
521
+ const plainText = richText ? stripHtml(currentValue) : currentValue;
522
+ const inputColors = theme.colors.control.input;
523
+ const borderRadius = theme.shape.input.md.borderRadius;
524
+ const typo = theme.typographyTokens;
525
+ const textStyleToken = textStyle ? typo.heading[textStyle] ?? typo.basic[textStyle] : null;
526
+ const fontSize = textStyleToken ? textStyleToken.fontSize : FIELD.fontSize;
527
+ const lineHeight = textStyleToken ? parseInt(String(textStyleToken.lineHeight), 10) : FIELD.lineHeight;
528
+ const fontWeight = textStyleToken ? textStyleToken.fontWeight : 400;
529
+ const fontFamily = textStyleToken && textStyleToken.lineHeightCategory === "display" ? theme.fonts.heading : theme.fonts.body;
530
+ const controlsTop = (fieldHeight ?? lineHeight + FIELD.framePadding * 2) - FIELD.framePadding + 4;
531
+ const enterEdit = () => {
532
+ if (disabled || isEditing) return;
533
+ setIsEditing(true);
534
+ setTimeout(focusField, 0);
535
+ };
536
+ const handleRichInput = (e) => {
537
+ handleChangeText(e.currentTarget.innerHTML);
538
+ };
539
+ const handlePaste = (e) => {
540
+ e.preventDefault();
541
+ const text = e.clipboardData.getData("text/plain");
542
+ document.execCommand("insertText", false, text);
543
+ };
544
+ const handleChangeText = (next) => {
545
+ onChangeText?.(next);
546
+ if (!isControlled) {
547
+ setInternalValue(next);
548
+ }
549
+ };
550
+ const commitExplicit = () => {
551
+ onConfirm?.(currentValue);
552
+ committedValue.current = currentValue;
553
+ };
554
+ const commitOnBlur = () => {
555
+ if (currentValue !== committedValue.current) {
556
+ onConfirm?.(currentValue);
557
+ committedValue.current = currentValue;
558
+ }
559
+ };
560
+ const exitEdit = () => {
561
+ if (!isFormMode) {
562
+ setIsEditing(false);
563
+ setFocused(false);
564
+ focusTrigger();
565
+ }
566
+ };
567
+ const handleConfirm = () => {
568
+ commitExplicit();
569
+ exitEdit();
570
+ };
571
+ const handleCancel = () => {
572
+ if (!isControlled) {
573
+ setInternalValue(committedValue.current);
574
+ }
575
+ onCancel?.();
576
+ exitEdit();
577
+ };
578
+ const handleKeyDown = (e) => {
579
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
580
+ e.preventDefault();
581
+ handleConfirm();
582
+ return;
583
+ }
584
+ if (e.key === "Escape") {
585
+ e.preventDefault();
586
+ handleCancel();
587
+ return;
588
+ }
589
+ onKeyDown?.(e);
590
+ };
591
+ const handleFocus = () => setFocused(true);
592
+ const handleBlur = () => {
593
+ setFocused(false);
594
+ commitOnBlur();
595
+ if (!isFormMode) {
596
+ setIsEditing(false);
597
+ }
598
+ };
599
+ let fieldBg = "transparent";
600
+ let fieldBorder = "transparent";
601
+ if (disabled) {
602
+ fieldBg = inputColors.bgDisable;
603
+ fieldBorder = inputColors.borderDisable;
604
+ } else if (isError) {
605
+ fieldBg = inputColors.bg;
606
+ fieldBorder = theme.colors.border.alert;
607
+ } else if (active) {
608
+ fieldBg = theme.colors.control.focus.bg;
609
+ fieldBorder = theme.colors.border.brand;
610
+ } else if (isFormMode) {
611
+ fieldBg = inputColors.bg;
612
+ fieldBorder = inputColors.border;
613
+ }
614
+ const textColor = disabled ? inputColors.textDisable : inputColors.text;
615
+ const displayColor = isFilled ? textColor : inputColors.placeholder;
616
+ const preventBlur = isWeb ? { onMouseDown: (e) => e.preventDefault() } : {};
617
+ const controlBg = theme.colors.control.mono.primary.bg;
618
+ const controlBgHover = theme.colors.control.mono.primary.bgHover;
619
+ const controlIconColor = theme.colors.control.mono.text.primary;
620
+ const isTrigger = !editing && !disabled;
621
+ const triggerProps = isTrigger ? {
622
+ as: "button",
623
+ type: "button",
624
+ id: triggerId,
625
+ onPress: enterEdit,
626
+ "aria-label": ariaLabel,
627
+ "aria-labelledby": ariaLabelledBy
628
+ } : {
629
+ "aria-disabled": disabled || void 0
630
+ };
631
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
632
+ Box,
633
+ {
634
+ position: "relative",
635
+ width: "100%",
636
+ testID,
637
+ className,
638
+ children: [
639
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { position: "relative", width: "100%", style: { minHeight: lineHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
640
+ Box,
641
+ {
642
+ ...triggerProps,
643
+ position: "absolute",
644
+ flexDirection: "row",
645
+ alignItems: editing || isError || disabled ? "flex-start" : "center",
646
+ gap: 8,
647
+ paddingVertical: FIELD.framePadding,
648
+ paddingHorizontal: FIELD.framePadding,
649
+ backgroundColor: fieldBg,
650
+ borderColor: fieldBorder,
651
+ borderWidth: 1,
652
+ cursor: disabled ? "not-allowed" : editing ? "text" : "pointer",
653
+ hoverStyle: !disabled && !editing && !isError ? {
654
+ backgroundColor: inputColors.bgHover,
655
+ borderColor: inputColors.borderHover
656
+ } : void 0,
657
+ style: {
658
+ // Pin top/left/right to the anchor (inflated outward); leave the bottom
659
+ // free so the field grows downward with multi-line content.
660
+ top: -FIELD.framePadding,
661
+ left: -FIELD.framePadding,
662
+ right: -FIELD.framePadding,
663
+ minHeight: lineHeight + FIELD.framePadding * 2,
664
+ borderRadius,
665
+ boxSizing: "border-box",
666
+ textAlign: "left",
667
+ width: "auto"
668
+ },
669
+ children: [
670
+ editing && richEnabled ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box, { flex: 1, position: "relative", children: [
671
+ !isFilled && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
672
+ Text,
673
+ {
674
+ "aria-hidden": true,
675
+ color: inputColors.placeholder,
676
+ fontSize,
677
+ fontWeight: String(fontWeight),
678
+ style: {
679
+ position: "absolute",
680
+ top: 0,
681
+ left: 0,
682
+ fontFamily,
683
+ lineHeight: `${lineHeight}px`,
684
+ pointerEvents: "none"
685
+ },
686
+ children: placeholder
687
+ }
688
+ ),
689
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
690
+ "div",
691
+ {
692
+ ref: editableRef,
693
+ id: inputId,
694
+ contentEditable: !disabled,
695
+ suppressContentEditableWarning: true,
696
+ role: "textbox",
697
+ "aria-multiline": "true",
698
+ "aria-label": ariaLabel,
699
+ "aria-labelledby": ariaLabelledBy,
700
+ "aria-invalid": isError || void 0,
701
+ "aria-describedby": errorMessage ? errorId : void 0,
702
+ "data-testid": "input-edit__field",
703
+ onInput: handleRichInput,
704
+ onFocus: handleFocus,
705
+ onBlur: handleBlur,
706
+ onKeyDown: handleKeyDown,
707
+ onPaste: handlePaste,
708
+ style: {
709
+ outline: "none",
710
+ minHeight: `${lineHeight}px`,
711
+ color: textColor,
712
+ fontFamily,
713
+ fontWeight,
714
+ fontSize: `${fontSize}px`,
715
+ lineHeight: `${lineHeight}px`,
716
+ whiteSpace: "pre-wrap",
717
+ wordBreak: "break-word"
718
+ }
719
+ }
720
+ )
721
+ ] }) : editing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { flex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
722
+ TextAreaPrimitive,
723
+ {
724
+ ref: inputRef,
725
+ id: inputId,
726
+ value: plainText,
727
+ placeholder,
728
+ onChangeText: handleChangeText,
729
+ onFocus: handleFocus,
730
+ onBlur: handleBlur,
731
+ onKeyDown: handleKeyDown,
732
+ disabled,
733
+ rows: rows ?? 1,
734
+ color: textColor,
735
+ fontSize,
736
+ fontFamily,
737
+ placeholderTextColor: inputColors.placeholder,
738
+ "aria-invalid": isError || void 0,
739
+ "aria-describedby": errorMessage ? errorId : void 0,
740
+ "aria-label": ariaLabel,
741
+ "aria-labelledby": ariaLabelledBy,
742
+ "data-testid": "input-edit__field",
743
+ style: {
744
+ display: "block",
745
+ overflow: "hidden",
746
+ fontWeight,
747
+ lineHeight: `${lineHeight}px`
748
+ },
749
+ ...rest
750
+ }
751
+ ) }) : richText && isWeb && isFilled ? (
752
+ // Rich display (read-only): render the stored HTML.
753
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
754
+ "div",
755
+ {
756
+ "data-testid": "input-edit__text",
757
+ dangerouslySetInnerHTML: { __html: currentValue },
758
+ style: {
759
+ flex: 1,
760
+ color: textColor,
761
+ fontFamily,
762
+ fontWeight,
763
+ fontSize: `${fontSize}px`,
764
+ lineHeight: `${lineHeight}px`,
765
+ whiteSpace: "pre-wrap",
766
+ wordBreak: "break-word"
767
+ }
768
+ }
769
+ )
770
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
771
+ Text,
772
+ {
773
+ color: displayColor,
774
+ fontSize,
775
+ fontWeight: String(fontWeight),
776
+ "data-testid": "input-edit__text",
777
+ style: {
778
+ flex: 1,
779
+ fontFamily,
780
+ lineHeight: `${lineHeight}px`,
781
+ wordBreak: "break-word",
782
+ // Preserve author line breaks in multi-line values.
783
+ whiteSpace: "pre-wrap"
784
+ },
785
+ children: isFilled ? plainText : placeholder
786
+ }
787
+ ),
788
+ icon && !editing && !isError && !disabled && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { alignItems: "center", justifyContent: "center", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { size: FIELD.iconSize, color: textColor, children: editIcon ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_xui_icons_base.Edit, {}) }) })
789
+ ]
790
+ }
791
+ ) }),
792
+ active && editControl && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
793
+ Box,
794
+ {
795
+ position: "absolute",
796
+ flexDirection: "row",
797
+ alignItems: "center",
798
+ backgroundColor: controlBg,
799
+ "data-testid": "input-edit__edit-control",
800
+ style: {
801
+ top: controlsTop,
802
+ right: -FIELD.framePadding,
803
+ borderRadius: 4,
804
+ overflow: "hidden",
805
+ ...isWeb ? {
806
+ boxShadow: POPOVER_SHADOW,
807
+ backdropFilter: "blur(12px)",
808
+ WebkitBackdropFilter: "blur(12px)"
809
+ } : {}
810
+ },
811
+ children: [
812
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
813
+ Box,
814
+ {
815
+ as: "button",
816
+ type: "button",
817
+ alignItems: "center",
818
+ justifyContent: "center",
819
+ backgroundColor: controlBg,
820
+ borderWidth: 0,
821
+ padding: 4,
822
+ cursor: "pointer",
823
+ onPress: handleConfirm,
824
+ "aria-label": "Confirm",
825
+ "data-testid": "input-edit__confirm",
826
+ hoverStyle: { backgroundColor: controlBgHover },
827
+ ...preventBlur,
828
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { size: CONTROL_ICON_SIZE, color: controlIconColor, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_xui_icons_base.Check, {}) })
829
+ }
830
+ ),
831
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
832
+ Box,
833
+ {
834
+ backgroundColor: theme.colors.border.inverse,
835
+ style: { width: 1, alignSelf: "stretch" }
836
+ }
837
+ ),
838
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
839
+ Box,
840
+ {
841
+ as: "button",
842
+ type: "button",
843
+ alignItems: "center",
844
+ justifyContent: "center",
845
+ backgroundColor: controlBg,
846
+ borderWidth: 0,
847
+ padding: 4,
848
+ cursor: "pointer",
849
+ onPress: handleCancel,
850
+ "aria-label": "Cancel",
851
+ "data-testid": "input-edit__cancel",
852
+ hoverStyle: { backgroundColor: controlBgHover },
853
+ ...preventBlur,
854
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { size: CONTROL_ICON_SIZE, color: controlIconColor, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_xui_icons_base.Remove, {}) })
855
+ }
856
+ )
857
+ ]
858
+ }
859
+ ),
860
+ active && tools && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
861
+ Box,
862
+ {
863
+ position: "absolute",
864
+ flexDirection: "row",
865
+ alignItems: "center",
866
+ gap: 4,
867
+ padding: 4,
868
+ backgroundColor: theme.colors.background.primary,
869
+ "data-testid": "input-edit__tools",
870
+ style: {
871
+ top: controlsTop,
872
+ left: -FIELD.framePadding,
873
+ borderRadius: 4,
874
+ ...isWeb ? {
875
+ boxShadow: POPOVER_SHADOW,
876
+ backdropFilter: "blur(12px)",
877
+ WebkitBackdropFilter: "blur(12px)"
878
+ } : {}
879
+ },
880
+ ...preventBlur,
881
+ children: tools
882
+ }
883
+ ),
884
+ isError && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
885
+ Box,
886
+ {
887
+ position: "relative",
888
+ style: {
889
+ marginTop: FIELD.framePadding + 4,
890
+ width: "max-content",
891
+ maxWidth: "100%",
892
+ ...isWeb ? {
893
+ filter: POPOVER_DROP_SHADOW,
894
+ WebkitFilter: POPOVER_DROP_SHADOW
895
+ } : {}
896
+ },
897
+ children: [
898
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
899
+ Box,
900
+ {
901
+ position: "absolute",
902
+ backgroundColor: theme.colors.background.primary,
903
+ style: {
904
+ width: 8,
905
+ height: 8,
906
+ top: -3,
907
+ left: 16,
908
+ transform: "rotate(45deg)"
909
+ }
910
+ }
911
+ ),
912
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
913
+ Box,
914
+ {
915
+ backgroundColor: theme.colors.background.primary,
916
+ paddingVertical: 8,
917
+ paddingHorizontal: 12,
918
+ style: {
919
+ borderRadius: 4,
920
+ ...isWeb ? {
921
+ backdropFilter: "blur(12px)",
922
+ WebkitBackdropFilter: "blur(12px)"
923
+ } : {}
924
+ },
925
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
926
+ Text,
927
+ {
928
+ id: errorId,
929
+ role: "status",
930
+ "aria-live": "polite",
931
+ color: theme.colors.content.alert.primary,
932
+ fontSize: FIELD.fontSize - 2,
933
+ style: { lineHeight: `${FIELD.lineHeight}px` },
934
+ children: errorMessage
935
+ }
936
+ )
937
+ }
938
+ )
939
+ ]
940
+ }
941
+ )
942
+ ]
943
+ }
944
+ );
945
+ }
946
+ );
947
+ InputEdit.displayName = "InputEdit";
948
+ // Annotate the CommonJS export names for ESM import in node:
949
+ 0 && (module.exports = {
950
+ InputEdit
951
+ });
952
+ //# sourceMappingURL=index.js.map