@wallarm-org/design-system 2.4.0 → 2.5.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.
@@ -2,10 +2,12 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { createPortal } from "react-dom";
5
+ import { trackDismissableElement } from "@zag-js/dismissable";
6
+ import { trapFocus } from "@zag-js/focus-trap";
5
7
  import { cn } from "../../../utils/cn.js";
6
8
  import { useTestId } from "../../../utils/testId.js";
7
- const FULLSCREEN_CLASSES = "fixed inset-16 z-50 m-0 w-auto h-auto min-w-0 min-h-0 max-w-[none] max-h-[none]";
8
- const BACKDROP_CLASSES = "fixed inset-0 z-40 backdrop-blur-xs bg-component-dialog-overlay";
9
+ const FULLSCREEN_CLASSES = cn("fixed inset-16 m-0 w-auto h-auto min-w-0 min-h-0 max-w-[none] max-h-[none]", "z-[calc(var(--drawer-positioner-z-index)+(var(--layer-index,0)*var(--drawer-level-ratio)))]");
10
+ const BACKDROP_CLASSES = cn("fixed inset-0 backdrop-blur-xs bg-component-dialog-overlay", "z-[calc(var(--drawer-overlay-z-index)+(var(--layer-index,0)*var(--drawer-level-ratio)))]");
9
11
  const HOST_CLASSES = "contents";
10
12
  const noop = ()=>{};
11
13
  const subscribeNoop = ()=>noop;
@@ -18,7 +20,7 @@ const createHost = ()=>{
18
20
  return host;
19
21
  };
