@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.
@@ -1,6 +1,6 @@
1
1
  import { Avatar as AvatarPrimitive } from "radix-ui";
2
2
  import * as React from "react";
3
3
  declare function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>): import("react/jsx-runtime").JSX.Element;
4
+ declare function AvatarImage({ className, src, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>): import("react/jsx-runtime").JSX.Element | null;
5
5
  declare function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): import("react/jsx-runtime").JSX.Element;
6
6
  export { Avatar, AvatarFallback, AvatarImage };
@@ -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
@@ -163,8 +163,13 @@ function AspectRatio({ ...props }) {
163
163
  function Avatar({ className, ...props }) {
164
164
  return (jsx(AvatarPrimitive.Root, { "data-slot": "avatar", className: cn$1("relative flex size-8 shrink-0 overflow-hidden rounded-full", className), ...props }));
165
165
  }
166
- function AvatarImage({ className, ...props }) {
167
- return (jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn$1("aspect-square size-full", className), ...props }));
166
+ function AvatarImage({ className, src, ...props }) {
167
+ // Empty/undefined src still mounts an <img> in some browsers and shows a
168
+ // broken-image glyph over AvatarFallback (e.g. a black "N" badge). Skip it.
169
+ if (src == null || src === "") {
170
+ return null;
171
+ }
172
+ return (jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", src: src, className: cn$1("aspect-square size-full", className), ...props }));
168
173
  }
169
174
  function AvatarFallback({ className, ...props }) {
170
175
  return (jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn$1("bg-muted flex size-full items-center justify-center rounded-full", className), ...props }));
@@ -15986,14 +15991,22 @@ function ScrollBar({ className, orientation = "vertical", ...props }) {
15986
15991
  "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
15992
  }
15988
15993
 
15989
- function Select({ onValueChange, ...props }) {
15990
- return (jsx(SelectPrimitive.Root, { "data-slot": "select", ...props, onValueChange: value => {
15991
- // Swallow the empty value Radix emits on its own.
15994
+ function Select({ onValueChange, onOpenChange, open, defaultOpen, ...props }) {
15995
+ // Tracked in a ref, not state: this only needs to be readable inside the
15996
+ // callback below, and putting it in state would re-render on every open.
15997
+ const isOpenRef = React.useRef(defaultOpen ?? false);
15998
+ if (open !== undefined)
15999
+ isOpenRef.current = open;
16000
+ return (jsx(SelectPrimitive.Root, { "data-slot": "select", ...props, open: open, defaultOpen: defaultOpen, onOpenChange: next => {
16001
+ isOpenRef.current = next;
16002
+ onOpenChange?.(next);
16003
+ }, onValueChange: value => {
16004
+ // Drop ONLY the empty value Radix echoes back on its own.
15992
16005
  //
15993
- // Radix keeps a hidden native <select> so the control participates in
16006
+ // Radix keeps a hidden native <select> so the control works inside
15994
16007
  // real forms. Whenever the controlled value changes it assigns that
15995
16008
  // value to the native node and dispatches a synthetic change event,
15996
- // which comes back out through onValueChange:
16009
+ // which comes straight back out through onValueChange:
15997
16010
  //
15998
16011
  // setValue.call(select, selectValue);
15999
16012
  // select.dispatchEvent(new Event("change", { bubbles: true }));
@@ -16001,24 +16014,23 @@ function Select({ onValueChange, ...props }) {
16001
16014
  // onChange: (event) => onValueChange(event.target.value)
16002
16015
  //
16003
16016
  // The native <option> list is registered by SelectItem, and the items
16004
- // live inside SelectContent — which is portalled and only mounted
16005
- // while the menu is open. So on a closed select the option for the
16006
- // incoming value usually does not exist yet, the DOM refuses the
16007
- // assignment, `select.value` collapses to "", and that empty string is
16008
- // what every consumer receives.
16009
- //
16010
- // In practice this fires exactly when server data lands in a form:
16011
- // the field is set to the saved value, Radix echoes back "", and the
16012
- // handler writes it into form state. Fields normalised through an
16013
- // enum/fallback then snap to their default; fields validated by zod
16014
- // fail on submit with "received ''".
16017
+ // live inside SelectContent — portalled, and only mounted while the
16018
+ // menu is open. On a closed select the option for the incoming value
16019
+ // usually does not exist yet, the DOM refuses the assignment,
16020
+ // `select.value` collapses to "", and that empty string reaches the
16021
+ // consumer. In a form this lands exactly when saved data arrives: the
16022
+ // field is set to its stored value, Radix echoes "", and the handler
16023
+ // writes that back enum fields then snap to their fallback and zod
16024
+ // rejects the submit with "received ''".
16015
16025
  //
16016
- // A genuine selection can never be empty that path is
16017
- // `context.onValueChange(value)` from SelectItem's handleSelect, using
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 === "")
16026
+ // The open check is what keeps a real "none" option working. Radix
16027
+ // does NOT forbid <SelectItem value="">, and picking one is a
16028
+ // legitimate way to clear a selection. A user pick always arrives
16029
+ // while the menu is still open SelectItem's handleSelect calls
16030
+ // onValueChange(value) BEFORE onOpenChange(false) whereas the echo
16031
+ // above fires from an effect with the menu closed. So only the closed
16032
+ // case is suppressed.
16033
+ if (value === "" && !isOpenRef.current)
16022
16034
  return;
16023
16035
  onValueChange?.(value);
16024
16036
  } }));