@perses-dev/components 0.56.0-beta.0 → 0.56.0-beta.1

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Imperative handle exposed by editor forms, allowing their parent to request closing them, e.g. when the user clicks
3
+ * outside of the Drawer containing the form. The form is responsible for closing itself, after asking for confirmation
4
+ * if there are unsaved changes.
5
+ */
6
+ export interface FormEditorHandle {
7
+ requestClose: () => void;
8
+ }
9
+ //# sourceMappingURL=form-editor-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-editor-handle.d.ts","sourceRoot":"","sources":["../../src/FormEditor/form-editor-handle.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B"}
@@ -0,0 +1,19 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Imperative handle exposed by editor forms, allowing their parent to request closing them, e.g. when the user clicks
15
+ * outside of the Drawer containing the form. The form is responsible for closing itself, after asking for confirmation
16
+ * if there are unsaved changes.
17
+ */ export { };
18
+
19
+ //# sourceMappingURL=form-editor-handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/FormEditor/form-editor-handle.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Imperative handle exposed by editor forms, allowing their parent to request closing them, e.g. when the user clicks\n * outside of the Drawer containing the form. The form is responsible for closing itself, after asking for confirmation\n * if there are unsaved changes.\n */\nexport interface FormEditorHandle {\n requestClose: () => void;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;;;CAIC,GACD,WAEC"}
@@ -1,2 +1,3 @@
1
1
  export * from './FormActions';
