Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(design): merge Univer-prefixed Tailwind utilities (#7261)
白熱63a807c98638
diff --git a/packages/design/src/helper/__tests__/clsx.spec.ts b/packages/design/src/helper/__tests__/clsx.spec.tsnew file mode 100644index 0000000000..147519e8d2--- /dev/null+++ b/packages/design/src/helper/__tests__/clsx.spec.ts@@ -0,0 +1,40 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { cva } from 'class-variance-authority';+import { describe, expect, it } from 'vitest';+import { clsx } from '../clsx';++describe('clsx', () => {+ it('merges Univer-prefixed conflicting utilities', () => {+ expect(clsx('univer-h-6', 'univer-h-[78px]')).toBe('univer-h-[78px]');+ expect(clsx('univer-px-3', 'univer-px-8')).toBe('univer-px-8');+ expect(clsx('univer-bg-transparent', 'univer-bg-[#e8eefc]')).toBe('univer-bg-[#e8eefc]');+ expect(clsx('dark:!univer-h-6', 'dark:!univer-h-[78px]')).toBe('dark:!univer-h-[78px]');+ });++ it('merges a className appended by CVA', () => {+ const buttonVariants = cva('', {+ variants: {+ size: {+ small: 'univer-h-6',+ },+ },+ });++ expect(clsx(buttonVariants({ size: 'small', className: 'univer-h-[78px]' }))).toBe('univer-h-[78px]');+ });+});diff --git a/packages/design/src/helper/clsx.ts b/packages/design/src/helper/clsx.tsindex 4d6869f29c..7cbf00ac85 100644--- a/packages/design/src/helper/clsx.ts+++ b/packages/design/src/helper/clsx.ts@@ -17,7 +17,9 @@/* eslint-disable no-restricted-imports */import type { ClassValue } from 'clsx';import { clsx as cn } from 'clsx';-import { twMerge } from 'tailwind-merge';+import { extendTailwindMerge } from 'tailwind-merge';++const twMerge = extendTailwindMerge({ prefix: 'univer-' });export function clsx(...inputs: ClassValue[]) {return twMerge(cn(inputs));