pesona-ui 1.0.31 → 1.0.33
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/dist/index.cjs.js +26 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +26 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -8193,35 +8193,50 @@ const Select = forwardRef((props, ref) => {
|
|
|
8193
8193
|
const dropdownRef = useRef(null);
|
|
8194
8194
|
const dropdownOptionsRef = useRef(null);
|
|
8195
8195
|
const selectRef = useRef(null);
|
|
8196
|
+
const displayText = options.find((opt) => opt.value === value)?.label ?? selectLabel;
|
|
8196
8197
|
useImperativeHandle(ref, () => selectRef.current);
|
|
8197
8198
|
useEffect(() => setIsOpen(false), []);
|
|
8198
8199
|
useOutsideClick([dropdownRef], () => {
|
|
8199
8200
|
setIsOpen(false);
|
|
8200
|
-
selectRef.current?.blur();
|
|
8201
|
+
selectRef.current?.blur();
|
|
8201
8202
|
});
|
|
8202
8203
|
useDropdownPositionAndScroll(isOpen, dropdownOptionsRef);
|
|
8203
|
-
const displayText = value
|
|
8204
|
-
? options.find((opt) => opt.value === value)?.label
|
|
8205
|
-
: selectLabel;
|
|
8206
8204
|
const handleOptionClick = (optionValue) => {
|
|
8205
|
+
const selectedOption = options.find((opt) => opt.value === optionValue);
|
|
8206
|
+
if (!selectedOption)
|
|
8207
|
+
return;
|
|
8208
|
+
// Pastikan nilai tetap sesuai tipe aslinya
|
|
8209
|
+
const actualValue = selectedOption.value;
|
|
8210
|
+
// Create synthetic event dengan tipe data yang benar
|
|
8207
8211
|
const syntheticEvent = {
|
|
8208
8212
|
target: {
|
|
8209
8213
|
name,
|
|
8210
|
-
value:
|
|
8214
|
+
value: actualValue, // Tetap gunakan tipe asli (number/string)
|
|
8215
|
+
type: 'select-one'
|
|
8211
8216
|
},
|
|
8217
|
+
currentTarget: {
|
|
8218
|
+
name,
|
|
8219
|
+
value: actualValue
|
|
8220
|
+
}
|
|
8212
8221
|
};
|
|
8222
|
+
// Trigger onChange dengan nilai yang benar
|
|
8213
8223
|
onChange?.(syntheticEvent);
|
|
8214
|
-
//
|
|
8224
|
+
// Update hidden select element - gunakan string untuk DOM tapi RHF tetap dapat nilai asli
|
|
8215
8225
|
if (selectRef.current) {
|
|
8216
|
-
selectRef.current.value = String(
|
|
8217
|
-
|
|
8226
|
+
selectRef.current.value = String(actualValue);
|
|
8227
|
+
// Buat custom event yang membawa nilai asli
|
|
8228
|
+
const customEvent = new CustomEvent('change', {
|
|
8229
|
+
bubbles: true,
|
|
8230
|
+
detail: { originalValue: actualValue }
|
|
8231
|
+
});
|
|
8232
|
+
selectRef.current.dispatchEvent(customEvent);
|
|
8218
8233
|
}
|
|
8219
8234
|
setIsOpen(false);
|
|
8220
8235
|
};
|
|
8221
8236
|
return (React.createElement(React.Fragment, null,
|
|
8222
|
-
React.createElement("select", { ref: selectRef, name: name, value: value, onChange: onChange, onBlur: onBlur, required: required, disabled: disabled, style: { position: 'absolute', left: '-9999px' }, tabIndex: -1
|
|
8237
|
+
React.createElement("select", { ref: selectRef, name: name, value: value !== undefined && value !== null && !Number.isNaN(value) ? value : '', onChange: onChange, onBlur: onBlur, required: required, disabled: disabled, style: { position: 'absolute', left: '-9999px' }, tabIndex: -1 },
|
|
8223
8238
|
React.createElement("option", { value: "" }, "Select an option"),
|
|
8224
|
-
options.map((opt) => (React.createElement("option", { key: opt.value, value: opt.value }, opt.label)))),
|
|
8239
|
+
options.map((opt) => (React.createElement("option", { key: opt.value, value: String(opt.value) }, opt.label)))),
|
|
8225
8240
|
label && !floatingLabel && (React.createElement("label", { htmlFor: name },
|
|
8226
8241
|
label,
|
|
8227
8242
|
" ",
|
|
@@ -8660,7 +8675,7 @@ const SelectWithSearch = forwardRef((props, ref) => {
|
|
|
8660
8675
|
setIsOpen(false);
|
|
8661
8676
|
};
|
|
8662
8677
|
return (React.createElement(React.Fragment, null,
|
|
8663
|
-
React.createElement("select", { ref: selectRef, name: name, value: value, onChange: onChange, style: { position: 'absolute', left: '-9999px' }, tabIndex: -1
|
|
8678
|
+
React.createElement("select", { ref: selectRef, name: name, value: value, onChange: onChange, style: { position: 'absolute', left: '-9999px' }, tabIndex: -1 },
|
|
8664
8679
|
React.createElement("option", { value: "" }, "Select an option"),
|
|
8665
8680
|
options.map((opt) => (React.createElement("option", { key: opt.value, value: opt.value }, opt.label)))),
|
|
8666
8681
|
label && !floatingLabel && (React.createElement("label", { htmlFor: name },
|