2
+ export * from './form-editor-handle';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -11,5 +11,6 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from "./FormActions.js";
14
+ export * from "./form-editor-handle.js";
14
15
 
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FormEditor/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './FormActions';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,mBAAgB"}
1
+ {"version":3,"sources":["../../src/FormEditor/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './FormActions';\nexport * from './form-editor-handle';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,mBAAgB;AAC9B,cAAc,0BAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableCell.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAoBtF,MAAM,WAAW,cAAe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M,qBAAqB,CAAC;AAoBtF,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC;IACnF,OAAO,EAAE,YAAY,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAGtC,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IAEvB,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,MAAM,CAAC;IACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;IACjH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,UAAmB,EACnB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,KAAK,EACL,KAAK,EACL,eAAe,EACf,QAAQ,EACR,sBAAsB,EACtB,GAAG,UAAU,EACd,EAAE,cAAc,GAAG,YAAY,CAmH/B"}
@@ -15,6 +15,7 @@ import { c as _c } from "react-compiler-runtime";
15
15
  import { Box, Link, TableCell as MuiTableCell, styled, useTheme } from "@mui/material";
16
16
  import { useEffect, useRef } from "react";
17
17
  import { hasDataFieldPatterns, replaceDataFields } from "../utils/data-field-interpolation.js";
18
+ import { sanitizeUrl } from "../utils/url.js";
18
19
  import { getTableCellLayout } from "./model/table-model.js";
19
20
  const StyledMuiTableCell = styled(MuiTableCell)(({ theme })=>({
20
21
  padding: 0,
@@ -32,7 +33,7 @@ const StyledMuiTableCell = styled(MuiTableCell)(({ theme })=>({
32
33
  }
33
34
  }));
34
35
  export function TableCell(t0) {
35
- const $ = _c(64);
36
+ const $ = _c(66);
36
37
  let adjacentCellsValuesMap;
37
38
  let align;
38
39
  let backgroundColor;
@@ -127,53 +128,65 @@ export function TableCell(t0) {
127
128
  t5 = undefined;
128
129
  break bb0;
129
130
  }
130
- if (adjacentCellsValuesMap && hasDataFieldPatterns(dataLink.url)) {
131
+ let url = dataLink.url;
132
+ if (adjacentCellsValuesMap && hasDataFieldPatterns(url)) {
131
133
  let t6;
132
- if ($[22] !== adjacentCellsValuesMap || $[23] !== dataLink.url) {
133
- t6 = replaceDataFields(dataLink.url, adjacentCellsValuesMap, {
134
+ if ($[22] !== adjacentCellsValuesMap || $[23] !== url) {
135
+ t6 = replaceDataFields(url, adjacentCellsValuesMap, {
134
136
  urlEncode: true
135
137
  });
136
138
  $[22] = adjacentCellsValuesMap;
137
- $[23] = dataLink.url;
139
+ $[23] = url;
138
140
  $[24] = t6;
139
141
  } else {
140
142
  t6 = $[24];
141
143
  }
142
- const { text } = t6;
143
- let t7;
144
- if ($[25] !== dataLink || $[26] !== text) {
145
- t7 = {
146
- ...dataLink,
147
- url: text
148
- };
149
- $[25] = dataLink;
150
- $[26] = text;
151
- $[27] = t7;
152
- } else {
153
- t7 = $[27];
154
- }
155
- t5 = t7;
144
+ url = t6.text;
145
+ }
146
+ let t6;
147
+ if ($[25] !== url) {
148
+ t6 = sanitizeUrl(url);
149
+ $[25] = url;
150
+ $[26] = t6;
151
+ } else {
152
+ t6 = $[26];
153
+ }
154
+ const safeUrl = t6;
155
+ if (safeUrl === undefined) {
156
+ t5 = undefined;
156
157
  break bb0;
157
158
  }
158
- t5 = dataLink;
159
+ let t7;
160
+ if ($[27] !== dataLink || $[28] !== safeUrl) {
161
+ t7 = {
162
+ ...dataLink,
163
+ url: safeUrl
164
+ };
165
+ $[27] = dataLink;
166
+ $[28] = safeUrl;
167
+ $[29] = t7;
168
+ } else {
169
+ t7 = $[29];
170
+ }
171
+ t5 = t7;
159
172
  }
160
173
  const modifiedDataLink = t5;
161
174
  const t6 = focusState !== "none" ? 0 : -1;
162
175
  let t7;
163
- if ($[28] !== width) {
176
+ if ($[30] !== width) {
164
177
  t7 = {
165
178
  width
166
179
  };
167
- $[28] = width;
168
- $[29] = t7;
180
+ $[30] = width;
181
+ $[31] = t7;
169
182
  } else {
170
- t7 = $[29];
183
+ t7 = $[31];
171
184
  }
172
185
  const t8 = isHeader ? `solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`;
173
186
  const t9 = `${backgroundColor ?? theme.palette.background.default} !important`;
174
187
  const t10 = `solid 1px ${theme.palette.info.main}`;
175
188
  let t11;
176
- if ($[30] !== t10 || $[31] !== t9) {
189
+ if ($[32] !== t10 || $[33] !== t9) {
177
190
  t11 = {
178
191
  position: "absolute",
179
192
  top: 0,
@@ -187,45 +200,45 @@ export function TableCell(t0) {
187
200
  outline: t10,
188
201
  outlineOffset: "-1px"
189
202
  };
190
- $[30] = t10;
191
- $[31] = t9;
192
- $[32] = t11;
203
+ $[32] = t10;
204
+ $[33] = t9;
205
+ $[34] = t11;
193
206
  } else {
194
- t11 = $[32];
207
+ t11 = $[34];
195
208
  }
196
209
  let t12;
197
- if ($[33] !== t11 || $[34] !== t8) {
210
+ if ($[35] !== t11 || $[36] !== t8) {
198
211
  t12 = {
199
212
  position: "relative",
200
213
  borderBottom: t8,
201
214
  "&:hover #original-cell": t11
202
215
  };
203
- $[33] = t11;
204
- $[34] = t8;
205
- $[35] = t12;
216
+ $[35] = t11;
217
+ $[36] = t8;
218
+ $[37] = t12;
206
219
  } else {
207
- t12 = $[35];
220
+ t12 = $[37];
208
221
  }
209
222
  let t13;
210
- if ($[36] !== defaultColumnHeight || $[37] !== density || $[38] !== isFirstColumn || $[39] !== isHeader || $[40] !== isLastColumn || $[41] !== theme) {
223
+ if ($[38] !== defaultColumnHeight || $[39] !== density || $[40] !== isFirstColumn || $[41] !== isHeader || $[42] !== isLastColumn || $[43] !== theme) {
211
224
  t13 = getTableCellLayout(theme, density, {
212
225
  isHeader,
213
226
  isLastColumn,
214
227
  isFirstColumn,
215
228
  defaultColumnHeight
216
229
  });
217
- $[36] = defaultColumnHeight;
218
- $[37] = density;
219
- $[38] = isFirstColumn;
220
- $[39] = isHeader;
221
- $[40] = isLastColumn;
222
- $[41] = theme;
223
- $[42] = t13;
230
+ $[38] = defaultColumnHeight;
231
+ $[39] = density;
232
+ $[40] = isFirstColumn;
233
+ $[41] = isHeader;
234
+ $[42] = isLastColumn;
235
+ $[43] = theme;
236
+ $[44] = t13;
224
237
  } else {
225
- t13 = $[42];
238
+ t13 = $[44];
226
239
  }
227
240
  let t14;
228
- if ($[43] !== t13) {
241
+ if ($[45] !== t13) {
229
242
  t14 = {
230
243
  ...t13,
231
244
  position: "relative",
@@ -234,41 +247,41 @@ export function TableCell(t0) {
234
247
  textOverflow: "ellipsis",
235
248
  flexDirection: "inherit"
236
249
  };
237
- $[43] = t13;
238
- $[44] = t14;
250
+ $[45] = t13;
251
+ $[46] = t14;
239
252
  } else {
240
- t14 = $[44];
253
+ t14 = $[46];
241
254
  }
242
255
  const t15 = backgroundColor ?? "inherit";
243
256
  const t16 = color ?? "inherit";
244
257
  let t17;
245
- if ($[45] !== t15 || $[46] !== t16) {
258
+ if ($[47] !== t15 || $[48] !== t16) {
246
259
  t17 = {
247
260
  backgroundColor: t15,
248
261
  color: t16
249
262
  };
250
- $[45] = t15;
251
- $[46] = t16;
252
- $[47] = t17;
263
+ $[47] = t15;
264
+ $[48] = t16;
265
+ $[49] = t17;
253
266
  } else {
254
- t17 = $[47];
267
+ t17 = $[49];
255
268
  }
256
269
  let t18;
257
- if ($[48] !== children || $[49] !== modifiedDataLink) {
270
+ if ($[50] !== children || $[51] !== modifiedDataLink) {
258
271
  t18 = modifiedDataLink ? /*#__PURE__*/ _jsx(Link, {
259
272
  href: modifiedDataLink.url,
260
273
  target: modifiedDataLink.targetBlank ? "_blank" : "_self",
261
274
  rel: modifiedDataLink.targetBlank ? "noopener noreferrer" : undefined,
262
275
  children: children
263
276
  }) : children;
264
- $[48] = children;
265
- $[49] = modifiedDataLink;
266
- $[50] = t18;
277
+ $[50] = children;
278
+ $[51] = modifiedDataLink;
279
+ $[52] = t18;
267
280
  } else {
268
- t18 = $[50];
281
+ t18 = $[52];
269
282
  }
270
283
  let t19;
271
- if ($[51] !== align || $[52] !== description || $[53] !== t14 || $[54] !== t17 || $[55] !== t18) {
284
+ if ($[53] !== align || $[54] !== description || $[55] !== t14 || $[56] !== t17 || $[57] !== t18) {
272
285
  t19 = /*#__PURE__*/ _jsx(Box, {
273
286
  id: "original-cell",
274
287
  sx: t14,
@@ -278,17 +291,17 @@ export function TableCell(t0) {
278
291
  textAlign: align,
279
292
  children: t18
280
293
  });
281
- $[51] = align;
282
- $[52] = description;
283
- $[53] = t14;
284
- $[54] = t17;
285
- $[55] = t18;
286
- $[56] = t19;
294
+ $[53] = align;
295
+ $[54] = description;
296
+ $[55] = t14;
297
+ $[56] = t17;
298
+ $[57] = t18;
299
+ $[58] = t19;
287
300
  } else {
288
- t19 = $[56];
301
+ t19 = $[58];
289
302
  }
290
303
  let t20;
291
- if ($[57] !== handleInteractionFocusTrigger || $[58] !== otherProps || $[59] !== t12 || $[60] !== t19 || $[61] !== t6 || $[62] !== t7) {
304
+ if ($[59] !== handleInteractionFocusTrigger || $[60] !== otherProps || $[61] !== t12 || $[62] !== t19 || $[63] !== t6 || $[64] !== t7) {
292
305
  t20 = /*#__PURE__*/ _jsx(StyledMuiTableCell, {
293
306
  ...otherProps,
294
307
  tabIndex: t6,
@@ -300,15 +313,15 @@ export function TableCell(t0) {
300
313
  ref: elRef,
301
314
  children: t19
302
315
  });
303
- $[57] = handleInteractionFocusTrigger;
304
- $[58] = otherProps;
305
- $[59] = t12;
306
- $[60] = t19;
307
- $[61] = t6;
308
- $[62] = t7;
309
- $[63] = t20;
316
+ $[59] = handleInteractionFocusTrigger;
317
+ $[60] = otherProps;
318
+ $[61] = t12;
319
+ $[62] = t19;
320
+ $[63] = t6;
321
+ $[64] = t7;
322
+ $[65] = t20;
310
323
  } else {
311
- t20 = $[63];
324
+ t20 = $[65];
312
325
  }
313
326
  return t20;
314
327
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Table/TableCell.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { TableCellProps as MuiTableCellProps } from '@mui/material';\nimport { Box, Link, TableCell as MuiTableCell, styled, useTheme } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { hasDataFieldPatterns, replaceDataFields } from '../utils/data-field-interpolation';\nimport type { DataLink, TableCellAlignment, TableDensity } from './model/table-model';\nimport { getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.default,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {\n density: TableDensity;\n defaultColumnHeight?: 'auto' | number;\n\n // These values are used to adjust the spacing for the first/last columns.\n isLastColumn: boolean;\n isFirstColumn: boolean;\n\n align?: TableCellAlignment;\n\n /**\n * Additional information to be displayed when hovering over the cell. This\n * may be the full cell value (e.g. to enable the user to see the full value\n * if it is ellipsized to fit into the space) or some other descriptive text\n * that is useful for the user.\n *\n * The hover behavior is currently managed with the `title` attribute, but this\n * may be changed to a tooltip in the future.\n */\n description?: string;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n color?: string;\n backgroundColor?: string;\n dataLink?: DataLink;\n adjacentCellsValuesMap?: Record<string, string>;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n defaultColumnHeight,\n focusState = 'none',\n onFocusTrigger,\n isFirstColumn,\n isLastColumn,\n description,\n align,\n color,\n backgroundColor,\n dataLink,\n adjacentCellsValuesMap,\n ...otherProps\n}: TableCellProps): ReactElement {\n const theme = useTheme();\n const elRef = useRef<HTMLTableCellElement>(null);\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details,[role=\"button\"]',\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n const modifiedDataLink = useMemo((): DataLink | undefined => {\n if (!dataLink) return undefined;\n\n if (adjacentCellsValuesMap && hasDataFieldPatterns(dataLink.url)) {\n const { text } = replaceDataFields(dataLink.url, adjacentCellsValuesMap, { urlEncode: true });\n return { ...dataLink, url: text };\n }\n return dataLink;\n }, [dataLink, adjacentCellsValuesMap]);\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n style={{ width: width }}\n sx={{\n position: 'relative',\n borderBottom: isHeader ? `solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`,\n '&:hover #original-cell': {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 10,\n width: 'fit-content',\n minWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'visible',\n backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,\n outline: `solid 1px ${theme.palette.info.main}`,\n outlineOffset: '-1px',\n },\n }}\n ref={elRef}\n >\n <Box\n id=\"original-cell\"\n sx={{\n ...getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n\n // Need to inherit from the MUI cell because this manages some ordering\n // that the `TableSortLabel` uses to determine the location of the icon\n // in headers.\n flexDirection: 'inherit',\n }}\n style={{\n backgroundColor: backgroundColor ?? 'inherit',\n color: color ?? 'inherit',\n }}\n title={description}\n aria-label={description}\n textAlign={align}\n >\n {modifiedDataLink ? (\n <Link\n href={modifiedDataLink.url}\n target={modifiedDataLink.targetBlank ? '_blank' : '_self'}\n rel={modifiedDataLink.targetBlank ? 'noopener noreferrer' : undefined}\n >\n {children}\n </Link>\n ) : (\n children\n )}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["Box","Link","TableCell","MuiTableCell","styled","useTheme","useEffect","useRef","hasDataFieldPatterns","replaceDataFields","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","default","outline","primary","main","outlineOffset","borderRadius"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,GAAG,EAAEC,IAAI,EAAEC,aAAaC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AAEvF,SAASC,SAAS,EAAWC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,uCAAoC;AAE5F,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,MAAMC,qBAAqBP,OAAOD,cAAc,CAAC,EAAES,KAAK,EAAE,GAAM,CAAA;QAC9DC,SAAS;QACTC,iBAAiB;QAEjB,uBAAuB;YACrB,kEAAkE;YAClEA,iBAAiBF,MAAMG,OAAO,CAACC,UAAU,CAACC,OAAO;QACnD;QACA,mBAAmB;YACjBC,SAAS,CAAC,UAAU,EAAEN,MAAMG,OAAO,CAACI,OAAO,CAACC,IAAI,EAAE;YAClD,uEAAuE;YACvE,4BAA4B;YAC5BC,eAAe;YACfC,cAAc;QAChB;IACF,CAAA;AAuCA,OAAO"}
1
+ {"version":3,"sources":["../../src/Table/TableCell.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { TableCellProps as MuiTableCellProps } from '@mui/material';\nimport { Box, Link, TableCell as MuiTableCell, styled, useTheme } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { hasDataFieldPatterns, replaceDataFields } from '../utils/data-field-interpolation';\nimport { sanitizeUrl } from '../utils/url';\nimport type { DataLink, TableCellAlignment, TableDensity } from './model/table-model';\nimport { getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.default,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {\n density: TableDensity;\n defaultColumnHeight?: 'auto' | number;\n\n // These values are used to adjust the spacing for the first/last columns.\n isLastColumn: boolean;\n isFirstColumn: boolean;\n\n align?: TableCellAlignment;\n\n /**\n * Additional information to be displayed when hovering over the cell. This\n * may be the full cell value (e.g. to enable the user to see the full value\n * if it is ellipsized to fit into the space) or some other descriptive text\n * that is useful for the user.\n *\n * The hover behavior is currently managed with the `title` attribute, but this\n * may be changed to a tooltip in the future.\n */\n description?: string;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n color?: string;\n backgroundColor?: string;\n dataLink?: DataLink;\n adjacentCellsValuesMap?: Record<string, string>;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n defaultColumnHeight,\n focusState = 'none',\n onFocusTrigger,\n isFirstColumn,\n isLastColumn,\n description,\n align,\n color,\n backgroundColor,\n dataLink,\n adjacentCellsValuesMap,\n ...otherProps\n}: TableCellProps): ReactElement {\n const theme = useTheme();\n const elRef = useRef<HTMLTableCellElement>(null);\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details,[role=\"button\"]',\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n const modifiedDataLink = useMemo((): DataLink | undefined => {\n if (!dataLink) return undefined;\n\n let url = dataLink.url;\n if (adjacentCellsValuesMap && hasDataFieldPatterns(url)) {\n url = replaceDataFields(url, adjacentCellsValuesMap, { urlEncode: true }).text;\n }\n const safeUrl = sanitizeUrl(url);\n if (safeUrl === undefined) return undefined;\n return { ...dataLink, url: safeUrl };\n }, [dataLink, adjacentCellsValuesMap]);\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n style={{ width: width }}\n sx={{\n position: 'relative',\n borderBottom: isHeader ? `solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`,\n '&:hover #original-cell': {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 10,\n width: 'fit-content',\n minWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'visible',\n backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,\n outline: `solid 1px ${theme.palette.info.main}`,\n outlineOffset: '-1px',\n },\n }}\n ref={elRef}\n >\n <Box\n id=\"original-cell\"\n sx={{\n ...getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n\n // Need to inherit from the MUI cell because this manages some ordering\n // that the `TableSortLabel` uses to determine the location of the icon\n // in headers.\n flexDirection: 'inherit',\n }}\n style={{\n backgroundColor: backgroundColor ?? 'inherit',\n color: color ?? 'inherit',\n }}\n title={description}\n aria-label={description}\n textAlign={align}\n >\n {modifiedDataLink ? (\n <Link\n href={modifiedDataLink.url}\n target={modifiedDataLink.targetBlank ? '_blank' : '_self'}\n rel={modifiedDataLink.targetBlank ? 'noopener noreferrer' : undefined}\n >\n {children}\n </Link>\n ) : (\n children\n )}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["Box","Link","TableCell","MuiTableCell","styled","useTheme","useEffect","useRef","hasDataFieldPatterns","replaceDataFields","sanitizeUrl","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","default","outline","primary","main","outlineOffset","borderRadius"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,GAAG,EAAEC,IAAI,EAAEC,aAAaC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AAEvF,SAASC,SAAS,EAAWC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,uCAAoC;AAC5F,SAASC,WAAW,QAAQ,kBAAe;AAE3C,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,MAAMC,qBAAqBR,OAAOD,cAAc,CAAC,EAAEU,KAAK,EAAE,GAAM,CAAA;QAC9DC,SAAS;QACTC,iBAAiB;QAEjB,uBAAuB;YACrB,kEAAkE;YAClEA,iBAAiBF,MAAMG,OAAO,CAACC,UAAU,CAACC,OAAO;QACnD;QACA,mBAAmB;YACjBC,SAAS,CAAC,UAAU,EAAEN,MAAMG,OAAO,CAACI,OAAO,CAACC,IAAI,EAAE;YAClD,uEAAuE;YACvE,4BAA4B;YAC5BC,eAAe;YACfC,cAAc;QAChB;IACF,CAAA;AAuCA,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedTable.d.ts","sourceRoot":"","sources":["../../src/Table/VirtualizedTable.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK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