funuicss 3.8.9 → 3.8.10
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/css/fun.css +0 -1
- package/package.json +1 -1
- package/ui/carousel/Carousel.d.ts +3 -0
- package/ui/carousel/Carousel.js +140 -16
- package/ui/feature/Feature.d.ts +17 -1
- package/ui/feature/Feature.js +25 -1
- package/ui/form/Form.d.ts +2 -2
- package/ui/form/Form.js +163 -120
- package/ui/input/Input.js +23 -988
- package/ui/notification/Notification.js +6 -2
package/ui/input/Input.js
CHANGED
|
@@ -71,7 +71,7 @@ var statusIcons = {
|
|
|
71
71
|
// Password toggle button component
|
|
72
72
|
var PasswordToggleButton = function (_a) {
|
|
73
73
|
var showPassword = _a.showPassword, onToggle = _a.onToggle, disabled = _a.disabled;
|
|
74
|
-
return (react_1.default.createElement("div", { onClick: onToggle, "aria-label": showPassword ? 'Hide password' : 'Show password', className: 'pointer hover-text-primary' }, showPassword ? react_1.default.createElement(pi_1.PiEyeSlash, null) : react_1.default.createElement(pi_1.PiEye, null)));
|
|
74
|
+
return (react_1.default.createElement("div", { onClick: !disabled ? onToggle : undefined, style: { cursor: disabled ? 'not-allowed' : 'pointer' }, "aria-label": showPassword ? 'Hide password' : 'Show password', className: 'pointer hover-text-primary' }, showPassword ? react_1.default.createElement(pi_1.PiEyeSlash, null) : react_1.default.createElement(pi_1.PiEye, null)));
|
|
75
75
|
};
|
|
76
76
|
// Utility function to generate CSS classes
|
|
77
77
|
var generateInputClasses = function (_a) {
|
|
@@ -144,7 +144,7 @@ var InputContainer = function (_a) {
|
|
|
144
144
|
status && statusIcons[status] && (react_1.default.createElement("span", { className: "helper-icon" }, statusIcons[status])),
|
|
145
145
|
react_1.default.createElement("span", null, helperText)))));
|
|
146
146
|
};
|
|
147
|
-
// Text Input Component
|
|
147
|
+
// Text Input Component - FIXED for space key issue
|
|
148
148
|
var TextInput = function (_a) {
|
|
149
149
|
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onClick = _a.onClick, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onKeyPress = _a.onKeyPress, onSubmit = _a.onSubmit, status = _a.status, funcss = _a.funcss, bg = _a.bg, _b = _a.fullWidth, fullWidth = _b === void 0 ? true : _b, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, startIcon = _a.startIcon, endIcon = _a.endIcon, prefix = _a.prefix, suffix = _a.suffix, stringPrefix = _a.stringPrefix, stringSuffix = _a.stringSuffix, iconicBg = _a.iconicBg, _c = _a.type, type = _c === void 0 ? 'text' : _c, label = _a.label, helperText = _a.helperText, _d = _a.variant, variant = _d === void 0 ? '' : _d, placeholder = _a.placeholder,
|
|
150
150
|
// HTML Input Attributes
|
|
@@ -158,12 +158,10 @@ var TextInput = function (_a) {
|
|
|
158
158
|
var isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
159
159
|
var isPasswordType = type === 'password';
|
|
160
160
|
(0, react_1.useEffect)(function () {
|
|
161
|
-
if (value !== undefined
|
|
161
|
+
if (value !== undefined) {
|
|
162
|
+
// CRITICAL: Preserve all characters including spaces
|
|
162
163
|
setInputValue(String(value));
|
|
163
164
|
}
|
|
164
|
-
else if (value === '') {
|
|
165
|
-
setInputValue('');
|
|
166
|
-
}
|
|
167
165
|
}, [value]);
|
|
168
166
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
169
167
|
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
@@ -243,9 +241,25 @@ var TextInput = function (_a) {
|
|
|
243
241
|
if (onBlur)
|
|
244
242
|
onBlur(e);
|
|
245
243
|
};
|
|
244
|
+
// FIXED: Handle key events properly
|
|
245
|
+
var handleKeyDown = function (e) {
|
|
246
|
+
// DO NOT prevent default for space key
|
|
247
|
+
if (onKeyDown)
|
|
248
|
+
onKeyDown(e);
|
|
249
|
+
};
|
|
250
|
+
var handleKeyUp = function (e) {
|
|
251
|
+
if (onKeyUp)
|
|
252
|
+
onKeyUp(e);
|
|
253
|
+
};
|
|
254
|
+
var handleKeyPress = function (e) {
|
|
255
|
+
// CRITICAL: DO NOT prevent default for any keys
|
|
256
|
+
// This allows space key to work
|
|
257
|
+
if (onKeyPress)
|
|
258
|
+
onKeyPress(e);
|
|
259
|
+
};
|
|
246
260
|
var showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
247
261
|
var inputType = isPasswordType ? (showPassword ? 'text' : 'password') : type;
|
|
248
|
-
var inputElement = (react_1.default.createElement("input", __assign({ ref: inputRef, id: id, name: name, className: className, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onClick: onClick, onKeyDown:
|
|
262
|
+
var inputElement = (react_1.default.createElement("input", __assign({ ref: inputRef, id: id, name: name, className: className, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onClick: onClick, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, onSubmit: onSubmit, defaultValue: defaultValue, type: inputType, placeholder: showPlaceholder ? placeholder : (!label ? placeholder : ''), style: style, value: inputValue,
|
|
249
263
|
// HTML Input Attributes
|
|
250
264
|
disabled: disabled, readOnly: readOnly, required: required, autoFocus: autoFocus, autoComplete: autoComplete, pattern: pattern, minLength: minLength, maxLength: maxLength, min: min, max: max, step: step, multiple: multiple, accept: accept, size: size, form: form, formNoValidate: formNoValidate, formTarget: formTarget, list: list, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, inputMode: inputMode }, rest)));
|
|
251
265
|
// Only use iconic wrapper when we have icons
|
|
@@ -263,12 +277,9 @@ var SelectInput = function (_a) {
|
|
|
263
277
|
var _g = (0, react_1.useState)(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
264
278
|
var _h = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), selectValue = _h[0], setSelectValue = _h[1];
|
|
265
279
|
(0, react_1.useEffect)(function () {
|
|
266
|
-
if (value !== undefined
|
|
280
|
+
if (value !== undefined) {
|
|
267
281
|
setSelectValue(String(value));
|
|
268
282
|
}
|
|
269
|
-
else if (value === '') {
|
|
270
|
-
setSelectValue('');
|
|
271
|
-
}
|
|
272
283
|
}, [value]);
|
|
273
284
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
274
285
|
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
@@ -364,12 +375,9 @@ var TextareaInput = function (_a) {
|
|
|
364
375
|
var _h = (0, react_1.useState)(false), isFocused = _h[0], setIsFocused = _h[1];
|
|
365
376
|
var _j = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), textValue = _j[0], setTextValue = _j[1];
|
|
366
377
|
(0, react_1.useEffect)(function () {
|
|
367
|
-
if (value !== undefined
|
|
378
|
+
if (value !== undefined) {
|
|
368
379
|
setTextValue(String(value));
|
|
369
380
|
}
|
|
370
|
-
else if (value === '') {
|
|
371
|
-
setTextValue('');
|
|
372
|
-
}
|
|
373
381
|
}, [value]);
|
|
374
382
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
375
383
|
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
@@ -482,976 +490,3 @@ var Input = function (_a) {
|
|
|
482
490
|
return react_1.default.createElement(exports.TextInput, __assign({}, finalInputProps));
|
|
483
491
|
};
|
|
484
492
|
exports.default = Input;
|
|
485
|
-
// 'use client'
|
|
486
|
-
// import React, { useState, useEffect, useRef } from 'react';
|
|
487
|
-
// import { PiCheck, PiCloudArrowUp, PiInfo, PiWarning, PiX, PiCheckCircle } from 'react-icons/pi';
|
|
488
|
-
// import Button from '../button/Button';
|
|
489
|
-
// import { useVariant } from '../theme/theme';
|
|
490
|
-
// import { useComponentConfiguration } from '../../utils/componentUtils';
|
|
491
|
-
// import { getDynamicIcon } from '../../utils/getDynamicIcon';
|
|
492
|
-
// import Text from '../text/Text';
|
|
493
|
-
// import { FileUpload } from './FileUpload';
|
|
494
|
-
// // Base types and interfaces
|
|
495
|
-
// interface BaseInputProps {
|
|
496
|
-
// id?: string;
|
|
497
|
-
// name?: string;
|
|
498
|
-
// value?: any;
|
|
499
|
-
// defaultValue?: string;
|
|
500
|
-
// onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
501
|
-
// status?: 'success' | 'warning' | 'danger' | 'info' ;
|
|
502
|
-
// funcss?: string;
|
|
503
|
-
// bg?: string;
|
|
504
|
-
// fullWidth?: boolean;
|
|
505
|
-
// flat?: boolean;
|
|
506
|
-
// bordered?: boolean;
|
|
507
|
-
// borderless?: boolean;
|
|
508
|
-
// rounded?: boolean;
|
|
509
|
-
// leftRounded?: boolean;
|
|
510
|
-
// rightRounded?: boolean;
|
|
511
|
-
// startIcon?: React.ReactNode;
|
|
512
|
-
// endIcon?: React.ReactNode;
|
|
513
|
-
// prefix?: React.ReactNode;
|
|
514
|
-
// suffix?: React.ReactNode;
|
|
515
|
-
// stringPrefix?: string;
|
|
516
|
-
// stringSuffix?: string;
|
|
517
|
-
// iconicBg?: string;
|
|
518
|
-
// variant?: string;
|
|
519
|
-
// label?: string;
|
|
520
|
-
// helperText?: string;
|
|
521
|
-
// }
|
|
522
|
-
// interface SelectOption {
|
|
523
|
-
// value: string;
|
|
524
|
-
// text: string;
|
|
525
|
-
// }
|
|
526
|
-
// interface TextInputProps extends BaseInputProps {
|
|
527
|
-
// type?: string;
|
|
528
|
-
// }
|
|
529
|
-
// interface SelectProps extends BaseInputProps {
|
|
530
|
-
// options?: SelectOption[];
|
|
531
|
-
// }
|
|
532
|
-
// interface TextareaProps extends BaseInputProps {
|
|
533
|
-
// rows?: number;
|
|
534
|
-
// }
|
|
535
|
-
// interface FileInputProps extends BaseInputProps {
|
|
536
|
-
// icon?: React.ReactNode;
|
|
537
|
-
// extra?: React.ReactNode;
|
|
538
|
-
// button?: React.ReactNode;
|
|
539
|
-
// btn?: boolean;
|
|
540
|
-
// }
|
|
541
|
-
// // Status icons mapping
|
|
542
|
-
// const statusIcons = {
|
|
543
|
-
// success: <PiCheckCircle />,
|
|
544
|
-
// warning: <PiWarning />,
|
|
545
|
-
// danger: <PiX />,
|
|
546
|
-
// info: <PiInfo />
|
|
547
|
-
// };
|
|
548
|
-
// // Utility function to generate CSS classes
|
|
549
|
-
// const generateInputClasses = ({
|
|
550
|
-
// status,
|
|
551
|
-
// rounded,
|
|
552
|
-
// bg,
|
|
553
|
-
// funcss,
|
|
554
|
-
// flat,
|
|
555
|
-
// leftRounded,
|
|
556
|
-
// rightRounded,
|
|
557
|
-
// bordered,
|
|
558
|
-
// borderless,
|
|
559
|
-
// additionalClasses = '',
|
|
560
|
-
// hasNoPrefix = false,
|
|
561
|
-
// hasNoLabel = false
|
|
562
|
-
// }: {
|
|
563
|
-
// status?: string;
|
|
564
|
-
// rounded?: boolean;
|
|
565
|
-
// bg?: string;
|
|
566
|
-
// funcss?: string;
|
|
567
|
-
// flat?: boolean;
|
|
568
|
-
// leftRounded?: boolean;
|
|
569
|
-
// rightRounded?: boolean;
|
|
570
|
-
// bordered?: boolean;
|
|
571
|
-
// borderless?: boolean;
|
|
572
|
-
// additionalClasses?: string;
|
|
573
|
-
// hasNoPrefix?: boolean;
|
|
574
|
-
// hasNoLabel?: boolean;
|
|
575
|
-
// }) => {
|
|
576
|
-
// const statusClass = status ? `${status}-input` : '';
|
|
577
|
-
// const roundedClass = rounded ? 'rounded' : '';
|
|
578
|
-
// const bgClass = bg || '';
|
|
579
|
-
// const flatClass = flat ? 'flat' : '';
|
|
580
|
-
// const cornerClass = leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '';
|
|
581
|
-
// const borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : (!bordered && !borderless ? 'borderedInput' : '');
|
|
582
|
-
// const noPrefixClass = hasNoPrefix ? 'no_prefix' : '';
|
|
583
|
-
// const noLabelClass = hasNoLabel ? 'no_label' : '';
|
|
584
|
-
// return `
|
|
585
|
-
// ${statusClass}
|
|
586
|
-
// ${roundedClass}
|
|
587
|
-
// ${bgClass}
|
|
588
|
-
// ${funcss || ''}
|
|
589
|
-
// ${flatClass}
|
|
590
|
-
// ${cornerClass}
|
|
591
|
-
// ${borderClass}
|
|
592
|
-
// ${additionalClasses}
|
|
593
|
-
// ${noPrefixClass}
|
|
594
|
-
// ${noLabelClass}
|
|
595
|
-
// input
|
|
596
|
-
// `.trim().replace(/\s+/g, ' ');
|
|
597
|
-
// };
|
|
598
|
-
// // Iconic Input Wrapper Component - UPDATED to match Button's pattern
|
|
599
|
-
// const IconicInputWrapper: React.FC<{
|
|
600
|
-
// startIcon?: React.ReactNode;
|
|
601
|
-
// endIcon?: React.ReactNode;
|
|
602
|
-
// prefix?: React.ReactNode;
|
|
603
|
-
// suffix?: React.ReactNode;
|
|
604
|
-
// iconicBg?: string;
|
|
605
|
-
// funcss?: string;
|
|
606
|
-
// stringPrefix?: string;
|
|
607
|
-
// stringSuffix?: string;
|
|
608
|
-
// children: React.ReactNode;
|
|
609
|
-
// }> = ({
|
|
610
|
-
// startIcon,
|
|
611
|
-
// endIcon,
|
|
612
|
-
// prefix,
|
|
613
|
-
// suffix,
|
|
614
|
-
// iconicBg,
|
|
615
|
-
// funcss,
|
|
616
|
-
// stringPrefix,
|
|
617
|
-
// stringSuffix,
|
|
618
|
-
// children
|
|
619
|
-
// }) => {
|
|
620
|
-
// // Match Button's pattern exactly - use proper priority
|
|
621
|
-
// const effectiveStartIcon = startIcon !== undefined ? startIcon : prefix;
|
|
622
|
-
// const effectiveEndIcon = endIcon !== undefined ? endIcon : suffix;
|
|
623
|
-
// // Determine which icons to show - MATCH BUTTON'S PATTERN EXACTLY
|
|
624
|
-
// const showPrefix = effectiveStartIcon !== undefined && effectiveStartIcon !== null;
|
|
625
|
-
// const showSuffix = effectiveEndIcon !== undefined && effectiveEndIcon !== null;
|
|
626
|
-
// if (!showPrefix && !showSuffix) {
|
|
627
|
-
// return <>{children}</>;
|
|
628
|
-
// }
|
|
629
|
-
// // Helper function to check if element is a React element
|
|
630
|
-
// function isReactElement(node: any): node is React.ReactElement {
|
|
631
|
-
// return React.isValidElement(node);
|
|
632
|
-
// }
|
|
633
|
-
// return (
|
|
634
|
-
// <div className={`icon-container ${showPrefix ? 'has-left-icon' : ''} ${funcss || ''}`}>
|
|
635
|
-
// {/* LEFT ICON - Match Button's exact conditional pattern */}
|
|
636
|
-
// {showPrefix && (
|
|
637
|
-
// <div
|
|
638
|
-
// className="leftIcon"
|
|
639
|
-
// style={{
|
|
640
|
-
// backgroundColor: iconicBg || '',
|
|
641
|
-
// border: iconicBg ? `0.1rem ${iconicBg} solid` : '',
|
|
642
|
-
// }}
|
|
643
|
-
// >
|
|
644
|
-
// {isReactElement(startIcon) ? startIcon
|
|
645
|
-
// : isReactElement(prefix) ? prefix
|
|
646
|
-
// : isReactElement(effectiveStartIcon) ? effectiveStartIcon
|
|
647
|
-
// : stringPrefix ? effectiveStartIcon : ''
|
|
648
|
-
// }
|
|
649
|
-
// </div>
|
|
650
|
-
// )}
|
|
651
|
-
// {children}
|
|
652
|
-
// {/* RIGHT ICON - Match Button's exact conditional pattern */}
|
|
653
|
-
// {showSuffix && (
|
|
654
|
-
// <div className="rightIcon" style={{ backgroundColor: iconicBg || '' }}>
|
|
655
|
-
// {isReactElement(endIcon) ? endIcon
|
|
656
|
-
// : isReactElement(suffix) ? suffix
|
|
657
|
-
// : isReactElement(effectiveEndIcon) ? effectiveEndIcon
|
|
658
|
-
// : stringSuffix ? effectiveEndIcon : ""
|
|
659
|
-
// }
|
|
660
|
-
// </div>
|
|
661
|
-
// )}
|
|
662
|
-
// </div>
|
|
663
|
-
// );
|
|
664
|
-
// };
|
|
665
|
-
// // Input Container with Floating Label
|
|
666
|
-
// const InputContainer: React.FC<{
|
|
667
|
-
// label?: string;
|
|
668
|
-
// status?: string;
|
|
669
|
-
// helperText?: string;
|
|
670
|
-
// children: React.ReactNode;
|
|
671
|
-
// isFocused: boolean;
|
|
672
|
-
// hasValue: boolean;
|
|
673
|
-
// fullWidth?: boolean;
|
|
674
|
-
// id?: string;
|
|
675
|
-
// startIcon?: React.ReactNode;
|
|
676
|
-
// prefix?: React.ReactNode;
|
|
677
|
-
// alwaysActiveLabel?: boolean;
|
|
678
|
-
// }> = ({ label, status, helperText, children, isFocused, hasValue, fullWidth, id, startIcon, prefix, alwaysActiveLabel = false }) => {
|
|
679
|
-
// const showFloatingLabel = label && (alwaysActiveLabel || isFocused || hasValue);
|
|
680
|
-
// return (
|
|
681
|
-
// <div className={`input-wrapper ${fullWidth ? 'full-width' : ''}`}>
|
|
682
|
-
// <div className="input-container-with-label">
|
|
683
|
-
// {label && (
|
|
684
|
-
// <label
|
|
685
|
-
// htmlFor={id}
|
|
686
|
-
// className={`floating-label ${startIcon || prefix ? "label-left" : ""} ${showFloatingLabel ? 'active' : ''} ${status ? `label-${status}` : ''}`}
|
|
687
|
-
// >
|
|
688
|
-
// {label}
|
|
689
|
-
// </label>
|
|
690
|
-
// )}
|
|
691
|
-
// {children}
|
|
692
|
-
// </div>
|
|
693
|
-
// {(helperText || status) && (
|
|
694
|
-
// <div className={`input-helper-text ${status ? `helper-${status}` : ''}`}>
|
|
695
|
-
// {status && statusIcons[status as keyof typeof statusIcons] && (
|
|
696
|
-
// <span className="helper-icon">{statusIcons[status as keyof typeof statusIcons]}</span>
|
|
697
|
-
// )}
|
|
698
|
-
// <span>{helperText}</span>
|
|
699
|
-
// </div>
|
|
700
|
-
// )}
|
|
701
|
-
// </div>
|
|
702
|
-
// );
|
|
703
|
-
// };
|
|
704
|
-
// // Text Input Component
|
|
705
|
-
// export const TextInput: React.FC<TextInputProps & React.InputHTMLAttributes<HTMLInputElement>> = ({
|
|
706
|
-
// id,
|
|
707
|
-
// name,
|
|
708
|
-
// value,
|
|
709
|
-
// defaultValue,
|
|
710
|
-
// onChange,
|
|
711
|
-
// status,
|
|
712
|
-
// funcss,
|
|
713
|
-
// bg,
|
|
714
|
-
// fullWidth = true,
|
|
715
|
-
// flat,
|
|
716
|
-
// bordered,
|
|
717
|
-
// borderless,
|
|
718
|
-
// rounded,
|
|
719
|
-
// leftRounded,
|
|
720
|
-
// rightRounded,
|
|
721
|
-
// startIcon,
|
|
722
|
-
// endIcon,
|
|
723
|
-
// prefix,
|
|
724
|
-
// suffix,
|
|
725
|
-
// stringPrefix,
|
|
726
|
-
// stringSuffix,
|
|
727
|
-
// iconicBg,
|
|
728
|
-
// type = 'text',
|
|
729
|
-
// label,
|
|
730
|
-
// helperText,
|
|
731
|
-
// variant = '',
|
|
732
|
-
// placeholder,
|
|
733
|
-
// ...rest
|
|
734
|
-
// }) => {
|
|
735
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
736
|
-
// const [inputValue, setInputValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
737
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
738
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
739
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
740
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
741
|
-
// const inputRef = useRef<HTMLInputElement>(null);
|
|
742
|
-
// const isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
743
|
-
// useEffect(() => {
|
|
744
|
-
// if (value !== undefined && value !== '') {
|
|
745
|
-
// setInputValue(String(value));
|
|
746
|
-
// } else if (value === '') {
|
|
747
|
-
// setInputValue('');
|
|
748
|
-
// }
|
|
749
|
-
// }, [value]);
|
|
750
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
751
|
-
// const localProps = {
|
|
752
|
-
// status,
|
|
753
|
-
// funcss,
|
|
754
|
-
// bg,
|
|
755
|
-
// fullWidth,
|
|
756
|
-
// flat,
|
|
757
|
-
// bordered,
|
|
758
|
-
// borderless,
|
|
759
|
-
// rounded,
|
|
760
|
-
// leftRounded,
|
|
761
|
-
// rightRounded,
|
|
762
|
-
// startIcon,
|
|
763
|
-
// endIcon,
|
|
764
|
-
// prefix,
|
|
765
|
-
// suffix,
|
|
766
|
-
// iconicBg,
|
|
767
|
-
// stringPrefix,
|
|
768
|
-
// stringSuffix,
|
|
769
|
-
// };
|
|
770
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
771
|
-
// const final = {
|
|
772
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
773
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
774
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
775
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
776
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
777
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
778
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
779
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
780
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
781
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
782
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
783
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
784
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
785
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
786
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
787
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
788
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
789
|
-
// };
|
|
790
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
791
|
-
// useEffect(() => {
|
|
792
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
793
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
794
|
-
// setPrefixNode(null);
|
|
795
|
-
// setHasValidStringPrefix(false);
|
|
796
|
-
// return;
|
|
797
|
-
// }
|
|
798
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
799
|
-
// if (node) {
|
|
800
|
-
// setPrefixNode(node);
|
|
801
|
-
// setHasValidStringPrefix(true);
|
|
802
|
-
// } else {
|
|
803
|
-
// setPrefixNode(null);
|
|
804
|
-
// setHasValidStringPrefix(false);
|
|
805
|
-
// }
|
|
806
|
-
// });
|
|
807
|
-
// }, [final.stringPrefix]);
|
|
808
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
809
|
-
// useEffect(() => {
|
|
810
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
811
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
812
|
-
// setSuffixNode(null);
|
|
813
|
-
// setHasValidStringSuffix(false);
|
|
814
|
-
// return;
|
|
815
|
-
// }
|
|
816
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
817
|
-
// if (node) {
|
|
818
|
-
// setSuffixNode(node);
|
|
819
|
-
// setHasValidStringSuffix(true);
|
|
820
|
-
// } else {
|
|
821
|
-
// setSuffixNode(null);
|
|
822
|
-
// setHasValidStringSuffix(false);
|
|
823
|
-
// }
|
|
824
|
-
// });
|
|
825
|
-
// }, [final.stringSuffix]);
|
|
826
|
-
// const { variant: themeVariant } = useVariant();
|
|
827
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
828
|
-
// const showPrefix = React.useMemo(() => {
|
|
829
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
830
|
-
// if (final.startIcon) return true;
|
|
831
|
-
// if (final.prefix) return true;
|
|
832
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
833
|
-
// return false;
|
|
834
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
835
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
836
|
-
// const showSuffix = React.useMemo(() => {
|
|
837
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
838
|
-
// if (final.endIcon) return true;
|
|
839
|
-
// if (final.suffix) return true;
|
|
840
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
841
|
-
// return false;
|
|
842
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
843
|
-
// // Get effective icons following Button's priority pattern
|
|
844
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
845
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
846
|
-
// if (final.startIcon) return final.startIcon;
|
|
847
|
-
// if (final.prefix) return final.prefix;
|
|
848
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
849
|
-
// return null;
|
|
850
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
851
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
852
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
853
|
-
// if (final.endIcon) return final.endIcon;
|
|
854
|
-
// if (final.suffix) return final.suffix;
|
|
855
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
856
|
-
// return null;
|
|
857
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
858
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
859
|
-
// const hasNoLabel = !label;
|
|
860
|
-
// const className = generateInputClasses({
|
|
861
|
-
// status: final.status,
|
|
862
|
-
// rounded: final.rounded,
|
|
863
|
-
// bg: final.bg,
|
|
864
|
-
// funcss: final.funcss,
|
|
865
|
-
// flat: final.flat,
|
|
866
|
-
// leftRounded: final.leftRounded,
|
|
867
|
-
// rightRounded: final.rightRounded,
|
|
868
|
-
// bordered: final.bordered,
|
|
869
|
-
// borderless: final.borderless,
|
|
870
|
-
// hasNoPrefix,
|
|
871
|
-
// hasNoLabel,
|
|
872
|
-
// });
|
|
873
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
874
|
-
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
875
|
-
// const newValue = e.target.value;
|
|
876
|
-
// setInputValue(newValue);
|
|
877
|
-
// if (onChange) onChange(e);
|
|
878
|
-
// };
|
|
879
|
-
// const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
880
|
-
// setIsFocused(true);
|
|
881
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
882
|
-
// };
|
|
883
|
-
// const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
884
|
-
// setIsFocused(false);
|
|
885
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
886
|
-
// };
|
|
887
|
-
// const showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
888
|
-
// const inputElement = (
|
|
889
|
-
// <input
|
|
890
|
-
// ref={inputRef}
|
|
891
|
-
// id={id}
|
|
892
|
-
// name={name}
|
|
893
|
-
// className={className}
|
|
894
|
-
// onChange={handleChange}
|
|
895
|
-
// onFocus={handleFocus}
|
|
896
|
-
// onBlur={handleBlur}
|
|
897
|
-
// defaultValue={defaultValue}
|
|
898
|
-
// type={type}
|
|
899
|
-
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
900
|
-
// style={style}
|
|
901
|
-
// value={inputValue}
|
|
902
|
-
// {...rest}
|
|
903
|
-
// />
|
|
904
|
-
// );
|
|
905
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
906
|
-
// const wrappedInput = showPrefix || showSuffix ? (
|
|
907
|
-
// <IconicInputWrapper
|
|
908
|
-
// startIcon={effectivePrefix}
|
|
909
|
-
// endIcon={effectiveSuffix}
|
|
910
|
-
// iconicBg={final.iconicBg}
|
|
911
|
-
// funcss={final.funcss}
|
|
912
|
-
// stringPrefix={stringPrefix}
|
|
913
|
-
// stringSuffix={stringSuffix}
|
|
914
|
-
// >
|
|
915
|
-
// {inputElement}
|
|
916
|
-
// </IconicInputWrapper>
|
|
917
|
-
// ) : (
|
|
918
|
-
// inputElement
|
|
919
|
-
// );
|
|
920
|
-
// return (
|
|
921
|
-
// <InputContainer
|
|
922
|
-
// startIcon={effectivePrefix}
|
|
923
|
-
// label={label}
|
|
924
|
-
// status={final.status}
|
|
925
|
-
// helperText={helperText}
|
|
926
|
-
// isFocused={isFocused}
|
|
927
|
-
// hasValue={!!inputValue}
|
|
928
|
-
// fullWidth={final.fullWidth}
|
|
929
|
-
// id={id}
|
|
930
|
-
// alwaysActiveLabel={isDateTimeInput}
|
|
931
|
-
// >
|
|
932
|
-
// {wrappedInput}
|
|
933
|
-
// </InputContainer>
|
|
934
|
-
// );
|
|
935
|
-
// };
|
|
936
|
-
// // Select Component - UPDATED to match pattern
|
|
937
|
-
// export const SelectInput: React.FC<SelectProps & React.SelectHTMLAttributes<HTMLSelectElement>> = ({
|
|
938
|
-
// id,
|
|
939
|
-
// name,
|
|
940
|
-
// value,
|
|
941
|
-
// defaultValue,
|
|
942
|
-
// onChange,
|
|
943
|
-
// status,
|
|
944
|
-
// funcss,
|
|
945
|
-
// bg,
|
|
946
|
-
// fullWidth,
|
|
947
|
-
// flat,
|
|
948
|
-
// bordered,
|
|
949
|
-
// borderless,
|
|
950
|
-
// rounded,
|
|
951
|
-
// leftRounded,
|
|
952
|
-
// rightRounded,
|
|
953
|
-
// startIcon,
|
|
954
|
-
// endIcon,
|
|
955
|
-
// prefix,
|
|
956
|
-
// suffix,
|
|
957
|
-
// stringPrefix,
|
|
958
|
-
// stringSuffix,
|
|
959
|
-
// iconicBg,
|
|
960
|
-
// options = [],
|
|
961
|
-
// label,
|
|
962
|
-
// helperText,
|
|
963
|
-
// variant = '',
|
|
964
|
-
// ...rest
|
|
965
|
-
// }) => {
|
|
966
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
967
|
-
// const [selectValue, setSelectValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
968
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
969
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
970
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
971
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
972
|
-
// useEffect(() => {
|
|
973
|
-
// if (value !== undefined && value !== '') {
|
|
974
|
-
// setSelectValue(String(value));
|
|
975
|
-
// } else if (value === '') {
|
|
976
|
-
// setSelectValue('');
|
|
977
|
-
// }
|
|
978
|
-
// }, [value]);
|
|
979
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
980
|
-
// const localProps = {
|
|
981
|
-
// status,
|
|
982
|
-
// funcss,
|
|
983
|
-
// bg,
|
|
984
|
-
// fullWidth,
|
|
985
|
-
// flat,
|
|
986
|
-
// bordered,
|
|
987
|
-
// borderless,
|
|
988
|
-
// rounded,
|
|
989
|
-
// leftRounded,
|
|
990
|
-
// rightRounded,
|
|
991
|
-
// startIcon,
|
|
992
|
-
// endIcon,
|
|
993
|
-
// prefix,
|
|
994
|
-
// suffix,
|
|
995
|
-
// iconicBg,
|
|
996
|
-
// stringPrefix,
|
|
997
|
-
// stringSuffix,
|
|
998
|
-
// };
|
|
999
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1000
|
-
// const final = {
|
|
1001
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
1002
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1003
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1004
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1005
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1006
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1007
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1008
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1009
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1010
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1011
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1012
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1013
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1014
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1015
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1016
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1017
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1018
|
-
// };
|
|
1019
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1020
|
-
// useEffect(() => {
|
|
1021
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
1022
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1023
|
-
// setPrefixNode(null);
|
|
1024
|
-
// setHasValidStringPrefix(false);
|
|
1025
|
-
// return;
|
|
1026
|
-
// }
|
|
1027
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1028
|
-
// if (node) {
|
|
1029
|
-
// setPrefixNode(node);
|
|
1030
|
-
// setHasValidStringPrefix(true);
|
|
1031
|
-
// } else {
|
|
1032
|
-
// setPrefixNode(null);
|
|
1033
|
-
// setHasValidStringPrefix(false);
|
|
1034
|
-
// }
|
|
1035
|
-
// });
|
|
1036
|
-
// }, [final.stringPrefix]);
|
|
1037
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1038
|
-
// useEffect(() => {
|
|
1039
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
1040
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1041
|
-
// setSuffixNode(null);
|
|
1042
|
-
// setHasValidStringSuffix(false);
|
|
1043
|
-
// return;
|
|
1044
|
-
// }
|
|
1045
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1046
|
-
// if (node) {
|
|
1047
|
-
// setSuffixNode(node);
|
|
1048
|
-
// setHasValidStringSuffix(true);
|
|
1049
|
-
// } else {
|
|
1050
|
-
// setSuffixNode(null);
|
|
1051
|
-
// setHasValidStringSuffix(false);
|
|
1052
|
-
// }
|
|
1053
|
-
// });
|
|
1054
|
-
// }, [final.stringSuffix]);
|
|
1055
|
-
// const selectHasValue = !!selectValue;
|
|
1056
|
-
// const { variant: themeVariant } = useVariant();
|
|
1057
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1058
|
-
// const showPrefix = React.useMemo(() => {
|
|
1059
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1060
|
-
// if (final.startIcon) return true;
|
|
1061
|
-
// if (final.prefix) return true;
|
|
1062
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1063
|
-
// return false;
|
|
1064
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1065
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1066
|
-
// const showSuffix = React.useMemo(() => {
|
|
1067
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1068
|
-
// if (final.endIcon) return true;
|
|
1069
|
-
// if (final.suffix) return true;
|
|
1070
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1071
|
-
// return false;
|
|
1072
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1073
|
-
// // Get effective icons following Button's priority pattern
|
|
1074
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
1075
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
1076
|
-
// if (final.startIcon) return final.startIcon;
|
|
1077
|
-
// if (final.prefix) return final.prefix;
|
|
1078
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
1079
|
-
// return null;
|
|
1080
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1081
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
1082
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
1083
|
-
// if (final.endIcon) return final.endIcon;
|
|
1084
|
-
// if (final.suffix) return final.suffix;
|
|
1085
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
1086
|
-
// return null;
|
|
1087
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1088
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
1089
|
-
// const hasNoLabel = !label;
|
|
1090
|
-
// const className = generateInputClasses({
|
|
1091
|
-
// status: final.status,
|
|
1092
|
-
// rounded: final.rounded,
|
|
1093
|
-
// bg: final.bg,
|
|
1094
|
-
// funcss: final.funcss,
|
|
1095
|
-
// flat: final.flat,
|
|
1096
|
-
// leftRounded: final.leftRounded,
|
|
1097
|
-
// rightRounded: final.rightRounded,
|
|
1098
|
-
// bordered: final.bordered,
|
|
1099
|
-
// borderless: final.borderless,
|
|
1100
|
-
// hasNoPrefix,
|
|
1101
|
-
// hasNoLabel,
|
|
1102
|
-
// });
|
|
1103
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1104
|
-
// const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
1105
|
-
// const newValue = e.target.value;
|
|
1106
|
-
// setSelectValue(newValue);
|
|
1107
|
-
// if (onChange) onChange(e);
|
|
1108
|
-
// };
|
|
1109
|
-
// const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1110
|
-
// setIsFocused(true);
|
|
1111
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
1112
|
-
// };
|
|
1113
|
-
// const handleBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1114
|
-
// setIsFocused(false);
|
|
1115
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
1116
|
-
// };
|
|
1117
|
-
// const selectElement = (
|
|
1118
|
-
// <select
|
|
1119
|
-
// id={id}
|
|
1120
|
-
// name={name}
|
|
1121
|
-
// className={className}
|
|
1122
|
-
// onChange={handleChange}
|
|
1123
|
-
// onFocus={handleFocus}
|
|
1124
|
-
// onBlur={handleBlur}
|
|
1125
|
-
// defaultValue={defaultValue}
|
|
1126
|
-
// value={selectValue}
|
|
1127
|
-
// style={style}
|
|
1128
|
-
// {...rest}
|
|
1129
|
-
// >
|
|
1130
|
-
// {options.map((option) => (
|
|
1131
|
-
// <option key={option.value} value={option.value}>
|
|
1132
|
-
// {option.text}
|
|
1133
|
-
// </option>
|
|
1134
|
-
// ))}
|
|
1135
|
-
// </select>
|
|
1136
|
-
// );
|
|
1137
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1138
|
-
// const wrappedSelect = showPrefix || showSuffix ? (
|
|
1139
|
-
// <IconicInputWrapper
|
|
1140
|
-
// startIcon={effectivePrefix}
|
|
1141
|
-
// endIcon={effectiveSuffix}
|
|
1142
|
-
// iconicBg={final.iconicBg}
|
|
1143
|
-
// funcss={final.funcss}
|
|
1144
|
-
// stringPrefix={stringPrefix}
|
|
1145
|
-
// stringSuffix={stringSuffix}
|
|
1146
|
-
// >
|
|
1147
|
-
// {selectElement}
|
|
1148
|
-
// </IconicInputWrapper>
|
|
1149
|
-
// ) : (
|
|
1150
|
-
// selectElement
|
|
1151
|
-
// );
|
|
1152
|
-
// return (
|
|
1153
|
-
// <InputContainer
|
|
1154
|
-
// startIcon={effectivePrefix}
|
|
1155
|
-
// label={label}
|
|
1156
|
-
// status={final.status}
|
|
1157
|
-
// helperText={helperText}
|
|
1158
|
-
// isFocused={isFocused}
|
|
1159
|
-
// hasValue={selectHasValue}
|
|
1160
|
-
// fullWidth={final.fullWidth}
|
|
1161
|
-
// id={id}
|
|
1162
|
-
// alwaysActiveLabel={true}
|
|
1163
|
-
// >
|
|
1164
|
-
// {wrappedSelect}
|
|
1165
|
-
// </InputContainer>
|
|
1166
|
-
// );
|
|
1167
|
-
// };
|
|
1168
|
-
// // Textarea Component - UPDATED to match pattern
|
|
1169
|
-
// export const TextareaInput: React.FC<TextareaProps & React.TextareaHTMLAttributes<HTMLTextAreaElement>> = ({
|
|
1170
|
-
// id,
|
|
1171
|
-
// name,
|
|
1172
|
-
// value,
|
|
1173
|
-
// defaultValue,
|
|
1174
|
-
// onChange,
|
|
1175
|
-
// status,
|
|
1176
|
-
// funcss,
|
|
1177
|
-
// bg,
|
|
1178
|
-
// fullWidth,
|
|
1179
|
-
// flat,
|
|
1180
|
-
// bordered,
|
|
1181
|
-
// borderless,
|
|
1182
|
-
// rounded,
|
|
1183
|
-
// leftRounded,
|
|
1184
|
-
// rightRounded,
|
|
1185
|
-
// startIcon,
|
|
1186
|
-
// endIcon,
|
|
1187
|
-
// prefix,
|
|
1188
|
-
// suffix,
|
|
1189
|
-
// stringPrefix,
|
|
1190
|
-
// stringSuffix,
|
|
1191
|
-
// iconicBg,
|
|
1192
|
-
// label,
|
|
1193
|
-
// helperText,
|
|
1194
|
-
// rows = 2,
|
|
1195
|
-
// variant = '',
|
|
1196
|
-
// placeholder,
|
|
1197
|
-
// ...rest
|
|
1198
|
-
// }) => {
|
|
1199
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
1200
|
-
// const [textValue, setTextValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
1201
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
1202
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
1203
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
1204
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
1205
|
-
// useEffect(() => {
|
|
1206
|
-
// if (value !== undefined && value !== '') {
|
|
1207
|
-
// setTextValue(String(value));
|
|
1208
|
-
// } else if (value === '') {
|
|
1209
|
-
// setTextValue('');
|
|
1210
|
-
// }
|
|
1211
|
-
// }, [value]);
|
|
1212
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1213
|
-
// const localProps = {
|
|
1214
|
-
// status,
|
|
1215
|
-
// funcss,
|
|
1216
|
-
// bg,
|
|
1217
|
-
// fullWidth,
|
|
1218
|
-
// flat,
|
|
1219
|
-
// bordered,
|
|
1220
|
-
// borderless,
|
|
1221
|
-
// rounded,
|
|
1222
|
-
// leftRounded,
|
|
1223
|
-
// rightRounded,
|
|
1224
|
-
// startIcon,
|
|
1225
|
-
// endIcon,
|
|
1226
|
-
// prefix,
|
|
1227
|
-
// suffix,
|
|
1228
|
-
// iconicBg,
|
|
1229
|
-
// stringPrefix,
|
|
1230
|
-
// stringSuffix,
|
|
1231
|
-
// };
|
|
1232
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1233
|
-
// const final = {
|
|
1234
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
1235
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1236
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1237
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1238
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1239
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1240
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1241
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1242
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1243
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1244
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1245
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1246
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1247
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1248
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1249
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1250
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1251
|
-
// };
|
|
1252
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1253
|
-
// useEffect(() => {
|
|
1254
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
1255
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1256
|
-
// setPrefixNode(null);
|
|
1257
|
-
// setHasValidStringPrefix(false);
|
|
1258
|
-
// return;
|
|
1259
|
-
// }
|
|
1260
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1261
|
-
// if (node) {
|
|
1262
|
-
// setPrefixNode(node);
|
|
1263
|
-
// setHasValidStringPrefix(true);
|
|
1264
|
-
// } else {
|
|
1265
|
-
// setPrefixNode(null);
|
|
1266
|
-
// setHasValidStringPrefix(false);
|
|
1267
|
-
// }
|
|
1268
|
-
// });
|
|
1269
|
-
// }, [final.stringPrefix]);
|
|
1270
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1271
|
-
// useEffect(() => {
|
|
1272
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
1273
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1274
|
-
// setSuffixNode(null);
|
|
1275
|
-
// setHasValidStringSuffix(false);
|
|
1276
|
-
// return;
|
|
1277
|
-
// }
|
|
1278
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1279
|
-
// if (node) {
|
|
1280
|
-
// setSuffixNode(node);
|
|
1281
|
-
// setHasValidStringSuffix(true);
|
|
1282
|
-
// } else {
|
|
1283
|
-
// setSuffixNode(null);
|
|
1284
|
-
// setHasValidStringSuffix(false);
|
|
1285
|
-
// }
|
|
1286
|
-
// });
|
|
1287
|
-
// }, [final.stringSuffix]);
|
|
1288
|
-
// const { variant: themeVariant } = useVariant();
|
|
1289
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1290
|
-
// const showPrefix = React.useMemo(() => {
|
|
1291
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1292
|
-
// if (final.startIcon) return true;
|
|
1293
|
-
// if (final.prefix) return true;
|
|
1294
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1295
|
-
// return false;
|
|
1296
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1297
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1298
|
-
// const showSuffix = React.useMemo(() => {
|
|
1299
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1300
|
-
// if (final.endIcon) return true;
|
|
1301
|
-
// if (final.suffix) return true;
|
|
1302
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1303
|
-
// return false;
|
|
1304
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1305
|
-
// // Get effective icons following Button's priority pattern
|
|
1306
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
1307
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
1308
|
-
// if (final.startIcon) return final.startIcon;
|
|
1309
|
-
// if (final.prefix) return final.prefix;
|
|
1310
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
1311
|
-
// return null;
|
|
1312
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1313
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
1314
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
1315
|
-
// if (final.endIcon) return final.endIcon;
|
|
1316
|
-
// if (final.suffix) return final.suffix;
|
|
1317
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
1318
|
-
// return null;
|
|
1319
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1320
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
1321
|
-
// const hasNoLabel = !label;
|
|
1322
|
-
// const className = generateInputClasses({
|
|
1323
|
-
// status: final.status,
|
|
1324
|
-
// rounded: final.rounded,
|
|
1325
|
-
// bg: final.bg,
|
|
1326
|
-
// funcss: final.funcss,
|
|
1327
|
-
// flat: final.flat,
|
|
1328
|
-
// leftRounded: final.leftRounded,
|
|
1329
|
-
// rightRounded: final.rightRounded,
|
|
1330
|
-
// bordered: final.bordered,
|
|
1331
|
-
// borderless: final.borderless,
|
|
1332
|
-
// hasNoPrefix,
|
|
1333
|
-
// hasNoLabel,
|
|
1334
|
-
// });
|
|
1335
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1336
|
-
// const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
1337
|
-
// const newValue = e.target.value;
|
|
1338
|
-
// setTextValue(newValue);
|
|
1339
|
-
// if (onChange) onChange(e);
|
|
1340
|
-
// };
|
|
1341
|
-
// const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1342
|
-
// setIsFocused(true);
|
|
1343
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
1344
|
-
// };
|
|
1345
|
-
// const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1346
|
-
// setIsFocused(false);
|
|
1347
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
1348
|
-
// };
|
|
1349
|
-
// const showPlaceholder = placeholder && label && (isFocused || !!textValue);
|
|
1350
|
-
// const textareaElement = (
|
|
1351
|
-
// <textarea
|
|
1352
|
-
// id={id}
|
|
1353
|
-
// name={name}
|
|
1354
|
-
// className={className}
|
|
1355
|
-
// onChange={handleChange}
|
|
1356
|
-
// onFocus={handleFocus}
|
|
1357
|
-
// onBlur={handleBlur}
|
|
1358
|
-
// defaultValue={defaultValue}
|
|
1359
|
-
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
1360
|
-
// style={style}
|
|
1361
|
-
// value={textValue}
|
|
1362
|
-
// rows={rows}
|
|
1363
|
-
// {...rest}
|
|
1364
|
-
// />
|
|
1365
|
-
// );
|
|
1366
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1367
|
-
// const wrappedTextarea = showPrefix || showSuffix ? (
|
|
1368
|
-
// <IconicInputWrapper
|
|
1369
|
-
// startIcon={effectivePrefix}
|
|
1370
|
-
// endIcon={effectiveSuffix}
|
|
1371
|
-
// iconicBg={final.iconicBg}
|
|
1372
|
-
// funcss={final.funcss}
|
|
1373
|
-
// stringPrefix={stringPrefix}
|
|
1374
|
-
// stringSuffix={stringSuffix}
|
|
1375
|
-
// >
|
|
1376
|
-
// {textareaElement}
|
|
1377
|
-
// </IconicInputWrapper>
|
|
1378
|
-
// ) : (
|
|
1379
|
-
// textareaElement
|
|
1380
|
-
// );
|
|
1381
|
-
// return (
|
|
1382
|
-
// <InputContainer
|
|
1383
|
-
// startIcon={effectivePrefix}
|
|
1384
|
-
// label={label}
|
|
1385
|
-
// status={final.status}
|
|
1386
|
-
// helperText={helperText}
|
|
1387
|
-
// isFocused={isFocused}
|
|
1388
|
-
// hasValue={!!textValue}
|
|
1389
|
-
// fullWidth={final.fullWidth}
|
|
1390
|
-
// id={id}
|
|
1391
|
-
// >
|
|
1392
|
-
// {wrappedTextarea}
|
|
1393
|
-
// </InputContainer>
|
|
1394
|
-
// );
|
|
1395
|
-
// };
|
|
1396
|
-
// // Main Input Component (backwards compatibility)
|
|
1397
|
-
// interface InputProps extends BaseInputProps {
|
|
1398
|
-
// select?: boolean;
|
|
1399
|
-
// multiline?: boolean;
|
|
1400
|
-
// file?: boolean;
|
|
1401
|
-
// noBorder?: boolean;
|
|
1402
|
-
// icon?: React.ReactNode;
|
|
1403
|
-
// extra?: React.ReactNode;
|
|
1404
|
-
// button?: React.ReactNode;
|
|
1405
|
-
// btn?: boolean;
|
|
1406
|
-
// type?: string;
|
|
1407
|
-
// options?: SelectOption[];
|
|
1408
|
-
// rows?: number;
|
|
1409
|
-
// }
|
|
1410
|
-
// const Input: React.FC<InputProps> = ({
|
|
1411
|
-
// select,
|
|
1412
|
-
// multiline,
|
|
1413
|
-
// file,
|
|
1414
|
-
// noBorder,
|
|
1415
|
-
// startIcon,
|
|
1416
|
-
// endIcon,
|
|
1417
|
-
// prefix,
|
|
1418
|
-
// suffix,
|
|
1419
|
-
// stringPrefix,
|
|
1420
|
-
// stringSuffix,
|
|
1421
|
-
// iconicBg,
|
|
1422
|
-
// type,
|
|
1423
|
-
// variant = '',
|
|
1424
|
-
// ...props
|
|
1425
|
-
// }) => {
|
|
1426
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1427
|
-
// const localProps = {
|
|
1428
|
-
// ...props,
|
|
1429
|
-
// startIcon,
|
|
1430
|
-
// endIcon,
|
|
1431
|
-
// prefix,
|
|
1432
|
-
// suffix,
|
|
1433
|
-
// iconicBg,
|
|
1434
|
-
// stringPrefix,
|
|
1435
|
-
// stringSuffix,
|
|
1436
|
-
// type,
|
|
1437
|
-
// };
|
|
1438
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1439
|
-
// const inputProps = {
|
|
1440
|
-
// ...props,
|
|
1441
|
-
// ...mergedProps,
|
|
1442
|
-
// variant,
|
|
1443
|
-
// borderless: noBorder !== undefined ? noBorder : (props.borderless !== undefined ? props.borderless : mergedProps.borderless),
|
|
1444
|
-
// type,
|
|
1445
|
-
// };
|
|
1446
|
-
// if (file || type === 'file') {
|
|
1447
|
-
// return <FileUpload {...inputProps} />;
|
|
1448
|
-
// }
|
|
1449
|
-
// if (select) {
|
|
1450
|
-
// return <SelectInput {...inputProps} />;
|
|
1451
|
-
// }
|
|
1452
|
-
// if (multiline) {
|
|
1453
|
-
// return <TextareaInput {...inputProps} />;
|
|
1454
|
-
// }
|
|
1455
|
-
// return <TextInput {...inputProps} />;
|
|
1456
|
-
// };
|
|
1457
|
-
// export default Input;
|