@stainless-api/ui-primitives 0.1.0-beta.32 → 0.1.0-beta.35

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.
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/components/Button.tsx
6
6
  function Button(props) {
7
- const { variant, children } = props;
7
+ const { variant, children, border, loading, ...rest } = props;
8
8
  const classes = clsx("stl-ui-button", {
9
9
  "stl-ui-button--outline": variant === "outline",
10
10
  "stl-ui-button--ghost": variant === "ghost",
@@ -16,20 +16,20 @@ function Button(props) {
16
16
  }, {
17
17
  "stl-ui-button--size-sm": props.size === "sm",
18
18
  "stl-ui-button--size-lg": props.size === "lg"
19
- }, "not-content", "stl-ui-not-prose", props.className);
20
- if ("href" in props) {
21
- const { href, ...rest$1 } = props;
22
- return /* @__PURE__ */ jsx("a", {
23
- href,
24
- ...rest$1,
25
- className: classes,
26
- children
27
- });
19
+ }, { "stl-ui-button--with-border": variant === "outline" || border }, { "stl-ui-button--loading": !!loading }, "not-content", "stl-ui-not-prose", props.className);
20
+ if (loading) {
21
+ rest["aria-disabled"] = "true";
22
+ rest["aria-label"] = loading.label;
23
+ rest["title"] = loading.label;
28
24
  }
29
- const { type, ...rest } = props;
25
+ if ("href" in rest) return /* @__PURE__ */ jsx("a", {
26
+ ...rest,
27
+ className: classes,
28
+ children
29
+ });
30
30
  return /* @__PURE__ */ jsx("button", {
31
- type: type ?? "button",
32
31
  ...rest,
32
+ type: rest.type ?? "button",
33
33
  className: classes,
34
34
  children
35
35
  });
@@ -9,6 +9,10 @@ type BaseProps = {
9
9
  className?: string;
10
10
  children?: React.ReactNode;
11
11
  size?: 'sm' | 'lg' | 'default';
12
+ border?: boolean;
13
+ loading?: {
14
+ label: string;
15
+ };
12
16
  };
13
17
  type AnchorBranch = BaseProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'className' | 'children'> & {
14
18
  href: string;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/Callout.d.ts
5
5
  type CalloutVariant = 'info' | 'note' | 'tip' | 'success' | 'warning' | 'danger';
@@ -13,6 +13,6 @@ declare function Callout({
13
13
  className,
14
14
  children,
15
15
  ...props
16
- }: CalloutProps): react_jsx_runtime2.JSX.Element;
16
+ }: CalloutProps): react_jsx_runtime0.JSX.Element;
17
17
  //#endregion
18
18
  export { CalloutProps as n, CalloutVariant as r, Callout as t };
@@ -1,2 +1,2 @@
1
- import { n as ButtonProps, r as ButtonVariant, t as Button } from "../Button-DJ4VsD2o.js";
1
+ import { n as ButtonProps, r as ButtonVariant, t as Button } from "../Button-D4DkAJY5.js";
2
2
  export { Button, ButtonProps, ButtonVariant };
@@ -1,3 +1,3 @@
1
- import { t as Button } from "../Button-DFAg4M-E.js";
1
+ import { t as Button } from "../Button-C1OEwBk_.js";
2
2
 
3
3
  export { Button };
@@ -1,2 +1,2 @@
1
- import { n as CalloutProps, r as CalloutVariant, t as Callout } from "../Callout-DTFAhHWq.js";
1
+ import { n as CalloutProps, r as CalloutVariant, t as Callout } from "../Callout-Desqa2PM.js";
2
2
  export { Callout, CalloutProps, CalloutVariant };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as AccordionProps, t as Accordion } from "./Accordion-Cj5GURin.js";
2
- import { n as ButtonProps, r as ButtonVariant, t as Button } from "./Button-DJ4VsD2o.js";
3
- import { n as CalloutProps, r as CalloutVariant, t as Callout } from "./Callout-DTFAhHWq.js";
2
+ import { n as ButtonProps, r as ButtonVariant, t as Button } from "./Button-D4DkAJY5.js";
3
+ import { n as CalloutProps, r as CalloutVariant, t as Callout } from "./Callout-Desqa2PM.js";
4
4
  import * as react3 from "react";
5
5
  import { ComponentProps } from "react";
6
6
  import * as react_jsx_runtime21 from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Button } from "./Button-DFAg4M-E.js";
1
+ import { t as Button } from "./Button-C1OEwBk_.js";
2
2
  import { t as Callout } from "./Callout-BGkXD7D2.js";
3
3
  import { t as Accordion } from "./Accordion-CL3Oarbz.js";
4
4
  import clsx from "clsx";
@@ -1,9 +1,11 @@
1
1
  //#region src/scripts/dropdown.ts
