@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/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
- return (require$$1.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props, onValueChange: value => {
16036
- // Swallow the empty value Radix emits on its own.
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 participates in
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 — which is portalled and only mounted
16050
- // while the menu is open. So on a closed select the option for the
16051
- // incoming value usually does not exist yet, the DOM refuses the
16052
- // assignment, `select.value` collapses to "", and that empty string is
16053
- // what every consumer receives.
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
- // In practice this fires exactly when server data lands in a form:
16056
- // the field is set to the saved value, Radix echoes back "", and the
16057
- // handler writes it into form state. Fields normalised through an
16058
- // enum/fallback then snap to their default; fields validated by zod
16059
- // fail on submit with "received ''".
16060
- //
16061
- // A genuine selection can never be empty — that path is
16062
- // `context.onValueChange(value)` from SelectItem's handleSelect, using
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
  } }));