@eintrek/erp-theme 1.4.6 → 1.4.8

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
@@ -208,8 +208,13 @@ function AspectRatio({ ...props }) {
208
208
  function Avatar({ className, ...props }) {
209
209
  return (require$$1.jsx(AvatarPrimitive__namespace.Root, { "data-slot": "avatar", className: cn$1("relative flex size-8 shrink-0 overflow-hidden rounded-full", className), ...props }));
210
210
  }
211
- function AvatarImage({ className, ...props }) {
212
- return (require$$1.jsx(AvatarPrimitive__namespace.Image, { "data-slot": "avatar-image", className: cn$1("aspect-square size-full", className), ...props }));
211
+ function AvatarImage({ className, src, ...props }) {
212
+ // Empty/undefined src still mounts an <img> in some browsers and shows a
213
+ // broken-image glyph over AvatarFallback (e.g. a black "N" badge). Skip it.
214
+ if (src == null || src === "") {
215
+ return null;
216
+ }
217
+ return (require$$1.jsx(AvatarPrimitive__namespace.Image, { "data-slot": "avatar-image", src: src, className: cn$1("aspect-square size-full", className), ...props }));
213
218
  }
214
219
  function AvatarFallback({ className, ...props }) {
215
220
  return (require$$1.jsx(AvatarPrimitive__namespace.Fallback, { "data-slot": "avatar-fallback", className: cn$1("bg-muted flex size-full items-center justify-center rounded-full", className), ...props }));
@@ -16031,14 +16036,22 @@ function ScrollBar({ className, orientation = "vertical", ...props }) {
16031
16036
  "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
16037
  }
16033
16038
 
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.
16039
+ function Select({ onValueChange, onOpenChange, open, defaultOpen, ...props }) {
16040
+ // Tracked in a ref, not state: this only needs to be readable inside the
16041
+ // callback below, and putting it in state would re-render on every open.
16042
+ const isOpenRef = React__namespace.useRef(defaultOpen ?? false);
16043
+ if (open !== undefined)
16044
+ isOpenRef.current = open;
16045
+ return (require$$1.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props, open: open, defaultOpen: defaultOpen, onOpenChange: next => {
16046
+ isOpenRef.current = next;
16047
+ onOpenChange?.(next);
16048
+ }, onValueChange: value => {
16049
+ // Drop ONLY the empty value Radix echoes back on its own.
16037
16050
  //
16038
- // Radix keeps a hidden native <select> so the control participates in
16051
+ // Radix keeps a hidden native <select> so the control works inside
16039
16052
  // real forms. Whenever the controlled value changes it assigns that
16040
16053
  // value to the native node and dispatches a synthetic change event,
16041
- // which comes back out through onValueChange:
16054
+ // which comes straight back out through onValueChange:
16042
16055
  //
16043
16056
  // setValue.call(select, selectValue);
16044
16057
  // select.dispatchEvent(new Event("change", { bubbles: true }));
@@ -16046,24 +16059,23 @@ function Select({ onValueChange, ...props }) {
16046
16059
  // onChange: (event) => onValueChange(event.target.value)
16047
16060
  //
16048
16061
  // 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.
16054
- //
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 ''".
16062
+ // live inside SelectContent — portalled, and only mounted while the
16063
+ // menu is open. On a closed select the option for the incoming value
16064
+ // usually does not exist yet, the DOM refuses the assignment,
16065
+ // `select.value` collapses to "", and that empty string reaches the
16066
+ // consumer. In a form this lands exactly when saved data arrives: the
16067
+ // field is set to its stored value, Radix echoes "", and the handler
16068
+ // writes that back enum fields then snap to their fallback and zod
16069
+ // rejects the submit with "received ''".
16060
16070
  //
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 === "")
16071
+ // The open check is what keeps a real "none" option working. Radix
16072
+ // does NOT forbid <SelectItem value="">, and picking one is a
16073
+ // legitimate way to clear a selection. A user pick always arrives
16074
+ // while the menu is still open SelectItem's handleSelect calls
16075
+ // onValueChange(value) BEFORE onOpenChange(false) whereas the echo
16076
+ // above fires from an effect with the menu closed. So only the closed
16077
+ // case is suppressed.
16078
+ if (value === "" && !isOpenRef.current)
16067
16079
  return;
16068
16080
  onValueChange?.(value);
16069
16081
  } }));