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