@estiva-app/ui 0.92.0 → 0.92.1
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/Button.d.ts +11 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/index.js +46 -47
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/registry.json +13 -1
- package/src/Button.mdx +25 -3
- package/src/Button.stories.tsx +15 -1
- package/src/Button.test.tsx +33 -0
- package/src/Button.tsx +65 -49
package/dist/Button.d.ts
CHANGED
|
@@ -49,7 +49,17 @@ export interface ButtonProps extends ComponentPropsWithRef<'button'> {
|
|
|
49
49
|
/** Why the action cannot succeed right now. Disables the button, keeps it
|
|
50
50
|
* reachable by keyboard, and shows the reason as a tooltip on hover. */
|
|
51
51
|
disabledReason?: string;
|
|
52
|
+
/**
|
|
53
|
+
* A link that looks like a button: an anchor, so the address stays real for a
|
|
54
|
+
* modified click, a new tab or "copy link address", as `IconButton` and `Link`
|
|
55
|
+
* keep it. A router app's `navigate` (AppProvider) moves in place. A link
|
|
56
|
+
* cannot be disabled, so while it would be (`disabled`, `disabledReason`, a
|
|
57
|
+
* busy Form) it is the button (Katerina, 30 October).
|
|
58
|
+
*/
|
|
59
|
+
href?: string;
|
|
60
|
+
/** With `href`: another site, or another app. Opens in a new tab, with `noopener noreferrer`, as `Link`'s does. */
|
|
61
|
+
external?: boolean;
|
|
52
62
|
children: ReactNode;
|
|
53
63
|
}
|
|
54
|
-
export declare function Button({ variant, size, leadingIcon, className, children, disabled, disabledReason, type, ...props }: ButtonProps): import("react").JSX.Element;
|
|
64
|
+
export declare function Button({ variant, size, leadingIcon, className, children, disabled, disabledReason, type, href, external, ...props }: ButtonProps): import("react").JSX.Element;
|
|
55
65
|
//# sourceMappingURL=Button.d.ts.map
|
package/dist/Button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAO7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,aAAa,GAAG,SAAS,CAAA;AACxF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAA;AAE5C,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAY,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IAClE,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;6EACyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mHAAmH;IACnH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,MAAM,CAAC,EACrB,OAAiB,EACjB,IAAgB,EAChB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,IAAe,EACf,IAAI,EACJ,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,WAAW,+BAyDb"}
|
package/dist/index.js
CHANGED
|
@@ -994,58 +994,57 @@ function Button({
|
|
|
994
994
|
disabled,
|
|
995
995
|
disabledReason,
|
|
996
996
|
type = "button",
|
|
997
|
+
href,
|
|
998
|
+
external = false,
|
|
997
999
|
...props
|
|
998
1000
|
}) {
|
|
999
1001
|
const hasLeadingIcon = !!leadingIcon;
|
|
1000
1002
|
const formBusy = useFormBusy();
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
// Disabled too, as it always drew.
|
|
1039
|
-
variant === "resolve" && "signal:bg-transparent signal:border signal:border-border-default signal:text-text-primary signal:shadow-none signal:hover:bg-success-muted signal:hover:border-success-outline signal:hover:text-success-default signal:transition-colors",
|
|
1040
|
-
className
|
|
1041
|
-
),
|
|
1042
|
-
...props,
|
|
1043
|
-
children: [
|
|
1044
|
-
leadingIcon,
|
|
1045
|
-
children
|
|
1046
|
-
]
|
|
1047
|
-
}
|
|
1003
|
+
const unusable = disabled || !!disabledReason || formBusy;
|
|
1004
|
+
const anchor = props;
|
|
1005
|
+
const inApp = useInAppClick(href, anchor.onClick);
|
|
1006
|
+
const look = (off) => cn(
|
|
1007
|
+
// No `self-center` here, deliberately — `IconButton` needs it and this
|
|
1008
|
+
// does not, and the difference is the `h-8` / `h-6` on the next two
|
|
1009
|
+
// lines. `align-items: stretch` only stretches a child whose cross
|
|
1010
|
+
// size is `auto`; a Button always states its height, so a stretching
|
|
1011
|
+
// parent cannot change it. Measured in Chrome on 2026-09-12, in the
|
|
1012
|
+
// 260px row of Finding 49: 32px with `self-center` and 32px without.
|
|
1013
|
+
// What the class DID do was override the caller on the other axis —
|
|
1014
|
+
// in a column it beats the parent's `items-start`, which centred the
|
|
1015
|
+
// four actions in Ship's `ProjectRail` and the trigger in five of
|
|
1016
|
+
// this package's own story frames, each of which asks for the top.
|
|
1017
|
+
// A control does not get to decide where its caller puts it.
|
|
1018
|
+
"inline-flex items-center justify-center gap-1 rounded-md transition-colors font-sans font-medium",
|
|
1019
|
+
size === "default" && "h-8 min-h-8 text-btn-default",
|
|
1020
|
+
size === "small" && "h-6 min-h-6 text-btn-small",
|
|
1021
|
+
// Extra right padding beside a leading icon, for optical balance.
|
|
1022
|
+
size === "default" && (hasLeadingIcon ? "pl-2 pr-3" : "px-2"),
|
|
1023
|
+
size === "small" && (hasLeadingIcon ? "pl-1.5 pr-2" : "px-1.5"),
|
|
1024
|
+
!off && (variant === "primary" || variant === "resolve") && "bg-accent-primary hover:bg-accent-hover text-text-inverse cursor-pointer signal:font-semibold",
|
|
1025
|
+
// @estiva-escape(no-copied-look): W2 (Katerina, 24 September: leave alone): an outlined button shares four words with Reaction's pill by coincidence
|
|
1026
|
+
!off && variant === "outlined" && "border border-border-default hover:bg-bg-hover text-text-primary cursor-pointer",
|
|
1027
|
+
!off && variant === "muted" && "hover:bg-bg-hover text-text-primary cursor-pointer",
|
|
1028
|
+
!off && variant === "destructive" && "hover:bg-error-muted text-error-default cursor-pointer",
|
|
1029
|
+
off && "bg-bg-disabled text-text-disabled",
|
|
1030
|
+
// `pointer-events-none` only where the button is truly out of reach.
|
|
1031
|
+
// With a `disabledReason` the button IS the tooltip's trigger, and a
|
|
1032
|
+
// trigger the pointer cannot land on never opens one — Base UI already
|
|
1033
|
+
// swallows the click (`focusableWhenDisabled` gives `aria-disabled`
|
|
1034
|
+
// and a prevented `onClick`), so nothing else needs it.
|
|
1035
|
+
off && !disabledReason && "pointer-events-none",
|
|
1036
|
+
off && variant === "outlined" && "border border-border-default",
|
|
1037
|
+
// Disabled too, as it always drew.
|
|
1038
|
+
variant === "resolve" && "signal:bg-transparent signal:border signal:border-border-default signal:text-text-primary signal:shadow-none signal:hover:bg-success-muted signal:hover:border-success-outline signal:hover:text-success-default signal:transition-colors",
|
|
1039
|
+
className
|
|
1048
1040
|
);
|
|
1041
|
+
const button = href && !unusable ? /* @__PURE__ */ jsxs8("a", { href, ...external ? { target: "_blank", rel: "noopener noreferrer" } : {}, className: look(false), ...anchor, onClick: inApp, children: [
|
|
1042
|
+
leadingIcon,
|
|
1043
|
+
children
|
|
1044
|
+
] }) : /* @__PURE__ */ jsxs8(BaseButton4, { type, disabled: unusable, focusableWhenDisabled: !!disabledReason, className: (state) => look(state.disabled), ...props, children: [
|
|
1045
|
+
leadingIcon,
|
|
1046
|
+
children
|
|
1047
|
+
] });
|
|
1049
1048
|
return disabledReason ? /* @__PURE__ */ jsx15(TooltipTrigger, { label: disabledReason, children: button }) : button;
|
|
1050
1049
|
}
|
|
1051
1050
|
|