@alexgorbatchev/shadcn 0.0.57 → 0.0.59

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/README.md CHANGED
@@ -439,7 +439,7 @@ Column `meta.filter` offers a column in `DataGridFilters`, hidden columns includ
439
439
 
440
440
  Import `DataGridSelectHeader` and `DataGridSelectCell` from `@alexgorbatchev/shadcn/data-grid`. Pass the current `useTable` result as `table` to both controls, and pass `row` and an accessible `label` to each cell. The header selects selectable filtered rows across all pages and preserves selections hidden by filters. It shows a mixed state when some of those rows are selected and disables itself when none are selectable. Its default label is "Select all filtered rows"; provide `label` to name the scope in your application. Cells follow native row selection rules, including disabled rows and partially selected parents. The controls observe selection changes without requiring the parent table selector to include selection state.
441
441
 
442
- For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's preferred size, bounded by its native sizing limits, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
442
+ For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's native current size, including controlled sizing state and its min/max bounds, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
443
443
 
444
444
  Keep preferred widths separate from the table's rendered sizing atom. In `onFitWidthChange`, store the reported width in a ref and write `fitDataGridColumnSizing(table, preferredWidths, width)` into the sizing atom. The helper temporarily shrinks required resizable columns toward their minima when needed and restores their preferred widths when space returns. In `onColumnSizingChange`, obtain new preferences with `constrainDataGridColumnSizing(table, updater, widthRef.current, preferredWidths)`, then derive the sizing atom with `fitDataGridColumnSizing`. Persist only the preferred widths, after the resize settles. Native pointer and keyboard resizing starts at the displayed width, stays within the available space, and leaves other columns' preferences unchanged. Widening a required column can hide optional columns again; widening an optional column preserves its fitted neighbours and the fill column's preferred space. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
445
445
 
@@ -56,18 +56,13 @@ var DataGridColumnFitContext = createContext(undefined);
56
56
  import { Subscribe } from "@tanstack/react-table";
57
57
  import { useContext } from "react";
58
58
 
59
- // src/components/data-grid/getDataGridFillPreferredSize.ts
60
- function getDataGridFillPreferredSize(column) {
61
- return Math.min(column.maxSize ?? Number.MAX_SAFE_INTEGER, Math.max(column.minSize ?? 20, column.size ?? 150));
62
- }
63
-
64
59
  // src/components/data-grid/getDataGridColumnFit.ts
