@alexgorbatchev/shadcn 0.0.146 → 0.0.148

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.
@@ -518,6 +518,7 @@ function OptionCheckboxGroup2({ analytics, density, className, ...props }) {
518
518
  });
519
519
  }
520
520
  var CARD_CLASS = "group/option-card grid w-full cursor-pointer grid-cols-[1.25rem_minmax(0,1fr)] items-start gap-x-2 rounded-md border border-input bg-card p-panel-sm text-start text-sm text-card-foreground transition-colors outline-none hover:bg-muted/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid data-checked:border-primary data-checked:ring-1 data-checked:ring-primary forced-colors:data-checked:border-[color:Highlight] aria-invalid:not-data-checked:border-destructive data-disabled:cursor-not-allowed data-disabled:opacity-50 data-disabled:hover:bg-card data-readonly:cursor-default data-folding:pb-10";
521
+ var CARD_CONTROL_SELECTOR = '[data-slot="option-card"], [data-slot="option-checkbox-card"]';
521
522
  function useFold(lines) {
522
523
  const ref = useRef(null);
523
524
  const [isOverflowing, setIsOverflowing] = useState(false);
@@ -539,9 +540,9 @@ function useFold(lines) {
539
540
  return {
540
541
  ref,
541
542
  height,
542
- isFoldable: lines !== undefined && (isOverflowing || isOpen),
543
+ isFoldable: lines !== undefined && isOverflowing && !isOpen,
543
544
  isOpen,
544
- toggle: () => setIsOpen((open) => !open)
545
+ open: () => setIsOpen(true)
545
546
  };
546
547
  }
547
548
  function getLineHeight(element) {
@@ -639,11 +640,14 @@ function FoldToggle({ fold, descriptionId }) {
639
640
  variant: "outline",
640
641
  size: "xs",
641
642
  "data-slot": "option-card-fold",
642
- "aria-expanded": fold.isOpen,
643
+ "aria-expanded": false,
643
644
  "aria-controls": descriptionId,
644
645
  className: "absolute end-3 bottom-1.5",
645
- onClick: fold.toggle,
646
- children: fold.isOpen ? "Less" : "More"
646
+ onClick: () => {
647
+ fold.ref.current?.closest(CARD_CONTROL_SELECTOR)?.focus();
648
+ fold.open();
649
+ },
650
+ children: "More"
647
651
  });
648
652
  }
649
653
  function useOptionCardIds() {
@@ -4243,6 +4247,13 @@ function ReadMore2({ maxHeight, density, className, style, children, ...props })
4243
4247
  const ref = useRef7(null);
4244
4248
  const [isOverflowing, setIsOverflowing] = useState8(false);
4245
4249
  const [isOpen, setIsOpen] = useState8(false);
4250
+ const shouldFocusContent = useRef7(false);
4251
+ useLayoutEffect3(() => {
4252
+ if (!isOpen || !shouldFocusContent.current)
4253
+ return;
4254
+ shouldFocusContent.current = false;
4255
+ ref.current?.focus();
4256
+ }, [isOpen]);
4246
4257
  useLayoutEffect3(() => {
4247
4258
  const element = ref.current;
4248
4259
  if (!element || isOpen)
@@ -4264,20 +4275,24 @@ function ReadMore2({ maxHeight, density, className, style, children, ...props })
4264
4275
  ref,
4265
4276
  "data-slot": "read-more-content",
4266
4277
  "data-folded": isFolded && isOverflowing || undefined,
4267
- className: cn2("w-full min-w-0 data-folded:mask-b-from-[calc(100%-2rem)] data-folded:mask-b-to-100%", isFolded && "overflow-hidden", className),
4278
+ tabIndex: isOpen ? -1 : undefined,
4279
+ className: cn2("w-full min-w-0 outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid data-folded:mask-b-from-[calc(100%-2rem)] data-folded:mask-b-to-100%", isFolded && "overflow-hidden", className),
4268
4280
  style: isFolded ? { ...style, maxHeight } : style,
4269
4281
  ...props,
4270
4282
  children
4271
4283
  }),
4272
- (isOverflowing || isOpen) && /* @__PURE__ */ jsx41(Button2, {
4284
+ isOverflowing && isFolded && /* @__PURE__ */ jsx41(Button2, {
4273
4285
  type: "button",
4274
4286
  variant: "link",
4275
4287
  size: "sm",
4276
4288
  "data-slot": "read-more-toggle",
4277
- "aria-expanded": isOpen,
4289
+ "aria-expanded": false,
4278
4290
  "aria-controls": `${id}-content`,
4279
- onClick: () => setIsOpen((open) => !open),
4280
- children: isOpen ? "Less" : "More"
4291
+ onClick: () => {
4292
+ shouldFocusContent.current = true;
4293
+ setIsOpen(true);
4294
+ },
4295
+ children: "More"
4281
4296
  })
4282
4297
  ]
4283
4298
  });
