@alexgorbatchev/shadcn 0.0.67 → 0.0.69

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.
@@ -2565,6 +2565,7 @@ function InlineEdit2({
2565
2565
  const shouldCancel = useRef2(false);
2566
2566
  const [isSaving, setSaving] = useState2(false);
2567
2567
  const [error, setError] = useState2(null);
2568
+ const [isErrorOpen, setErrorOpen] = useState2(false);
2568
2569
  useEffect2(() => {
2569
2570
  input.current?.focus();
2570
2571
  if (shouldSelectOnMount)
@@ -2580,73 +2581,85 @@ function InlineEdit2({
2580
2581
  }
2581
2582
  setSaving(true);
2582
2583
  setError("");
2584
+ setErrorOpen(false);
2583
2585
  try {
2584
2586
  await onCommit(value);
2585
2587
  track({ name: "ui.commit" });
2586
2588
  } catch (error) {
2587
2589
  isFinished.current = false;
2588
2590
  setError(renderError ? renderError(error) : "Could not save this edit.");
2591
+ setErrorOpen(true);
2589
2592
  } finally {
2590
2593
  setSaving(false);
2591
2594
  }
2592
2595
  };
2593
- return /* @__PURE__ */ jsx26("form", {
2596
+ return /* @__PURE__ */ jsxs15("form", {
2594
2597
  className: "min-w-0",
2595
2598
  onSubmit: (event) => {
2596
2599
  event.preventDefault();
2597
2600
  save();
2598
2601
  },
2599
- children: /* @__PURE__ */ jsxs15(Tooltip2, {
2600
- open: Boolean(error),
2601
- triggerId,
2602
- children: [
2603
- /* @__PURE__ */ jsx26(TooltipTrigger2, {
2604
- id: triggerId,
2605
- render: /* @__PURE__ */ jsx26(Input2, {
2606
- analytics: false,
2607
- ref: input,
2608
- density,
2609
- className: "h-[1lh] rounded-none border-0 px-0 py-0 text-[length:inherit] leading-[inherit]",
2610
- "aria-label": label,
2611
- "aria-invalid": Boolean(error),
2612
- "aria-errormessage": error ? errorId : undefined,
2613
- "aria-description": "Enter saves. Escape cancels.",
2614
- value,
2615
- disabled: isDisabled || isSaving,
2616
- onChange: (event) => onValueChange(event.target.value),
2617
- onBlur: () => {
2618
- if (shouldCancel.current && !isFinished.current) {
2619
- isFinished.current = true;
2620
- onCancel();
2621
- } else
2622
- save();
2623
- },
2624
- onKeyDown: (event) => {
2625
- if (event.key === "Escape") {
2626
- event.preventDefault();
2627
- event.stopPropagation();
2628
- shouldCancel.current = true;
2629
- event.currentTarget.blur();
2630
- } else if (event.key === "Enter") {
2631
- event.preventDefault();
2632
- event.currentTarget.blur();
2602
+ children: [
2603
+ /* @__PURE__ */ jsxs15(Tooltip2, {
2604
+ open: Boolean(error) && isErrorOpen,
2605
+ onOpenChange: setErrorOpen,
2606
+ disableHoverablePopup: true,
2607
+ triggerId,
2608
+ children: [
2609
+ /* @__PURE__ */ jsx26(TooltipTrigger2, {
2610
+ id: triggerId,
2611
+ render: /* @__PURE__ */ jsx26(Input2, {
2612
+ analytics: false,
2613
+ ref: input,
2614
+ density,
2615
+ className: "h-[1lh] rounded-none border-0 px-0 py-0 text-[length:inherit] leading-[inherit]",
2616
+ "aria-label": label,
2617
+ "aria-invalid": Boolean(error),
2618
+ "aria-errormessage": error ? errorId : undefined,
2619
+ "aria-description": "Enter saves. Escape cancels.",
2620
+ value,
2621
+ disabled: isDisabled || isSaving,
2622
+ onChange: (event) => onValueChange(event.target.value),
2623
+ onBlur: () => {
2624
+ if (shouldCancel.current && !isFinished.current) {
2625
+ isFinished.current = true;
2626
+ onCancel();
2627
+ } else
2628
+ save();
2629
+ },
2630
+ onKeyDown: (event) => {
2631
+ if (event.key === "Escape") {
2632
+ event.preventDefault();
2633
+ event.stopPropagation();
2634
+ shouldCancel.current = true;
2635
+ event.currentTarget.blur();
2636
+ } else if (event.key === "Enter") {
2637
+ event.preventDefault();
2638
+ event.currentTarget.blur();
2639
+ }
2633
2640
  }
2634
- }
2635
- })
2636
- }),
2637
- error && /* @__PURE__ */ jsx26(TooltipContent2, {
2638
- density,
2639
- side: "bottom",
2640
- align: "start",
2641
- children: /* @__PURE__ */ jsx26("p", {
2642
- id: errorId,
2643
- role: "alert",
2644
- className: "text-destructive",
2645
- children: error
2641
+ })
2642
+ }),
2643
+ error && /* @__PURE__ */ jsx26(TooltipContent2, {
2644
+ density,
2645
+ side: "bottom",
2646
+ align: "start",
2647
+ "data-testid": "InlineEdit--error-popup",
2648
+ "aria-hidden": true,
2649
+ children: /* @__PURE__ */ jsx26("p", {
2650
+ className: "text-destructive",
2651
+ children: error
2652
+ })
2646
2653
  })
2647
- })
2648
- ]
2649
- })
2654
+ ]
2655
+ }),
2656
+ error && /* @__PURE__ */ jsx26("p", {
2657
+ id: errorId,
2658
+ role: "alert",
2659
+ className: "sr-only",
2660
+ children: error
2661
+ })
2662
+ ]
2650
2663
  });
2651
2664
  }
2652
2665
  // src/components/StarRating.tsx
@@ -31,7 +31,7 @@ import {
31
31
  DrawerHeader2,
32
32
  DrawerTitle2,
33
33
  DrawerDescription2
34
- } from "../../chunk-hz08pzsc.js";
34
+ } from "../../chunk-pr5s27j8.js";
35
35
  import {
36
36
  MenuPopup,
37
37
  MenuItem2,
@@ -679,7 +679,7 @@ var JsonInput = ({ props, bindings, emit }) => {
679
679
  const hasValidation = !!(bindings?.value && props.checks?.length);
680
680
  const { errors, validate } = useFieldValidation(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
681
681
  return /* @__PURE__ */ jsxs14("div", {
682
- className: "space-y-2",
682
+ className: "w-full space-y-2",
683
683
  children: [
684
684
  props.label && /* @__PURE__ */ jsx23(Label2, {
685
685
  htmlFor: id,
@@ -731,7 +731,7 @@ var JsonTextarea = ({ props, bindings }) => {
731
731
  const hasValidation = !!(bindings?.value && props.checks?.length);
732
732
  const { errors, validate } = useFieldValidation2(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
733
733
  return /* @__PURE__ */ jsxs15("div", {
734
- className: "space-y-2",
734
+ className: "w-full space-y-2",
735
735
  children: [
736
736
  props.label && /* @__PURE__ */ jsx24(Label2, {
737
737
  htmlFor: id,
@@ -1,9 +1,11 @@
1
- import type { ReactElement, ReactNode } from "react";
1
+ import { type ReactElement, type ReactNode } from "react";
2
2
  import { type LayoutStorage } from "react-resizable-panels";
3
3
  interface ISplitViewProps {
4
4
  sidebar: ReactNode;
5
5
  children: ReactNode;
6
6
  storageKey: string;
7
+ sidebarPosition?: "start" | "end";
8
+ sidebarOpen?: boolean;
7
9
  storage?: LayoutStorage;
8
10
  sidebarLabel: string;
9
11
  contentLabel: string;
@@ -15,5 +17,5 @@ interface ISplitViewProps {
15
17
  /** Fill a bounded parent; mobile navigation scrolls within at most 35% of its height. */
16
18
  layout?: "content" | "fill";
17
19
  }
18
- export declare function SplitView({ sidebar, children, storageKey, storage, sidebarLabel, contentLabel, resizeLabel, defaultSidebarSize, sidebarPadding, contentPadding, layout: layoutMode, }: ISplitViewProps): ReactElement;
20
+ export declare function SplitView({ sidebar, children, storageKey, sidebarPosition, sidebarOpen, storage, sidebarLabel, contentLabel, resizeLabel, defaultSidebarSize, sidebarPadding, contentPadding, layout: layoutMode, }: ISplitViewProps): ReactElement;
19
21
  export {};
@@ -16,7 +16,8 @@ import {
16
16
  } from "../../chunk-k99h6evz.js";
17
17
  import"../../chunk-5mydsjp3.js";
18
18
  // src/components/resizable/SplitView.tsx
19
- import { useDefaultLayout } from "react-resizable-panels";
19
+ import { useEffect } from "react";
20
+ import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
20
21
  import { jsx, jsxs } from "react/jsx-runtime";
21
22
  var layoutStorage = {
22
23
  getItem(key) {
@@ -42,6 +43,8 @@ function SplitView({
42
43
  sidebar,
43
44
  children,
44
45
  storageKey,
46
+ sidebarPosition = "start",
47
+ sidebarOpen = true,
45
48
  storage = layoutStorage,
46
49
  sidebarLabel,
47
50
  contentLabel,
@@ -54,54 +57,65 @@ function SplitView({
54
57
  const isFill = layoutMode === "fill";
55
58
  const isWide = useMediaQuery("(min-width: 1024px)");
56
59
  const layout = useDefaultLayout({ id: storageKey, storage, onlySaveAfterUserInteractions: true });
60
+ const sidebarRef = usePanelRef();
61
+ useEffect(() => {
62
+ if (!isWide)
63
+ return;
64
+ if (sidebarOpen)
65
+ sidebarRef.current?.expand();
66
+ else
67
+ sidebarRef.current?.collapse();
68
+ }, [isWide, sidebarOpen, sidebarRef]);
69
+ const sidebarContent = /* @__PURE__ */ jsx("aside", {
70
+ hidden: !sidebarOpen,
71
+ "aria-label": sidebarLabel,
72
+ className: cn2("min-w-0 bg-card", isWide && "h-full", sidebarPadding === "panel" && "p-4", isFill && "min-h-0 overflow-y-auto", !isWide && isFill && "max-h-[35%] shrink-0"),
73
+ children: sidebar
74
+ });
75
+ const content = /* @__PURE__ */ jsx("section", {
76
+ "aria-label": contentLabel,
77
+ className: cn2("min-w-0 bg-card", isWide && "h-full", contentPadding === "panel" && "p-4", isFill && "flex min-h-0 flex-1 flex-col overflow-hidden"),
78
+ children
79
+ });
57
80
  if (!isWide)
58
81
  return /* @__PURE__ */ jsxs("div", {
59
82
  className: cn2("flex min-w-0 flex-col bg-card", isFill && "h-full min-h-0 overflow-hidden"),
60
83
  children: [
61
- /* @__PURE__ */ jsx("aside", {
62
- "aria-label": sidebarLabel,
63
- className: cn2("min-w-0", sidebarPadding === "panel" && "p-4", isFill && "max-h-[35%] shrink-0 overflow-y-auto"),
64
- children: sidebar
65
- }),
84
+ sidebarPosition === "start" ? sidebarContent : content,
66
85
  /* @__PURE__ */ jsx(Separator2, {
67
- thickness: "strong"
86
+ thickness: "strong",
87
+ hidden: !sidebarOpen
68
88
  }),
69
- /* @__PURE__ */ jsx("section", {
70
- "aria-label": contentLabel,
71
- className: cn2("min-w-0", contentPadding === "panel" && "p-4", isFill && "flex min-h-0 flex-1 flex-col overflow-hidden"),
72
- children
73
- })
89
+ sidebarPosition === "start" ? content : sidebarContent
74
90
  ]
75
91
  });
92
+ const sidebarPanel = /* @__PURE__ */ jsx(ResizablePanel2, {
93
+ id: "sidebar",
94
+ panelRef: sidebarRef,
95
+ collapsible: true,
96
+ collapsedSize: 0,
97
+ defaultSize: sidebarOpen ? defaultSidebarSize : 0,
98
+ minSize: 200,
99
+ maxSize: "50%",
100
+ children: sidebarContent
101
+ });
102
+ const contentPanel = /* @__PURE__ */ jsx(ResizablePanel2, {
103
+ id: "content",
104
+ minSize: "35%",
105
+ children: content
106
+ });
76
107
  return /* @__PURE__ */ jsxs(Resizable2, {
77
108
  orientation: "horizontal",
78
109
  defaultLayout: layout.defaultLayout,
79
110
  onLayoutChanged: layout.onLayoutChanged,
80
111
  children: [
81
- /* @__PURE__ */ jsx(ResizablePanel2, {
82
- id: "sidebar",
83
- defaultSize: defaultSidebarSize,
84
- minSize: 200,
85
- maxSize: "50%",
86
- children: /* @__PURE__ */ jsx("aside", {
87
- "aria-label": sidebarLabel,
88
- className: cn2("h-full min-w-0 bg-card", sidebarPadding === "panel" && "p-4", isFill && "min-h-0 overflow-y-auto"),
89
- children: sidebar
90
- })
91
- }),
112
+ sidebarPosition === "start" ? sidebarPanel : contentPanel,
92
113
  /* @__PURE__ */ jsx(ResizableHandle2, {
93
114
  thickness: "strong",
115
+ disabled: !sidebarOpen,
94
116
  "aria-label": resizeLabel
95
117
  }),
96
- /* @__PURE__ */ jsx(ResizablePanel2, {
97
- id: "content",
98
- minSize: "35%",
99
- children: /* @__PURE__ */ jsx("section", {
100
- "aria-label": contentLabel,
101
- className: cn2("h-full min-w-0 bg-card", contentPadding === "panel" && "p-4", isFill && "flex min-h-0 flex-col overflow-hidden"),
102
- children
103
- })
104
- })
118
+ sidebarPosition === "start" ? contentPanel : sidebarPanel
105
119
  ]
106
120
  });
107
121
  }
package/dist/index.js CHANGED
@@ -171,7 +171,7 @@ import {
171
171
  StatusTracker2,
172
172
  DashboardLayout2,
173
173
  BillingUsage2
174
- } from "./chunk-hz08pzsc.js";
174
+ } from "./chunk-pr5s27j8.js";
175
175
  import {
176
176
  Tabs2,
177
177
  tabsListVariants2,
package/dist/prototype.js CHANGED
@@ -2051,7 +2051,7 @@ var program = new Command;
2051
2051
  // package.json
2052
2052
  var package_default = {
2053
2053
  name: "@alexgorbatchev/shadcn",
2054
- version: "0.0.67",
2054
+ version: "0.0.69",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -474,3 +474,20 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
474
474
  }
475
475
  }
476
476
  ```
477
+
478
+ ### FullWidthTextFields
479
+
480
+ ```tsx
481
+ {
482
+ args: {
483
+ spec: {
484
+ root: "fields",
485
+ elements: {
486
+ fields: { type: "Stack", props: { align: "start" }, children: ["name", "notes"] },
487
+ name: { type: "Input", props: { label: "Full width name" } },
488
+ notes: { type: "Textarea", props: { label: "Full width notes" } },
489
+ },
490
+ },
491
+ }
492
+ }
493
+ ```
@@ -66,6 +66,18 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
66
66
  }
67
67
  ```
68
68
 
69
+ ### DismissedValidation
70
+
71
+ ```tsx
72
+ {
73
+ args: {
74
+ onCommit: async () => {
75
+ throw new Error("Private storage diagnostic");
76
+ },
77
+ }
78
+ }
79
+ ```
80
+
69
81
  ### UnchangedEnter
70
82
 
71
83
  ```tsx
@@ -103,3 +103,27 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
103
103
  </div>)
104
104
  }
105
105
  ```
106
+
107
+ ### TrailingSidebar
108
+
109
+ ```tsx
110
+ {
111
+ args: { sidebarPosition: "end" }
112
+ }
113
+ ```
114
+
115
+ ### ToggleTrailingSidebar
116
+
117
+ ```tsx
118
+ {
119
+ render: function Example(args) {
120
+ const [open, setOpen] = useState(true);
121
+ return (<div className="h-96 w-[900px]">
122
+ <SplitView {...args} sidebarPosition="end" sidebarOpen={open} layout="fill" sidebar={<h2>Discussion</h2>}>
123
+ <Button onClick={() => setOpen(!open)}>Toggle discussion</Button>
124
+ <input aria-label="Draft answer" defaultValue=""/>
125
+ </SplitView>
126
+ </div>);
127
+ }
128
+ }
129
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {