mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
Uses JSON5 to parse values input by the user in the extension storage
viewer. Fallback to a string if the value cannot be parsed.
This allows a user to input `{foo: "bar"}` and have that value stored
as a JSON object in storage.
Bug: 40963428
Change-Id: I63e81fce5b8a0248d3698cc8c44a6ff24d3e4345
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5928646
Reviewed-by: Danil Somsikov <dsv@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Commit-Queue: Oliver Dunk <oliverdunk@chromium.org>
25 lines
899 B
TypeScript
25 lines
899 B
TypeScript
// Copyright 2024 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import type * as DataGrid from '../ui/legacy/components/data_grid/data_grid.js';
|
|
|
|
export function getCellElementFromNodeAndColumnId<T>(
|
|
dataGrid: DataGrid.DataGrid.DataGridImpl<T>, node: DataGrid.DataGrid.DataGridNode<T>, columnId: string): Element|
|
|
null {
|
|
const column = dataGrid.columns[columnId];
|
|
const cellIndex = dataGrid.visibleColumnsArray.indexOf(column);
|
|
return node.element()?.children[cellIndex] || null;
|
|
}
|
|
|
|
export function selectNodeByKey<T>(
|
|
dataGrid: DataGrid.DataGrid.DataGridImpl<T>, key: string|null): DataGrid.DataGrid.DataGridNode<T>|null {
|
|
for (const node of dataGrid.rootNode().children) {
|
|
if (node?.data?.key === key) {
|
|
node.select();
|
|
return node;
|
|
}
|
|
}
|
|
return null;
|
|
}
|