65
60
  function getDataGridColumnFit(table, width) {
66
61
  const columns = table.getVisibleLeafColumns();
67
62
  let remaining = width;
68
63
  for (const column of columns) {
69
64
  if (column.columnDef.meta?.fill)
70
- remaining -= getDataGridFillPreferredSize(column.columnDef);
65
+ remaining -= column.getSize();
71
66
  else if (!column.getCanHide())
72
67
  remaining -= column.getSize();
73
68
  }
@@ -92,7 +87,7 @@ function getDataGridColumnFitMaximum(table, columnId, width) {
92
87
  if (other.id === columnId)
93
88
  return sum;
94
89
  if (other.columnDef.meta?.fill) {
95
- return sum + (isRequired ? other.columnDef.minSize ?? 20 : getDataGridFillPreferredSize(other.columnDef));
90
+ return sum + (isRequired ? other.columnDef.minSize ?? 20 : other.getSize());
96
91
  }
97
92
  if (isRequired && other.getCanHide() || hidden.includes(other.id))
98
93
  return sum;
@@ -7,7 +7,7 @@ import {
7
7
  DataGridColumnHeader2,
8
8
  DataGridFilter2,
9
9
  DataGridPagination2
10
- } from "../../chunk-kyctwprg.js";
10
+ } from "../../chunk-8m97h03v.js";
11
11
  import"../../chunk-7ny0vyek.js";
12
12
  import"../../chunk-8ssktt4b.js";
13
13
  import"../../chunk-en44w1pn.js";
@@ -9,7 +9,7 @@ interface IVirtualDataGridProps<T extends RowData, TSelected> {
9
9
  estimateRowHeight?: number;
10
10
  overscan?: number;
11
11
  /**
12
- * Reserve one fill column's preferred `size` and hide optional columns that do not fit, in their chosen order.
12
+ * Reserve one fill column's native current size and hide optional columns that do not fit, in their chosen order.
13
13
  * The fill column may shrink toward `minSize` when only required columns remain. Replaces
14
14
  * `meta.visibleFrom` breakpoints; saved visibility and widths are unchanged. Use exactly one fill column, and
15
15
  * ensure required columns' minima plus its minimum fit the smallest supported container. Only leaf headers resize.
@@ -10,7 +10,7 @@ import {
10
10
  DataGridHeaderRows,
11
11
  DataGridCells2,
12
12
  DataGridColumns
13
- } from "../../chunk-kyctwprg.js";
13
+ } from "../../chunk-8m97h03v.js";
14
14
  import"../../chunk-7ny0vyek.js";
15
15
  import"../../chunk-8ssktt4b.js";
16
16
  import"../../chunk-e6hk39ev.js";
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.57",
2054
+ version: "0.0.59",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -3107,9 +3107,10 @@ var package_default = {
3107
3107
  },
3108
3108
  scripts: {
3109
3109
  test: "vitest run --config .storybook/vitest.config.ts && bun run test:native && bun run test:package",
3110
- "test:package": "bun run build && bun test scripts/__tests__ ./.storybook/__tests__/createStorybookViteConfig.test.ts",
3111
- "test:preview": "bun test scripts/storybookPreview.test.ts",
3112
- "test:prototype": "bun test --config=./cli/bunfig.toml --coverage cli && vitest run --config .storybook/vitest.prototype.config.ts --coverage",
3110
+ "test:package": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts package",
3111
+ "test:preview": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts preview",
3112
+ "test:prototype": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts prototype",
3113
+ "test:cli": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts cli",
3113
3114
  "test:native": "vitest run --config .storybook/vitest.native.config.ts",
3114
3115
  "test:coverage": "vitest run --config .storybook/vitest.coverage.config.ts --coverage",
3115
3116
  "test:contrast": "vitest run --config .storybook/vitest.contrast.config.ts",
@@ -3118,7 +3119,7 @@ var package_default = {
3118
3119
  lint: "oxlint --deny-warnings src .storybook scripts cli templates/prototype/src templates/prototype/vite.config.ts && oxfmt --check . && bun run lint:unused",
3119
3120
  "lint:unused": "ts-unused check tsconfig.json",
3120
3121
  storybook: "bun scripts/buildLlmDocs.ts && storybook dev --host 127.0.0.1 -p 6006 --no-open",
3121
- "build-storybook": "bun scripts/buildLlmDocs.ts && storybook build",
3122
+ "build-storybook": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts storybook",
3122
3123
  prepack: "bun run build",
3123
3124
  "test:reduced-motion": "vitest run --config .storybook/vitest.reduced-motion.config.ts",
3124
3125
  "test:visual": "vitest run --config .storybook/vitest.visual.config.ts Button.stories.tsx Badge.stories.tsx Card.stories.tsx Input.stories.tsx ScrollArea.stories.tsx",
@@ -3187,6 +3188,7 @@ var package_default = {
3187
3188
  "embla-carousel-autoplay": "8.6.0",
3188
3189
  "embla-carousel-react": "^8.6.0",
3189
3190
  "es-toolkit": "1.52.0",
3191
+ execa: "10.2.1",
3190
3192
  "heat-graph": "0.0.25",
3191
3193
  "input-otp": "1.5.0",
3192
3194
  leaflet: "^1.9.4",
@@ -3577,28 +3579,55 @@ async function runWorkspace(directory, action, port) {
3577
3579
 
3578
3580
  // cli/createProgram.ts
3579
3581
  function createProgram(options) {
3582
+ const width = Number.isFinite(options.width) && options.width >= 1 ? Math.floor(options.width) : 100;
3580
3583
  const program = new Command("shadcn-prototype").description("Create and preview editable React mockups.").version(package_default.version).exitOverride().showHelpAfterError();
3581
3584
  program.configureOutput({ writeOut: options.writeOut, writeErr: options.writeErr });
3582
3585
  program.configureHelp({
3586
+ helpWidth: width,
3587
+ minWidthToWrap: 1,
3588
+ displayWidth: Bun.stringWidth,
3583
3589
  formatHelp(command, helper) {
3584
- const lines = [`Usage: ${helper.commandUsage(command)}`, "", command.description(), "", "Options:"];
3585
- for (const option of helper.visibleOptions(command))
3586
- lines.push(` ${option.flags} ${option.description}`);
3590
+ const wrap = (text) => options.isAgent ? text : helper.boxWrap(text, width);
3591
+ const formatItem = (term, description, prefix = " ", continuation = " ") => {
3592
+ const prefixWidth = helper.displayWidth(prefix);
3593
+ const descriptionColumn = Math.max(prefixWidth + 2, Math.min(45, Math.floor(width / 2)));
3594
+ const termWidth = descriptionColumn - 4;
3595
+ const connect = (line) => continuation + line.slice(continuation.length);
3596
+ if (prefixWidth + helper.displayWidth(term) + 2 > descriptionColumn) {
3597
+ const wrappedTerm = helper.boxWrap(term, Math.max(1, width - prefixWidth)).split(`
3598
+ `).map((line, index) => `${index === 0 ? prefix : continuation}${line}`).join(`
3599
+ `);
3600
+ if (!description)
3601
+ return wrappedTerm;
3602
+ const wrappedDescription = helper.formatItem("", termWidth, description, helper).split(`
3603
+ `).map(connect);
3604
+ return [wrappedTerm, ...wrappedDescription].join(`
3605
+ `);
3606
+ }
3607
+ return helper.formatItem(`${prefix.slice(2)}${term}`, termWidth, description, helper).split(`
3608
+ `).map((line, index) => index === 0 ? line : connect(line)).join(`
3609
+ `);
3610
+ };
3611
+ const lines = [wrap(`Usage: ${helper.commandUsage(command)}`), "", wrap(command.description()), "", "Options:"];
3612
+ for (const option of helper.visibleOptions(command)) {
3613
+ lines.push(options.isAgent ? ` ${option.flags} ${option.description}` : formatItem(option.flags, option.description));
3614
+ }
3587
3615
  const visit = (parent, prefix) => {
3588
3616
  const commands = helper.visibleCommands(parent);
3589
3617
  for (const [index, child] of commands.entries()) {
3590
3618
  const isLast = index === commands.length - 1;
3591
3619
  const marker = options.isAgent ? "- " : isLast ? "\u2570\u2500 " : "\u251C\u2500 ";
3592
- const name = `${prefix}${marker}${helper.subcommandTerm(child)}`;
3593
- lines.push(options.isAgent ? `${name}: ${child.description()}` : `${name.padEnd(44)} ${child.description()}`);
3594
- visit(child, `${prefix}${options.isAgent ? " " : isLast ? " " : "\u2502 "}`);
3620
+ const term = helper.subcommandTerm(child);
3621
+ const continuation = `${prefix}${options.isAgent ? " " : isLast ? " " : "\u2502 "}`;
3622
+ lines.push(options.isAgent ? `${prefix}${marker}${term}: ${child.description()}` : formatItem(term, child.description(), `${prefix}${marker}`, continuation));
3623
+ visit(child, continuation);
3595
3624
  }
3596
3625
  };
3597
3626
  if (command.commands.length) {
3598
3627
  lines.push("", "Commands:");
3599
3628
  visit(command, " ");
3600
3629
  }
3601
- const body = lines.map((line) => !options.isAgent && line.length > options.width ? `${line.slice(0, Math.max(0, options.width - 3))}...` : line).join(`
3630
+ const body = lines.join(`
3602
3631
  `) + `
3603
3632
  `;
3604
3633
  return options.isAgent ? "ALERT: Agents must read `AGENT=1 shadcn-prototype skill` before using this tool.\n" + body : body;
@@ -84,6 +84,14 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
84
84
  }
85
85
  ```
86
86
 
87
+ ### PreferredFillWidth
88
+
89
+ ```tsx
90
+ {
91
+ render: () => <VirtualDataGridExample files={fixture_gridFiles} width={420} fitColumns preferredFillSize={240}/>
92
+ }
93
+ ```
94
+
87
95
  ### FittedColumnGroups
88
96
 
89
97
  ```tsx
package/llms/setup.md CHANGED
@@ -439,7 +439,7 @@ Column `meta.filter` offers a column in `DataGridFilters`, hidden columns includ
439
439
 
440
440
  Import `DataGridSelectHeader` and `DataGridSelectCell` from `@alexgorbatchev/shadcn/data-grid`. Pass the current `useTable` result as `table` to both controls, and pass `row` and an accessible `label` to each cell. The header selects selectable filtered rows across all pages and preserves selections hidden by filters. It shows a mixed state when some of those rows are selected and disables itself when none are selectable. Its default label is "Select all filtered rows"; provide `label` to name the scope in your application. Cells follow native row selection rules, including disabled rows and partially selected parents. The controls observe selection changes without requiring the parent table selector to include selection state.
441
441
 
442
- For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's preferred size, bounded by its native sizing limits, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
442
+ For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's native current size, including controlled sizing state and its min/max bounds, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
443
443
 
444
444
  Keep preferred widths separate from the table's rendered sizing atom. In `onFitWidthChange`, store the reported width in a ref and write `fitDataGridColumnSizing(table, preferredWidths, width)` into the sizing atom. The helper temporarily shrinks required resizable columns toward their minima when needed and restores their preferred widths when space returns. In `onColumnSizingChange`, obtain new preferences with `constrainDataGridColumnSizing(table, updater, widthRef.current, preferredWidths)`, then derive the sizing atom with `fitDataGridColumnSizing`. Persist only the preferred widths, after the resize settles. Native pointer and keyboard resizing starts at the displayed width, stays within the available space, and leaves other columns' preferences unchanged. Widening a required column can hide optional columns again; widening an optional column preserves its fitted neighbours and the fill column's preferred space. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
445
445
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1056,9 +1056,10 @@
1056
1056
  },
1057
1057
  "scripts": {
1058
1058
  "test": "vitest run --config .storybook/vitest.config.ts && bun run test:native && bun run test:package",
1059
- "test:package": "bun run build && bun test scripts/__tests__ ./.storybook/__tests__/createStorybookViteConfig.test.ts",
1060
- "test:preview": "bun test scripts/storybookPreview.test.ts",
1061
- "test:prototype": "bun test --config=./cli/bunfig.toml --coverage cli && vitest run --config .storybook/vitest.prototype.config.ts --coverage",
1059
+ "test:package": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts package",
1060
+ "test:preview": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts preview",
1061
+ "test:prototype": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts prototype",
1062
+ "test:cli": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts cli",
1062
1063
  "test:native": "vitest run --config .storybook/vitest.native.config.ts",
1063
1064
  "test:coverage": "vitest run --config .storybook/vitest.coverage.config.ts --coverage",
1064
1065
  "test:contrast": "vitest run --config .storybook/vitest.contrast.config.ts",
@@ -1067,7 +1068,7 @@
1067
1068
  "lint": "oxlint --deny-warnings src .storybook scripts cli templates/prototype/src templates/prototype/vite.config.ts && oxfmt --check . && bun run lint:unused",
1068
1069
  "lint:unused": "ts-unused check tsconfig.json",
1069
1070
  "storybook": "bun scripts/buildLlmDocs.ts && storybook dev --host 127.0.0.1 -p 6006 --no-open",
1070
- "build-storybook": "bun scripts/buildLlmDocs.ts && storybook build",
1071
+ "build-storybook": "NODE_DISABLE_COMPILE_CACHE=1 bun scripts/runTestSuite.ts storybook",
1071
1072
  "prepack": "bun run build",
1072
1073
  "test:reduced-motion": "vitest run --config .storybook/vitest.reduced-motion.config.ts",
1073
1074
  "test:visual": "vitest run --config .storybook/vitest.visual.config.ts Button.stories.tsx Badge.stories.tsx Card.stories.tsx Input.stories.tsx ScrollArea.stories.tsx",
@@ -1136,6 +1137,7 @@
1136
1137
  "embla-carousel-autoplay": "8.6.0",
1137
1138
  "embla-carousel-react": "^8.6.0",
1138
1139
  "es-toolkit": "1.52.0",
1140
+ "execa": "10.2.1",
1139
1141
  "heat-graph": "0.0.25",
1140
1142
  "input-otp": "1.5.0",
1141
1143
  "leaflet": "^1.9.4",
@@ -1,3 +0,0 @@
1
- import type { ColumnDef_ColumnSizing } from "@tanstack/react-table";
2
- /** The fill reservation before optional columns are admitted, bounded by the column's native sizing limits. */
3
- export declare function getDataGridFillPreferredSize(column: ColumnDef_ColumnSizing): number;