refactor(editor): add runtime type checks to database cell values (#10770)

This commit is contained in:
zzj3720
2025-03-12 09:22:41 +00:00
parent fd3ce431fe
commit 01151ec18f
54 changed files with 775 additions and 629 deletions
@@ -23,7 +23,6 @@ import { html } from 'lit/static-html.js';
import { inputConfig, typeConfig } from '../../../core/common/property-menu.js';
import type { Property } from '../../../core/view-manager/property.js';
import type { NumberPropertyDataType } from '../../../property-presets/index.js';
import { numberFormats } from '../../../property-presets/number/utils/formats.js';
import { DEFAULT_COLUMN_TITLE_HEIGHT } from '../consts.js';
import type { TableColumn, TableSingleView } from '../table-view-manager.js';
@@ -91,12 +90,7 @@ export class MobileTableColumnHeader extends SignalWatcher(
items: [
numberFormatConfig(this.column),
...numberFormats.map(format => {
const data = (
this.column as Property<
number,
NumberPropertyDataType
>
).data$.value;
const data = this.column.data$.value;
return menu.action({
isSelected: data.format === format.type,
prefix: html`<span
@@ -39,7 +39,6 @@ import {
droppable,
} from '../../../../core/utils/wc-dnd/dnd-context.js';
import type { Property } from '../../../../core/view-manager/property.js';
import type { NumberPropertyDataType } from '../../../../property-presets/index.js';
import { numberFormats } from '../../../../property-presets/number/utils/formats.js';
import { ShowQuickSettingBarContextKey } from '../../../../widget-presets/quick-setting-bar/context.js';
import { DEFAULT_COLUMN_TITLE_HEIGHT } from '../../consts.js';
@@ -222,12 +221,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
items: [
numberFormatConfig(this.column),
...numberFormats.map(format => {
const data = (
this.column as Property<
number,
NumberPropertyDataType
>
).data$.value;
const data = this.column.data$.value;
return menu.action({
isSelected: data.format === format.type,
prefix: html`<span
@@ -81,7 +81,7 @@ export class DatabaseColumnStatsCell extends SignalWatcher(
return this.column.valueGet(id);
});
}
return this.column.cells$.value.map(cell => cell.value$.value);
return this.column.cells$.value.map(cell => cell.jsonValue$.value);
});
groups$ = computed(() => {
@@ -14,6 +14,7 @@ import {
groupTraitKey,
sortByManually,
} from '../../core/group-by/trait.js';
import { fromJson } from '../../core/property/utils';
import { SortManager, sortTraitKey } from '../../core/sort/manager.js';
import { PropertyBase } from '../../core/view-manager/property.js';
import {
@@ -327,8 +328,8 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
Object.entries(defaultValues).forEach(([propertyId, jsonValue]) => {
const property = this.propertyGet(propertyId);
const propertyMeta = this.propertyMetaGet(property.type$.value);
if (propertyMeta?.config.cellFromJson) {
const value = propertyMeta.config.cellFromJson({
if (propertyMeta) {
const value = fromJson(propertyMeta.config, {
value: jsonValue,
data: property.data$.value,
dataSource: this.dataSource,