funuicss 3.8.8 → 3.8.9
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 -0
- 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/feature/Feature.d.ts +9 -38
- package/ui/feature/Feature.js +62 -147
- 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 +382 -316
- package/ui/input/Input.d.ts +16 -21
- package/ui/input/Input.js +135 -359
- 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: 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)));
|
|
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,47 +86,61 @@ 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
|
};
|
|
@@ -136,12 +153,10 @@ 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
161
|
if (value !== undefined && value !== '') {
|
|
147
162
|
setInputValue(String(value));
|
|
@@ -151,6 +166,13 @@ var TextInput = function (_a) {
|
|
|
151
166
|
}
|
|
152
167
|
}, [value]);
|
|
153
168
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
169
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
170
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
171
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
172
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
173
|
+
// Convert string icons to ReactNode
|
|
174
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
175
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
154
176
|
var localProps = {
|
|
155
177
|
status: status,
|
|
156
178
|
funcss: funcss,
|
|
@@ -162,13 +184,11 @@ var TextInput = function (_a) {
|
|
|
162
184
|
rounded: rounded,
|
|
163
185
|
leftRounded: leftRounded,
|
|
164
186
|
rightRounded: rightRounded,
|
|
165
|
-
startIcon:
|
|
166
|
-
endIcon:
|
|
167
|
-
prefix: prefix,
|
|
168
|
-
suffix: suffix,
|
|
187
|
+
startIcon: startIconNode,
|
|
188
|
+
endIcon: endIconNode,
|
|
169
189
|
iconicBg: iconicBg,
|
|
170
|
-
|
|
171
|
-
|
|
190
|
+
label: label,
|
|
191
|
+
helperText: helperText,
|
|
172
192
|
};
|
|
173
193
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
174
194
|
var final = {
|
|
@@ -182,97 +202,16 @@ var TextInput = function (_a) {
|
|
|
182
202
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
183
203
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
184
204
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
185
|
-
startIcon:
|
|
186
|
-
endIcon:
|
|
187
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
188
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
205
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
206
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
189
207
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
190
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
191
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
192
208
|
};
|
|
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;
|
|
209
|
+
// For password fields, show toggle button if no endIcon/suffix/stringSuffix is provided
|
|
210
|
+
var passwordToggleIcon = isPasswordType && !effectiveEndIcon ? (react_1.default.createElement(PasswordToggleButton, { showPassword: showPassword, onToggle: function () { return setShowPassword(!showPassword); }, disabled: disabled })) : null;
|
|
211
|
+
var effectiveEndIconWithPassword = passwordToggleIcon || final.endIcon;
|
|
212
|
+
var showPrefix = !!final.startIcon;
|
|
213
|
+
var showSuffix = !!effectiveEndIconWithPassword;
|
|
214
|
+
var hasNoPrefix = !showPrefix;
|
|
276
215
|
var hasNoLabel = !label;
|
|
277
216
|
var className = generateInputClasses({
|
|
278
217
|
status: final.status,
|
|
@@ -305,15 +244,16 @@ var TextInput = function (_a) {
|
|
|
305
244
|
onBlur(e);
|
|
306
245
|
};
|
|
307
246
|
var showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
308
|
-
var
|
|
247
|
+
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: onKeyDown, onKeyUp: onKeyUp, onKeyPress: onKeyPress, onSubmit: onSubmit, defaultValue: defaultValue, type: inputType, placeholder: showPlaceholder ? placeholder : (!label ? placeholder : ''), style: style, value: inputValue,
|
|
309
249
|
// HTML Input Attributes
|
|
310
250
|
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:
|
|
251
|
+
// Only use iconic wrapper when we have icons
|
|
252
|
+
var wrappedInput = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: effectiveEndIconWithPassword, iconicBg: final.iconicBg, funcss: final.funcss }, inputElement)) : (inputElement);
|
|
253
|
+
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
254
|
};
|
|
315
255
|
exports.TextInput = TextInput;
|
|
316
|
-
// Select Component
|
|
256
|
+
// Select Component
|
|
317
257
|
var SelectInput = function (_a) {
|
|
318
258
|
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
259
|
// HTML Select Attributes
|
|
@@ -322,10 +262,6 @@ var SelectInput = function (_a) {
|
|
|
322
262
|
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
263
|
var _g = (0, react_1.useState)(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
324
264
|
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
265
|
(0, react_1.useEffect)(function () {
|
|
330
266
|
if (value !== undefined && value !== '') {
|
|
331
267
|
setSelectValue(String(value));
|
|
@@ -335,6 +271,13 @@ var SelectInput = function (_a) {
|
|
|
335
271
|
}
|
|
336
272
|
}, [value]);
|
|
337
273
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
274
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
275
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
276
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
277
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
278
|
+
// Convert string icons to ReactNode
|
|
279
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
280
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
338
281
|
var localProps = {
|
|
339
282
|
status: status,
|
|
340
283
|
funcss: funcss,
|
|
@@ -346,13 +289,11 @@ var SelectInput = function (_a) {
|
|
|
346
289
|
rounded: rounded,
|
|
347
290
|
leftRounded: leftRounded,
|
|
348
291
|
rightRounded: rightRounded,
|
|
349
|
-
startIcon:
|
|
350
|
-
endIcon:
|
|
351
|
-
prefix: prefix,
|
|
352
|
-
suffix: suffix,
|
|
292
|
+
startIcon: startIconNode,
|
|
293
|
+
endIcon: endIconNode,
|
|
353
294
|
iconicBg: iconicBg,
|
|
354
|
-
|
|
355
|
-
|
|
295
|
+
label: label,
|
|
296
|
+
helperText: helperText,
|
|
356
297
|
};
|
|
357
298
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
358
299
|
var final = {
|
|
@@ -366,98 +307,14 @@ var SelectInput = function (_a) {
|
|
|
366
307
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
367
308
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
368
309
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
369
|
-
startIcon:
|
|
370
|
-
endIcon:
|
|
371
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
372
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
310
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
311
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
373
312
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
374
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
375
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
376
313
|
};
|
|
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
314
|
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;
|
|
315
|
+
var showPrefix = !!final.startIcon;
|
|
316
|
+
var showSuffix = !!final.endIcon;
|
|
317
|
+
var hasNoPrefix = !showPrefix;
|
|
461
318
|
var hasNoLabel = !label;
|
|
462
319
|
var className = generateInputClasses({
|
|
463
320
|
status: final.status,
|
|
@@ -489,18 +346,15 @@ var SelectInput = function (_a) {
|
|
|
489
346
|
if (onBlur)
|
|
490
347
|
onBlur(e);
|
|
491
348
|
};
|
|
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));
|
|
349
|
+
// Extract only valid HTML select attributes for the select element
|
|
350
|
+
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);
|
|
351
|
+
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)); })));
|
|
352
|
+
// Only use iconic wrapper when we have icons
|
|
353
|
+
var wrappedSelect = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: final.endIcon, iconicBg: final.iconicBg, funcss: final.funcss }, selectElement)) : (selectElement);
|
|
354
|
+
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
355
|
};
|
|
502
356
|
exports.SelectInput = SelectInput;
|
|
503
|
-
// Textarea Component
|
|
357
|
+
// Textarea Component
|
|
504
358
|
var TextareaInput = function (_a) {
|
|
505
359
|
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
360
|
// HTML Textarea Attributes
|
|
@@ -509,10 +363,6 @@ var TextareaInput = function (_a) {
|
|
|
509
363
|
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
364
|
var _h = (0, react_1.useState)(false), isFocused = _h[0], setIsFocused = _h[1];
|
|
511
365
|
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
366
|
(0, react_1.useEffect)(function () {
|
|
517
367
|
if (value !== undefined && value !== '') {
|
|
518
368
|
setTextValue(String(value));
|
|
@@ -522,6 +372,13 @@ var TextareaInput = function (_a) {
|
|
|
522
372
|
}
|
|
523
373
|
}, [value]);
|
|
524
374
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
375
|
+
// Determine effective icons with priority: startIcon > prefix > stringPrefix
|
|
376
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
377
|
+
// Determine effective icons with priority: endIcon > suffix > stringSuffix
|
|
378
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
379
|
+
// Convert string icons to ReactNode
|
|
380
|
+
var startIconNode = useIcon(effectiveStartIcon);
|
|
381
|
+
var endIconNode = useIcon(effectiveEndIcon);
|
|
525
382
|
var localProps = {
|
|
526
383
|
status: status,
|
|
527
384
|
funcss: funcss,
|
|
@@ -533,13 +390,11 @@ var TextareaInput = function (_a) {
|
|
|
533
390
|
rounded: rounded,
|
|
534
391
|
leftRounded: leftRounded,
|
|
535
392
|
rightRounded: rightRounded,
|
|
536
|
-
startIcon:
|
|
537
|
-
endIcon:
|
|
538
|
-
prefix: prefix,
|
|
539
|
-
suffix: suffix,
|
|
393
|
+
startIcon: startIconNode,
|
|
394
|
+
endIcon: endIconNode,
|
|
540
395
|
iconicBg: iconicBg,
|
|
541
|
-
|
|
542
|
-
|
|
396
|
+
label: label,
|
|
397
|
+
helperText: helperText,
|
|
543
398
|
};
|
|
544
399
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
545
400
|
var final = {
|
|
@@ -553,97 +408,13 @@ var TextareaInput = function (_a) {
|
|
|
553
408
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
554
409
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
555
410
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
556
|
-
startIcon:
|
|
557
|
-
endIcon:
|
|
558
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
559
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
411
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
412
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
560
413
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
561
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
562
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
563
414
|
};
|
|
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;
|
|
415
|
+
var showPrefix = !!final.startIcon;
|
|
416
|
+
var showSuffix = !!final.endIcon;
|
|
417
|
+
var hasNoPrefix = !showPrefix;
|
|
647
418
|
var hasNoLabel = !label;
|
|
648
419
|
var className = generateInputClasses({
|
|
649
420
|
status: final.status,
|
|
@@ -676,34 +447,39 @@ var TextareaInput = function (_a) {
|
|
|
676
447
|
onBlur(e);
|
|
677
448
|
};
|
|
678
449
|
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));
|
|
450
|
+
// Extract only valid HTML textarea attributes
|
|
451
|
+
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);
|
|
452
|
+
var textareaElement = react_1.default.createElement("textarea", __assign({}, textareaAttributes));
|
|
453
|
+
// Only use iconic wrapper when we have icons
|
|
454
|
+
var wrappedTextarea = showPrefix || showSuffix ? (react_1.default.createElement(IconicInputWrapper, { startIcon: final.startIcon, endIcon: final.endIcon, iconicBg: final.iconicBg, funcss: final.funcss }, textareaElement)) : (textareaElement);
|
|
455
|
+
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
456
|
};
|
|
690
457
|
exports.TextareaInput = TextareaInput;
|
|
691
458
|
var Input = function (_a) {
|
|
692
|
-
var select = _a.select, multiline = _a.multiline,
|
|
459
|
+
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
460
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
694
|
-
|
|
461
|
+
// Determine effective icons with priority:
|
|
462
|
+
// For start: startIcon > prefix > stringPrefix
|
|
463
|
+
// For end: endIcon > suffix > stringSuffix
|
|
464
|
+
var effectiveStartIcon = startIcon || prefix || stringPrefix;
|
|
465
|
+
var effectiveEndIcon = endIcon || suffix || stringSuffix;
|
|
466
|
+
// Create local props object including all input props
|
|
467
|
+
var localProps = __assign(__assign({}, props), { startIcon: effectiveStartIcon, endIcon: effectiveEndIcon, iconicBg: iconicBg, type: type,
|
|
468
|
+
// Ensure all event handlers are passed through
|
|
469
|
+
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
470
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
471
|
+
// Build the final props object
|
|
472
|
+
var inputProps = __assign(__assign(__assign(__assign({}, mergedProps), {
|
|
473
|
+
// Then spread all component-specific props to ensure they override theme
|
|
474
|
+
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 });
|
|
475
|
+
var finalInputProps = __assign(__assign({}, inputProps), { onChange: props.onChange || inputProps.onChange, onBlur: props.onBlur || inputProps.onBlur, onFocus: props.onFocus || inputProps.onFocus });
|
|
700
476
|
if (select) {
|
|
701
|
-
return react_1.default.createElement(exports.SelectInput, __assign({},
|
|
477
|
+
return react_1.default.createElement(exports.SelectInput, __assign({}, finalInputProps));
|
|
702
478
|
}
|
|
703
479
|
if (multiline) {
|
|
704
|
-
return react_1.default.createElement(exports.TextareaInput, __assign({},
|
|
480
|
+
return react_1.default.createElement(exports.TextareaInput, __assign({}, finalInputProps));
|
|
705
481
|
}
|
|
706
|
-
return react_1.default.createElement(exports.TextInput, __assign({},
|
|
482
|
+
return react_1.default.createElement(exports.TextInput, __assign({}, finalInputProps));
|
|
707
483
|
};
|
|
708
484
|
exports.default = Input;
|
|
709
485
|
// 'use client'
|