2
+ const initialized = /* @__PURE__ */ new WeakSet();
2
3
  function initDropdown({ root, onSelect, initialValue }) {
3
4
  if (!root) {
4
5
  console.error("Dropdown root element not found");
5
6
  return;
6
7
  }
8
+ if (initialized.has(root)) return;
7
9
  const trigger = root.querySelector("[data-part=\"trigger\"]");
8
10
  const menu = root.querySelector("[data-part=\"menu\"]");
9
11
  if (!trigger) {
@@ -128,6 +130,7 @@ function initDropdown({ root, onSelect, initialValue }) {
128
130
  document.addEventListener("click", (e) => {
129
131
  if (!root.contains(e.target)) close();
130
132
  });
133
+ initialized.add(root);
131
134
  }
132
135
 
133
136
  //#endregion
package/dist/styles.css CHANGED
@@ -129,8 +129,8 @@ body {
129
129
  ) {
130
130
  padding: 12px 20px;
131
131
  border-radius: var(--stl-ui-layout-border-radius-sml);
132
- border: 1px solid var(--stl-ui-border);
133
- background-color: var(--stl-ui-muted-background);
132
+ border: 1px solid var(--stl-color-border-faint);
133
+ background-color: var(--stl-color-faint-background);
134
134
  overflow: scroll;
135
135
  margin-bottom: 1rem;
136
136
  }
@@ -422,6 +422,7 @@ body {
422
422
  }
423
423
 
424
424
  /* --- COLOR VARIANTS --- */
425
+
425
426
  .stl-ui-button--accent {
426
427
  color: var(--stl-color-accent-inverse-foreground);
427
428
  background-color: var(--stl-color-accent-inverse-background);
@@ -436,6 +437,9 @@ body {
436
437
  &:hover {
437
438
  background-color: var(--stl-color-accent-muted-background-hover);
438
439
  }
440
+ &.stl-ui-button--with-border {
441
+ border-color: var(--stl-color-accent-border);
442
+ }
439
443
  }
440
444
 
441
445
  .stl-ui-button--muted {
@@ -444,6 +448,9 @@ body {
444
448
  &:hover {
445
449
  background-color: var(--stl-color-muted-background-hover);
446
450
  }
451
+ &.stl-ui-button--with-border {
452
+ border-color: var(--stl-color-border);
453
+ }
447
454
  }
448
455
 
449
456
  .stl-ui-button--outline {
@@ -451,7 +458,9 @@ body {
451
458
  background-color: var(--stl-color-ui-background);
452
459
  border-color: var(--stl-color-border);
453
460
  &:hover {
454
- background-color: var(--stl-color-ui-background-hover);
461
+ background:
462
+ linear-gradient(var(--stl-color-ui-background-hover), var(--stl-color-ui-background-hover)),
463
+ linear-gradient(var(--stl-color-ui-background), var(--stl-color-ui-background));
455
464
  }
456
465
  }
457
466
 
@@ -461,6 +470,9 @@ body {
461
470
  &:hover {
462
471
  background-color: var(--stl-color-background-hover);
463
472
  }
473
+ &.stl-ui-button--with-border {
474
+ border-color: var(--stl-color-border);
475
+ }
464
476
  }
465
477
 
466
478
  .stl-ui-button--success {
@@ -479,6 +491,41 @@ body {
479
491
  }
480
492
  }
481
493
 
494
+ /* --- LOADING STATE --- */
495
+
496
+ /**
497
+ * When loading, set aria-disabled="true" and aria-label="<Doing action...>"
498
+ * Don't use disabled, it loses focus.
499
+ */
500
+
501
+ .stl-ui-button--loading {
502
+ -webkit-text-fill-color: transparent;
503
+ position: relative;
504
+
505
+ & * {
506
+ color: transparent;
507
+ }
508
+
509
+ &::before {
510
+ content: '';
511
+ animation: stl-ui-button--loading-spin 1s linear infinite;
512
+ position: absolute;
513
+ width: 16px;
514
+ height: 16px;
515
+ mask-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWxvYWRlci1jaXJjbGUtaWNvbiBsdWNpZGUtbG9hZGVyLWNpcmNsZSI+PHBhdGggZD0iTTIxIDEyYTkgOSAwIDEgMS02LjIxOS04LjU2Ii8+PC9zdmc+');
516
+ mask-size: contain;
517
+ mask-position: center;
518
+ mask-repeat: no-repeat;
519
+ background: currentColor;
520
+ }
521
+ }
522
+
523
+ @keyframes stl-ui-button--loading-spin {
524
+ to {
525
+ transform: rotate(360deg);
526
+ }
527
+ }
528
+
482
529
  /* --- SIZE VARIANTS --- */
483
530
  .stl-ui-button--size-sm {
484
531
  height: 24px;
@@ -625,8 +672,8 @@ a.stl-ui-button {
625
672
  }
626
673
 
627
674
  /**
628
- * Dropdown Button
629
- */
675
+ * Dropdown Button
676
+ */
630
677
  .stl-ui-dropdown-button--action {
631
678
  display: flex;
632
679
  align-items: center;
@@ -667,12 +714,12 @@ a.stl-ui-button {
667
714
  }
668
715
 
669
716
  /**
670
- * Dropdown Menu
671
- */
717
+ * Dropdown Menu
718
+ */
672
719
  .stl-ui-dropdown-menu {
673
720
  --stl-ui-dropdown-menu-background-color: var(--stl-color-ui-background);
674
721
  --stl-ui-dropdown-menu-border-color: var(--stl-color-border);
675
- --stl-ui-dropdown-menu-box-shadow: var(--stl-ui-shadow-md);
722
+ --stl-ui-dropdown-menu-box-shadow: 0px 4px 4px -2px #00000014;
676
723
  --stl-ui-dropdown-menu-border-radius: var(--stl-ui-layout-border-radius-sml);
677
724
 
678
725
  /* opaque background with sometimes-transparent color on top in image layer*/
@@ -691,6 +738,7 @@ a.stl-ui-button {
691
738
  right: 0;
692
739
  z-index: 1000;
693
740
  min-width: 100%;
741
+ width: max-content;
694
742
  padding: 4px;
695
743
  display: none;
696
744
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/ui-primitives",
3
- "version": "0.1.0-beta.32",
3
+ "version": "0.1.0-beta.35",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -17,7 +17,7 @@
17
17
  "lucide-react": "^0.555.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@types/react": "^19.2.7",
20
+ "@types/react": "19.2.7",
21
21
  "@types/react-dom": "^19.2.3",
22
22
  "react": "^19.2.1",
23
23
  "react-dom": "^19.2.1",