@eintrek/erp-theme 1.4.6 → 1.4.7
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/components/ui/select.d.ts +1 -1
- package/dist/index.esm.js +29 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16031,14 +16031,22 @@ function ScrollBar({ className, orientation = "vertical", ...props }) {
|
|
|
16031
16031
|
"h-2.5 flex-col border-t border-t-transparent", className), ...props, children: require$$1.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "bg-border relative flex-1 rounded-full" }) }));
|
|
16032
16032
|
}
|
|
16033
16033
|
|
|
16034
|
-
function Select({ onValueChange, ...props }) {
|
|
16035
|
-
|
|
16036
|
-
|
|
16034
|
+
function Select({ onValueChange, onOpenChange, open, defaultOpen, ...props }) {
|
|
16035
|
+
// Tracked in a ref, not state: this only needs to be readable inside the
|
|
16036
|
+
// callback below, and putting it in state would re-render on every open.
|
|
16037
|
+
const isOpenRef = React__namespace.useRef(defaultOpen ?? false);
|
|
16038
|
+
if (open !== undefined)
|
|
16039
|
+
isOpenRef.current = open;
|
|
16040
|
+
return (require$$1.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props, open: open, defaultOpen: defaultOpen, onOpenChange: next => {
|
|
16041
|
+
isOpenRef.current = next;
|
|
16042
|
+
onOpenChange?.(next);
|
|
16043
|
+
}, onValueChange: value => {
|
|
16044
|
+
// Drop ONLY the empty value Radix echoes back on its own.
|
|
16037
16045
|
//
|
|
16038
|
-
// Radix keeps a hidden native <select> so the control
|
|
16046
|
+
// Radix keeps a hidden native <select> so the control works inside
|
|
16039
16047
|
// real forms. Whenever the controlled value changes it assigns that
|
|
16040
16048
|
// value to the native node and dispatches a synthetic change event,
|
|
16041
|
-
// which comes back out through onValueChange:
|
|
16049
|
+
// which comes straight back out through onValueChange:
|
|
16042
16050
|
//
|
|
16043
16051
|
// setValue.call(select, selectValue);
|
|
16044
16052
|
// select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
@@ -16046,24 +16054,23 @@ function Select({ onValueChange, ...props }) {
|
|
|
16046
16054
|
// onChange: (event) => onValueChange(event.target.value)
|
|
16047
16055
|
//
|
|
16048
16056
|
// The native <option> list is registered by SelectItem, and the items
|
|
16049
|
-
// live inside SelectContent —
|
|
16050
|
-
//
|
|
16051
|
-
//
|
|
16052
|
-
//
|
|
16053
|
-
//
|
|
16057
|
+
// live inside SelectContent — portalled, and only mounted while the
|
|
16058
|
+
// menu is open. On a closed select the option for the incoming value
|
|
16059
|
+
// usually does not exist yet, the DOM refuses the assignment,
|
|
16060
|
+
// `select.value` collapses to "", and that empty string reaches the
|
|
16061
|
+
// consumer. In a form this lands exactly when saved data arrives: the
|
|
16062
|
+
// field is set to its stored value, Radix echoes "", and the handler
|
|
16063
|
+
// writes that back — enum fields then snap to their fallback and zod
|
|
16064
|
+
// rejects the submit with "received ''".
|
|
16054
16065
|
//
|
|
16055
|
-
//
|
|
16056
|
-
//
|
|
16057
|
-
//
|
|
16058
|
-
//
|
|
16059
|
-
//
|
|
16060
|
-
//
|
|
16061
|
-
//
|
|
16062
|
-
|
|
16063
|
-
// the item's own value — so dropping "" costs nothing. Consumers that
|
|
16064
|
-
// really want a "none" option should give it an explicit sentinel
|
|
16065
|
-
// value; Radix reserves "" for the placeholder.
|
|
16066
|
-
if (value === "")
|
|
16066
|
+
// The open check is what keeps a real "none" option working. Radix
|
|
16067
|
+
// does NOT forbid <SelectItem value="">, and picking one is a
|
|
16068
|
+
// legitimate way to clear a selection. A user pick always arrives
|
|
16069
|
+
// while the menu is still open — SelectItem's handleSelect calls
|
|
16070
|
+
// onValueChange(value) BEFORE onOpenChange(false) — whereas the echo
|
|
16071
|
+
// above fires from an effect with the menu closed. So only the closed
|
|
16072
|
+
// case is suppressed.
|
|
16073
|
+
if (value === "" && !isOpenRef.current)
|
|
16067
16074
|
return;
|
|
16068
16075
|
onValueChange?.(value);
|
|
16069
16076
|
} }));
|