funuicss 3.8.7 → 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 +702 -87
- package/index.d.ts +3 -0
- package/index.js +8 -2
- package/package.json +1 -1
- package/ui/button/Button.d.ts +6 -5
- package/ui/button/Button.js +190 -84
- package/ui/div/Div.d.ts +3 -1
- package/ui/div/Div.js +2 -2
- 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 +77 -0
- package/ui/form/Form.js +724 -0
- package/ui/input/FileUpload.js +370 -21
- package/ui/input/Input.d.ts +44 -15
- package/ui/input/Input.js +1145 -369
- package/ui/products/CartModal.d.ts +0 -2
- package/ui/products/CartModal.js +59 -39
- package/ui/products/ProductCard.js +9 -22
- package/ui/products/ProductDetail.js +136 -97
- package/ui/products/ProductLoader.d.ts +3 -0
- package/ui/products/ProductLoader.js +22 -0
- package/ui/products/Store.d.ts +32 -7
- package/ui/products/Store.js +393 -94
- package/ui/progress/Bar.js +2 -2
- package/ui/sidebar/SideBar.js +1 -2
- package/ui/specials/CircleGroup.d.ts +2 -1
- package/ui/specials/CircleGroup.js +3 -3
- package/ui/theme/theme.d.ts +4 -0
- package/ui/theme/theme.js +336 -133
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,59 +86,77 @@ 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) : '') },
|
|
140
|
+
label,
|
|
141
|
+
required && react_1.default.createElement("span", { className: "required-indicator" }, "*"))),
|
|
123
142
|
children),
|
|
124
|
-
(helperText
|
|
143
|
+
(helperText) && (react_1.default.createElement("div", { className: "input-helper-text ".concat(status ? "helper-".concat(status) : '') },
|
|
125
144
|
status && statusIcons[status] && (react_1.default.createElement("span", { className: "helper-icon" }, statusIcons[status])),
|
|
126
145
|
react_1.default.createElement("span", null, helperText)))));
|
|
127
146
|
};
|
|
128
147
|
// Text Input Component
|
|
129
148
|
var TextInput = function (_a) {
|
|
130
|
-
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, 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,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var _j = (0, react_1.useState)(false),
|
|
136
|
-
var _k = (0, react_1.useState)(
|
|
149
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onClick = _a.onClick, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onKeyPress = _a.onKeyPress, onSubmit = _a.onSubmit, status = _a.status, funcss = _a.funcss, bg = _a.bg, _b = _a.fullWidth, fullWidth = _b === void 0 ? true : _b, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, startIcon = _a.startIcon, endIcon = _a.endIcon, prefix = _a.prefix, suffix = _a.suffix, stringPrefix = _a.stringPrefix, stringSuffix = _a.stringSuffix, iconicBg = _a.iconicBg, _c = _a.type, type = _c === void 0 ? 'text' : _c, label = _a.label, helperText = _a.helperText, _d = _a.variant, variant = _d === void 0 ? '' : _d, placeholder = _a.placeholder,
|
|
150
|
+
// HTML Input Attributes
|
|
151
|
+
_e = _a.disabled,
|
|
152
|
+
// HTML Input Attributes
|
|
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"]);
|
|
154
|
+
var _j = (0, react_1.useState)(false), isFocused = _j[0], setIsFocused = _j[1];
|
|
155
|
+
var _k = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), inputValue = _k[0], setInputValue = _k[1];
|
|
156
|
+
var _l = (0, react_1.useState)(false), showPassword = _l[0], setShowPassword = _l[1];
|
|
137
157
|
var inputRef = (0, react_1.useRef)(null);
|
|
138
158
|
var isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
159
|
+
var isPasswordType = type === 'password';
|
|
139
160
|
(0, react_1.useEffect)(function () {
|
|
140
161
|
if (value !== undefined && value !== '') {
|
|
141
162
|
setInputValue(String(value));
|
|
@@ -145,6 +166,13 @@ var TextInput = function (_a) {
|
|
|
145
166
|
}
|
|
146
167
|
}, [value]);
|
|
147
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);
|
|
148
176
|
var localProps = {
|
|
149
177
|
status: status,
|
|
150
178
|
funcss: funcss,
|
|
@@ -156,13 +184,11 @@ var TextInput = function (_a) {
|
|
|
156
184
|
rounded: rounded,
|
|
157
185
|
leftRounded: leftRounded,
|
|
158
186
|
rightRounded: rightRounded,
|
|
159
|
-
startIcon:
|
|
160
|
-
endIcon:
|
|
161
|
-
prefix: prefix,
|
|
162
|
-
suffix: suffix,
|
|
187
|
+
startIcon: startIconNode,
|
|
188
|
+
endIcon: endIconNode,
|
|
163
189
|
iconicBg: iconicBg,
|
|
164
|
-
|
|
165
|
-
|
|
190
|
+
label: label,
|
|
191
|
+
helperText: helperText,
|
|
166
192
|
};
|
|
167
193
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
168
194
|
var final = {
|
|
@@ -176,97 +202,16 @@ var TextInput = function (_a) {
|
|
|
176
202
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
177
203
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
178
204
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
179
|
-
startIcon:
|
|
180
|
-
endIcon:
|
|
181
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
182
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
205
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
206
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
183
207
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
184
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
185
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
186
208
|
};
|
|
187
|
-
//
|
|
188
|
-
(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
196
|
-
if (node) {
|
|
197
|
-
setPrefixNode(node);
|
|
198
|
-
setHasValidStringPrefix(true);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
setPrefixNode(null);
|
|
202
|
-
setHasValidStringPrefix(false);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}, [final.stringPrefix]);
|
|
206
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
207
|
-
(0, react_1.useEffect)(function () {
|
|
208
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
209
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
210
|
-
setSuffixNode(null);
|
|
211
|
-
setHasValidStringSuffix(false);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
215
|
-
if (node) {
|
|
216
|
-
setSuffixNode(node);
|
|
217
|
-
setHasValidStringSuffix(true);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
setSuffixNode(null);
|
|
221
|
-
setHasValidStringSuffix(false);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}, [final.stringSuffix]);
|
|
225
|
-
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
226
|
-
// Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
227
|
-
var showPrefix = react_1.default.useMemo(function () {
|
|
228
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
229
|
-
if (final.startIcon)
|
|
230
|
-
return true;
|
|
231
|
-
if (final.prefix)
|
|
232
|
-
return true;
|
|
233
|
-
if (hasValidStringPrefix && prefixNode)
|
|
234
|
-
return true;
|
|
235
|
-
return false;
|
|
236
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
237
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
238
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
239
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
240
|
-
if (final.endIcon)
|
|
241
|
-
return true;
|
|
242
|
-
if (final.suffix)
|
|
243
|
-
return true;
|
|
244
|
-
if (hasValidStringSuffix && suffixNode)
|
|
245
|
-
return true;
|
|
246
|
-
return false;
|
|
247
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
248
|
-
// Get effective icons following Button's priority pattern
|
|
249
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
250
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
251
|
-
if (final.startIcon)
|
|
252
|
-
return final.startIcon;
|
|
253
|
-
if (final.prefix)
|
|
254
|
-
return final.prefix;
|
|
255
|
-
if (hasValidStringPrefix)
|
|
256
|
-
return prefixNode;
|
|
257
|
-
return null;
|
|
258
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
259
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
260
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
261
|
-
if (final.endIcon)
|
|
262
|
-
return final.endIcon;
|
|
263
|
-
if (final.suffix)
|
|
264
|
-
return final.suffix;
|
|
265
|
-
if (hasValidStringSuffix)
|
|
266
|
-
return suffixNode;
|
|
267
|
-
return null;
|
|
268
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
269
|
-
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;
|
|
270
215
|
var hasNoLabel = !label;
|
|
271
216
|
var className = generateInputClasses({
|
|
272
217
|
status: final.status,
|
|
@@ -290,30 +235,33 @@ var TextInput = function (_a) {
|
|
|
290
235
|
};
|
|
291
236
|
var handleFocus = function (e) {
|
|
292
237
|
setIsFocused(true);
|
|
293
|
-
if (
|
|
294
|
-
|
|
238
|
+
if (onFocus)
|
|
239
|
+
onFocus(e);
|
|
295
240
|
};
|
|
296
241
|
var handleBlur = function (e) {
|
|
297
242
|
setIsFocused(false);
|
|
298
|
-
if (
|
|
299
|
-
|
|
243
|
+
if (onBlur)
|
|
244
|
+
onBlur(e);
|
|
300
245
|
};
|
|
301
246
|
var showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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,
|
|
249
|
+
// HTML Input Attributes
|
|
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)));
|
|
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));
|
|
306
254
|
};
|
|
307
255
|
exports.TextInput = TextInput;
|
|
308
|
-
// Select Component
|
|
256
|
+
// Select Component
|
|
309
257
|
var SelectInput = function (_a) {
|
|
310
|
-
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, 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,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var
|
|
316
|
-
var
|
|
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,
|
|
259
|
+
// HTML Select Attributes
|
|
260
|
+
_d = _a.disabled,
|
|
261
|
+
// HTML Select Attributes
|
|
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"]);
|
|
263
|
+
var _g = (0, react_1.useState)(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
264
|
+
var _h = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), selectValue = _h[0], setSelectValue = _h[1];
|
|
317
265
|
(0, react_1.useEffect)(function () {
|
|
318
266
|
if (value !== undefined && value !== '') {
|
|
319
267
|
setSelectValue(String(value));
|
|
@@ -323,6 +271,13 @@ var SelectInput = function (_a) {
|
|
|
323
271
|
}
|
|
324
272
|
}, [value]);
|
|
325
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);
|
|
326
281
|
var localProps = {
|
|
327
282
|
status: status,
|
|
328
283
|
funcss: funcss,
|
|
@@ -334,13 +289,11 @@ var SelectInput = function (_a) {
|
|
|
334
289
|
rounded: rounded,
|
|
335
290
|
leftRounded: leftRounded,
|
|
336
291
|
rightRounded: rightRounded,
|
|
337
|
-
startIcon:
|
|
338
|
-
endIcon:
|
|
339
|
-
prefix: prefix,
|
|
340
|
-
suffix: suffix,
|
|
292
|
+
startIcon: startIconNode,
|
|
293
|
+
endIcon: endIconNode,
|
|
341
294
|
iconicBg: iconicBg,
|
|
342
|
-
|
|
343
|
-
|
|
295
|
+
label: label,
|
|
296
|
+
helperText: helperText,
|
|
344
297
|
};
|
|
345
298
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
346
299
|
var final = {
|
|
@@ -354,98 +307,14 @@ var SelectInput = function (_a) {
|
|
|
354
307
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
355
308
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
356
309
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
357
|
-
startIcon:
|
|
358
|
-
endIcon:
|
|
359
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
360
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
310
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
311
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
361
312
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
362
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
363
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
364
313
|
};
|
|
365
|
-
// Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
366
|
-
(0, react_1.useEffect)(function () {
|
|
367
|
-
var effectiveStringPrefix = final.stringPrefix;
|
|
368
|
-
if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
369
|
-
setPrefixNode(null);
|
|
370
|
-
setHasValidStringPrefix(false);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
374
|
-
if (node) {
|
|
375
|
-
setPrefixNode(node);
|
|
376
|
-
setHasValidStringPrefix(true);
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
setPrefixNode(null);
|
|
380
|
-
setHasValidStringPrefix(false);
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}, [final.stringPrefix]);
|
|
384
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
385
|
-
(0, react_1.useEffect)(function () {
|
|
386
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
387
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
388
|
-
setSuffixNode(null);
|
|
389
|
-
setHasValidStringSuffix(false);
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
393
|
-
if (node) {
|
|
394
|
-
setSuffixNode(node);
|
|
395
|
-
setHasValidStringSuffix(true);
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
setSuffixNode(null);
|
|
399
|
-
setHasValidStringSuffix(false);
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}, [final.stringSuffix]);
|
|
403
314
|
var selectHasValue = !!selectValue;
|
|
404
|
-
var
|
|
405
|
-
|
|
406
|
-
var
|
|
407
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
408
|
-
if (final.startIcon)
|
|
409
|
-
return true;
|
|
410
|
-
if (final.prefix)
|
|
411
|
-
return true;
|
|
412
|
-
if (hasValidStringPrefix && prefixNode)
|
|
413
|
-
return true;
|
|
414
|
-
return false;
|
|
415
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
416
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
417
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
418
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
419
|
-
if (final.endIcon)
|
|
420
|
-
return true;
|
|
421
|
-
if (final.suffix)
|
|
422
|
-
return true;
|
|
423
|
-
if (hasValidStringSuffix && suffixNode)
|
|
424
|
-
return true;
|
|
425
|
-
return false;
|
|
426
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
427
|
-
// Get effective icons following Button's priority pattern
|
|
428
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
429
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
430
|
-
if (final.startIcon)
|
|
431
|
-
return final.startIcon;
|
|
432
|
-
if (final.prefix)
|
|
433
|
-
return final.prefix;
|
|
434
|
-
if (hasValidStringPrefix)
|
|
435
|
-
return prefixNode;
|
|
436
|
-
return null;
|
|
437
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
438
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
439
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
440
|
-
if (final.endIcon)
|
|
441
|
-
return final.endIcon;
|
|
442
|
-
if (final.suffix)
|
|
443
|
-
return final.suffix;
|
|
444
|
-
if (hasValidStringSuffix)
|
|
445
|
-
return suffixNode;
|
|
446
|
-
return null;
|
|
447
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
448
|
-
var hasNoPrefix = !effectivePrefix;
|
|
315
|
+
var showPrefix = !!final.startIcon;
|
|
316
|
+
var showSuffix = !!final.endIcon;
|
|
317
|
+
var hasNoPrefix = !showPrefix;
|
|
449
318
|
var hasNoLabel = !label;
|
|
450
319
|
var className = generateInputClasses({
|
|
451
320
|
status: final.status,
|
|
@@ -469,29 +338,31 @@ var SelectInput = function (_a) {
|
|
|
469
338
|
};
|
|
470
339
|
var handleFocus = function (e) {
|
|
471
340
|
setIsFocused(true);
|
|
472
|
-
if (
|
|
473
|
-
|
|
341
|
+
if (onFocus)
|
|
342
|
+
onFocus(e);
|
|
474
343
|
};
|
|
475
344
|
var handleBlur = function (e) {
|
|
476
345
|
setIsFocused(false);
|
|
477
|
-
if (
|
|
478
|
-
|
|
346
|
+
if (onBlur)
|
|
347
|
+
onBlur(e);
|
|
479
348
|
};
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
var
|
|
483
|
-
|
|
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));
|
|
484
355
|
};
|
|
485
356
|
exports.SelectInput = SelectInput;
|
|
486
|
-
// Textarea Component
|
|
357
|
+
// Textarea Component
|
|
487
358
|
var TextareaInput = function (_a) {
|
|
488
|
-
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, 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, _c = _a.variant, variant = _c === void 0 ? '' : _c, placeholder = _a.placeholder,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
var _h = (0, react_1.useState)(false),
|
|
494
|
-
var _j = (0, react_1.useState)(
|
|
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,
|
|
360
|
+
// HTML Textarea Attributes
|
|
361
|
+
_d = _a.disabled,
|
|
362
|
+
// HTML Textarea Attributes
|
|
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"]);
|
|
364
|
+
var _h = (0, react_1.useState)(false), isFocused = _h[0], setIsFocused = _h[1];
|
|
365
|
+
var _j = (0, react_1.useState)(value !== undefined ? String(value) : defaultValue || ''), textValue = _j[0], setTextValue = _j[1];
|
|
495
366
|
(0, react_1.useEffect)(function () {
|
|
496
367
|
if (value !== undefined && value !== '') {
|
|
497
368
|
setTextValue(String(value));
|
|
@@ -501,6 +372,13 @@ var TextareaInput = function (_a) {
|
|
|
501
372
|
}
|
|
502
373
|
}, [value]);
|
|
503
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);
|
|
504
382
|
var localProps = {
|
|
505
383
|
status: status,
|
|
506
384
|
funcss: funcss,
|
|
@@ -512,13 +390,11 @@ var TextareaInput = function (_a) {
|
|
|
512
390
|
rounded: rounded,
|
|
513
391
|
leftRounded: leftRounded,
|
|
514
392
|
rightRounded: rightRounded,
|
|
515
|
-
startIcon:
|
|
516
|
-
endIcon:
|
|
517
|
-
prefix: prefix,
|
|
518
|
-
suffix: suffix,
|
|
393
|
+
startIcon: startIconNode,
|
|
394
|
+
endIcon: endIconNode,
|
|
519
395
|
iconicBg: iconicBg,
|
|
520
|
-
|
|
521
|
-
|
|
396
|
+
label: label,
|
|
397
|
+
helperText: helperText,
|
|
522
398
|
};
|
|
523
399
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
524
400
|
var final = {
|
|
@@ -532,97 +408,13 @@ var TextareaInput = function (_a) {
|
|
|
532
408
|
rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
533
409
|
leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
534
410
|
rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
535
|
-
startIcon:
|
|
536
|
-
endIcon:
|
|
537
|
-
prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
538
|
-
suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
411
|
+
startIcon: startIconNode !== undefined ? startIconNode : mergedProps.startIcon,
|
|
412
|
+
endIcon: endIconNode !== undefined ? endIconNode : mergedProps.endIcon,
|
|
539
413
|
iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
540
|
-
stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
541
|
-
stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
542
414
|
};
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
547
|
-
setPrefixNode(null);
|
|
548
|
-
setHasValidStringPrefix(false);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringPrefix).then(function (node) {
|
|
552
|
-
if (node) {
|
|
553
|
-
setPrefixNode(node);
|
|
554
|
-
setHasValidStringPrefix(true);
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
setPrefixNode(null);
|
|
558
|
-
setHasValidStringPrefix(false);
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
}, [final.stringPrefix]);
|
|
562
|
-
// Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
563
|
-
(0, react_1.useEffect)(function () {
|
|
564
|
-
var effectiveStringSuffix = final.stringSuffix;
|
|
565
|
-
if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
566
|
-
setSuffixNode(null);
|
|
567
|
-
setHasValidStringSuffix(false);
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
(0, getDynamicIcon_1.getDynamicIcon)(effectiveStringSuffix).then(function (node) {
|
|
571
|
-
if (node) {
|
|
572
|
-
setSuffixNode(node);
|
|
573
|
-
setHasValidStringSuffix(true);
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
setSuffixNode(null);
|
|
577
|
-
setHasValidStringSuffix(false);
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
}, [final.stringSuffix]);
|
|
581
|
-
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
582
|
-
// Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
583
|
-
var showPrefix = react_1.default.useMemo(function () {
|
|
584
|
-
// Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
585
|
-
if (final.startIcon)
|
|
586
|
-
return true;
|
|
587
|
-
if (final.prefix)
|
|
588
|
-
return true;
|
|
589
|
-
if (hasValidStringPrefix && prefixNode)
|
|
590
|
-
return true;
|
|
591
|
-
return false;
|
|
592
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
593
|
-
// Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
594
|
-
var showSuffix = react_1.default.useMemo(function () {
|
|
595
|
-
// Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
596
|
-
if (final.endIcon)
|
|
597
|
-
return true;
|
|
598
|
-
if (final.suffix)
|
|
599
|
-
return true;
|
|
600
|
-
if (hasValidStringSuffix && suffixNode)
|
|
601
|
-
return true;
|
|
602
|
-
return false;
|
|
603
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
604
|
-
// Get effective icons following Button's priority pattern
|
|
605
|
-
var effectivePrefix = react_1.default.useMemo(function () {
|
|
606
|
-
// Priority: startIcon > prefix > stringPrefix
|
|
607
|
-
if (final.startIcon)
|
|
608
|
-
return final.startIcon;
|
|
609
|
-
if (final.prefix)
|
|
610
|
-
return final.prefix;
|
|
611
|
-
if (hasValidStringPrefix)
|
|
612
|
-
return prefixNode;
|
|
613
|
-
return null;
|
|
614
|
-
}, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
615
|
-
var effectiveSuffix = react_1.default.useMemo(function () {
|
|
616
|
-
// Priority: endIcon > suffix > stringSuffix
|
|
617
|
-
if (final.endIcon)
|
|
618
|
-
return final.endIcon;
|
|
619
|
-
if (final.suffix)
|
|
620
|
-
return final.suffix;
|
|
621
|
-
if (hasValidStringSuffix)
|
|
622
|
-
return suffixNode;
|
|
623
|
-
return null;
|
|
624
|
-
}, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
625
|
-
var hasNoPrefix = !effectivePrefix;
|
|
415
|
+
var showPrefix = !!final.startIcon;
|
|
416
|
+
var showSuffix = !!final.endIcon;
|
|
417
|
+
var hasNoPrefix = !showPrefix;
|
|
626
418
|
var hasNoLabel = !label;
|
|
627
419
|
var className = generateInputClasses({
|
|
628
420
|
status: final.status,
|
|
@@ -646,36 +438,1020 @@ var TextareaInput = function (_a) {
|
|
|
646
438
|
};
|
|
647
439
|
var handleFocus = function (e) {
|
|
648
440
|
setIsFocused(true);
|
|
649
|
-
if (
|
|
650
|
-
|
|
441
|
+
if (onFocus)
|
|
442
|
+
onFocus(e);
|
|
651
443
|
};
|
|
652
444
|
var handleBlur = function (e) {
|
|
653
445
|
setIsFocused(false);
|
|
654
|
-
if (
|
|
655
|
-
|
|
446
|
+
if (onBlur)
|
|
447
|
+
onBlur(e);
|
|
656
448
|
};
|
|
657
449
|
var showPlaceholder = placeholder && label && (isFocused || !!textValue);
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
var
|
|
661
|
-
|
|
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));
|
|
662
456
|
};
|
|
663
457
|
exports.TextareaInput = TextareaInput;
|
|
664
458
|
var Input = function (_a) {
|
|
665
|
-
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"]);
|
|
666
460
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
667
|
-
|
|
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 });
|
|
668
470
|
var mergedProps = mergeWithLocal(localProps).props;
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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 });
|
|
673
476
|
if (select) {
|
|
674
|
-
return react_1.default.createElement(exports.SelectInput, __assign({},
|
|
477
|
+
return react_1.default.createElement(exports.SelectInput, __assign({}, finalInputProps));
|
|
675
478
|
}
|
|
676
479
|
if (multiline) {
|
|
677
|
-
return react_1.default.createElement(exports.TextareaInput, __assign({},
|
|
480
|
+
return react_1.default.createElement(exports.TextareaInput, __assign({}, finalInputProps));
|
|
678
481
|
}
|
|
679
|
-
return react_1.default.createElement(exports.TextInput, __assign({},
|
|
482
|
+
return react_1.default.createElement(exports.TextInput, __assign({}, finalInputProps));
|
|
680
483
|
};
|
|
681
484
|
exports.default = Input;
|
|
485
|
+
// 'use client'
|
|
486
|
+
// import React, { useState, useEffect, useRef } from 'react';
|
|
487
|
+
// import { PiCheck, PiCloudArrowUp, PiInfo, PiWarning, PiX, PiCheckCircle } from 'react-icons/pi';
|
|
488
|
+
// import Button from '../button/Button';
|
|
489
|
+
// import { useVariant } from '../theme/theme';
|
|
490
|
+
// import { useComponentConfiguration } from '../../utils/componentUtils';
|
|
491
|
+
// import { getDynamicIcon } from '../../utils/getDynamicIcon';
|
|
492
|
+
// import Text from '../text/Text';
|
|
493
|
+
// import { FileUpload } from './FileUpload';
|
|
494
|
+
// // Base types and interfaces
|
|
495
|
+
// interface BaseInputProps {
|
|
496
|
+
// id?: string;
|
|
497
|
+
// name?: string;
|
|
498
|
+
// value?: any;
|
|
499
|
+
// defaultValue?: string;
|
|
500
|
+
// onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
501
|
+
// status?: 'success' | 'warning' | 'danger' | 'info' ;
|
|
502
|
+
// funcss?: string;
|
|
503
|
+
// bg?: string;
|
|
504
|
+
// fullWidth?: boolean;
|
|
505
|
+
// flat?: boolean;
|
|
506
|
+
// bordered?: boolean;
|
|
507
|
+
// borderless?: boolean;
|
|
508
|
+
// rounded?: boolean;
|
|
509
|
+
// leftRounded?: boolean;
|
|
510
|
+
// rightRounded?: boolean;
|
|
511
|
+
// startIcon?: React.ReactNode;
|
|
512
|
+
// endIcon?: React.ReactNode;
|
|
513
|
+
// prefix?: React.ReactNode;
|
|
514
|
+
// suffix?: React.ReactNode;
|
|
515
|
+
// stringPrefix?: string;
|
|
516
|
+
// stringSuffix?: string;
|
|
517
|
+
// iconicBg?: string;
|
|
518
|
+
// variant?: string;
|
|
519
|
+
// label?: string;
|
|
520
|
+
// helperText?: string;
|
|
521
|
+
// }
|
|
522
|
+
// interface SelectOption {
|
|
523
|
+
// value: string;
|
|
524
|
+
// text: string;
|
|
525
|
+
// }
|
|
526
|
+
// interface TextInputProps extends BaseInputProps {
|
|
527
|
+
// type?: string;
|
|
528
|
+
// }
|
|
529
|
+
// interface SelectProps extends BaseInputProps {
|
|
530
|
+
// options?: SelectOption[];
|
|
531
|
+
// }
|
|
532
|
+
// interface TextareaProps extends BaseInputProps {
|
|
533
|
+
// rows?: number;
|
|
534
|
+
// }
|
|
535
|
+
// interface FileInputProps extends BaseInputProps {
|
|
536
|
+
// icon?: React.ReactNode;
|
|
537
|
+
// extra?: React.ReactNode;
|
|
538
|
+
// button?: React.ReactNode;
|
|
539
|
+
// btn?: boolean;
|
|
540
|
+
// }
|
|
541
|
+
// // Status icons mapping
|
|
542
|
+
// const statusIcons = {
|
|
543
|
+
// success: <PiCheckCircle />,
|
|
544
|
+
// warning: <PiWarning />,
|
|
545
|
+
// danger: <PiX />,
|
|
546
|
+
// info: <PiInfo />
|
|
547
|
+
// };
|
|
548
|
+
// // Utility function to generate CSS classes
|
|
549
|
+
// const generateInputClasses = ({
|
|
550
|
+
// status,
|
|
551
|
+
// rounded,
|
|
552
|
+
// bg,
|
|
553
|
+
// funcss,
|
|
554
|
+
// flat,
|
|
555
|
+
// leftRounded,
|
|
556
|
+
// rightRounded,
|
|
557
|
+
// bordered,
|
|
558
|
+
// borderless,
|
|
559
|
+
// additionalClasses = '',
|
|
560
|
+
// hasNoPrefix = false,
|
|
561
|
+
// hasNoLabel = false
|
|
562
|
+
// }: {
|
|
563
|
+
// status?: string;
|
|
564
|
+
// rounded?: boolean;
|
|
565
|
+
// bg?: string;
|
|
566
|
+
// funcss?: string;
|
|
567
|
+
// flat?: boolean;
|
|
568
|
+
// leftRounded?: boolean;
|
|
569
|
+
// rightRounded?: boolean;
|
|
570
|
+
// bordered?: boolean;
|
|
571
|
+
// borderless?: boolean;
|
|
572
|
+
// additionalClasses?: string;
|
|
573
|
+
// hasNoPrefix?: boolean;
|
|
574
|
+
// hasNoLabel?: boolean;
|
|
575
|
+
// }) => {
|
|
576
|
+
// const statusClass = status ? `${status}-input` : '';
|
|
577
|
+
// const roundedClass = rounded ? 'rounded' : '';
|
|
578
|
+
// const bgClass = bg || '';
|
|
579
|
+
// const flatClass = flat ? 'flat' : '';
|
|
580
|
+
// const cornerClass = leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '';
|
|
581
|
+
// const borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : (!bordered && !borderless ? 'borderedInput' : '');
|
|
582
|
+
// const noPrefixClass = hasNoPrefix ? 'no_prefix' : '';
|
|
583
|
+
// const noLabelClass = hasNoLabel ? 'no_label' : '';
|
|
584
|
+
// return `
|
|
585
|
+
// ${statusClass}
|
|
586
|
+
// ${roundedClass}
|
|
587
|
+
// ${bgClass}
|
|
588
|
+
// ${funcss || ''}
|
|
589
|
+
// ${flatClass}
|
|
590
|
+
// ${cornerClass}
|
|
591
|
+
// ${borderClass}
|
|
592
|
+
// ${additionalClasses}
|
|
593
|
+
// ${noPrefixClass}
|
|
594
|
+
// ${noLabelClass}
|
|
595
|
+
// input
|
|
596
|
+
// `.trim().replace(/\s+/g, ' ');
|
|
597
|
+
// };
|
|
598
|
+
// // Iconic Input Wrapper Component - UPDATED to match Button's pattern
|
|
599
|
+
// const IconicInputWrapper: React.FC<{
|
|
600
|
+
// startIcon?: React.ReactNode;
|
|
601
|
+
// endIcon?: React.ReactNode;
|
|
602
|
+
// prefix?: React.ReactNode;
|
|
603
|
+
// suffix?: React.ReactNode;
|
|
604
|
+
// iconicBg?: string;
|
|
605
|
+
// funcss?: string;
|
|
606
|
+
// stringPrefix?: string;
|
|
607
|
+
// stringSuffix?: string;
|
|
608
|
+
// children: React.ReactNode;
|
|
609
|
+
// }> = ({
|
|
610
|
+
// startIcon,
|
|
611
|
+
// endIcon,
|
|
612
|
+
// prefix,
|
|
613
|
+
// suffix,
|
|
614
|
+
// iconicBg,
|
|
615
|
+
// funcss,
|
|
616
|
+
// stringPrefix,
|
|
617
|
+
// stringSuffix,
|
|
618
|
+
// children
|
|
619
|
+
// }) => {
|
|
620
|
+
// // Match Button's pattern exactly - use proper priority
|
|
621
|
+
// const effectiveStartIcon = startIcon !== undefined ? startIcon : prefix;
|
|
622
|
+
// const effectiveEndIcon = endIcon !== undefined ? endIcon : suffix;
|
|
623
|
+
// // Determine which icons to show - MATCH BUTTON'S PATTERN EXACTLY
|
|
624
|
+
// const showPrefix = effectiveStartIcon !== undefined && effectiveStartIcon !== null;
|
|
625
|
+
// const showSuffix = effectiveEndIcon !== undefined && effectiveEndIcon !== null;
|
|
626
|
+
// if (!showPrefix && !showSuffix) {
|
|
627
|
+
// return <>{children}</>;
|
|
628
|
+
// }
|
|
629
|
+
// // Helper function to check if element is a React element
|
|
630
|
+
// function isReactElement(node: any): node is React.ReactElement {
|
|
631
|
+
// return React.isValidElement(node);
|
|
632
|
+
// }
|
|
633
|
+
// return (
|
|
634
|
+
// <div className={`icon-container ${showPrefix ? 'has-left-icon' : ''} ${funcss || ''}`}>
|
|
635
|
+
// {/* LEFT ICON - Match Button's exact conditional pattern */}
|
|
636
|
+
// {showPrefix && (
|
|
637
|
+
// <div
|
|
638
|
+
// className="leftIcon"
|
|
639
|
+
// style={{
|
|
640
|
+
// backgroundColor: iconicBg || '',
|
|
641
|
+
// border: iconicBg ? `0.1rem ${iconicBg} solid` : '',
|
|
642
|
+
// }}
|
|
643
|
+
// >
|
|
644
|
+
// {isReactElement(startIcon) ? startIcon
|
|
645
|
+
// : isReactElement(prefix) ? prefix
|
|
646
|
+
// : isReactElement(effectiveStartIcon) ? effectiveStartIcon
|
|
647
|
+
// : stringPrefix ? effectiveStartIcon : ''
|
|
648
|
+
// }
|
|
649
|
+
// </div>
|
|
650
|
+
// )}
|
|
651
|
+
// {children}
|
|
652
|
+
// {/* RIGHT ICON - Match Button's exact conditional pattern */}
|
|
653
|
+
// {showSuffix && (
|
|
654
|
+
// <div className="rightIcon" style={{ backgroundColor: iconicBg || '' }}>
|
|
655
|
+
// {isReactElement(endIcon) ? endIcon
|
|
656
|
+
// : isReactElement(suffix) ? suffix
|
|
657
|
+
// : isReactElement(effectiveEndIcon) ? effectiveEndIcon
|
|
658
|
+
// : stringSuffix ? effectiveEndIcon : ""
|
|
659
|
+
// }
|
|
660
|
+
// </div>
|
|
661
|
+
// )}
|
|
662
|
+
// </div>
|
|
663
|
+
// );
|
|
664
|
+
// };
|
|
665
|
+
// // Input Container with Floating Label
|
|
666
|
+
// const InputContainer: React.FC<{
|
|
667
|
+
// label?: string;
|
|
668
|
+
// status?: string;
|
|
669
|
+
// helperText?: string;
|
|
670
|
+
// children: React.ReactNode;
|
|
671
|
+
// isFocused: boolean;
|
|
672
|
+
// hasValue: boolean;
|
|
673
|
+
// fullWidth?: boolean;
|
|
674
|
+
// id?: string;
|
|
675
|
+
// startIcon?: React.ReactNode;
|
|
676
|
+
// prefix?: React.ReactNode;
|
|
677
|
+
// alwaysActiveLabel?: boolean;
|
|
678
|
+
// }> = ({ label, status, helperText, children, isFocused, hasValue, fullWidth, id, startIcon, prefix, alwaysActiveLabel = false }) => {
|
|
679
|
+
// const showFloatingLabel = label && (alwaysActiveLabel || isFocused || hasValue);
|
|
680
|
+
// return (
|
|
681
|
+
// <div className={`input-wrapper ${fullWidth ? 'full-width' : ''}`}>
|
|
682
|
+
// <div className="input-container-with-label">
|
|
683
|
+
// {label && (
|
|
684
|
+
// <label
|
|
685
|
+
// htmlFor={id}
|
|
686
|
+
// className={`floating-label ${startIcon || prefix ? "label-left" : ""} ${showFloatingLabel ? 'active' : ''} ${status ? `label-${status}` : ''}`}
|
|
687
|
+
// >
|
|
688
|
+
// {label}
|
|
689
|
+
// </label>
|
|
690
|
+
// )}
|
|
691
|
+
// {children}
|
|
692
|
+
// </div>
|
|
693
|
+
// {(helperText || status) && (
|
|
694
|
+
// <div className={`input-helper-text ${status ? `helper-${status}` : ''}`}>
|
|
695
|
+
// {status && statusIcons[status as keyof typeof statusIcons] && (
|
|
696
|
+
// <span className="helper-icon">{statusIcons[status as keyof typeof statusIcons]}</span>
|
|
697
|
+
// )}
|
|
698
|
+
// <span>{helperText}</span>
|
|
699
|
+
// </div>
|
|
700
|
+
// )}
|
|
701
|
+
// </div>
|
|
702
|
+
// );
|
|
703
|
+
// };
|
|
704
|
+
// // Text Input Component
|
|
705
|
+
// export const TextInput: React.FC<TextInputProps & React.InputHTMLAttributes<HTMLInputElement>> = ({
|
|
706
|
+
// id,
|
|
707
|
+
// name,
|
|
708
|
+
// value,
|
|
709
|
+
// defaultValue,
|
|
710
|
+
// onChange,
|
|
711
|
+
// status,
|
|
712
|
+
// funcss,
|
|
713
|
+
// bg,
|
|
714
|
+
// fullWidth = true,
|
|
715
|
+
// flat,
|
|
716
|
+
// bordered,
|
|
717
|
+
// borderless,
|
|
718
|
+
// rounded,
|
|
719
|
+
// leftRounded,
|
|
720
|
+
// rightRounded,
|
|
721
|
+
// startIcon,
|
|
722
|
+
// endIcon,
|
|
723
|
+
// prefix,
|
|
724
|
+
// suffix,
|
|
725
|
+
// stringPrefix,
|
|
726
|
+
// stringSuffix,
|
|
727
|
+
// iconicBg,
|
|
728
|
+
// type = 'text',
|
|
729
|
+
// label,
|
|
730
|
+
// helperText,
|
|
731
|
+
// variant = '',
|
|
732
|
+
// placeholder,
|
|
733
|
+
// ...rest
|
|
734
|
+
// }) => {
|
|
735
|
+
// const [isFocused, setIsFocused] = useState(false);
|
|
736
|
+
// const [inputValue, setInputValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
737
|
+
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
738
|
+
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
739
|
+
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
740
|
+
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
741
|
+
// const inputRef = useRef<HTMLInputElement>(null);
|
|
742
|
+
// const isDateTimeInput = ['date', 'time', 'month', 'week', 'datetime-local'].includes(type || '');
|
|
743
|
+
// useEffect(() => {
|
|
744
|
+
// if (value !== undefined && value !== '') {
|
|
745
|
+
// setInputValue(String(value));
|
|
746
|
+
// } else if (value === '') {
|
|
747
|
+
// setInputValue('');
|
|
748
|
+
// }
|
|
749
|
+
// }, [value]);
|
|
750
|
+
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
751
|
+
// const localProps = {
|
|
752
|
+
// status,
|
|
753
|
+
// funcss,
|
|
754
|
+
// bg,
|
|
755
|
+
// fullWidth,
|
|
756
|
+
// flat,
|
|
757
|
+
// bordered,
|
|
758
|
+
// borderless,
|
|
759
|
+
// rounded,
|
|
760
|
+
// leftRounded,
|
|
761
|
+
// rightRounded,
|
|
762
|
+
// startIcon,
|
|
763
|
+
// endIcon,
|
|
764
|
+
// prefix,
|
|
765
|
+
// suffix,
|
|
766
|
+
// iconicBg,
|
|
767
|
+
// stringPrefix,
|
|
768
|
+
// stringSuffix,
|
|
769
|
+
// };
|
|
770
|
+
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
771
|
+
// const final = {
|
|
772
|
+
// status: status !== undefined ? status : mergedProps.status,
|
|
773
|
+
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
774
|
+
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
775
|
+
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
776
|
+
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
777
|
+
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
778
|
+
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
779
|
+
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
780
|
+
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
781
|
+
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
782
|
+
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
783
|
+
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
784
|
+
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
785
|
+
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
786
|
+
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
787
|
+
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
788
|
+
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
789
|
+
// };
|
|
790
|
+
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
791
|
+
// useEffect(() => {
|
|
792
|
+
// const effectiveStringPrefix = final.stringPrefix;
|
|
793
|
+
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
794
|
+
// setPrefixNode(null);
|
|
795
|
+
// setHasValidStringPrefix(false);
|
|
796
|
+
// return;
|
|
797
|
+
// }
|
|
798
|
+
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
799
|
+
// if (node) {
|
|
800
|
+
// setPrefixNode(node);
|
|
801
|
+
// setHasValidStringPrefix(true);
|
|
802
|
+
// } else {
|
|
803
|
+
// setPrefixNode(null);
|
|
804
|
+
// setHasValidStringPrefix(false);
|
|
805
|
+
// }
|
|
806
|
+
// });
|
|
807
|
+
// }, [final.stringPrefix]);
|
|
808
|
+
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
809
|
+
// useEffect(() => {
|
|
810
|
+
// const effectiveStringSuffix = final.stringSuffix;
|
|
811
|
+
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
812
|
+
// setSuffixNode(null);
|
|
813
|
+
// setHasValidStringSuffix(false);
|
|
814
|
+
// return;
|
|
815
|
+
// }
|
|
816
|
+
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
817
|
+
// if (node) {
|
|
818
|
+
// setSuffixNode(node);
|
|
819
|
+
// setHasValidStringSuffix(true);
|
|
820
|
+
// } else {
|
|
821
|
+
// setSuffixNode(null);
|
|
822
|
+
// setHasValidStringSuffix(false);
|
|
823
|
+
// }
|
|
824
|
+
// });
|
|
825
|
+
// }, [final.stringSuffix]);
|
|
826
|
+
// const { variant: themeVariant } = useVariant();
|
|
827
|
+
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
828
|
+
// const showPrefix = React.useMemo(() => {
|
|
829
|
+
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
830
|
+
// if (final.startIcon) return true;
|
|
831
|
+
// if (final.prefix) return true;
|
|
832
|
+
// if (hasValidStringPrefix && prefixNode) return true;
|
|
833
|
+
// return false;
|
|
834
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
835
|
+
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
836
|
+
// const showSuffix = React.useMemo(() => {
|
|
837
|
+
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
838
|
+
// if (final.endIcon) return true;
|
|
839
|
+
// if (final.suffix) return true;
|
|
840
|
+
// if (hasValidStringSuffix && suffixNode) return true;
|
|
841
|
+
// return false;
|
|
842
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
843
|
+
// // Get effective icons following Button's priority pattern
|
|
844
|
+
// const effectivePrefix = React.useMemo(() => {
|
|
845
|
+
// // Priority: startIcon > prefix > stringPrefix
|
|
846
|
+
// if (final.startIcon) return final.startIcon;
|
|
847
|
+
// if (final.prefix) return final.prefix;
|
|
848
|
+
// if (hasValidStringPrefix) return prefixNode;
|
|
849
|
+
// return null;
|
|
850
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
851
|
+
// const effectiveSuffix = React.useMemo(() => {
|
|
852
|
+
// // Priority: endIcon > suffix > stringSuffix
|
|
853
|
+
// if (final.endIcon) return final.endIcon;
|
|
854
|
+
// if (final.suffix) return final.suffix;
|
|
855
|
+
// if (hasValidStringSuffix) return suffixNode;
|
|
856
|
+
// return null;
|
|
857
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
858
|
+
// const hasNoPrefix = !effectivePrefix;
|
|
859
|
+
// const hasNoLabel = !label;
|
|
860
|
+
// const className = generateInputClasses({
|
|
861
|
+
// status: final.status,
|
|
862
|
+
// rounded: final.rounded,
|
|
863
|
+
// bg: final.bg,
|
|
864
|
+
// funcss: final.funcss,
|
|
865
|
+
// flat: final.flat,
|
|
866
|
+
// leftRounded: final.leftRounded,
|
|
867
|
+
// rightRounded: final.rightRounded,
|
|
868
|
+
// bordered: final.bordered,
|
|
869
|
+
// borderless: final.borderless,
|
|
870
|
+
// hasNoPrefix,
|
|
871
|
+
// hasNoLabel,
|
|
872
|
+
// });
|
|
873
|
+
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
874
|
+
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
875
|
+
// const newValue = e.target.value;
|
|
876
|
+
// setInputValue(newValue);
|
|
877
|
+
// if (onChange) onChange(e);
|
|
878
|
+
// };
|
|
879
|
+
// const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
880
|
+
// setIsFocused(true);
|
|
881
|
+
// if (rest.onFocus) rest.onFocus(e);
|
|
882
|
+
// };
|
|
883
|
+
// const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
884
|
+
// setIsFocused(false);
|
|
885
|
+
// if (rest.onBlur) rest.onBlur(e);
|
|
886
|
+
// };
|
|
887
|
+
// const showPlaceholder = placeholder && label && (isFocused || !!inputValue);
|
|
888
|
+
// const inputElement = (
|
|
889
|
+
// <input
|
|
890
|
+
// ref={inputRef}
|
|
891
|
+
// id={id}
|
|
892
|
+
// name={name}
|
|
893
|
+
// className={className}
|
|
894
|
+
// onChange={handleChange}
|
|
895
|
+
// onFocus={handleFocus}
|
|
896
|
+
// onBlur={handleBlur}
|
|
897
|
+
// defaultValue={defaultValue}
|
|
898
|
+
// type={type}
|
|
899
|
+
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
900
|
+
// style={style}
|
|
901
|
+
// value={inputValue}
|
|
902
|
+
// {...rest}
|
|
903
|
+
// />
|
|
904
|
+
// );
|
|
905
|
+
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
906
|
+
// const wrappedInput = showPrefix || showSuffix ? (
|
|
907
|
+
// <IconicInputWrapper
|
|
908
|
+
// startIcon={effectivePrefix}
|
|
909
|
+
// endIcon={effectiveSuffix}
|
|
910
|
+
// iconicBg={final.iconicBg}
|
|
911
|
+
// funcss={final.funcss}
|
|
912
|
+
// stringPrefix={stringPrefix}
|
|
913
|
+
// stringSuffix={stringSuffix}
|
|
914
|
+
// >
|
|
915
|
+
// {inputElement}
|
|
916
|
+
// </IconicInputWrapper>
|
|
917
|
+
// ) : (
|
|
918
|
+
// inputElement
|
|
919
|
+
// );
|
|
920
|
+
// return (
|
|
921
|
+
// <InputContainer
|
|
922
|
+
// startIcon={effectivePrefix}
|
|
923
|
+
// label={label}
|
|
924
|
+
// status={final.status}
|
|
925
|
+
// helperText={helperText}
|
|
926
|
+
// isFocused={isFocused}
|
|
927
|
+
// hasValue={!!inputValue}
|
|
928
|
+
// fullWidth={final.fullWidth}
|
|
929
|
+
// id={id}
|
|
930
|
+
// alwaysActiveLabel={isDateTimeInput}
|
|
931
|
+
// >
|
|
932
|
+
// {wrappedInput}
|
|
933
|
+
// </InputContainer>
|
|
934
|
+
// );
|
|
935
|
+
// };
|
|
936
|
+
// // Select Component - UPDATED to match pattern
|
|
937
|
+
// export const SelectInput: React.FC<SelectProps & React.SelectHTMLAttributes<HTMLSelectElement>> = ({
|
|
938
|
+
// id,
|
|
939
|
+
// name,
|
|
940
|
+
// value,
|
|
941
|
+
// defaultValue,
|
|
942
|
+
// onChange,
|
|
943
|
+
// status,
|
|
944
|
+
// funcss,
|
|
945
|
+
// bg,
|
|
946
|
+
// fullWidth,
|
|
947
|
+
// flat,
|
|
948
|
+
// bordered,
|
|
949
|
+
// borderless,
|
|
950
|
+
// rounded,
|
|
951
|
+
// leftRounded,
|
|
952
|
+
// rightRounded,
|
|
953
|
+
// startIcon,
|
|
954
|
+
// endIcon,
|
|
955
|
+
// prefix,
|
|
956
|
+
// suffix,
|
|
957
|
+
// stringPrefix,
|
|
958
|
+
// stringSuffix,
|
|
959
|
+
// iconicBg,
|
|
960
|
+
// options = [],
|
|
961
|
+
// label,
|
|
962
|
+
// helperText,
|
|
963
|
+
// variant = '',
|
|
964
|
+
// ...rest
|
|
965
|
+
// }) => {
|
|
966
|
+
// const [isFocused, setIsFocused] = useState(false);
|
|
967
|
+
// const [selectValue, setSelectValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
968
|
+
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
969
|
+
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
970
|
+
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
971
|
+
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
972
|
+
// useEffect(() => {
|
|
973
|
+
// if (value !== undefined && value !== '') {
|
|
974
|
+
// setSelectValue(String(value));
|
|
975
|
+
// } else if (value === '') {
|
|
976
|
+
// setSelectValue('');
|
|
977
|
+
// }
|
|
978
|
+
// }, [value]);
|
|
979
|
+
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
980
|
+
// const localProps = {
|
|
981
|
+
// status,
|
|
982
|
+
// funcss,
|
|
983
|
+
// bg,
|
|
984
|
+
// fullWidth,
|
|
985
|
+
// flat,
|
|
986
|
+
// bordered,
|
|
987
|
+
// borderless,
|
|
988
|
+
// rounded,
|
|
989
|
+
// leftRounded,
|
|
990
|
+
// rightRounded,
|
|
991
|
+
// startIcon,
|
|
992
|
+
// endIcon,
|
|
993
|
+
// prefix,
|
|
994
|
+
// suffix,
|
|
995
|
+
// iconicBg,
|
|
996
|
+
// stringPrefix,
|
|
997
|
+
// stringSuffix,
|
|
998
|
+
// };
|
|
999
|
+
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1000
|
+
// const final = {
|
|
1001
|
+
// status: status !== undefined ? status : mergedProps.status,
|
|
1002
|
+
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1003
|
+
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1004
|
+
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1005
|
+
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1006
|
+
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1007
|
+
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1008
|
+
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1009
|
+
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1010
|
+
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1011
|
+
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1012
|
+
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1013
|
+
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1014
|
+
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1015
|
+
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1016
|
+
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1017
|
+
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1018
|
+
// };
|
|
1019
|
+
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1020
|
+
// useEffect(() => {
|
|
1021
|
+
// const effectiveStringPrefix = final.stringPrefix;
|
|
1022
|
+
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1023
|
+
// setPrefixNode(null);
|
|
1024
|
+
// setHasValidStringPrefix(false);
|
|
1025
|
+
// return;
|
|
1026
|
+
// }
|
|
1027
|
+
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1028
|
+
// if (node) {
|
|
1029
|
+
// setPrefixNode(node);
|
|
1030
|
+
// setHasValidStringPrefix(true);
|
|
1031
|
+
// } else {
|
|
1032
|
+
// setPrefixNode(null);
|
|
1033
|
+
// setHasValidStringPrefix(false);
|
|
1034
|
+
// }
|
|
1035
|
+
// });
|
|
1036
|
+
// }, [final.stringPrefix]);
|
|
1037
|
+
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1038
|
+
// useEffect(() => {
|
|
1039
|
+
// const effectiveStringSuffix = final.stringSuffix;
|
|
1040
|
+
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1041
|
+
// setSuffixNode(null);
|
|
1042
|
+
// setHasValidStringSuffix(false);
|
|
1043
|
+
// return;
|
|
1044
|
+
// }
|
|
1045
|
+
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1046
|
+
// if (node) {
|
|
1047
|
+
// setSuffixNode(node);
|
|
1048
|
+
// setHasValidStringSuffix(true);
|
|
1049
|
+
// } else {
|
|
1050
|
+
// setSuffixNode(null);
|
|
1051
|
+
// setHasValidStringSuffix(false);
|
|
1052
|
+
// }
|
|
1053
|
+
// });
|
|
1054
|
+
// }, [final.stringSuffix]);
|
|
1055
|
+
// const selectHasValue = !!selectValue;
|
|
1056
|
+
// const { variant: themeVariant } = useVariant();
|
|
1057
|
+
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1058
|
+
// const showPrefix = React.useMemo(() => {
|
|
1059
|
+
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1060
|
+
// if (final.startIcon) return true;
|
|
1061
|
+
// if (final.prefix) return true;
|
|
1062
|
+
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1063
|
+
// return false;
|
|
1064
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1065
|
+
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1066
|
+
// const showSuffix = React.useMemo(() => {
|
|
1067
|
+
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1068
|
+
// if (final.endIcon) return true;
|
|
1069
|
+
// if (final.suffix) return true;
|
|
1070
|
+
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1071
|
+
// return false;
|
|
1072
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1073
|
+
// // Get effective icons following Button's priority pattern
|
|
1074
|
+
// const effectivePrefix = React.useMemo(() => {
|
|
1075
|
+
// // Priority: startIcon > prefix > stringPrefix
|
|
1076
|
+
// if (final.startIcon) return final.startIcon;
|
|
1077
|
+
// if (final.prefix) return final.prefix;
|
|
1078
|
+
// if (hasValidStringPrefix) return prefixNode;
|
|
1079
|
+
// return null;
|
|
1080
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1081
|
+
// const effectiveSuffix = React.useMemo(() => {
|
|
1082
|
+
// // Priority: endIcon > suffix > stringSuffix
|
|
1083
|
+
// if (final.endIcon) return final.endIcon;
|
|
1084
|
+
// if (final.suffix) return final.suffix;
|
|
1085
|
+
// if (hasValidStringSuffix) return suffixNode;
|
|
1086
|
+
// return null;
|
|
1087
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1088
|
+
// const hasNoPrefix = !effectivePrefix;
|
|
1089
|
+
// const hasNoLabel = !label;
|
|
1090
|
+
// const className = generateInputClasses({
|
|
1091
|
+
// status: final.status,
|
|
1092
|
+
// rounded: final.rounded,
|
|
1093
|
+
// bg: final.bg,
|
|
1094
|
+
// funcss: final.funcss,
|
|
1095
|
+
// flat: final.flat,
|
|
1096
|
+
// leftRounded: final.leftRounded,
|
|
1097
|
+
// rightRounded: final.rightRounded,
|
|
1098
|
+
// bordered: final.bordered,
|
|
1099
|
+
// borderless: final.borderless,
|
|
1100
|
+
// hasNoPrefix,
|
|
1101
|
+
// hasNoLabel,
|
|
1102
|
+
// });
|
|
1103
|
+
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1104
|
+
// const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
1105
|
+
// const newValue = e.target.value;
|
|
1106
|
+
// setSelectValue(newValue);
|
|
1107
|
+
// if (onChange) onChange(e);
|
|
1108
|
+
// };
|
|
1109
|
+
// const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1110
|
+
// setIsFocused(true);
|
|
1111
|
+
// if (rest.onFocus) rest.onFocus(e);
|
|
1112
|
+
// };
|
|
1113
|
+
// const handleBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
1114
|
+
// setIsFocused(false);
|
|
1115
|
+
// if (rest.onBlur) rest.onBlur(e);
|
|
1116
|
+
// };
|
|
1117
|
+
// const selectElement = (
|
|
1118
|
+
// <select
|
|
1119
|
+
// id={id}
|
|
1120
|
+
// name={name}
|
|
1121
|
+
// className={className}
|
|
1122
|
+
// onChange={handleChange}
|
|
1123
|
+
// onFocus={handleFocus}
|
|
1124
|
+
// onBlur={handleBlur}
|
|
1125
|
+
// defaultValue={defaultValue}
|
|
1126
|
+
// value={selectValue}
|
|
1127
|
+
// style={style}
|
|
1128
|
+
// {...rest}
|
|
1129
|
+
// >
|
|
1130
|
+
// {options.map((option) => (
|
|
1131
|
+
// <option key={option.value} value={option.value}>
|
|
1132
|
+
// {option.text}
|
|
1133
|
+
// </option>
|
|
1134
|
+
// ))}
|
|
1135
|
+
// </select>
|
|
1136
|
+
// );
|
|
1137
|
+
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1138
|
+
// const wrappedSelect = showPrefix || showSuffix ? (
|
|
1139
|
+
// <IconicInputWrapper
|
|
1140
|
+
// startIcon={effectivePrefix}
|
|
1141
|
+
// endIcon={effectiveSuffix}
|
|
1142
|
+
// iconicBg={final.iconicBg}
|
|
1143
|
+
// funcss={final.funcss}
|
|
1144
|
+
// stringPrefix={stringPrefix}
|
|
1145
|
+
// stringSuffix={stringSuffix}
|
|
1146
|
+
// >
|
|
1147
|
+
// {selectElement}
|
|
1148
|
+
// </IconicInputWrapper>
|
|
1149
|
+
// ) : (
|
|
1150
|
+
// selectElement
|
|
1151
|
+
// );
|
|
1152
|
+
// return (
|
|
1153
|
+
// <InputContainer
|
|
1154
|
+
// startIcon={effectivePrefix}
|
|
1155
|
+
// label={label}
|
|
1156
|
+
// status={final.status}
|
|
1157
|
+
// helperText={helperText}
|
|
1158
|
+
// isFocused={isFocused}
|
|
1159
|
+
// hasValue={selectHasValue}
|
|
1160
|
+
// fullWidth={final.fullWidth}
|
|
1161
|
+
// id={id}
|
|
1162
|
+
// alwaysActiveLabel={true}
|
|
1163
|
+
// >
|
|
1164
|
+
// {wrappedSelect}
|
|
1165
|
+
// </InputContainer>
|
|
1166
|
+
// );
|
|
1167
|
+
// };
|
|
1168
|
+
// // Textarea Component - UPDATED to match pattern
|
|
1169
|
+
// export const TextareaInput: React.FC<TextareaProps & React.TextareaHTMLAttributes<HTMLTextAreaElement>> = ({
|
|
1170
|
+
// id,
|
|
1171
|
+
// name,
|
|
1172
|
+
// value,
|
|
1173
|
+
// defaultValue,
|
|
1174
|
+
// onChange,
|
|
1175
|
+
// status,
|
|
1176
|
+
// funcss,
|
|
1177
|
+
// bg,
|
|
1178
|
+
// fullWidth,
|
|
1179
|
+
// flat,
|
|
1180
|
+
// bordered,
|
|
1181
|
+
// borderless,
|
|
1182
|
+
// rounded,
|
|
1183
|
+
// leftRounded,
|
|
1184
|
+
// rightRounded,
|
|
1185
|
+
// startIcon,
|
|
1186
|
+
// endIcon,
|
|
1187
|
+
// prefix,
|
|
1188
|
+
// suffix,
|
|
1189
|
+
// stringPrefix,
|
|
1190
|
+
// stringSuffix,
|
|
1191
|
+
// iconicBg,
|
|
1192
|
+
// label,
|
|
1193
|
+
// helperText,
|
|
1194
|
+
// rows = 2,
|
|
1195
|
+
// variant = '',
|
|
1196
|
+
// placeholder,
|
|
1197
|
+
// ...rest
|
|
1198
|
+
// }) => {
|
|
1199
|
+
// const [isFocused, setIsFocused] = useState(false);
|
|
1200
|
+
// const [textValue, setTextValue] = useState<string>(value !== undefined ? String(value) : defaultValue || '');
|
|
1201
|
+
// const [prefixNode, setPrefixNode] = useState<React.ReactNode>(null);
|
|
1202
|
+
// const [suffixNode, setSuffixNode] = useState<React.ReactNode>(null);
|
|
1203
|
+
// const [hasValidStringPrefix, setHasValidStringPrefix] = useState(false);
|
|
1204
|
+
// const [hasValidStringSuffix, setHasValidStringSuffix] = useState(false);
|
|
1205
|
+
// useEffect(() => {
|
|
1206
|
+
// if (value !== undefined && value !== '') {
|
|
1207
|
+
// setTextValue(String(value));
|
|
1208
|
+
// } else if (value === '') {
|
|
1209
|
+
// setTextValue('');
|
|
1210
|
+
// }
|
|
1211
|
+
// }, [value]);
|
|
1212
|
+
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1213
|
+
// const localProps = {
|
|
1214
|
+
// status,
|
|
1215
|
+
// funcss,
|
|
1216
|
+
// bg,
|
|
1217
|
+
// fullWidth,
|
|
1218
|
+
// flat,
|
|
1219
|
+
// bordered,
|
|
1220
|
+
// borderless,
|
|
1221
|
+
// rounded,
|
|
1222
|
+
// leftRounded,
|
|
1223
|
+
// rightRounded,
|
|
1224
|
+
// startIcon,
|
|
1225
|
+
// endIcon,
|
|
1226
|
+
// prefix,
|
|
1227
|
+
// suffix,
|
|
1228
|
+
// iconicBg,
|
|
1229
|
+
// stringPrefix,
|
|
1230
|
+
// stringSuffix,
|
|
1231
|
+
// };
|
|
1232
|
+
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1233
|
+
// const final = {
|
|
1234
|
+
// status: status !== undefined ? status : mergedProps.status,
|
|
1235
|
+
// funcss: funcss !== undefined ? funcss : mergedProps.funcss,
|
|
1236
|
+
// bg: bg !== undefined ? bg : mergedProps.bg,
|
|
1237
|
+
// fullWidth: fullWidth !== undefined ? fullWidth : mergedProps.fullWidth,
|
|
1238
|
+
// flat: flat !== undefined ? flat : mergedProps.flat,
|
|
1239
|
+
// bordered: bordered !== undefined ? bordered : mergedProps.bordered,
|
|
1240
|
+
// borderless: borderless !== undefined ? borderless : mergedProps.borderless,
|
|
1241
|
+
// rounded: rounded !== undefined ? rounded : mergedProps.rounded,
|
|
1242
|
+
// leftRounded: leftRounded !== undefined ? leftRounded : mergedProps.leftRounded,
|
|
1243
|
+
// rightRounded: rightRounded !== undefined ? rightRounded : mergedProps.rightRounded,
|
|
1244
|
+
// startIcon: startIcon !== undefined ? startIcon : mergedProps.startIcon,
|
|
1245
|
+
// endIcon: endIcon !== undefined ? endIcon : mergedProps.endIcon,
|
|
1246
|
+
// prefix: prefix !== undefined ? prefix : mergedProps.prefix,
|
|
1247
|
+
// suffix: suffix !== undefined ? suffix : mergedProps.suffix,
|
|
1248
|
+
// iconicBg: iconicBg !== undefined ? iconicBg : mergedProps.iconicBg,
|
|
1249
|
+
// stringPrefix: stringPrefix !== undefined ? stringPrefix : mergedProps.stringPrefix,
|
|
1250
|
+
// stringSuffix: stringSuffix !== undefined ? stringSuffix : mergedProps.stringSuffix,
|
|
1251
|
+
// };
|
|
1252
|
+
// // Handle stringPrefix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1253
|
+
// useEffect(() => {
|
|
1254
|
+
// const effectiveStringPrefix = final.stringPrefix;
|
|
1255
|
+
// if (!effectiveStringPrefix || effectiveStringPrefix.trim() === '') {
|
|
1256
|
+
// setPrefixNode(null);
|
|
1257
|
+
// setHasValidStringPrefix(false);
|
|
1258
|
+
// return;
|
|
1259
|
+
// }
|
|
1260
|
+
// getDynamicIcon(effectiveStringPrefix).then((node) => {
|
|
1261
|
+
// if (node) {
|
|
1262
|
+
// setPrefixNode(node);
|
|
1263
|
+
// setHasValidStringPrefix(true);
|
|
1264
|
+
// } else {
|
|
1265
|
+
// setPrefixNode(null);
|
|
1266
|
+
// setHasValidStringPrefix(false);
|
|
1267
|
+
// }
|
|
1268
|
+
// });
|
|
1269
|
+
// }, [final.stringPrefix]);
|
|
1270
|
+
// // Handle stringSuffix - MATCH BUTTON'S PATTERN EXACTLY
|
|
1271
|
+
// useEffect(() => {
|
|
1272
|
+
// const effectiveStringSuffix = final.stringSuffix;
|
|
1273
|
+
// if (!effectiveStringSuffix || effectiveStringSuffix.trim() === '') {
|
|
1274
|
+
// setSuffixNode(null);
|
|
1275
|
+
// setHasValidStringSuffix(false);
|
|
1276
|
+
// return;
|
|
1277
|
+
// }
|
|
1278
|
+
// getDynamicIcon(effectiveStringSuffix).then((node) => {
|
|
1279
|
+
// if (node) {
|
|
1280
|
+
// setSuffixNode(node);
|
|
1281
|
+
// setHasValidStringSuffix(true);
|
|
1282
|
+
// } else {
|
|
1283
|
+
// setSuffixNode(null);
|
|
1284
|
+
// setHasValidStringSuffix(false);
|
|
1285
|
+
// }
|
|
1286
|
+
// });
|
|
1287
|
+
// }, [final.stringSuffix]);
|
|
1288
|
+
// const { variant: themeVariant } = useVariant();
|
|
1289
|
+
// // Determine which prefix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1290
|
+
// const showPrefix = React.useMemo(() => {
|
|
1291
|
+
// // Priority order: startIcon (local) > prefix (local) > stringPrefix (dynamic)
|
|
1292
|
+
// if (final.startIcon) return true;
|
|
1293
|
+
// if (final.prefix) return true;
|
|
1294
|
+
// if (hasValidStringPrefix && prefixNode) return true;
|
|
1295
|
+
// return false;
|
|
1296
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1297
|
+
// // Determine which suffix to show with proper priority - MATCH BUTTON'S PATTERN
|
|
1298
|
+
// const showSuffix = React.useMemo(() => {
|
|
1299
|
+
// // Priority order: endIcon (local) > suffix (local) > stringSuffix (dynamic)
|
|
1300
|
+
// if (final.endIcon) return true;
|
|
1301
|
+
// if (final.suffix) return true;
|
|
1302
|
+
// if (hasValidStringSuffix && suffixNode) return true;
|
|
1303
|
+
// return false;
|
|
1304
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1305
|
+
// // Get effective icons following Button's priority pattern
|
|
1306
|
+
// const effectivePrefix = React.useMemo(() => {
|
|
1307
|
+
// // Priority: startIcon > prefix > stringPrefix
|
|
1308
|
+
// if (final.startIcon) return final.startIcon;
|
|
1309
|
+
// if (final.prefix) return final.prefix;
|
|
1310
|
+
// if (hasValidStringPrefix) return prefixNode;
|
|
1311
|
+
// return null;
|
|
1312
|
+
// }, [final.startIcon, final.prefix, hasValidStringPrefix, prefixNode]);
|
|
1313
|
+
// const effectiveSuffix = React.useMemo(() => {
|
|
1314
|
+
// // Priority: endIcon > suffix > stringSuffix
|
|
1315
|
+
// if (final.endIcon) return final.endIcon;
|
|
1316
|
+
// if (final.suffix) return final.suffix;
|
|
1317
|
+
// if (hasValidStringSuffix) return suffixNode;
|
|
1318
|
+
// return null;
|
|
1319
|
+
// }, [final.endIcon, final.suffix, hasValidStringSuffix, suffixNode]);
|
|
1320
|
+
// const hasNoPrefix = !effectivePrefix;
|
|
1321
|
+
// const hasNoLabel = !label;
|
|
1322
|
+
// const className = generateInputClasses({
|
|
1323
|
+
// status: final.status,
|
|
1324
|
+
// rounded: final.rounded,
|
|
1325
|
+
// bg: final.bg,
|
|
1326
|
+
// funcss: final.funcss,
|
|
1327
|
+
// flat: final.flat,
|
|
1328
|
+
// leftRounded: final.leftRounded,
|
|
1329
|
+
// rightRounded: final.rightRounded,
|
|
1330
|
+
// bordered: final.bordered,
|
|
1331
|
+
// borderless: final.borderless,
|
|
1332
|
+
// hasNoPrefix,
|
|
1333
|
+
// hasNoLabel,
|
|
1334
|
+
// });
|
|
1335
|
+
// const style = final.fullWidth ? { width: '100%' } : undefined;
|
|
1336
|
+
// const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
1337
|
+
// const newValue = e.target.value;
|
|
1338
|
+
// setTextValue(newValue);
|
|
1339
|
+
// if (onChange) onChange(e);
|
|
1340
|
+
// };
|
|
1341
|
+
// const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1342
|
+
// setIsFocused(true);
|
|
1343
|
+
// if (rest.onFocus) rest.onFocus(e);
|
|
1344
|
+
// };
|
|
1345
|
+
// const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
1346
|
+
// setIsFocused(false);
|
|
1347
|
+
// if (rest.onBlur) rest.onBlur(e);
|
|
1348
|
+
// };
|
|
1349
|
+
// const showPlaceholder = placeholder && label && (isFocused || !!textValue);
|
|
1350
|
+
// const textareaElement = (
|
|
1351
|
+
// <textarea
|
|
1352
|
+
// id={id}
|
|
1353
|
+
// name={name}
|
|
1354
|
+
// className={className}
|
|
1355
|
+
// onChange={handleChange}
|
|
1356
|
+
// onFocus={handleFocus}
|
|
1357
|
+
// onBlur={handleBlur}
|
|
1358
|
+
// defaultValue={defaultValue}
|
|
1359
|
+
// placeholder={showPlaceholder ? placeholder : (!label ? placeholder : '')}
|
|
1360
|
+
// style={style}
|
|
1361
|
+
// value={textValue}
|
|
1362
|
+
// rows={rows}
|
|
1363
|
+
// {...rest}
|
|
1364
|
+
// />
|
|
1365
|
+
// );
|
|
1366
|
+
// // Only use iconic wrapper when we have icons, matching Button's pattern
|
|
1367
|
+
// const wrappedTextarea = showPrefix || showSuffix ? (
|
|
1368
|
+
// <IconicInputWrapper
|
|
1369
|
+
// startIcon={effectivePrefix}
|
|
1370
|
+
// endIcon={effectiveSuffix}
|
|
1371
|
+
// iconicBg={final.iconicBg}
|
|
1372
|
+
// funcss={final.funcss}
|
|
1373
|
+
// stringPrefix={stringPrefix}
|
|
1374
|
+
// stringSuffix={stringSuffix}
|
|
1375
|
+
// >
|
|
1376
|
+
// {textareaElement}
|
|
1377
|
+
// </IconicInputWrapper>
|
|
1378
|
+
// ) : (
|
|
1379
|
+
// textareaElement
|
|
1380
|
+
// );
|
|
1381
|
+
// return (
|
|
1382
|
+
// <InputContainer
|
|
1383
|
+
// startIcon={effectivePrefix}
|
|
1384
|
+
// label={label}
|
|
1385
|
+
// status={final.status}
|
|
1386
|
+
// helperText={helperText}
|
|
1387
|
+
// isFocused={isFocused}
|
|
1388
|
+
// hasValue={!!textValue}
|
|
1389
|
+
// fullWidth={final.fullWidth}
|
|
1390
|
+
// id={id}
|
|
1391
|
+
// >
|
|
1392
|
+
// {wrappedTextarea}
|
|
1393
|
+
// </InputContainer>
|
|
1394
|
+
// );
|
|
1395
|
+
// };
|
|
1396
|
+
// // Main Input Component (backwards compatibility)
|
|
1397
|
+
// interface InputProps extends BaseInputProps {
|
|
1398
|
+
// select?: boolean;
|
|
1399
|
+
// multiline?: boolean;
|
|
1400
|
+
// file?: boolean;
|
|
1401
|
+
// noBorder?: boolean;
|
|
1402
|
+
// icon?: React.ReactNode;
|
|
1403
|
+
// extra?: React.ReactNode;
|
|
1404
|
+
// button?: React.ReactNode;
|
|
1405
|
+
// btn?: boolean;
|
|
1406
|
+
// type?: string;
|
|
1407
|
+
// options?: SelectOption[];
|
|
1408
|
+
// rows?: number;
|
|
1409
|
+
// }
|
|
1410
|
+
// const Input: React.FC<InputProps> = ({
|
|
1411
|
+
// select,
|
|
1412
|
+
// multiline,
|
|
1413
|
+
// file,
|
|
1414
|
+
// noBorder,
|
|
1415
|
+
// startIcon,
|
|
1416
|
+
// endIcon,
|
|
1417
|
+
// prefix,
|
|
1418
|
+
// suffix,
|
|
1419
|
+
// stringPrefix,
|
|
1420
|
+
// stringSuffix,
|
|
1421
|
+
// iconicBg,
|
|
1422
|
+
// type,
|
|
1423
|
+
// variant = '',
|
|
1424
|
+
// ...props
|
|
1425
|
+
// }) => {
|
|
1426
|
+
// const { mergeWithLocal } = useComponentConfiguration('Input', variant);
|
|
1427
|
+
// const localProps = {
|
|
1428
|
+
// ...props,
|
|
1429
|
+
// startIcon,
|
|
1430
|
+
// endIcon,
|
|
1431
|
+
// prefix,
|
|
1432
|
+
// suffix,
|
|
1433
|
+
// iconicBg,
|
|
1434
|
+
// stringPrefix,
|
|
1435
|
+
// stringSuffix,
|
|
1436
|
+
// type,
|
|
1437
|
+
// };
|
|
1438
|
+
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
1439
|
+
// const inputProps = {
|
|
1440
|
+
// ...props,
|
|
1441
|
+
// ...mergedProps,
|
|
1442
|
+
// variant,
|
|
1443
|
+
// borderless: noBorder !== undefined ? noBorder : (props.borderless !== undefined ? props.borderless : mergedProps.borderless),
|
|
1444
|
+
// type,
|
|
1445
|
+
// };
|
|
1446
|
+
// if (file || type === 'file') {
|
|
1447
|
+
// return <FileUpload {...inputProps} />;
|
|
1448
|
+
// }
|
|
1449
|
+
// if (select) {
|
|
1450
|
+
// return <SelectInput {...inputProps} />;
|
|
1451
|
+
// }
|
|
1452
|
+
// if (multiline) {
|
|
1453
|
+
// return <TextareaInput {...inputProps} />;
|
|
1454
|
+
// }
|
|
1455
|
+
// return <TextInput {...inputProps} />;
|
|
1456
|
+
// };
|
|
1457
|
+
// export default Input;
|