20
22
  const CodeSnippetFrame = (t0)=>{
21
- const $ = c(40);
23
+ const $ = c(45);
22
24
  let children;
23
25
  let className;
24
26
  let isFullscreen;
@@ -96,96 +98,129 @@ const CodeSnippetFrame = (t0)=>{
96
98
  useLayoutEffect(t3, t4);
97
99
  let t5;
98
100
  let t6;
99
- if ($[15] !== isFullscreen || $[16] !== setIsFullscreen) {
101
+ if ($[15] !== host || $[16] !== isFullscreen || $[17] !== setIsFullscreen) {
100
102
  t5 = ()=>{
101
- if (!isFullscreen) return;
102
- const handleKeyDown = (event)=>{
103
- if ("Escape" === event.key && !event.defaultPrevented) setIsFullscreen(false);
103
+ if (!isFullscreen || !host) return;
104
+ const options = {
105
+ onRequestDismiss: (event)=>{
106
+ event.preventDefault();
107
+ setIsFullscreen(false);
108
+ }
109
+ };
110
+ const untrack = trackDismissableElement(host, options);
111
+ const untrap = trapFocus(host);
112
+ return ()=>{
113
+ untrap();
114
+ untrack();
104
115
  };
105
- document.addEventListener("keydown", handleKeyDown);
106
- return ()=>document.removeEventListener("keydown", handleKeyDown);
107
116
  };
108
117
  t6 = [
109
118
  isFullscreen,
119
+ host,
110
120
  setIsFullscreen
111
121
  ];
112
- $[15] = isFullscreen;
113
- $[16] = setIsFullscreen;
114
- $[17] = t5;
115
- $[18] = t6;
122
+ $[15] = host;
123
+ $[16] = isFullscreen;
124
+ $[17] = setIsFullscreen;
125
+ $[18] = t5;
126
+ $[19] = t6;
116
127
  } else {
117
- t5 = $[17];
118
- t6 = $[18];
128
+ t5 = $[18];
129
+ t6 = $[19];
119
130
  }
120
131
  useEffect(t5, t6);
121
132
  let t7;
122
- if ($[19] !== backdropTestId || $[20] !== isFullscreen || $[21] !== setIsFullscreen) {
123
- t7 = isFullscreen ? /*#__PURE__*/ jsx("div", {
133
+ let t8;
134
+ if ($[20] !== isFullscreen || $[21] !== setIsFullscreen) {
135
+ t7 = ()=>{
136
+ if (!isFullscreen) return;
137
+ const handleKeyDown = (event_0)=>{
138
+ if ("Escape" === event_0.key && !event_0.defaultPrevented) setIsFullscreen(false);
139
+ };
140
+ document.addEventListener("keydown", handleKeyDown);
141
+ return ()=>document.removeEventListener("keydown", handleKeyDown);
142
+ };
143
+ t8 = [
144
+ isFullscreen,
145
+ setIsFullscreen
146
+ ];
147
+ $[20] = isFullscreen;
148
+ $[21] = setIsFullscreen;
149
+ $[22] = t7;
150
+ $[23] = t8;
151
+ } else {
152
+ t7 = $[22];
153
+ t8 = $[23];
154
+ }
155
+ useEffect(t7, t8);
156
+ let t9;
157
+ if ($[24] !== backdropTestId || $[25] !== isFullscreen || $[26] !== setIsFullscreen) {
158
+ t9 = isFullscreen ? /*#__PURE__*/ jsx("div", {
124
159
  "aria-hidden": "true",
125
160
  "data-testid": backdropTestId,
126
161
  className: BACKDROP_CLASSES,
127
162
  onClick: ()=>setIsFullscreen(false)
128
163
  }) : null;
129
- $[19] = backdropTestId;
130
- $[20] = isFullscreen;
131
- $[21] = setIsFullscreen;
132
- $[22] = t7;
133
- } else t7 = $[22];
134
- const t8 = isFullscreen && FULLSCREEN_CLASSES;
135
- let t9;
136
- if ($[23] !== className || $[24] !== t8) {
137
- t9 = cn(className, t8);
138
- $[23] = className;
139
- $[24] = t8;
140
- $[25] = t9;
141
- } else t9 = $[25];
142
- let t10;
143
- if ($[26] !== children || $[27] !== props || $[28] !== ref || $[29] !== t9) {
144
- t10 = /*#__PURE__*/ jsx("div", {
164
+ $[24] = backdropTestId;
165
+ $[25] = isFullscreen;
166
+ $[26] = setIsFullscreen;
167
+ $[27] = t9;
168
+ } else t9 = $[27];
169
+ const t10 = isFullscreen && FULLSCREEN_CLASSES;
170
+ let t11;
171
+ if ($[28] !== className || $[29] !== t10) {
172
+ t11 = cn(className, t10);
173
+ $[28] = className;
174
+ $[29] = t10;
175
+ $[30] = t11;
176
+ } else t11 = $[30];
177
+ let t12;
178
+ if ($[31] !== children || $[32] !== props || $[33] !== ref || $[34] !== t11) {
179
+ t12 = /*#__PURE__*/ jsx("div", {
145
180
  ...props,
146
181
  ref: ref,
147
- className: t9,
182
+ className: t11,
148
183
  children: children
149
184
  });
150
- $[26] = children;
151
- $[27] = props;
152
- $[28] = ref;
153
- $[29] = t9;
154
- $[30] = t10;
155
- } else t10 = $[30];
156
- let t11;
157
- if ($[31] !== t10 || $[32] !== t7) {
158
- t11 = /*#__PURE__*/ jsxs(Fragment, {
185
+ $[31] = children;
186
+ $[32] = props;
187
+ $[33] = ref;
188
+ $[34] = t11;
189
+ $[35] = t12;
190
+ } else t12 = $[35];
191
+ let t13;
192
+ if ($[36] !== t12 || $[37] !== t9) {
193
+ t13 = /*#__PURE__*/ jsxs(Fragment, {
159
194
  children: [
160
- t7,
161
- t10
195
+ t9,
196
+ t12
162
197
  ]
163
198
  });
164
- $[31] = t10;
165
- $[32] = t7;
166
- $[33] = t11;
167
- } else t11 = $[33];
168
- const frame = t11;
169
- let t12;
170
- if ($[34] !== frame || $[35] !== host || $[36] !== portalReady) {
171
- t12 = portalReady && host ? /*#__PURE__*/ createPortal(frame, host) : frame;
172
- $[34] = frame;
173
- $[35] = host;
174
- $[36] = portalReady;
175
- $[37] = t12;
176
- } else t12 = $[37];
177
- let t13;
178
- if ($[38] !== t12) {
179
- t13 = /*#__PURE__*/ jsx("div", {
199
+ $[36] = t12;
200
+ $[37] = t9;
201
+ $[38] = t13;
202
+ } else t13 = $[38];
203
+ const frame = t13;
204
+ let t14;
205
+ if ($[39] !== frame || $[40] !== host || $[41] !== portalReady) {
206
+ t14 = portalReady && host ? /*#__PURE__*/ createPortal(frame, host) : frame;
207
+ $[39] = frame;
208
+ $[40] = host;
209
+ $[41] = portalReady;
210
+ $[42] = t14;
211
+ } else t14 = $[42];
212
+ let t15;
213
+ if ($[43] !== t14) {
214
+ t15 = /*#__PURE__*/ jsx("div", {
180
215
  ref: placeholderRef,
181
216
  "data-slot": "code-snippet-frame",
182
217
  className: HOST_CLASSES,
183
- children: t12
218
+ children: t14
184
219
  });
185
- $[38] = t12;
186
- $[39] = t13;
187
- } else t13 = $[39];
188
- return t13;
220
+ $[43] = t14;
221
+ $[44] = t15;
222
+ } else t15 = $[44];
223
+ return t15;
189
224
  };
190
225
  CodeSnippetFrame.displayName = "CodeSnippetFrame";
191
226
  export { CodeSnippetFrame };
@@ -2,18 +2,19 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from "react";
3
3
  import { cn } from "../../utils/cn.js";
4
4
  import { useStickyGroupParent } from "./hooks/index.js";
5
- import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID, useTableValue, withTableState } from "./lib/index.js";
5
+ import { TABLE_DRAG_HANDLE_COLUMN_ID, TABLE_EXPAND_COLUMN_ID, TABLE_SELECT_COLUMN_ID, useRenderEveryTime, useTableValue, withTableState } from "./lib/index.js";
6
6
  import { Td, Tr } from "./primitives/index.js";
7
7
  import { TableBodyCell } from "./TableBody/TableBodyCell.js";
8
8
  import { TableColGroup } from "./TableColGroup.js";
9
9
  import { useTableContext } from "./TableContext/index.js";
10
+ import { TableFullWidthCell } from "./TableRow.js";
10
11
  const SYSTEM_COLUMN_IDS = new Set([
11
12
  TABLE_EXPAND_COLUMN_ID,
12
13
  TABLE_SELECT_COLUMN_ID,
13
14
  TABLE_DRAG_HANDLE_COLUMN_ID
14
15
  ]);
15
16
  const StickyGroupParent = ({ tableWidth, headerHeight })=>{
16
- const { table, containerRef, tbodyRef, virtualizerRef, virtualized } = useTableContext();
17
+ const { table, containerRef, tbodyRef, virtualizerRef, virtualized, renderFullWidthGroupRow } = useTableContext();
17
18
  const useWindowScroll = 'window' === virtualized;
18
19
  const { stickyRow, pushUpOffset } = useStickyGroupParent({
19
20
  table,
@@ -64,6 +65,8 @@ const StickyGroupParent = ({ tableWidth, headerHeight })=>{
64
65
  const dataCells = cells?.filter((c)=>!SYSTEM_COLUMN_IDS.has(c.column.id));
65
66
  const firstDataCell = dataCells?.[0];
66
67
  const isSelected = useTableValue(()=>stickyRow?.getIsAllSubRowsSelected());
68
+ const fullWidthContent = useRenderEveryTime(()=>stickyRow ? renderFullWidthGroupRow?.(stickyRow) : void 0);
69
+ const isFullWidth = void 0 !== fullWidthContent;
67
70
  return /*#__PURE__*/ jsx("div", {
68
71
  className: "sticky z-[21] h-0 overflow-visible pointer-events-none",
69
72
  style: {
@@ -98,12 +101,16 @@ const StickyGroupParent = ({ tableWidth, headerHeight })=>{
98
101
  cell: cell,
99
102
  disablePinnedShadow: true
100
103
  }, cell.id)),
101
- firstDataCell && /*#__PURE__*/ jsx(TableBodyCell, {
104
+ isFullWidth && /*#__PURE__*/ jsx(TableFullWidthCell, {
105
+ colSpan: dataCells.length,
106
+ children: fullWidthContent
107
+ }),
108
+ !isFullWidth && firstDataCell && /*#__PURE__*/ jsx(TableBodyCell, {
102
109
  cell: firstDataCell,
103
110
  className: "border-r-0",
104
111
  disablePinnedShadow: true
105
112
  }),
106
- withTableState(table.state, ()=>dataCells.slice(1).map((cell)=>/*#__PURE__*/ jsx(Td, {
113
+ withTableState(table.state, ()=>(isFullWidth ? [] : dataCells).slice(1).map((cell)=>/*#__PURE__*/ jsx(Td, {
107
114
  className: cn('border-b border-border-primary-light bg-bg-surface-2 overlay', 'group-hover/row:overlay-states-primary-hover group-data-[selected]/row:overlay-states-primary-active', 'group-data-[preview-active]/row:overlay-states-primary-hover group-has-[[data-state=open]]/row:overlay-states-primary-hover'),
108
115
  style: {
109
116
  width: cell.column.getSize()
@@ -1,17 +1,25 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c as compiler_runtime_c } from "react/compiler-runtime";
3
3
  import { flexRender } from "@tanstack/react-table";
4
4
  import { cn } from "../../../utils/cn.js";
5
- import { getAlignClass, withTableState } from "../lib/index.js";
5
+ import { getAlignClass, useRenderEveryTime, withTableState } from "../lib/index.js";
6
6
  import { Td, Tr } from "../primitives/index.js";
7
7
  import { useTableContext } from "../TableContext/index.js";
8
8
  const TableRowOverlayInner = (t0)=>{
9
- const $ = compiler_runtime_c(6);
9
+ const $ = compiler_runtime_c(10);
10
10
  const { row } = t0;
11
- const { table } = useTableContext();
11
+ const { table, renderFullWidthRow } = useTableContext();
12
12
  let t1;
13
- if ($[0] !== row || $[1] !== table) {
14
- t1 = ()=>{
13
+ if ($[0] !== renderFullWidthRow || $[1] !== row) {
14
+ t1 = ()=>renderFullWidthRow?.(row);
15
+ $[0] = renderFullWidthRow;
16
+ $[1] = row;
17
+ $[2] = t1;
18
+ } else t1 = $[2];
19
+ const fullWidthContent = useRenderEveryTime(t1);
20
+ let t2;
21
+ if ($[3] !== fullWidthContent || $[4] !== row || $[5] !== table) {
22
+ t2 = ()=>{
15
23
  const visibleColumns = table.getVisibleLeafColumns();
16
24
  return /*#__PURE__*/ jsx("table", {
17
25
  className: "w-full table-fixed border-collapse",
@@ -20,36 +28,44 @@ const TableRowOverlayInner = (t0)=>{
20
28
  cursor: "grabbing"
21
29
  },
22
30
  children: /*#__PURE__*/ jsx("tbody", {
23
- children: /*#__PURE__*/ jsx(Tr, {
31
+ children: /*#__PURE__*/ jsxs(Tr, {
24
32
  className: "pointer-events-none shadow-lg opacity-90 bg-bg-primary",
25
- children: row.getVisibleCells().map((cell)=>{
26
- const column = visibleColumns.find((c)=>c.id === cell.column.id);
27
- const meta = cell.column.columnDef.meta;
28
- return /*#__PURE__*/ jsx(Td, {
33
+ children: [
34
+ void 0 !== fullWidthContent && /*#__PURE__*/ jsx(Td, {
29
35
  pinned: false,
30
- className: cn(getAlignClass(meta), meta?.cellClassName),
31
- style: {
32
- width: column?.getSize()
33
- },
34
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
35
- }, cell.id);
36
- })
36
+ colSpan: row.getVisibleCells().length,
37
+ children: fullWidthContent
38
+ }),
39
+ (void 0 === fullWidthContent ? row.getVisibleCells() : []).map((cell)=>{
40
+ const column = visibleColumns.find((c)=>c.id === cell.column.id);
41
+ const meta = cell.column.columnDef.meta;
42
+ return /*#__PURE__*/ jsx(Td, {
43
+ pinned: false,
44
+ className: cn(getAlignClass(meta), meta?.cellClassName),
45
+ style: {
46
+ width: column?.getSize()
47
+ },
48
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
49
+ }, cell.id);
50
+ })
51
+ ]
37
52
  })
38
53
  })
39
54
  });
40
55
  };
41
- $[0] = row;
42
- $[1] = table;
43
- $[2] = t1;
44
- } else t1 = $[2];
45
- let t2;
46
- if ($[3] !== t1 || $[4] !== table.state) {
47
- t2 = withTableState(table.state, t1);
48
- $[3] = t1;
49
- $[4] = table.state;
50
- $[5] = t2;
51
- } else t2 = $[5];
52
- return t2;
56
+ $[3] = fullWidthContent;
57
+ $[4] = row;
58
+ $[5] = table;
59
+ $[6] = t2;
60
+ } else t2 = $[6];
61
+ let t3;
62
+ if ($[7] !== t2 || $[8] !== table.state) {
63
+ t3 = withTableState(table.state, t2);
64
+ $[7] = t2;
65
+ $[8] = table.state;
66
+ $[9] = t3;
67
+ } else t3 = $[9];
68
+ return t3;
53
69
  };
54
70
  const TableRowOverlay = TableRowOverlayInner;
55
71
  TableRowOverlay.displayName = "TableRowOverlay";