funuicss 3.8.8 → 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 +311 -1
- package/index.d.ts +2 -0
- package/index.js +6 -2
- package/package.json +1 -1
- package/ui/button/Button.d.ts +4 -4
- package/ui/button/Button.js +187 -82
- package/ui/carousel/Carousel.d.ts +3 -0
- package/ui/carousel/Carousel.js +140 -16
- package/ui/feature/Feature.d.ts +26 -39
- package/ui/feature/Feature.js +87 -148
- package/ui/flex/Flex.d.ts +11 -10
- package/ui/flex/Flex.js +102 -6
- package/ui/form/Form.d.ts +21 -12
- package/ui/form/Form.js +428 -319
- package/ui/input/Input.d.ts +16 -21
- package/ui/input/Input.js +156 -1345
- package/ui/notification/Notification.js +6 -2
- package/ui/products/ProductDetail.js +31 -23
- package/ui/products/Store.js +5 -5
- package/ui/sidebar/SideBar.js +1 -2
- package/ui/specials/CircleGroup.d.ts +2 -1
- package/ui/specials/CircleGroup.js +3 -3
package/ui/input/Input.js
CHANGED
|
@@ -59,10 +59,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
59
59
|
exports.TextareaInput = exports.SelectInput = exports.TextInput = void 0;
|
|
60
60
|
var react_1 = __importStar(require("react"));
|
|
61
61
|
var pi_1 = require("react-icons/pi");
|
|
62
|
-
var theme_1 = require("../theme/theme");
|
|
63
62
|
var componentUtils_1 = require("../../utils/componentUtils");
|
|
64
63
|
var getDynamicIcon_1 = require("../../utils/getDynamicIcon");
|
|
65
|
-
var FileUpload_1 = require("./FileUpload");
|
|
66
64
|
// Status icons mapping
|
|
67
65
|
var statusIcons = {
|
|
68
66
|
success: react_1.default.createElement(pi_1.PiCheckCircle, null),
|
|
@@ -70,6 +68,11 @@ var statusIcons = {
|
|
|
70
68
|
danger: react_1.default.createElement(pi_1.PiX, null),
|
|
71
69
|
info: react_1.default.createElement(pi_1.PiInfo, null)
|
|
72
70
|
};
|
|
71
|
+
// Password toggle button component
|
|
72
|
+
var PasswordToggleButton = function (_a) {
|
|
73
|
+
var showPassword = _a.showPassword, onToggle = _a.onToggle, disabled = _a.disabled;
|
|
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
|
+
};
|
|
73
76
|
// Utility function to generate CSS classes
|
|
74
77
|
var generateInputClasses = function (_a) {
|
|
75
78
|
var status = _a.status, rounded = _a.rounded, bg = _a.bg, funcss = _a.funcss, flat = _a.flat, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, bordered = _a.bordered, borderless = _a.borderless, _b = _a.additionalClasses, additionalClasses = _b === void 0 ? '' : _b, _c = _a.hasNoPrefix, hasNoPrefix = _c === void 0 ? false : _c, _d = _a.hasNoLabel, hasNoLabel = _d === void 0 ? false : _d;
|
|
@@ -83,51 +86,65 @@ var generateInputClasses = function (_a) {
|
|
|
83
86
|
var noLabelClass = hasNoLabel ? 'no_label' : '';
|
|
84
87
|
return "\n ".concat(statusClass, "\n ").concat(roundedClass, "\n ").concat(bgClass, "\n ").concat(funcss || '', "\n ").concat(flatClass, "\n ").concat(cornerClass, "\n ").concat(borderClass, "\n ").concat(additionalClasses, "\n ").concat(noPrefixClass, "\n ").concat(noLabelClass, "\n input\n ").trim().replace(/\s+/g, ' ');
|
|
85
88
|
};
|
|
86
|
-
//
|
|
89
|
+
// Function to get icon from string or ReactNode
|
|
90
|
+
var useIcon = function (iconProp) {
|
|
91
|
+
var _a = (0, react_1.useState)(null), iconNode = _a[0], setIconNode = _a[1];
|
|
92
|
+
(0, react_1.useEffect)(function () {
|
|
93
|
+
if (!iconProp) {
|
|
94
|
+
setIconNode(null);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// If it's already a ReactNode, use it directly
|
|
98
|
+
if (react_1.default.isValidElement(iconProp)) {
|
|
99
|
+
setIconNode(iconProp);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// If it's a string, try to get dynamic icon
|
|
103
|
+
if (typeof iconProp === 'string') {
|
|
104
|
+
(0, getDynamicIcon_1.getDynamicIcon)(iconProp).then(function (node) {
|
|
105
|
+
if (node) {
|
|
106
|
+
setIconNode(node);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// If dynamic icon fails, show the string as text
|
|
110
|
+
setIconNode(react_1.default.createElement("span", null, iconProp));
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, [iconProp]);
|
|
115
|
+
return iconNode;
|
|
116
|
+
};
|
|
117
|
+
// Iconic Input Wrapper Component
|
|
87
118
|
var IconicInputWrapper = function (_a) {
|
|
88
|
-
var startIcon = _a.startIcon, endIcon = _a.endIcon,
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
// Determine which icons to show - MATCH BUTTON'S PATTERN EXACTLY
|
|
93
|
-
var showPrefix = effectiveStartIcon !== undefined && effectiveStartIcon !== null;
|
|
94
|
-
var showSuffix = effectiveEndIcon !== undefined && effectiveEndIcon !== null;
|
|
95
|
-
if (!showPrefix && !showSuffix) {
|
|
119
|
+
var startIcon = _a.startIcon, endIcon = _a.endIcon, iconicBg = _a.iconicBg, funcss = _a.funcss, children = _a.children;
|
|
120
|
+
var showLeftIcon = !!startIcon;
|
|
121
|
+
var showRightIcon = !!endIcon;
|
|
122
|
+
if (!showLeftIcon && !showRightIcon) {
|
|
96
123
|
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
97
124
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return react_1.default.isValidElement(node);
|
|
101
|
-
}
|
|
102
|
-
return (react_1.default.createElement("div", { className: "icon-container ".concat(showPrefix ? 'has-left-icon' : '', " ").concat(funcss || '') },
|
|
103
|
-
showPrefix && (react_1.default.createElement("div", { className: "leftIcon", style: {
|
|
125
|
+
return (react_1.default.createElement("div", { className: "icon-container ".concat(showLeftIcon ? 'has-left-icon' : '', " ").concat(funcss || '') },
|
|
126
|
+
showLeftIcon && (react_1.default.createElement("div", { className: "leftIcon", style: {
|
|
104
127
|
backgroundColor: iconicBg || '',
|
|
105
128
|
border: iconicBg ? "0.1rem ".concat(iconicBg, " solid") : '',
|
|
106
|
-
} },
|
|
107
|
-
: isReactElement(prefix) ? prefix
|
|
108
|
-
: isReactElement(effectiveStartIcon) ? effectiveStartIcon
|
|
109
|
-
: stringPrefix ? effectiveStartIcon : '')),
|
|
129
|
+
} }, startIcon)),
|
|
110
130
|
children,
|
|
111
|
-
|
|
112
|
-
: isReactElement(suffix) ? suffix
|
|
113
|
-
: isReactElement(effectiveEndIcon) ? effectiveEndIcon
|
|
114
|
-
: stringSuffix ? effectiveEndIcon : ""))));
|
|
131
|
+
showRightIcon && (react_1.default.createElement("div", { className: "rightIcon", style: { backgroundColor: iconicBg || '' } }, endIcon))));
|
|
115
132
|
};
|
|
116
133
|
// Input Container with Floating Label
|
|
117
134
|
var InputContainer = function (_a) {
|
|
118
|
-
var label = _a.label, status = _a.status, helperText = _a.helperText, children = _a.children, isFocused = _a.isFocused, hasValue = _a.hasValue, fullWidth = _a.fullWidth, id = _a.id, startIcon = _a.startIcon,
|
|
135
|
+
var label = _a.label, status = _a.status, helperText = _a.helperText, children = _a.children, isFocused = _a.isFocused, hasValue = _a.hasValue, fullWidth = _a.fullWidth, id = _a.id, startIcon = _a.startIcon, _b = _a.alwaysActiveLabel, alwaysActiveLabel = _b === void 0 ? false : _b, _c = _a.required, required = _c === void 0 ? false : _c;
|
|
119
136
|
var showFloatingLabel = label && (alwaysActiveLabel || isFocused || hasValue);
|
|
120
137
|
return (react_1.default.createElement("div", { className: "input-wrapper ".concat(fullWidth ? 'full-width' : '') },
|
|
121
138
|
react_1.default.createElement("div", { className: "input-container-with-label" },
|
|
122
|
-
label && (react_1.default.createElement("label", { htmlFor: id, className: "floating-label ".concat(startIcon
|
|
139
|
+
label && (react_1.default.createElement("label", { htmlFor: id, className: "floating-label ".concat(startIcon ? "label-left" : "", " ").concat(showFloatingLabel ? 'active' : '', " ").concat(status ? "label-".concat(status) : '') },
|
|
123
140
|
label,
|
|
124
141
|
required && react_1.default.createElement("span", { className: "required-indicator" }, "*"))),
|
|
125
142
|
children),
|
|
126
|
-
(helperText
|
|
143
|
+
(helperText) && (react_1.default.createElement("div", { className: "input-helper-text ".concat(status ? "helper-".concat(status) : '') },
|
|
127
144
|
status && statusIcons[status] && (react_1.default.createElement("span", { className: "helper-icon" }, statusIcons[status])),
|
|
128
145
|
react_1.default.createElement("span", null, helperText)))));
|
|
129
146
|
};
|
|
130
|
-
// Text Input Component
|
|
147
|
+
// Text Input Component - FIXED for space key issue
|
|
131
148
|
var TextInput = function (_a) {
|
|
132
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,
|
|
133
150
|
// HTML Input Attributes
|
|
@@ -136,21 +153,24 @@ var TextInput = function (_a) {
|
|
|
136
153
|
disabled = _e === void 0 ? false : _e, _f = _a.readOnly, readOnly = _f === void 0 ? false : _f, _g = _a.required, required = _g === void 0 ? false : _g, _h = _a.autoFocus, autoFocus = _h === void 0 ? false : _h, autoComplete = _a.autoComplete, pattern = _a.pattern, minLength = _a.minLength, maxLength = _a.maxLength, min = _a.min, max = _a.max, step = _a.step, multiple = _a.multiple, accept = _a.accept, size = _a.size, form = _a.form, formNoValidate = _a.formNoValidate, formTarget = _a.formTarget, list = _a.list, autoCapitalize = _a.autoCapitalize, autoCorrect = _a.autoCorrect, spellCheck = _a.spellCheck, inputMode = _a.inputMode, dirname = _a.dirname, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "onBlur", "onFocus", "onClick", "onKeyDown", "onKeyUp", "onKeyPress", "onSubmit", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "prefix", "suffix", "stringPrefix", "stringSuffix", "iconicBg", "type", "label", "helperText", "variant", "placeholder", "disabled", "readOnly", "required", "autoFocus", "autoComplete", "pattern", "minLength", "maxLength", "min", "max", "step", "multiple", "accept", "size", "form", "formNoValidate", "formTarget", "list", "autoCapitalize", "autoCorrect", "spellCheck", "inputMode", "dirname"]);
|
|
137
154
|
var _j = (0, react_1.useState)(false), isFocused = _j[0], setIsFocused = _j[1];
|
|
138
155
|
var _k = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), inputValue = _k[0], setInputValue = _k[1];
|
|
139
|
-
var _l = (0, react_1.useState)(
|
|
140
|
-
var _m = (0, react_1.useState)(null), suffixNode = _m[0], setSuffixNode = _m[1];
|
|
141
|
-
var _o = (0, react_1.useState)(false), hasValidStringPrefix = _o[0], setHasValidStringPrefix = _o[1];
|
|
142
|
-
var _p = (0, react_1.useState)(false), hasValidStringSuffix = _p[0], setHasValidStringSuffix = _p[1];
|
|
156
|
+
var _l = (0, react_1.useState)(false), showPassword = _l[0], setShowPassword = _l[1];
|
|
143
157
|
var inputRef = (0, react_1.useRef)(null);
|
|
144
158
|
var isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
159
|
+
var isPasswordType = type === 'password';
|
|
145
160
|
(0, react_1.useEffect)(function () {
|
|
146
|
-
if (value !== undefined
|
|
161
|
+
if (value !== undefined) {
|
|
162
|
+
// CRITICAL: Preserve all characters including spaces
|
|
147
163
|
setInputValue(String(value));
|
|
148
164
|
}
|
|
149
|
-
else if (value === '') {
|
|
150
|
-
setInputValue('');
|
|
151
|
-
}
|
|
152
165
|
}, [value]);
|
|
153
166
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
167
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
168
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
169
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
170
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
171
|
+
// Convert string icons to ReactNode
|
|
172
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
173
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
154
174
|
var localProps = {
|
|
155
175
|
status: status,
|
|
156
176
|
funcss: funcss,
|
|
@@ -162,13 +182,11 @@ var TextInput = function (_a) {
|
|
|
162
182
|
rounded: rounded,
|
|
163
183
|
leftRounded: leftRounded,
|
|
164
184
|
rightRounded: rightRounded,
|
|
165
|
-
startIcon:
|
|
166
|
-
endIcon:
|
|
167
|
-
prefix: prefix,
|
|
168
|
-
suffix: suffix,
|
|
185
|
+
startIcon: startIconNode,
|
|
186
|
+
endIcon: endIconNode,
|
|
169
187
|
iconicBg: iconicBg,
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
label: label,
|
|
189
|
+
helperText: helperText,
|
|
172
190
|
};
|
|
173
191
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
174
192
|
var final = {
|
|
@@ -182,97 +200,16 @@ var TextInput = function (_a) {
|
|
|
182
200
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
183
201
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
184
202
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
185
|
-
startIcon:
|
|
186
|
-
endIcon:
|
|
187
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
188
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
203
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
204
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
189
205
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
190
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
191
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
192
206
|
};
|
|
193
|
-
//
|
|
194
|
-
(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
202
|
-
if (node) {
|
|
203
|
-
setPrefixNode(node);
|
|
204
|
-
setHasValidStringPrefix(true);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
setPrefixNode(null);
|
|
208
|
-
setHasValidStringPrefix(false);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}, [final.stringPrefix]);
|
|
212
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
213
|
-
(0, react_1.useEffect)(function () {
|
|
214
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
215
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
216
|
-
setSuffixNode(null);
|
|
217
|
-
setHasValidStringSuffix(false);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
221
|
-
if (node) {
|
|
222
|
-
setSuffixNode(node);
|
|
223
|
-
setHasValidStringSuffix(true);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
setSuffixNode(null);
|
|
227
|
-
setHasValidStringSuffix(false);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}, [final.stringSuffix]);
|
|
231
|
-
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
232
|
-
// Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
233
|
-
var showPrefix = react_1.default.useMemo(function () {
|
|
234
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
235
|
-
if (final.startIcon)
|
|
236
|
-
return true;
|
|
237
|
-
if (final.prefix)
|
|
238
|
-
return true;
|
|
239
|
-
if (hasValidStringPrefix && prefixNode)
|
|
240
|
-
return true;
|
|
241
|
-
return false;
|
|
242
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
243
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
244
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
245
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
246
|
-
if (final.endIcon)
|
|
247
|
-
return true;
|
|
248
|
-
if (final.suffix)
|
|
249
|
-
return true;
|
|
250
|
-
if (hasValidStringSuffix && suffixNode)
|
|
251
|
-
return true;
|
|
252
|
-
return false;
|
|
253
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
254
|
-
// Get effective icons following Button's priority pattern
|
|
255
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
256
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
257
|
-
if (final.startIcon)
|
|
258
|
-
return final.startIcon;
|
|
259
|
-
if (final.prefix)
|
|
260
|
-
return final.prefix;
|
|
261
|
-
if (hasValidStringPrefix)
|
|
262
|
-
return prefixNode;
|
|
263
|
-
return null;
|
|
264
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
265
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
266
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
267
|
-
if (final.endIcon)
|
|
268
|
-
return final.endIcon;
|
|
269
|
-
if (final.suffix)
|
|
270
|
-
return final.suffix;
|
|
271
|
-
if (hasValidStringSuffix)
|
|
272
|
-
return suffixNode;
|
|
273
|
-
return null;
|
|
274
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
275
|
-
var hasNoPrefix = !effectivePrefix;
|
|
207
|
+
// For password fields, show toggle button if no endIcon/suffix/stringSuffix is provided
|
|
208
|
+
var passwordToggleIcon = isPasswordType && !effectiveEndIcon ? (react_1.default.createElement(PasswordToggleButton, { showPassword: showPassword, onToggle: function () { return setShowPassword(!showPassword); }, disabled: disabled })) : null;
|
|
209
|
+
var effectiveEndIconWithPassword = passwordToggleIcon || final.endIcon;
|
|
210
|
+
var showPrefix = !!final.startIcon;
|
|
211
|
+
var showSuffix = !!effectiveEndIconWithPassword;
|
|
212
|
+
var hasNoPrefix = !showPrefix;
|
|
276
213
|
var hasNoLabel = !label;
|
|
277
214
|
var className = generateInputClasses({
|
|
278
215
|
status: final.status,
|
|
@@ -304,16 +241,33 @@ var TextInput = function (_a) {
|
|
|
304
241
|
if (onBlur)
|
|
305
242
|
onBlur(e);
|
|
306
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
|
+
};
|
|
307
260
|
var showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
308
|
-
var
|
|
261
|
+
var inputType = isPasswordType ? (showPassword ? 'text' : 'password') : type;
|
|
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,
|
|
309
263
|
// HTML Input Attributes
|
|
310
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)));
|
|
311
|
-
// Only use iconic wrapper when we have icons
|
|
312
|
-
var wrappedInput = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon:
|
|
313
|
-
return (react_1.default.createElement(InputContainer, { startIcon:
|
|
265
|
+
// Only use iconic wrapper when we have icons
|
|
266
|
+
var wrappedInput = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: effectiveEndIconWithPassword, iconicBg: final.iconicBg, funcss: final.funcss }, inputElement)) : (inputElement);
|
|
267
|
+
return (react_1.default.createElement(InputContainer, { startIcon: final.startIcon, label: label, status: final.status, helperText: helperText, isFocused: isFocused, hasValue: !!inputValue, fullWidth: final.fullWidth, id: id, alwaysActiveLabel: isDateTimeInput, required: required }, wrappedInput));
|
|
314
268
|
};
|
|
315
269
|
exports.TextInput = TextInput;
|
|
316
|
-
// Select Component
|
|
270
|
+
// Select Component
|
|
317
271
|
var SelectInput = function (_a) {
|
|
318
272
|
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, fullWidth = _a.fullWidth, 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, _b = _a.options, options = _b === void 0 ? [] : _b, label = _a.label, helperText = _a.helperText, _c = _a.variant, variant = _c === void 0 ? '' : _c,
|
|
319
273
|
// HTML Select Attributes
|
|
@@ -322,19 +276,19 @@ var SelectInput = function (_a) {
|
|
|
322
276
|
disabled = _d === void 0 ? false : _d, _e = _a.required, required = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, form = _a.form, formNoValidate = _a.formNoValidate, formTarget = _a.formTarget, size = _a.size, multiple = _a.multiple, autoComplete = _a.autoComplete, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "onBlur", "onFocus", "onClick", "onKeyDown", "onKeyUp", "onKeyPress", "onSubmit", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "prefix", "suffix", "stringPrefix", "stringSuffix", "iconicBg", "options", "label", "helperText", "variant", "disabled", "required", "autoFocus", "form", "formNoValidate", "formTarget", "size", "multiple", "autoComplete"]);
|
|
323
277
|
var _g = (0, react_1.useState)(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
324
278
|
var _h = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), selectValue = _h[0], setSelectValue = _h[1];
|
|
325
|
-
var _j = (0, react_1.useState)(null), prefixNode = _j[0], setPrefixNode = _j[1];
|
|
326
|
-
var _k = (0, react_1.useState)(null), suffixNode = _k[0], setSuffixNode = _k[1];
|
|
327
|
-
var _l = (0, react_1.useState)(false), hasValidStringPrefix = _l[0], setHasValidStringPrefix = _l[1];
|
|
328
|
-
var _m = (0, react_1.useState)(false), hasValidStringSuffix = _m[0], setHasValidStringSuffix = _m[1];
|
|
329
279
|
(0, react_1.useEffect)(function () {
|
|
330
|
-
if (value !== undefined
|
|
280
|
+
if (value !== undefined) {
|
|
331
281
|
setSelectValue(String(value));
|
|
332
282
|
}
|
|
333
|
-
else if (value === '') {
|
|
334
|
-
setSelectValue('');
|
|
335
|
-
}
|
|
336
283
|
}, [value]);
|
|
337
284
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
285
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
286
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
287
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
288
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
289
|
+
// Convert string icons to ReactNode
|
|
290
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
291
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
338
292
|
var localProps = {
|
|
339
293
|
status: status,
|
|
340
294
|
funcss: funcss,
|
|
@@ -346,13 +300,11 @@ var SelectInput = function (_a) {
|
|
|
346
300
|
rounded: rounded,
|
|
347
301
|
leftRounded: leftRounded,
|
|
348
302
|
rightRounded: rightRounded,
|
|
349
|
-
startIcon:
|
|
350
|
-
endIcon:
|
|
351
|
-
prefix: prefix,
|
|
352
|
-
suffix: suffix,
|
|
303
|
+
startIcon: startIconNode,
|
|
304
|
+
endIcon: endIconNode,
|
|
353
305
|
iconicBg: iconicBg,
|
|
354
|
-
|
|
355
|
-
|
|
306
|
+
label: label,
|
|
307
|
+
helperText: helperText,
|
|
356
308
|
};
|
|
357
309
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
358
310
|
var final = {
|
|
@@ -366,98 +318,14 @@ var SelectInput = function (_a) {
|
|
|
366
318
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
367
319
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
368
320
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
369
|
-
startIcon:
|
|
370
|
-
endIcon:
|
|
371
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
372
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
321
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
322
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
373
323
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
374
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
375
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
376
324
|
};
|
|
377
|
-
// Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
378
|
-
(0, react_1.useEffect)(function () {
|
|
379
|
-
var effectiveStringPrefix = final.stringPrefix;
|
|
380
|
-
if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
381
|
-
setPrefixNode(null);
|
|
382
|
-
setHasValidStringPrefix(false);
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
386
|
-
if (node) {
|
|
387
|
-
setPrefixNode(node);
|
|
388
|
-
setHasValidStringPrefix(true);
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
setPrefixNode(null);
|
|
392
|
-
setHasValidStringPrefix(false);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}, [final.stringPrefix]);
|
|
396
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
397
|
-
(0, react_1.useEffect)(function () {
|
|
398
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
399
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
400
|
-
setSuffixNode(null);
|
|
401
|
-
setHasValidStringSuffix(false);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
405
|
-
if (node) {
|
|
406
|
-
setSuffixNode(node);
|
|
407
|
-
setHasValidStringSuffix(true);
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
setSuffixNode(null);
|
|
411
|
-
setHasValidStringSuffix(false);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}, [final.stringSuffix]);
|
|
415
325
|
var selectHasValue = !!selectValue;
|
|
416
|
-
var
|
|
417
|
-
|
|
418
|
-
var
|
|
419
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
420
|
-
if (final.startIcon)
|
|
421
|
-
return true;
|
|
422
|
-
if (final.prefix)
|
|
423
|
-
return true;
|
|
424
|
-
if (hasValidStringPrefix && prefixNode)
|
|
425
|
-
return true;
|
|
426
|
-
return false;
|
|
427
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
428
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
429
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
430
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
431
|
-
if (final.endIcon)
|
|
432
|
-
return true;
|
|
433
|
-
if (final.suffix)
|
|
434
|
-
return true;
|
|
435
|
-
if (hasValidStringSuffix && suffixNode)
|
|
436
|
-
return true;
|
|
437
|
-
return false;
|
|
438
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
439
|
-
// Get effective icons following Button's priority pattern
|
|
440
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
441
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
442
|
-
if (final.startIcon)
|
|
443
|
-
return final.startIcon;
|
|
444
|
-
if (final.prefix)
|
|
445
|
-
return final.prefix;
|
|
446
|
-
if (hasValidStringPrefix)
|
|
447
|
-
return prefixNode;
|
|
448
|
-
return null;
|
|
449
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
450
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
451
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
452
|
-
if (final.endIcon)
|
|
453
|
-
return final.endIcon;
|
|
454
|
-
if (final.suffix)
|
|
455
|
-
return final.suffix;
|
|
456
|
-
if (hasValidStringSuffix)
|
|
457
|
-
return suffixNode;
|
|
458
|
-
return null;
|
|
459
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
460
|
-
var hasNoPrefix = !effectivePrefix;
|
|
326
|
+
var showPrefix = !!final.startIcon;
|
|
327
|
+
var showSuffix = !!final.endIcon;
|
|
328
|
+
var hasNoPrefix = !showPrefix;
|
|
461
329
|
var hasNoLabel = !label;
|
|
462
330
|
var className = generateInputClasses({
|
|
463
331
|
status: final.status,
|
|
@@ -489,18 +357,15 @@ var SelectInput = function (_a) {
|
|
|
489
357
|
if (onBlur)
|
|
490
358
|
onBlur(e);
|
|
491
359
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
// Only use iconic wrapper when we have icons, matching Button's pattern
|
|
499
|
-
var wrappedSelect = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: effectivePrefix, endIcon: effectiveSuffix, iconicBg: final.iconicBg, funcss: final.funcss, stringPrefix: stringPrefix, stringSuffix: stringSuffix }, selectElement)) : (selectElement);
|
|
500
|
-
return (react_1.default.createElement(InputContainer, { startIcon: effectivePrefix, label: label, status: final.status, helperText: helperText, isFocused: isFocused, hasValue: selectHasValue, fullWidth: final.fullWidth, id: id, alwaysActiveLabel: true, required: required }, wrappedSelect));
|
|
360
|
+
// Extract only valid HTML select attributes for the select element
|
|
361
|
+
var selectAttributes = __assign({ id: id, name: name, className: className, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onKeyPress: onKeyPress, onSubmit: onSubmit, defaultValue: defaultValue, value: selectValue, style: style, disabled: disabled, required: required, autoFocus: autoFocus, form: form, size: size, multiple: multiple, autoComplete: autoComplete }, rest);
|
|
362
|
+
var selectElement = (react_1.default.createElement("select", __assign({}, selectAttributes), options.map(function (option) { return (react_1.default.createElement("option", { key: option.value, value: option.value }, option.text)); })));
|
|
363
|
+
// Only use iconic wrapper when we have icons
|
|
364
|
+
var wrappedSelect = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: final.endIcon, iconicBg: final.iconicBg, funcss: final.funcss }, selectElement)) : (selectElement);
|
|
365
|
+
return (react_1.default.createElement(InputContainer, { startIcon: final.startIcon, label: label, status: final.status, helperText: helperText, isFocused: isFocused, hasValue: selectHasValue, fullWidth: final.fullWidth, id: id, alwaysActiveLabel: true, required: required }, wrappedSelect));
|
|
501
366
|
};
|
|
502
367
|
exports.SelectInput = SelectInput;
|
|
503
|
-
// Textarea Component
|
|
368
|
+
// Textarea Component
|
|
504
369
|
var TextareaInput = function (_a) {
|
|
505
370
|
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, fullWidth = _a.fullWidth, 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, label = _a.label, helperText = _a.helperText, _b = _a.rows, rows = _b === void 0 ? 2 : _b, cols = _a.cols, wrap = _a.wrap, _c = _a.variant, variant = _c === void 0 ? '' : _c, placeholder = _a.placeholder,
|
|
506
371
|
// HTML Textarea Attributes
|
|
@@ -509,19 +374,19 @@ var TextareaInput = function (_a) {
|
|
|
509
374
|
disabled = _d === void 0 ? false : _d, _e = _a.readOnly, readOnly = _e === void 0 ? false : _e, _f = _a.required, required = _f === void 0 ? false : _f, _g = _a.autoFocus, autoFocus = _g === void 0 ? false : _g, autoComplete = _a.autoComplete, minLength = _a.minLength, maxLength = _a.maxLength, form = _a.form, formNoValidate = _a.formNoValidate, formTarget = _a.formTarget, dirname = _a.dirname, autoCapitalize = _a.autoCapitalize, autoCorrect = _a.autoCorrect, spellCheck = _a.spellCheck, inputMode = _a.inputMode, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "onBlur", "onFocus", "onClick", "onKeyDown", "onKeyUp", "onKeyPress", "onSubmit", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "prefix", "suffix", "stringPrefix", "stringSuffix", "iconicBg", "label", "helperText", "rows", "cols", "wrap", "variant", "placeholder", "disabled", "readOnly", "required", "autoFocus", "autoComplete", "minLength", "maxLength", "form", "formNoValidate", "formTarget", "dirname", "autoCapitalize", "autoCorrect", "spellCheck", "inputMode"]);
|
|
510
375
|
var _h = (0, react_1.useState)(false), isFocused = _h[0], setIsFocused = _h[1];
|
|
511
376
|
var _j = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), textValue = _j[0], setTextValue = _j[1];
|
|
512
|
-
var _k = (0, react_1.useState)(null), prefixNode = _k[0], setPrefixNode = _k[1];
|
|
513
|
-
var _l = (0, react_1.useState)(null), suffixNode = _l[0], setSuffixNode = _l[1];
|
|
514
|
-
var _m = (0, react_1.useState)(false), hasValidStringPrefix = _m[0], setHasValidStringPrefix = _m[1];
|
|
515
|
-
var _o = (0, react_1.useState)(false), hasValidStringSuffix = _o[0], setHasValidStringSuffix = _o[1];
|
|
516
377
|
(0, react_1.useEffect)(function () {
|
|
517
|
-
if (value !== undefined
|
|
378
|
+
if (value !== undefined) {
|
|
518
379
|
setTextValue(String(value));
|
|
519
380
|
}
|
|
520
|
-
else if (value === '') {
|
|
521
|
-
setTextValue('');
|
|
522
|
-
}
|
|
523
381
|
}, [value]);
|
|
524
382
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
383
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
384
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
385
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
386
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
387
|
+
// Convert string icons to ReactNode
|
|
388
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
389
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
525
390
|
var localProps = {
|
|
526
391
|
status: status,
|
|
527
392
|
funcss: funcss,
|
|
@@ -533,13 +398,11 @@ var TextareaInput = function (_a) {
|
|
|
533
398
|
rounded: rounded,
|
|
534
399
|
leftRounded: leftRounded,
|
|
535
400
|
rightRounded: rightRounded,
|
|
536
|
-
startIcon:
|
|
537
|
-
endIcon:
|
|
538
|
-
prefix: prefix,
|
|
539
|
-
suffix: suffix,
|
|
401
|
+
startIcon: startIconNode,
|
|
402
|
+
endIcon: endIconNode,
|
|
540
403
|
iconicBg: iconicBg,
|
|
541
|
-
|
|
542
|
-
|
|
404
|
+
label: label,
|
|
405
|
+
helperText: helperText,
|
|
543
406
|
};
|
|
544
407
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
545
408
|
var final = {
|
|
@@ -553,97 +416,13 @@ var TextareaInput = function (_a) {
|
|
|
553
416
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
554
417
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
555
418
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
556
|
-
startIcon:
|
|
557
|
-
endIcon:
|
|
558
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
559
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
419
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
420
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
560
421
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
561
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
562
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
563
422
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
568
|
-
setPrefixNode(null);
|
|
569
|
-
setHasValidStringPrefix(false);
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
573
|
-
if (node) {
|
|
574
|
-
setPrefixNode(node);
|
|
575
|
-
setHasValidStringPrefix(true);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
setPrefixNode(null);
|
|
579
|
-
setHasValidStringPrefix(false);
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
}, [final.stringPrefix]);
|
|
583
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
584
|
-
(0, react_1.useEffect)(function () {
|
|
585
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
586
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
587
|
-
setSuffixNode(null);
|
|
588
|
-
setHasValidStringSuffix(false);
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
592
|
-
if (node) {
|
|
593
|
-
setSuffixNode(node);
|
|
594
|
-
setHasValidStringSuffix(true);
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
setSuffixNode(null);
|
|
598
|
-
setHasValidStringSuffix(false);
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
}, [final.stringSuffix]);
|
|
602
|
-
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
603
|
-
// Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
604
|
-
var showPrefix = react_1.default.useMemo(function () {
|
|
605
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
606
|
-
if (final.startIcon)
|
|
607
|
-
return true;
|
|
608
|
-
if (final.prefix)
|
|
609
|
-
return true;
|
|
610
|
-
if (hasValidStringPrefix && prefixNode)
|
|
611
|
-
return true;
|
|
612
|
-
return false;
|
|
613
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
614
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
615
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
616
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
617
|
-
if (final.endIcon)
|
|
618
|
-
return true;
|
|
619
|
-
if (final.suffix)
|
|
620
|
-
return true;
|
|
621
|
-
if (hasValidStringSuffix && suffixNode)
|
|
622
|
-
return true;
|
|
623
|
-
return false;
|
|
624
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
625
|
-
// Get effective icons following Button's priority pattern
|
|
626
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
627
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
628
|
-
if (final.startIcon)
|
|
629
|
-
return final.startIcon;
|
|
630
|
-
if (final.prefix)
|
|
631
|
-
return final.prefix;
|
|
632
|
-
if (hasValidStringPrefix)
|
|
633
|
-
return prefixNode;
|
|
634
|
-
return null;
|
|
635
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
636
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
637
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
638
|
-
if (final.endIcon)
|
|
639
|
-
return final.endIcon;
|
|
640
|
-
if (final.suffix)
|
|
641
|
-
return final.suffix;
|
|
642
|
-
if (hasValidStringSuffix)
|
|
643
|
-
return suffixNode;
|
|
644
|
-
return null;
|
|
645
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
646
|
-
var hasNoPrefix = !effectivePrefix;
|
|
423
|
+
var showPrefix = !!final.startIcon;
|
|
424
|
+
var showSuffix = !!final.endIcon;
|
|
425
|
+
var hasNoPrefix = !showPrefix;
|
|
647
426
|
var hasNoLabel = !label;
|
|
648
427
|
var className = generateInputClasses({
|
|
649
428
|
status: final.status,
|
|
@@ -676,1006 +455,38 @@ var TextareaInput = function (_a) {
|
|
|
676
455
|
onBlur(e);
|
|
677
456
|
};
|
|
678
457
|
var showPlaceholder = placeholder && label && (isFocused || !!textValue);
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, inputMode: inputMode }, rest)));
|
|
686
|
-
// Only use iconic wrapper when we have icons, matching Button's pattern
|
|
687
|
-
var wrappedTextarea = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: effectivePrefix, endIcon: effectiveSuffix, iconicBg: final.iconicBg, funcss: final.funcss, stringPrefix: stringPrefix, stringSuffix: stringSuffix }, textareaElement)) : (textareaElement);
|
|
688
|
-
return (react_1.default.createElement(InputContainer, { startIcon: effectivePrefix, label: label, status: final.status, helperText: helperText, isFocused: isFocused, hasValue: !!textValue, fullWidth: final.fullWidth, id: id, required: required }, wrappedTextarea));
|
|
458
|
+
// Extract only valid HTML textarea attributes
|
|
459
|
+
var textareaAttributes = __assign({ id: id, name: name, className: className, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onKeyPress: onKeyPress, onSubmit: onSubmit, defaultValue: defaultValue, placeholder: showPlaceholder ? placeholder : (!label ? placeholder : ''), style: style, value: textValue, rows: rows, cols: cols, wrap: wrap, disabled: disabled, readOnly: readOnly, required: required, autoFocus: autoFocus, autoComplete: autoComplete, minLength: minLength, maxLength: maxLength, form: form, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, spellCheck: spellCheck, inputMode: inputMode }, rest);
|
|
460
|
+
var textareaElement = react_1.default.createElement("textarea", __assign({}, textareaAttributes));
|
|
461
|
+
// Only use iconic wrapper when we have icons
|
|
462
|
+
var wrappedTextarea = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: final.endIcon, iconicBg: final.iconicBg, funcss: final.funcss }, textareaElement)) : (textareaElement);
|
|
463
|
+
return (react_1.default.createElement(InputContainer, { startIcon: final.startIcon, label: label, status: final.status, helperText: helperText, isFocused: isFocused, hasValue: !!textValue, fullWidth: final.fullWidth, id: id, required: required }, wrappedTextarea));
|
|
689
464
|
};
|
|
690
465
|
exports.TextareaInput = TextareaInput;
|
|
691
466
|
var Input = function (_a) {
|
|
692
|
-
var select = _a.select, multiline = _a.multiline,
|
|
467
|
+
var select = _a.select, multiline = _a.multiline, noBorder = _a.noBorder, startIcon = _a.startIcon, endIcon = _a.endIcon, prefix = _a.prefix, suffix = _a.suffix, stringPrefix = _a.stringPrefix, stringSuffix = _a.stringSuffix, iconicBg = _a.iconicBg, type = _a.type, _b = _a.variant, variant = _b === void 0 ? '' : _b, props = __rest(_a, ["select", "multiline", "noBorder", "startIcon", "endIcon", "prefix", "suffix", "stringPrefix", "stringSuffix", "iconicBg", "type", "variant"]);
|
|
693
468
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
694
|
-
|
|
469
|
+
// Determine effective icons with priority:
|
|
470
|
+
// For start: startIcon > prefix > stringPrefix
|
|
471
|
+
// For end: endIcon > suffix > stringSuffix
|
|
472
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
473
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
474
|
+
// Create local props object including all input props
|
|
475
|
+
var localProps = __assign(__assign({}, props), { startIcon: effectiveStartIcon, endIcon: effectiveEndIcon, iconicBg: iconicBg, type: type,
|
|
476
|
+
// Ensure all event handlers are passed through
|
|
477
|
+
onChange: props.onChange, onBlur: props.onBlur, onFocus: props.onFocus, onClick: props.onClick, onKeyDown: props.onKeyDown, onKeyUp: props.onKeyUp, onKeyPress: props.onKeyPress, onSubmit: props.onSubmit });
|
|
695
478
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
479
|
+
// Build the final props object
|
|
480
|
+
var inputProps = __assign(__assign(__assign(__assign({}, mergedProps), {
|
|
481
|
+
// Then spread all component-specific props to ensure they override theme
|
|
482
|
+
startIcon: effectiveStartIcon, endIcon: effectiveEndIcon, stringPrefix: stringPrefix, stringSuffix: stringSuffix, iconicBg: iconicBg }), props), { borderless: noBorder !== undefined ? noBorder : (props.borderless !== undefined ? props.borderless : mergedProps.borderless), type: type, variant: variant });
|
|
483
|
+
var finalInputProps = __assign(__assign({}, inputProps), { onChange: props.onChange || inputProps.onChange, onBlur: props.onBlur || inputProps.onBlur, onFocus: props.onFocus || inputProps.onFocus });
|
|
700
484
|
if (select) {
|
|
701
|
-
return react_1.default.createElement(exports.SelectInput, __assign({},
|
|
485
|
+
return react_1.default.createElement(exports.SelectInput, __assign({}, finalInputProps));
|
|
702
486
|
}
|
|
703
487
|
if (multiline) {
|
|
704
|
-
return react_1.default.createElement(exports.TextareaInput, __assign({},
|
|
488
|
+
return react_1.default.createElement(exports.TextareaInput, __assign({}, finalInputProps));
|
|
705
489
|
}
|
|
706
|
-
return react_1.default.createElement(exports.TextInput, __assign({},
|
|
490
|
+
return react_1.default.createElement(exports.TextInput, __assign({}, finalInputProps));
|
|
707
491
|
};
|
|
708
492
|
exports.default = Input;
|
|
709
|
-
// 'use client'
|
|
710
|
-
// import React, { useState, useEffect, useRef } from 'react';
|
|
711
|
-
// import { PiCheck, PiCloudArrowUp, PiInfo, PiWarning, PiX, PiCheckCircle } from 'react-icons/pi';
|
|
712
|
-
// import Button from '../button/Button';
|
|
713
|
-
// import { useVariant } from '../theme/theme';
|
|
714
|
-
// import { useComponentConfiguration } from '../../utils/componentUtils';
|
|
715
|
-
// import { getDynamicIcon } from '../../utils/getDynamicIcon';
|
|
716
|
-
// import Text from '../text/Text';
|
|
717
|
-
// import { FileUpload } from './FileUpload';
|
|
718
|
-
// // Base types and interfaces
|
|
719
|
-
// interface BaseInputProps {
|
|
720
|
-
// id?: string;
|
|
721
|
-
// name?: string;
|
|
722
|
-
// value?: any;
|
|
723
|
-
// defaultValue?: string;
|
|
724
|
-
// onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
725
|
-
// status?: 'success' | 'warning' | 'danger' | 'info' ;
|
|
726
|
-
// funcss?: string;
|
|
727
|
-
// bg?: string;
|
|
728
|
-
// fullWidth?: boolean;
|
|
729
|
-
// flat?: boolean;
|
|
730
|
-
// bordered?: boolean;
|
|
731
|
-
// borderless?: boolean;
|
|
732
|
-
// rounded?: boolean;
|
|
733
|
-
// leftRounded?: boolean;
|
|
734
|
-
// rightRounded?: boolean;
|
|
735
|
-
// startIcon?: React.ReactNode;
|
|
736
|
-
// endIcon?: React.ReactNode;
|
|
737
|
-
// prefix?: React.ReactNode;
|
|
738
|
-
// suffix?: React.ReactNode;
|
|
739
|
-
// stringPrefix?: string;
|
|
740
|
-
// stringSuffix?: string;
|
|
741
|
-
// iconicBg?: string;
|
|
742
|
-
// variant?: string;
|
|
743
|
-
// label?: string;
|
|
744
|
-
// helperText?: string;
|
|
745
|
-
// }
|
|
746
|
-
// interface SelectOption {
|
|
747
|
-
// value: string;
|
|
748
|
-
// text: string;
|
|
749
|
-
// }
|
|
750
|
-
// interface TextInputProps extends BaseInputProps {
|
|
751
|
-
// type?: string;
|
|
752
|
-
// }
|
|
753
|
-
// interface SelectProps extends BaseInputProps {
|
|
754
|
-
// options?: SelectOption[];
|
|
755
|
-
// }
|
|
756
|
-
// interface TextareaProps extends BaseInputProps {
|
|
757
|
-
// rows?: number;
|
|
758
|
-
// }
|
|
759
|
-
// interface FileInputProps extends BaseInputProps {
|
|
760
|
-
// icon?: React.ReactNode;
|
|
761
|
-
// extra?: React.ReactNode;
|
|
762
|
-
// button?: React.ReactNode;
|
|
763
|
-
// btn?: boolean;
|
|
764
|
-
// }
|
|
765
|
-
// // Status icons mapping
|
|
766
|
-
// const statusIcons = {
|
|
767
|
-
// success: <PiCheckCircle />,
|
|
768
|
-
// warning: <PiWarning />,
|
|
769
|
-
// danger: <PiX />,
|
|
770
|
-
// info: <PiInfo />
|
|
771
|
-
// };
|
|
772
|
-
// // Utility function to generate CSS classes
|
|
773
|
-
// const generateInputClasses = ({
|
|
774
|
-
// status,
|
|
775
|
-
// rounded,
|
|
776
|
-
// bg,
|
|
777
|
-
// funcss,
|
|
778
|
-
// flat,
|
|
779
|
-
// leftRounded,
|
|
780
|
-
// rightRounded,
|
|
781
|
-
// bordered,
|
|
782
|
-
// borderless,
|
|
783
|
-
// additionalClasses = '',
|
|
784
|
-
// hasNoPrefix = false,
|
|
785
|
-
// hasNoLabel = false
|
|
786
|
-
// }: {
|
|
787
|
-
// status?: string;
|
|
788
|
-
// rounded?: boolean;
|
|
789
|
-
// bg?: string;
|
|
790
|
-
// funcss?: string;
|
|
791
|
-
// flat?: boolean;
|
|
792
|
-
// leftRounded?: boolean;
|
|
793
|
-
// rightRounded?: boolean;
|
|
794
|
-
// bordered?: boolean;
|
|
795
|
-
// borderless?: boolean;
|
|
796
|
-
// additionalClasses?: string;
|
|
797
|
-
// hasNoPrefix?: boolean;
|
|
798
|
-
// hasNoLabel?: boolean;
|
|
799
|
-
// }) => {
|
|
800
|
-
// const statusClass = status ? `${status}-input` : '';
|
|
801
|
-
// const roundedClass = rounded ? 'rounded' : '';
|
|
802
|
-
// const bgClass = bg || '';
|
|
803
|
-
// const flatClass = flat ? 'flat' : '';
|
|
804
|
-
// const cornerClass = leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '';
|
|
805
|
-
// const borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : (!bordered && !borderless ? 'borderedInput' : '');
|
|
806
|
-
// const noPrefixClass = hasNoPrefix ? 'no_prefix' : '';
|
|
807
|
-
// const noLabelClass = hasNoLabel ? 'no_label' : '';
|
|
808
|
-
// return `
|
|
809
|
-
// ${statusClass}
|
|
810
|
-
// ${roundedClass}
|
|
811
|
-
// ${bgClass}
|
|
812
|
-
// ${funcss || ''}
|
|
813
|
-
// ${flatClass}
|
|
814
|
-
// ${cornerClass}
|
|
815
|
-
// ${borderClass}
|
|
816
|
-
// ${additionalClasses}
|
|
817
|
-
// ${noPrefixClass}
|
|
818
|
-
// ${noLabelClass}
|
|
819
|
-
// input
|
|
820
|
-
// `.trim().replace(/\s+/g, ' ');
|
|
821
|
-
// };
|
|
822
|
-
// // Iconic Input Wrapper Component - UPDATED to match Button's pattern
|
|
823
|
-
// const IconicInputWrapper: React.FC<{
|
|
824
|
-
// startIcon?: React.ReactNode;
|
|
825
|
-
// endIcon?: React.ReactNode;
|
|
826
|
-
// prefix?: React.ReactNode;
|
|
827
|
-
// suffix?: React.ReactNode;
|
|
828
|
-
// iconicBg?: string;
|
|
829
|
-
// funcss?: string;
|
|
830
|
-
// stringPrefix?: string;
|
|
831
|
-
// stringSuffix?: string;
|
|
832
|
-
// children: React.ReactNode;
|
|
833
|
-
// }> = ({
|
|
834
|
-
// startIcon,
|
|
835
|
-
// endIcon,
|
|
836
|
-
// prefix,
|
|
837
|
-
// suffix,
|
|
838
|
-
// iconicBg,
|
|
839
|
-
// funcss,
|
|
840
|
-
// stringPrefix,
|
|
841
|
-
// stringSuffix,
|
|
842
|
-
// children
|
|
843
|
-
// }) => {
|
|
844
|
-
// // Match Button's pattern exactly - use proper priority
|
|
845
|
-
// const effectiveStartIcon = startIcon !== undefined ? startIcon : prefix;
|
|
846
|
-
// const effectiveEndIcon = endIcon !== undefined ? endIcon : suffix;
|
|
847
|
-
// // Determine which icons to show - MATCH BUTTON'S PATTERN EXACTLY
|
|
848
|
-
// const showPrefix = effectiveStartIcon !== undefined && effectiveStartIcon !== null;
|
|
849
|
-
// const showSuffix = effectiveEndIcon !== undefined && effectiveEndIcon !== null;
|
|
850
|
-
// if (!showPrefix && !showSuffix) {
|
|
851
|
-
// return <>{children}</>;
|
|
852
|
-
// }
|
|
853
|
-
// // Helper function to check if element is a React element
|
|
854
|
-
// function isReactElement(node: any): node is React.ReactElement {
|
|
855
|
-
// return React.isValidElement(node);
|
|
856
|
-
// }
|
|
857
|
-
// return (
|
|
858
|
-
// <div className={`icon-container ${showPrefix ? 'has-left-icon' : ''} ${funcss || ''}`}>
|
|
859
|
-
// {/* LEFT ICON - Match Button's exact conditional pattern */}
|
|
860
|
-
// {showPrefix && (
|
|
861
|
-
// <div
|
|
862
|
-
// className="leftIcon"
|
|
863
|
-
// style={{
|
|
864
|
-
// backgroundColor: iconicBg || '',
|
|
865
|
-
// border: iconicBg ? `0.1rem ${iconicBg} solid` : '',
|
|
866
|
-
// }}
|
|
867
|
-
// >
|
|
868
|
-
// {isReactElement(startIcon) ? startIcon
|
|
869
|
-
// : isReactElement(prefix) ? prefix
|
|
870
|
-
// : isReactElement(effectiveStartIcon) ? effectiveStartIcon
|
|
871
|
-
// : stringPrefix ? effectiveStartIcon : ''
|
|
872
|
-
// }
|
|
873
|
-
// </div>
|
|
874
|
-
// )}
|
|
875
|
-
// {children}
|
|
876
|
-
// {/* RIGHT ICON - Match Button's exact conditional pattern */}
|
|
877
|
-
// {showSuffix && (
|
|
878
|
-
// <div className="rightIcon" style={{ backgroundColor: iconicBg || '' }}>
|
|
879
|
-
// {isReactElement(endIcon) ? endIcon
|
|
880
|
-
// : isReactElement(suffix) ? suffix
|
|
881
|
-
// : isReactElement(effectiveEndIcon) ? effectiveEndIcon
|
|
882
|
-
// : stringSuffix ? effectiveEndIcon : ""
|
|
883
|
-
// }
|
|
884
|
-
// </div>
|
|
885
|
-
// )}
|
|
886
|
-
// </div>
|
|
887
|
-
// );
|
|
888
|
-
// };
|
|
889
|
-
// // Input Container with Floating Label
|
|
890
|
-
// const InputContainer: React.FC<{
|
|
891
|
-
// label?: string;
|
|
892
|
-
// status?: string;
|
|
893
|
-
// helperText?: string;
|
|
894
|
-
// children: React.ReactNode;
|
|
895
|
-
// isFocused: boolean;
|
|
896
|
-
// hasValue: boolean;
|
|
897
|
-
// fullWidth?: boolean;
|
|
898
|
-
// id?: string;
|
|
899
|
-
// startIcon?: React.ReactNode;
|
|
900
|
-
// prefix?: React.ReactNode;
|
|
901
|
-
// alwaysActiveLabel?: boolean;
|
|
902
|
-
// }> = ({ label, status, helperText, children, isFocused, hasValue, fullWidth, id, startIcon, prefix, alwaysActiveLabel = false }) => {
|
|
903
|
-
// const showFloatingLabel = label && (alwaysActiveLabel || isFocused || hasValue);
|
|
904
|
-
// return (
|
|
905
|
-
// <div className={`input-wrapper ${fullWidth ? 'full-width' : ''}`}>
|
|
906
|
-
// <div className="input-container-with-label">
|
|
907
|
-
// {label && (
|
|
908
|
-
// <label
|
|
909
|
-
// htmlFor={id}
|
|
910
|
-
// className={`floating-label ${startIcon || prefix ? "label-left" : ""} ${showFloatingLabel ? 'active' : ''} ${status ? `label-${status}` : ''}`}
|
|
911
|
-
// >
|
|
912
|
-
// {label}
|
|
913
|
-
// </label>
|
|
914
|
-
// )}
|
|
915
|
-
// {children}
|
|
916
|
-
// </div>
|
|
917
|
-
// {(helperText || status) && (
|
|
918
|
-
// <div className={`input-helper-text ${status ? `helper-${status}` : ''}`}>
|
|
919
|
-
// {status && statusIcons[status as keyof typeof statusIcons] && (
|
|
920
|
-
// <span className="helper-icon">{statusIcons[status as keyof typeof statusIcons]}</span>
|
|
921
|
-
// )}
|
|
922
|
-
// <span>{helperText}</span>
|
|
923
|
-
// </div>
|
|
924
|
-
// )}
|
|
925
|
-
// </div>
|
|
926
|
-
// );
|
|
927
|
-
// };
|
|
928
|
-
// // Text Input Component
|
|
929
|
-
// export const TextInput: React.FC<TextInputProps & React.InputHTMLAttributes<HTMLInputElement>> = ({
|
|
930
|
-
// id,
|
|
931
|
-
// name,
|
|
932
|
-
// value,
|
|
933
|
-
// defaultValue,
|
|
934
|
-
// onChange,
|
|
935
|
-
// status,
|
|
936
|
-
// funcss,
|
|
937
|
-
// bg,
|
|
938
|
-
// fullWidth = true,
|
|
939
|
-
// flat,
|
|
940
|
-
// bordered,
|
|
941
|
-
// borderless,
|
|
942
|
-
// rounded,
|
|
943
|
-
// leftRounded,
|
|
944
|
-
// rightRounded,
|
|
945
|
-
// startIcon,
|
|
946
|
-
// endIcon,
|
|
947
|
-
// prefix,
|
|
948
|
-
// suffix,
|
|
949
|
-
// stringPrefix,
|
|
950
|
-
// stringSuffix,
|
|
951
|
-
// iconicBg,
|
|
952
|
-
// type = 'text',
|
|
953
|
-
// label,
|
|
954
|
-
// helperText,
|
|
955
|
-
// variant = '',
|
|
956
|
-
// placeholder,
|
|
957
|
-
// ...rest
|
|
958
|
-
// }) => {
|
|
959
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
960
|
-
// const [inputValue, setInputValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
961
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
962
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
963
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
964
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
965
|
-
// const inputRef = useRef<HTMLInputElement>(null);
|
|
966
|
-
// const isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
967
|
-
// useEffect(() => {
|
|
968
|
-
// if (value !== undefined && value !== '') {
|
|
969
|
-
// setInputValue(String(value));
|
|
970
|
-
// } else if (value === '') {
|
|
971
|
-
// setInputValue('');
|
|
972
|
-
// }
|
|
973
|
-
// }, [value]);
|
|
974
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
975
|
-
// const localProps = {
|
|
976
|
-
// status,
|
|
977
|
-
// funcss,
|
|
978
|
-
// bg,
|
|
979
|
-
// fullWidth,
|
|
980
|
-
// flat,
|
|
981
|
-
// bordered,
|
|
982
|
-
// borderless,
|
|
983
|
-
// rounded,
|
|
984
|
-
// leftRounded,
|
|
985
|
-
// rightRounded,
|
|
986
|
-
// startIcon,
|
|
987
|
-
// endIcon,
|
|
988
|
-
// prefix,
|
|
989
|
-
// suffix,
|
|
990
|
-
// iconicBg,
|
|
991
|
-
// stringPrefix,
|
|
992
|
-
// stringSuffix,
|
|
993
|
-
// };
|
|
994
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
995
|
-
// const final = {
|
|
996
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
997
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
998
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
999
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1000
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1001
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1002
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1003
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1004
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1005
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1006
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1007
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1008
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1009
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1010
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1011
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1012
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1013
|
-
// };
|
|
1014
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1015
|
-
// useEffect(() => {
|
|
1016
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
1017
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1018
|
-
// setPrefixNode(null);
|
|
1019
|
-
// setHasValidStringPrefix(false);
|
|
1020
|
-
// return;
|
|
1021
|
-
// }
|
|
1022
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1023
|
-
// if (node) {
|
|
1024
|
-
// setPrefixNode(node);
|
|
1025
|
-
// setHasValidStringPrefix(true);
|
|
1026
|
-
// } else {
|
|
1027
|
-
// setPrefixNode(null);
|
|
1028
|
-
// setHasValidStringPrefix(false);
|
|
1029
|
-
// }
|
|
1030
|
-
// });
|
|
1031
|
-
// }, [final.stringPrefix]);
|
|
1032
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1033
|
-
// useEffect(() => {
|
|
1034
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
1035
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1036
|
-
// setSuffixNode(null);
|
|
1037
|
-
// setHasValidStringSuffix(false);
|
|
1038
|
-
// return;
|
|
1039
|
-
// }
|
|
1040
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1041
|
-
// if (node) {
|
|
1042
|
-
// setSuffixNode(node);
|
|
1043
|
-
// setHasValidStringSuffix(true);
|
|
1044
|
-
// } else {
|
|
1045
|
-
// setSuffixNode(null);
|
|
1046
|
-
// setHasValidStringSuffix(false);
|
|
1047
|
-
// }
|
|
1048
|
-
// });
|
|
1049
|
-
// }, [final.stringSuffix]);
|
|
1050
|
-
// const { variant: themeVariant } = useVariant();
|
|
1051
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1052
|
-
// const showPrefix = React.useMemo(() => {
|
|
1053
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1054
|
-
// if (final.startIcon) return true;
|
|
1055
|
-
// if (final.prefix) return true;
|
|
1056
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1057
|
-
// return false;
|
|
1058
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1059
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1060
|
-
// const showSuffix = React.useMemo(() => {
|
|
1061
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1062
|
-
// if (final.endIcon) return true;
|
|
1063
|
-
// if (final.suffix) return true;
|
|
1064
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1065
|
-
// return false;
|
|
1066
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1067
|
-
// // Get effective icons following Button's priority pattern
|
|
1068
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
1069
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
1070
|
-
// if (final.startIcon) return final.startIcon;
|
|
1071
|
-
// if (final.prefix) return final.prefix;
|
|
1072
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
1073
|
-
// return null;
|
|
1074
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1075
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
1076
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
1077
|
-
// if (final.endIcon) return final.endIcon;
|
|
1078
|
-
// if (final.suffix) return final.suffix;
|
|
1079
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
1080
|
-
// return null;
|
|
1081
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1082
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
1083
|
-
// const hasNoLabel = !label;
|
|
1084
|
-
// const className = generateInputClasses({
|
|
1085
|
-
// status: final.status,
|
|
1086
|
-
// rounded: final.rounded,
|
|
1087
|
-
// bg: final.bg,
|
|
1088
|
-
// funcss: final.funcss,
|
|
1089
|
-
// flat: final.flat,
|
|
1090
|
-
// leftRounded: final.leftRounded,
|
|
1091
|
-
// rightRounded: final.rightRounded,
|
|
1092
|
-
// bordered: final.bordered,
|
|
1093
|
-
// borderless: final.borderless,
|
|
1094
|
-
// hasNoPrefix,
|
|
1095
|
-
// hasNoLabel,
|
|
1096
|
-
// });
|
|
1097
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1098
|
-
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
1099
|
-
// const newValue = e.target.value;
|
|
1100
|
-
// setInputValue(newValue);
|
|
1101
|
-
// if (onChange) onChange(e);
|
|
1102
|
-
// };
|
|
1103
|
-
// const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
1104
|
-
// setIsFocused(true);
|
|
1105
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
1106
|
-
// };
|
|
1107
|
-
// const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
1108
|
-
// setIsFocused(false);
|
|
1109
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
1110
|
-
// };
|
|
1111
|
-
// const showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
1112
|
-
// const inputElement = (
|
|
1113
|
-
// <input
|
|
1114
|
-
// ref={inputRef}
|
|
1115
|
-
// id={id}
|
|
1116
|
-
// name={name}
|
|
1117
|
-
// className={className}
|
|
1118
|
-
// onChange={handleChange}
|
|
1119
|
-
// onFocus={handleFocus}
|
|
1120
|
-
// onBlur={handleBlur}
|
|
1121
|
-
// defaultValue={defaultValue}
|
|
1122
|
-
// type={type}
|
|
1123
|
-
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
1124
|
-
// style={style}
|
|
1125
|
-
// value={inputValue}
|
|
1126
|
-
// {...rest}
|
|
1127
|
-
// />
|
|
1128
|
-
// );
|
|
1129
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1130
|
-
// const wrappedInput = showPrefix || showSuffix ? (
|
|
1131
|
-
// <IconicInputWrapper
|
|
1132
|
-
// startIcon={effectivePrefix}
|
|
1133
|
-
// endIcon={effectiveSuffix}
|
|
1134
|
-
// iconicBg={final.iconicBg}
|
|
1135
|
-
// funcss={final.funcss}
|
|
1136
|
-
// stringPrefix={stringPrefix}
|
|
1137
|
-
// stringSuffix={stringSuffix}
|
|
1138
|
-
// >
|
|
1139
|
-
// {inputElement}
|
|
1140
|
-
// </IconicInputWrapper>
|
|
1141
|
-
// ) : (
|
|
1142
|
-
// inputElement
|
|
1143
|
-
// );
|
|
1144
|
-
// return (
|
|
1145
|
-
// <InputContainer
|
|
1146
|
-
// startIcon={effectivePrefix}
|
|
1147
|
-
// label={label}
|
|
1148
|
-
// status={final.status}
|
|
1149
|
-
// helperText={helperText}
|
|
1150
|
-
// isFocused={isFocused}
|
|
1151
|
-
// hasValue={!!inputValue}
|
|
1152
|
-
// fullWidth={final.fullWidth}
|
|
1153
|
-
// id={id}
|
|
1154
|
-
// alwaysActiveLabel={isDateTimeInput}
|
|
1155
|
-
// >
|
|
1156
|
-
// {wrappedInput}
|
|
1157
|
-
// </InputContainer>
|
|
1158
|
-
// );
|
|
1159
|
-
// };
|
|
1160
|
-
// // Select Component - UPDATED to match pattern
|
|
1161
|
-
// export const SelectInput: React.FC<SelectProps & React.SelectHTMLAttributes<HTMLSelectElement>> = ({
|
|
1162
|
-
// id,
|
|
1163
|
-
// name,
|
|
1164
|
-
// value,
|
|
1165
|
-
// defaultValue,
|
|
1166
|
-
// onChange,
|
|
1167
|
-
// status,
|
|
1168
|
-
// funcss,
|
|
1169
|
-
// bg,
|
|
1170
|
-
// fullWidth,
|
|
1171
|
-
// flat,
|
|
1172
|
-
// bordered,
|
|
1173
|
-
// borderless,
|
|
1174
|
-
// rounded,
|
|
1175
|
-
// leftRounded,
|
|
1176
|
-
// rightRounded,
|
|
1177
|
-
// startIcon,
|
|
1178
|
-
// endIcon,
|
|
1179
|
-
// prefix,
|
|
1180
|
-
// suffix,
|
|
1181
|
-
// stringPrefix,
|
|
1182
|
-
// stringSuffix,
|
|
1183
|
-
// iconicBg,
|
|
1184
|
-
// options = [],
|
|
1185
|
-
// label,
|
|
1186
|
-
// helperText,
|
|
1187
|
-
// variant = '',
|
|
1188
|
-
// ...rest
|
|
1189
|
-
// }) => {
|
|
1190
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
1191
|
-
// const [selectValue, setSelectValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
1192
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
1193
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
1194
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
1195
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
1196
|
-
// useEffect(() => {
|
|
1197
|
-
// if (value !== undefined && value !== '') {
|
|
1198
|
-
// setSelectValue(String(value));
|
|
1199
|
-
// } else if (value === '') {
|
|
1200
|
-
// setSelectValue('');
|
|
1201
|
-
// }
|
|
1202
|
-
// }, [value]);
|
|
1203
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1204
|
-
// const localProps = {
|
|
1205
|
-
// status,
|
|
1206
|
-
// funcss,
|
|
1207
|
-
// bg,
|
|
1208
|
-
// fullWidth,
|
|
1209
|
-
// flat,
|
|
1210
|
-
// bordered,
|
|
1211
|
-
// borderless,
|
|
1212
|
-
// rounded,
|
|
1213
|
-
// leftRounded,
|
|
1214
|
-
// rightRounded,
|
|
1215
|
-
// startIcon,
|
|
1216
|
-
// endIcon,
|
|
1217
|
-
// prefix,
|
|
1218
|
-
// suffix,
|
|
1219
|
-
// iconicBg,
|
|
1220
|
-
// stringPrefix,
|
|
1221
|
-
// stringSuffix,
|
|
1222
|
-
// };
|
|
1223
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1224
|
-
// const final = {
|
|
1225
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
1226
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1227
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1228
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1229
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1230
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1231
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1232
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1233
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1234
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1235
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1236
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1237
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1238
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1239
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1240
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1241
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1242
|
-
// };
|
|
1243
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1244
|
-
// useEffect(() => {
|
|
1245
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
1246
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1247
|
-
// setPrefixNode(null);
|
|
1248
|
-
// setHasValidStringPrefix(false);
|
|
1249
|
-
// return;
|
|
1250
|
-
// }
|
|
1251
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1252
|
-
// if (node) {
|
|
1253
|
-
// setPrefixNode(node);
|
|
1254
|
-
// setHasValidStringPrefix(true);
|
|
1255
|
-
// } else {
|
|
1256
|
-
// setPrefixNode(null);
|
|
1257
|
-
// setHasValidStringPrefix(false);
|
|
1258
|
-
// }
|
|
1259
|
-
// });
|
|
1260
|
-
// }, [final.stringPrefix]);
|
|
1261
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1262
|
-
// useEffect(() => {
|
|
1263
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
1264
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1265
|
-
// setSuffixNode(null);
|
|
1266
|
-
// setHasValidStringSuffix(false);
|
|
1267
|
-
// return;
|
|
1268
|
-
// }
|
|
1269
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1270
|
-
// if (node) {
|
|
1271
|
-
// setSuffixNode(node);
|
|
1272
|
-
// setHasValidStringSuffix(true);
|
|
1273
|
-
// } else {
|
|
1274
|
-
// setSuffixNode(null);
|
|
1275
|
-
// setHasValidStringSuffix(false);
|
|
1276
|
-
// }
|
|
1277
|
-
// });
|
|
1278
|
-
// }, [final.stringSuffix]);
|
|
1279
|
-
// const selectHasValue = !!selectValue;
|
|
1280
|
-
// const { variant: themeVariant } = useVariant();
|
|
1281
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1282
|
-
// const showPrefix = React.useMemo(() => {
|
|
1283
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1284
|
-
// if (final.startIcon) return true;
|
|
1285
|
-
// if (final.prefix) return true;
|
|
1286
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1287
|
-
// return false;
|
|
1288
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1289
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1290
|
-
// const showSuffix = React.useMemo(() => {
|
|
1291
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1292
|
-
// if (final.endIcon) return true;
|
|
1293
|
-
// if (final.suffix) return true;
|
|
1294
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1295
|
-
// return false;
|
|
1296
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1297
|
-
// // Get effective icons following Button's priority pattern
|
|
1298
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
1299
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
1300
|
-
// if (final.startIcon) return final.startIcon;
|
|
1301
|
-
// if (final.prefix) return final.prefix;
|
|
1302
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
1303
|
-
// return null;
|
|
1304
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1305
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
1306
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
1307
|
-
// if (final.endIcon) return final.endIcon;
|
|
1308
|
-
// if (final.suffix) return final.suffix;
|
|
1309
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
1310
|
-
// return null;
|
|
1311
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1312
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
1313
|
-
// const hasNoLabel = !label;
|
|
1314
|
-
// const className = generateInputClasses({
|
|
1315
|
-
// status: final.status,
|
|
1316
|
-
// rounded: final.rounded,
|
|
1317
|
-
// bg: final.bg,
|
|
1318
|
-
// funcss: final.funcss,
|
|
1319
|
-
// flat: final.flat,
|
|
1320
|
-
// leftRounded: final.leftRounded,
|
|
1321
|
-
// rightRounded: final.rightRounded,
|
|
1322
|
-
// bordered: final.bordered,
|
|
1323
|
-
// borderless: final.borderless,
|
|
1324
|
-
// hasNoPrefix,
|
|
1325
|
-
// hasNoLabel,
|
|
1326
|
-
// });
|
|
1327
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1328
|
-
// const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
1329
|
-
// const newValue = e.target.value;
|
|
1330
|
-
// setSelectValue(newValue);
|
|
1331
|
-
// if (onChange) onChange(e);
|
|
1332
|
-
// };
|
|
1333
|
-
// const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1334
|
-
// setIsFocused(true);
|
|
1335
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
1336
|
-
// };
|
|
1337
|
-
// const handleBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1338
|
-
// setIsFocused(false);
|
|
1339
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
1340
|
-
// };
|
|
1341
|
-
// const selectElement = (
|
|
1342
|
-
// <select
|
|
1343
|
-
// id={id}
|
|
1344
|
-
// name={name}
|
|
1345
|
-
// className={className}
|
|
1346
|
-
// onChange={handleChange}
|
|
1347
|
-
// onFocus={handleFocus}
|
|
1348
|
-
// onBlur={handleBlur}
|
|
1349
|
-
// defaultValue={defaultValue}
|
|
1350
|
-
// value={selectValue}
|
|
1351
|
-
// style={style}
|
|
1352
|
-
// {...rest}
|
|
1353
|
-
// >
|
|
1354
|
-
// {options.map((option) => (
|
|
1355
|
-
// <option key={option.value} value={option.value}>
|
|
1356
|
-
// {option.text}
|
|
1357
|
-
// </option>
|
|
1358
|
-
// ))}
|
|
1359
|
-
// </select>
|
|
1360
|
-
// );
|
|
1361
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1362
|
-
// const wrappedSelect = showPrefix || showSuffix ? (
|
|
1363
|
-
// <IconicInputWrapper
|
|
1364
|
-
// startIcon={effectivePrefix}
|
|
1365
|
-
// endIcon={effectiveSuffix}
|
|
1366
|
-
// iconicBg={final.iconicBg}
|
|
1367
|
-
// funcss={final.funcss}
|
|
1368
|
-
// stringPrefix={stringPrefix}
|
|
1369
|
-
// stringSuffix={stringSuffix}
|
|
1370
|
-
// >
|
|
1371
|
-
// {selectElement}
|
|
1372
|
-
// </IconicInputWrapper>
|
|
1373
|
-
// ) : (
|
|
1374
|
-
// selectElement
|
|
1375
|
-
// );
|
|
1376
|
-
// return (
|
|
1377
|
-
// <InputContainer
|
|
1378
|
-
// startIcon={effectivePrefix}
|
|
1379
|
-
// label={label}
|
|
1380
|
-
// status={final.status}
|
|
1381
|
-
// helperText={helperText}
|
|
1382
|
-
// isFocused={isFocused}
|
|
1383
|
-
// hasValue={selectHasValue}
|
|
1384
|
-
// fullWidth={final.fullWidth}
|
|
1385
|
-
// id={id}
|
|
1386
|
-
// alwaysActiveLabel={true}
|
|
1387
|
-
// >
|
|
1388
|
-
// {wrappedSelect}
|
|
1389
|
-
// </InputContainer>
|
|
1390
|
-
// );
|
|
1391
|
-
// };
|
|
1392
|
-
// // Textarea Component - UPDATED to match pattern
|
|
1393
|
-
// export const TextareaInput: React.FC<TextareaProps & React.TextareaHTMLAttributes<HTMLTextAreaElement>> = ({
|
|
1394
|
-
// id,
|
|
1395
|
-
// name,
|
|
1396
|
-
// value,
|
|
1397
|
-
// defaultValue,
|
|
1398
|
-
// onChange,
|
|
1399
|
-
// status,
|
|
1400
|
-
// funcss,
|
|
1401
|
-
// bg,
|
|
1402
|
-
// fullWidth,
|
|
1403
|
-
// flat,
|
|
1404
|
-
// bordered,
|
|
1405
|
-
// borderless,
|
|
1406
|
-
// rounded,
|
|
1407
|
-
// leftRounded,
|
|
1408
|
-
// rightRounded,
|
|
1409
|
-
// startIcon,
|
|
1410
|
-
// endIcon,
|
|
1411
|
-
// prefix,
|
|
1412
|
-
// suffix,
|
|
1413
|
-
// stringPrefix,
|
|
1414
|
-
// stringSuffix,
|
|
1415
|
-
// iconicBg,
|
|
1416
|
-
// label,
|
|
1417
|
-
// helperText,
|
|
1418
|
-
// rows = 2,
|
|
1419
|
-
// variant = '',
|
|
1420
|
-
// placeholder,
|
|
1421
|
-
// ...rest
|
|
1422
|
-
// }) => {
|
|
1423
|
-
// const [isFocused, setIsFocused] = useState(false);
|
|
1424
|
-
// const [textValue, setTextValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
1425
|
-
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
1426
|
-
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
1427
|
-
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
1428
|
-
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
1429
|
-
// useEffect(() => {
|
|
1430
|
-
// if (value !== undefined && value !== '') {
|
|
1431
|
-
// setTextValue(String(value));
|
|
1432
|
-
// } else if (value === '') {
|
|
1433
|
-
// setTextValue('');
|
|
1434
|
-
// }
|
|
1435
|
-
// }, [value]);
|
|
1436
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1437
|
-
// const localProps = {
|
|
1438
|
-
// status,
|
|
1439
|
-
// funcss,
|
|
1440
|
-
// bg,
|
|
1441
|
-
// fullWidth,
|
|
1442
|
-
// flat,
|
|
1443
|
-
// bordered,
|
|
1444
|
-
// borderless,
|
|
1445
|
-
// rounded,
|
|
1446
|
-
// leftRounded,
|
|
1447
|
-
// rightRounded,
|
|
1448
|
-
// startIcon,
|
|
1449
|
-
// endIcon,
|
|
1450
|
-
// prefix,
|
|
1451
|
-
// suffix,
|
|
1452
|
-
// iconicBg,
|
|
1453
|
-
// stringPrefix,
|
|
1454
|
-
// stringSuffix,
|
|
1455
|
-
// };
|
|
1456
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1457
|
-
// const final = {
|
|
1458
|
-
// status: status !== undefined ? status : mergedProps.status,
|
|
1459
|
-
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1460
|
-
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1461
|
-
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1462
|
-
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1463
|
-
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1464
|
-
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1465
|
-
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1466
|
-
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1467
|
-
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1468
|
-
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1469
|
-
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1470
|
-
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1471
|
-
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1472
|
-
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1473
|
-
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1474
|
-
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1475
|
-
// };
|
|
1476
|
-
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1477
|
-
// useEffect(() => {
|
|
1478
|
-
// const effectiveStringPrefix = final.stringPrefix;
|
|
1479
|
-
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1480
|
-
// setPrefixNode(null);
|
|
1481
|
-
// setHasValidStringPrefix(false);
|
|
1482
|
-
// return;
|
|
1483
|
-
// }
|
|
1484
|
-
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1485
|
-
// if (node) {
|
|
1486
|
-
// setPrefixNode(node);
|
|
1487
|
-
// setHasValidStringPrefix(true);
|
|
1488
|
-
// } else {
|
|
1489
|
-
// setPrefixNode(null);
|
|
1490
|
-
// setHasValidStringPrefix(false);
|
|
1491
|
-
// }
|
|
1492
|
-
// });
|
|
1493
|
-
// }, [final.stringPrefix]);
|
|
1494
|
-
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1495
|
-
// useEffect(() => {
|
|
1496
|
-
// const effectiveStringSuffix = final.stringSuffix;
|
|
1497
|
-
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1498
|
-
// setSuffixNode(null);
|
|
1499
|
-
// setHasValidStringSuffix(false);
|
|
1500
|
-
// return;
|
|
1501
|
-
// }
|
|
1502
|
-
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1503
|
-
// if (node) {
|
|
1504
|
-
// setSuffixNode(node);
|
|
1505
|
-
// setHasValidStringSuffix(true);
|
|
1506
|
-
// } else {
|
|
1507
|
-
// setSuffixNode(null);
|
|
1508
|
-
// setHasValidStringSuffix(false);
|
|
1509
|
-
// }
|
|
1510
|
-
// });
|
|
1511
|
-
// }, [final.stringSuffix]);
|
|
1512
|
-
// const { variant: themeVariant } = useVariant();
|
|
1513
|
-
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1514
|
-
// const showPrefix = React.useMemo(() => {
|
|
1515
|
-
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1516
|
-
// if (final.startIcon) return true;
|
|
1517
|
-
// if (final.prefix) return true;
|
|
1518
|
-
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1519
|
-
// return false;
|
|
1520
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1521
|
-
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1522
|
-
// const showSuffix = React.useMemo(() => {
|
|
1523
|
-
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1524
|
-
// if (final.endIcon) return true;
|
|
1525
|
-
// if (final.suffix) return true;
|
|
1526
|
-
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1527
|
-
// return false;
|
|
1528
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1529
|
-
// // Get effective icons following Button's priority pattern
|
|
1530
|
-
// const effectivePrefix = React.useMemo(() => {
|
|
1531
|
-
// // Priority: startIcon > prefix > stringPrefix
|
|
1532
|
-
// if (final.startIcon) return final.startIcon;
|
|
1533
|
-
// if (final.prefix) return final.prefix;
|
|
1534
|
-
// if (hasValidStringPrefix) return prefixNode;
|
|
1535
|
-
// return null;
|
|
1536
|
-
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1537
|
-
// const effectiveSuffix = React.useMemo(() => {
|
|
1538
|
-
// // Priority: endIcon > suffix > stringSuffix
|
|
1539
|
-
// if (final.endIcon) return final.endIcon;
|
|
1540
|
-
// if (final.suffix) return final.suffix;
|
|
1541
|
-
// if (hasValidStringSuffix) return suffixNode;
|
|
1542
|
-
// return null;
|
|
1543
|
-
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1544
|
-
// const hasNoPrefix = !effectivePrefix;
|
|
1545
|
-
// const hasNoLabel = !label;
|
|
1546
|
-
// const className = generateInputClasses({
|
|
1547
|
-
// status: final.status,
|
|
1548
|
-
// rounded: final.rounded,
|
|
1549
|
-
// bg: final.bg,
|
|
1550
|
-
// funcss: final.funcss,
|
|
1551
|
-
// flat: final.flat,
|
|
1552
|
-
// leftRounded: final.leftRounded,
|
|
1553
|
-
// rightRounded: final.rightRounded,
|
|
1554
|
-
// bordered: final.bordered,
|
|
1555
|
-
// borderless: final.borderless,
|
|
1556
|
-
// hasNoPrefix,
|
|
1557
|
-
// hasNoLabel,
|
|
1558
|
-
// });
|
|
1559
|
-
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1560
|
-
// const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
1561
|
-
// const newValue = e.target.value;
|
|
1562
|
-
// setTextValue(newValue);
|
|
1563
|
-
// if (onChange) onChange(e);
|
|
1564
|
-
// };
|
|
1565
|
-
// const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1566
|
-
// setIsFocused(true);
|
|
1567
|
-
// if (rest.onFocus) rest.onFocus(e);
|
|
1568
|
-
// };
|
|
1569
|
-
// const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1570
|
-
// setIsFocused(false);
|
|
1571
|
-
// if (rest.onBlur) rest.onBlur(e);
|
|
1572
|
-
// };
|
|
1573
|
-
// const showPlaceholder = placeholder && label && (isFocused || !!textValue);
|
|
1574
|
-
// const textareaElement = (
|
|
1575
|
-
// <textarea
|
|
1576
|
-
// id={id}
|
|
1577
|
-
// name={name}
|
|
1578
|
-
// className={className}
|
|
1579
|
-
// onChange={handleChange}
|
|
1580
|
-
// onFocus={handleFocus}
|
|
1581
|
-
// onBlur={handleBlur}
|
|
1582
|
-
// defaultValue={defaultValue}
|
|
1583
|
-
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
1584
|
-
// style={style}
|
|
1585
|
-
// value={textValue}
|
|
1586
|
-
// rows={rows}
|
|
1587
|
-
// {...rest}
|
|
1588
|
-
// />
|
|
1589
|
-
// );
|
|
1590
|
-
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1591
|
-
// const wrappedTextarea = showPrefix || showSuffix ? (
|
|
1592
|
-
// <IconicInputWrapper
|
|
1593
|
-
// startIcon={effectivePrefix}
|
|
1594
|
-
// endIcon={effectiveSuffix}
|
|
1595
|
-
// iconicBg={final.iconicBg}
|
|
1596
|
-
// funcss={final.funcss}
|
|
1597
|
-
// stringPrefix={stringPrefix}
|
|
1598
|
-
// stringSuffix={stringSuffix}
|
|
1599
|
-
// >
|
|
1600
|
-
// {textareaElement}
|
|
1601
|
-
// </IconicInputWrapper>
|
|
1602
|
-
// ) : (
|
|
1603
|
-
// textareaElement
|
|
1604
|
-
// );
|
|
1605
|
-
// return (
|
|
1606
|
-
// <InputContainer
|
|
1607
|
-
// startIcon={effectivePrefix}
|
|
1608
|
-
// label={label}
|
|
1609
|
-
// status={final.status}
|
|
1610
|
-
// helperText={helperText}
|
|
1611
|
-
// isFocused={isFocused}
|
|
1612
|
-
// hasValue={!!textValue}
|
|
1613
|
-
// fullWidth={final.fullWidth}
|
|
1614
|
-
// id={id}
|
|
1615
|
-
// >
|
|
1616
|
-
// {wrappedTextarea}
|
|
1617
|
-
// </InputContainer>
|
|
1618
|
-
// );
|
|
1619
|
-
// };
|
|
1620
|
-
// // Main Input Component (backwards compatibility)
|
|
1621
|
-
// interface InputProps extends BaseInputProps {
|
|
1622
|
-
// select?: boolean;
|
|
1623
|
-
// multiline?: boolean;
|
|
1624
|
-
// file?: boolean;
|
|
1625
|
-
// noBorder?: boolean;
|
|
1626
|
-
// icon?: React.ReactNode;
|
|
1627
|
-
// extra?: React.ReactNode;
|
|
1628
|
-
// button?: React.ReactNode;
|
|
1629
|
-
// btn?: boolean;
|
|
1630
|
-
// type?: string;
|
|
1631
|
-
// options?: SelectOption[];
|
|
1632
|
-
// rows?: number;
|
|
1633
|
-
// }
|
|
1634
|
-
// const Input: React.FC<InputProps> = ({
|
|
1635
|
-
// select,
|
|
1636
|
-
// multiline,
|
|
1637
|
-
// file,
|
|
1638
|
-
// noBorder,
|
|
1639
|
-
// startIcon,
|
|
1640
|
-
// endIcon,
|
|
1641
|
-
// prefix,
|
|
1642
|
-
// suffix,
|
|
1643
|
-
// stringPrefix,
|
|
1644
|
-
// stringSuffix,
|
|
1645
|
-
// iconicBg,
|
|
1646
|
-
// type,
|
|
1647
|
-
// variant = '',
|
|
1648
|
-
// ...props
|
|
1649
|
-
// }) => {
|
|
1650
|
-
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1651
|
-
// const localProps = {
|
|
1652
|
-
// ...props,
|
|
1653
|
-
// startIcon,
|
|
1654
|
-
// endIcon,
|
|
1655
|
-
// prefix,
|
|
1656
|
-
// suffix,
|
|
1657
|
-
// iconicBg,
|
|
1658
|
-
// stringPrefix,
|
|
1659
|
-
// stringSuffix,
|
|
1660
|
-
// type,
|
|
1661
|
-
// };
|
|
1662
|
-
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1663
|
-
// const inputProps = {
|
|
1664
|
-
// ...props,
|
|
1665
|
-
// ...mergedProps,
|
|
1666
|
-
// variant,
|
|
1667
|
-
// borderless: noBorder !== undefined ? noBorder : (props.borderless !== undefined ? props.borderless : mergedProps.borderless),
|
|
1668
|
-
// type,
|
|
1669
|
-
// };
|
|
1670
|
-
// if (file || type === 'file') {
|
|
1671
|
-
// return <FileUpload {...inputProps} />;
|
|
1672
|
-
// }
|
|
1673
|
-
// if (select) {
|
|
1674
|
-
// return <SelectInput {...inputProps} />;
|
|
1675
|
-
// }
|
|
1676
|
-
// if (multiline) {
|
|
1677
|
-
// return <TextareaInput {...inputProps} />;
|
|
1678
|
-
// }
|
|
1679
|
-
// return <TextInput {...inputProps} />;
|
|
1680
|
-
// };
|
|
1681
|
-
// export default Input;
|