@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Select as SelectPrimitive } from "radix-ui";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
declare function Select({ onValueChange, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function Select({ onValueChange, onOpenChange, open, defaultOpen, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
package/dist/index.esm.js
CHANGED
|
@@ -15986,14 +15986,22 @@ function ScrollBar({ className, orientation = "vertical", ...props }) {
|
|
|
15986
15986
|
"h-2.5 flex-col border-t border-t-transparent", className), ...props, children: jsx(ScrollAreaPrimitive.ScrollAreaThumb, { "data-slot": "scroll-area-thumb", className: "bg-border relative flex-1 rounded-full" }) }));
|
|
15987
15987
|
}
|
|
15988
15988
|
|
|
15989
|
-
function Select({ onValueChange, ...props }) {
|
|
15990
|
-
|
|
15991
|
-
|
|
15989
|
+
function Select({ onValueChange, onOpenChange, open, defaultOpen, ...props }) {
|
|
15990
|
+
// Tracked in a ref, not state: this only needs to be readable inside the
|
|
15991
|
+
// callback below, and putting it in state would re-render on every open.
|
|
15992
|
+
const isOpenRef = React.useRef(defaultOpen ?? false);
|
|
15993
|
+
if (open !== undefined)
|
|
15994
|
+
isOpenRef.current = open;
|
|
15995
|
+
return (jsx(SelectPrimitive.Root, { "data-slot": "select", ...props, open: open, defaultOpen: defaultOpen, onOpenChange: next => {
|
|
15996
|
+
isOpenRef.current = next;
|
|
15997
|
+
onOpenChange?.(next);
|
|
15998
|
+
}, onValueChange: value => {
|
|
15999
|
+
// Drop ONLY the empty value Radix echoes back on its own.
|
|
15992
16000
|
//
|
|
15993
|
-
// Radix keeps a hidden native <select> so the control
|
|
16001
|
+
// Radix keeps a hidden native <select> so the control works inside
|
|
15994
16002
|
// real forms. Whenever the controlled value changes it assigns that
|
|
15995
16003
|
// value to the native node and dispatches a synthetic change event,
|
|
15996
|
-
// which comes back out through onValueChange:
|
|
16004
|
+
// which comes straight back out through onValueChange:
|
|
15997
16005
|
//
|
|
15998
16006
|
// setValue.call(select, selectValue);
|
|
15999
16007
|
// select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
@@ -16001,24 +16009,23 @@ function Select({ onValueChange, ...props }) {
|
|
|
16001
16009
|
// onChange: (event) => onValueChange(event.target.value)
|
|
16002
16010
|
//
|
|
16003
16011
|
// The native <option> list is registered by SelectItem, and the items
|
|
16004
|
-
// live inside SelectContent —
|
|
16005
|
-
//
|
|
16006
|
-
//
|
|
16007
|
-
//
|
|
16008
|
-
//
|
|
16012
|
+
// live inside SelectContent — portalled, and only mounted while the
|
|
16013
|
+
// menu is open. On a closed select the option for the incoming value
|
|
16014
|
+
// usually does not exist yet, the DOM refuses the assignment,
|
|
16015
|
+
// `select.value` collapses to "", and that empty string reaches the
|
|
16016
|
+
// consumer. In a form this lands exactly when saved data arrives: the
|
|
16017
|
+
// field is set to its stored value, Radix echoes "", and the handler
|
|
16018
|
+
// writes that back — enum fields then snap to their fallback and zod
|
|
16019
|
+
// rejects the submit with "received ''".
|
|
16009
16020
|
//
|
|
16010
|
-
//
|
|
16011
|
-
//
|
|
16012
|
-
//
|
|
16013
|
-
//
|
|
16014
|
-
//
|
|
16015
|
-
//
|
|
16016
|
-
//
|
|
16017
|
-
|
|
16018
|
-
// the item's own value — so dropping "" costs nothing. Consumers that
|
|
16019
|
-
// really want a "none" option should give it an explicit sentinel
|
|
16020
|
-
// value; Radix reserves "" for the placeholder.
|
|
16021
|
-
if (value === "")
|
|
16021
|
+
// The open check is what keeps a real "none" option working. Radix
|
|
16022
|
+
// does NOT forbid <SelectItem value="">, and picking one is a
|
|
16023
|
+
// legitimate way to clear a selection. A user pick always arrives
|
|
16024
|
+
// while the menu is still open — SelectItem's handleSelect calls
|
|
16025
|
+
// onValueChange(value) BEFORE onOpenChange(false) — whereas the echo
|
|
16026
|
+
// above fires from an effect with the menu closed. So only the closed
|
|
16027
|
+
// case is suppressed.
|
|
16028
|
+
if (value === "" && !isOpenRef.current)
|
|
16022
16029
|
return;
|
|
16023
16030
|
onValueChange?.(value);
|
|
16024
16031
|
} }));
|