Skip to content

feat(theme): support configuring the default table theme - #5309

Merged
fangsmile merged 1 commit into
VisActor:developfrom
kitee0325:feat/set-default-theme
Sep 10, 2026
Merged

feat(theme): support configuring the default table theme#5309
fangsmile merged 1 commit into
VisActor:developfrom
kitee0325:feat/set-default-theme

Conversation

@kitee0325

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • New feature
  • TypeScript definition update
  • Test Case
  • Site / documentation update

🔗 Related issue link

No existing issue. This PR proposes a public default-theme configuration API for applications and component libraries.

💡 Background and solution

Applications currently have to pass a theme to every table. Registering a theme named DEFAULT only affects name lookup, while construction and update fallbacks still use a separate default reference. Mutating the existing default object also risks stale resolved-style caches.

Add VTable.themes.setDefaultTheme(theme: ITableThemeDefine): void. It installs a new TableTheme and synchronizes the named DEFAULT export, the internal fallback and the built-in name lookup. A supplied TableTheme is copied through its existing extends() API to preserve inherited styles without sharing resolved caches.

const originalDefault = VTable.themes.DEFAULT;
VTable.themes.setDefaultTheme(originalDefault.extends({
  bodyStyle: { color: '#243447' },
  headerStyle: { bgColor: '#f2f4f7' }
}));
const table = new VTable.ListTable({ container, columns, records });

The supplied theme replaces the previous default; explicit extends() is used for merging. Existing instances and previously extended themes retain their theme objects. Future updateOption() calls without a theme use the configured default. Explicit themes, other built-in themes, registered-name precedence, updateTheme(), and property assignment keep their existing semantics. Standalone partial themes do not inherit the configured default. The setting is shared by callers using the same VTable runtime and is intended for initialization.

Validation (Node.js 22.23.2, macOS):

  • Rush selective install completed successfully.
  • Editors declarations generated with the repository TypeScript compiler (tsc --emitDeclarationOnly).
  • rushx compile in packages/vtable: passed.
  • rushx test --runInBand --runTestsByPath __tests__/default-theme.test.ts __tests__/default-theme-table.test.ts __tests__/functional-icons-theme.test.ts: 3 suites / 11 tests passed. Jest printed an open-handles warning, then exited successfully.
  • ESLint on all changed TypeScript files: passed.
  • Repository Prettier 2.8.8 check: passed.
  • git diff --cached --check: passed.
  • Repository Git hooks (lint-staged and commitlint): passed.
  • rush change --verify --target-branch origin/develop --no-fetch: passed.
  • Full rush build --to @visactor/vtable blocked before the core build: the existing bundler requires an unavailable vue peer through @vitejs/plugin-vue after selective install. No unrelated dependency changes are included. Full bundle validation remains for CI / a complete development environment.

📝 Changelog

Language Changelog
🇺🇸 English Add themes.setDefaultTheme() to configure the default theme used by tables without an explicit theme.
🇨🇳 Chinese 新增 themes.setDefaultTheme(),用于配置未显式指定主题的表格所使用的默认主题。

The existing default and all current behavior remain unchanged unless the new API is called. Calls affect the shared runtime's default for subsequent operations; existing instances are not automatically updated.

☑️ Self-Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed (usage examples in both guides; existing rendering behavior is unchanged)
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed (Rush-generated change file)

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@kitee0325

Copy link
Copy Markdown
Contributor Author

@fangsmile 您好,看到您维护过主题入口,也在近期处理了 #5301 等核心 API 改动,想请您帮忙审查这个默认主题配置 PR。

这里新增 themes.setDefaultTheme(),让应用或组件库在初始化时统一设置原生默认主题,并保留显式主题、注册主题及 extends() 的原有行为。已补充中英文文档和测试,本地 11 项相关测试、类型和提交规范检查通过;完整构建的环境限制已在 PR 描述中说明。

目前 Unit test CI 和 Bug Server CI 显示 action_required,烦请协助检查并批准本次 Fork 的 CI 运行。如果 API 方向合适,也希望评估纳入下一个版本;如需调整,我会继续跟进。谢谢!

@fangsmile
fangsmile merged commit 8fc8227 into VisActor:develop Sep 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants