@momoi-labs/kiso-react 0.20.0 → 0.21.0

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.
@@ -15,8 +15,9 @@ export type PaneGridProps = Omit<React.ComponentProps<"section">, "title"> & {
15
15
  pack?: boolean;
16
16
  scrollPages?: number;
17
17
  debug?: boolean;
18
+ static?: boolean;
18
19
  };
19
- export declare function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutChange, overflow, flow, fill, pack, scrollPages, debug, className, children, ...props }: PaneGridProps): React.JSX.Element;
20
+ export declare function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutChange, overflow, flow, fill, pack, scrollPages, debug, static: isStatic, className, children, ...props }: PaneGridProps): React.JSX.Element;
20
21
  export type GridPaneProps = Omit<React.ComponentProps<"article">, "title" | "id"> & {
21
22
  id: string;
22
23
  title: string;
package/dist/pane-grid.js CHANGED
@@ -76,7 +76,7 @@ function layRow(ids, specs, sizes, columns, options) {
76
76
  }
77
77
  return lines;
78
78
  }
79
- export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutChange, overflow = "wrap", flow = "rows", fill = false, pack = false, scrollPages = 2, debug = false, className, children, ...props }) {
79
+ export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutChange, overflow = "wrap", flow = "rows", fill = false, pack = false, scrollPages = 2, debug = false, static: isStatic = false, className, children, ...props }) {
80
80
  const elements = new Map();
81
81
  const specs = [];
82
82
  for (const child of React.Children.toArray(children)) {
@@ -108,11 +108,11 @@ export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutCha
108
108
  observer.observe(body);
109
109
  return () => observer.disconnect();
110
110
  }, []);
111
- const columns = pickColumns(width);
111
+ const columns = isStatic ? 1 : pickColumns(width);
112
112
  const compact = columns !== COLUMNS;
113
113
  const stacked = columns === 1;
114
114
  const scrolling = overflow === "scroll" && !stacked;
115
- const masonry = flow === "masonry" && overflow === "wrap";
115
+ const masonry = flow === "masonry" && overflow === "wrap" && !isStatic;
116
116
  const scrollMax = columns * Math.max(1, scrollPages);
117
117
  let gridRow = 0;
118
118
  const rows = layout.rows.map((ids) => {
@@ -438,7 +438,7 @@ export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutCha
438
438
  for (const line of row.lines) {
439
439
  for (const item of line.items) {
440
440
  const max = masonry ? columns : scrolling ? Math.min(columns, item.size + scrollMax - line.used) : item.size + line.free;
441
- placements.set(item.id, { id: item.id, row: line.scroll ? 1 : line.row, col: item.col, span: item.span, size: item.size, min: item.min, max, compact, stacked, debug });
441
+ placements.set(item.id, { id: item.id, row: line.scroll ? 1 : line.row, col: item.col, span: item.span, size: item.size, min: item.min, max, compact, stacked, static: isStatic, debug });
442
442
  }
443
443
  }
444
444
  }
@@ -449,8 +449,8 @@ export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutCha
449
449
  return null;
450
450
  return (_jsx(PaneContext.Provider, { value: { placement, api }, children: element }, id));
451
451
  };
452
- return (_jsxs("section", { "data-slot": "pane-grid", className: cn("pane-grid", className), ...props, children: [title != null && _jsx("h2", { "data-slot": "pane-grid-title", className: "pane-grid-title t-h2", children: title }), _jsxs("div", { ref: bodyRef, "data-slot": "pane-grid-body", className: "pane-grid-body", "data-columns": columns, "data-compact": compact ? "true" : undefined, "data-overflow": overflow, "data-flow": masonry ? "masonry" : "rows", "data-debug": debug ? "true" : undefined, style: { "--pane-cols": columns, "--pane-grid-width": `${width}px` }, children: [rows.flatMap((row, index) => [
453
- (index > 0 || debug) && (_jsx("div", { className: "pane-grid-rule", "data-pane-row": index, "aria-hidden": "true", style: { "--r": row.lines[0].row }, children: debug && `row ${index + 1} · ${row.lines.map((line) => `${line.used}/${columns}${line.scroll ? " ⇆ scroll" : ""}`).join(" + ")}` }, `rule-${index}`)),
452
+ return (_jsxs("section", { "data-slot": "pane-grid", className: cn("pane-grid", className), ...props, children: [title != null && _jsx("h2", { "data-slot": "pane-grid-title", className: "pane-grid-title t-h2", children: title }), _jsxs("div", { ref: bodyRef, "data-slot": "pane-grid-body", className: "pane-grid-body", "data-columns": columns, "data-compact": compact ? "true" : undefined, "data-overflow": overflow, "data-flow": masonry ? "masonry" : "rows", "data-debug": debug ? "true" : undefined, "data-static": isStatic ? "true" : undefined, style: { "--pane-cols": columns, "--pane-grid-width": `${width}px` }, children: [rows.flatMap((row, index) => [
453
+ (index > 0 || debug) && !isStatic && (_jsx("div", { className: "pane-grid-rule", "data-pane-row": index, "aria-hidden": "true", style: { "--r": row.lines[0].row }, children: debug && `row ${index + 1} · ${row.lines.map((line) => `${line.used}/${columns}${line.scroll ? " ⇆ scroll" : ""}`).join(" + ")}` }, `rule-${index}`)),
454
454
  ...(masonry ? row.ids.map(renderPane) : row.lines.flatMap((line) => line.scroll
455
455
  ? [
456
456
  _jsx("div", { className: "pane-grid-scroll", style: { "--r": line.row, "--n": line.used }, children: line.items.map((item) => renderPane(item.id)) }, `scroll-${line.items[0].id}`),
@@ -466,19 +466,25 @@ export function GridPane({ id, title, min: _min, size: _size, newRow: _newRow, a
466
466
  if (!context)
467
467
  throw new Error("GridPane must be a child of PaneGrid.");
468
468
  const { placement, api } = context;
469
- return (_jsxs("article", { "data-slot": "grid-pane", "data-pane-id": id, className: cn("grid-pane card", className), style: { "--r": placement.row, "--c": placement.col, "--s": placement.span, ...style }, ...props, children: [_jsxs("div", { "data-slot": "grid-pane-head", className: "grid-pane-head", role: "button", tabIndex: 0, "aria-label": `Move ${title}`, onPointerDown: (event) => api.startMove(id, event), onKeyDown: (event) => {
470
- if (event.target !== event.currentTarget)
471
- return;
472
- if (event.key === "ArrowLeft" || (placement.stacked && event.key === "ArrowUp"))
473
- api.moveBy(id, -1);
474
- else if (event.key === "ArrowRight" || (placement.stacked && event.key === "ArrowDown"))
475
- api.moveBy(id, 1);
476
- else if (event.key === "Enter" || event.key === " ")
477
- api.toggleRow(id);
478
- else
479
- return;
480
- event.preventDefault();
481
- }, children: [_jsx(GripVertical, { className: "icon grid-pane-grip", "aria-hidden": "true" }), _jsx("h3", { "data-slot": "grid-pane-title", className: "grid-pane-title t-h3", children: title }), placement.debug && _jsxs("span", { className: "grid-pane-meta", children: ["size=", placement.size, " \u00B7 min=", placement.min, " \u00B7 max=", placement.max] }), actions != null && _jsx("div", { "data-slot": "grid-pane-actions", className: "grid-pane-actions", children: actions })] }), _jsx("div", { "data-slot": "grid-pane-body", className: "grid-pane-body", children: children }), !placement.compact && (_jsx("div", { "data-slot": "grid-pane-resizer", className: "grid-pane-resizer", role: "separator", tabIndex: 0, "aria-orientation": "vertical", "aria-label": `Resize ${title}`, "aria-valuenow": placement.size, "aria-valuemin": placement.min, "aria-valuemax": placement.max, "aria-disabled": placement.min === placement.max || undefined, onPointerDown: (event) => api.startResize(id, event), onKeyDown: (event) => {
469
+ return (_jsxs("article", { "data-slot": "grid-pane", "data-pane-id": id, className: cn("grid-pane card", className), style: { "--r": placement.row, "--c": placement.col, "--s": placement.span, ...style }, ...props, children: [_jsxs("div", { "data-slot": "grid-pane-head", className: "grid-pane-head", ...(!placement.static && {
470
+ role: "button",
471
+ tabIndex: 0,
472
+ "aria-label": `Move ${title}`,
473
+ onPointerDown: (event) => api.startMove(id, event),
474
+ onKeyDown: (event) => {
475
+ if (event.target !== event.currentTarget)
476
+ return;
477
+ if (event.key === "ArrowLeft" || (placement.stacked && event.key === "ArrowUp"))
478
+ api.moveBy(id, -1);
479
+ else if (event.key === "ArrowRight" || (placement.stacked && event.key === "ArrowDown"))
480
+ api.moveBy(id, 1);
481
+ else if (event.key === "Enter" || event.key === " ")
482
+ api.toggleRow(id);
483
+ else
484
+ return;
485
+ event.preventDefault();
486
+ },
487
+ }), children: [!placement.static && _jsx(GripVertical, { className: "icon grid-pane-grip", "aria-hidden": "true" }), _jsx("h3", { "data-slot": "grid-pane-title", className: "grid-pane-title t-h3", children: title }), placement.debug && _jsxs("span", { className: "grid-pane-meta", children: ["size=", placement.size, " \u00B7 min=", placement.min, " \u00B7 max=", placement.max] }), actions != null && _jsx("div", { "data-slot": "grid-pane-actions", className: "grid-pane-actions", children: actions })] }), _jsx("div", { "data-slot": "grid-pane-body", className: "grid-pane-body", children: children }), !placement.compact && (_jsx("div", { "data-slot": "grid-pane-resizer", className: "grid-pane-resizer", role: "separator", tabIndex: 0, "aria-orientation": "vertical", "aria-label": `Resize ${title}`, "aria-valuenow": placement.size, "aria-valuemin": placement.min, "aria-valuemax": placement.max, "aria-disabled": placement.min === placement.max || undefined, onPointerDown: (event) => api.startResize(id, event), onKeyDown: (event) => {
482
488
  if (event.key === "ArrowRight")
483
489
  api.resize(id, placement.size + 1);
484
490
  else if (event.key === "ArrowLeft")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Kiso React components built with shadcn/ui and Radix",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "prepack": "npm run build"
33
33
  },
34
34
  "dependencies": {
35
- "@momoi-labs/kiso": "^0.25.0",
35
+ "@momoi-labs/kiso": "^0.26.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7",