@@ -23,8 +23,9 @@ interface IOptionCardContentProps {
23
23
  /** A short explanation shown below the label, such as the option's trade-off. */
24
24
  description?: ReactNode;
25
25
  /**
26
- * Folds the description after this many lines, with a More button that shows the rest. The button sits inside the
27
- * card's border but outside the card's control, so pressing it never changes the choice.
26
+ * Folds the description after this many lines, with a More button that shows the rest for good: once unfolded, the
27
+ * description stays open and the button goes away. The button sits inside the card's border but outside the card's
28
+ * control, so pressing it never changes the choice.
28
29
  */
29
30
  descriptionLines?: number;
30
31
  /** Marks the option the author recommends with a tag after its label and a tinted border. */
@@ -5,8 +5,9 @@ type ReadMoreProps = ComponentProps<"div"> & IDensityProps & {
5
5
  maxHeight: string;
6
6
  };
7
7
  /**
8
- * Long content folded to `maxHeight`, with a More button that shows the rest and Less that folds it again. Content
9
- * that fits shows in full with no button. The fold fades out its last line so the cut reads as intended.
8
+ * Long content folded to `maxHeight`, with a More button that shows the rest for good: once unfolded, the content stays
9
+ * open, the button goes away and focus moves to the content. Content that fits shows in full with no button. The fold
10
+ * fades out its last line so the cut reads as intended.
10
11
  */
11
12
  declare function ReadMore({ maxHeight, density, className, style, children, ...props }: ReadMoreProps): ReactElement;
12
13
  export { ReadMore };
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-wq1prnfw.js";
29
+ } from "../../chunk-v1semj30.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
@@ -2745,6 +2745,7 @@ function TreeSelect({
2745
2745
  return /* @__PURE__ */ jsx3(TreeItem, {
2746
2746
  item,
2747
2747
  expandOn: "disclosure",
2748
+ hasIcon: false,
2748
2749
  description,
2749
2750
  isDimmed: Boolean(node.disabledReason),
2750
2751
  "aria-disabled": node.disabledReason || isDisabled ? true : undefined,
package/dist/index.js CHANGED
@@ -188,7 +188,7 @@ import {
188
188
  DashboardLayout2,
189
189
  BillingUsage2,
190
190
  SelectionAction2
191
- } from "./chunk-wq1prnfw.js";
191
+ } from "./chunk-v1semj30.js";
192
192
  import {
193
193
  statusDotVariants2,
194
194
  StatusDot2
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.146",
2054
+ version: "0.0.148",
2055
2055
  description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -1,6 +1,6 @@
1
1
  # ReadMore
2
2
 
3
- ReadMore folds long content to `maxHeight` with a More button, and Less folds it again. Content that fits shows in full without a button.
3
+ ReadMore folds long content to `maxHeight` with a More button that unfolds it for good: no Less button follows. Content that fits shows in full without a button.
4
4
 
5
5
  Story: @alexgorbatchev/shadcn/components/layout/ReadMore
6
6
  Source: src/components/stories/layout/ReadMore.stories.tsx
package/llms.txt CHANGED
@@ -444,7 +444,7 @@ Generated from the public package exports and Storybook sources.
444
444
  - [PageHeader](./llms/components/layout/PageHeader.md)
445
445
  - [PageIntro](./llms/components/layout/PageIntro.md)
446
446
  - [PanelHeader](./llms/components/layout/PanelHeader.md)
447
- - [ReadMore](./llms/components/layout/ReadMore.md): ReadMore folds long content to `maxHeight` with a More button, and Less folds it again. Content that fits shows in full without a button.
447
+ - [ReadMore](./llms/components/layout/ReadMore.md): ReadMore folds long content to `maxHeight` with a More button that unfolds it for good: no Less button follows. Content that fits shows in full without a button.
448
448
  - [Resizable](./llms/components/layout/Resizable.md)
449
449
  - [ScrollArea](./llms/components/layout/ScrollArea.md)
450
450
  - [Separator](./llms/components/layout/Separator.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.146",
3
+ "version": "0.0.148",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {