21 lines
867 B
TypeScript
21 lines
867 B
TypeScript
import React from 'react'
|
||
import { renderToString } from 'react-dom/server'
|
||
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs'
|
||
import { Form, Input, ConfigProvider } from 'antd'
|
||
|
||
// 只渲染【没有 Form 包裹】的 Form.Item,看 vertical 样式是否存在
|
||
const App = () => (
|
||
<ConfigProvider theme={{ cssVar: true, hashed: false }}>
|
||
<Form.Item label="孤立字段" layout="vertical" style={{ width: 128 }}>
|
||
<Input />
|
||
</Form.Item>
|
||
</ConfigProvider>
|
||
)
|
||
const cache = createCache()
|
||
renderToString(<StyleProvider cache={cache}><App /></StyleProvider>)
|
||
const css = String(extractStyle(cache, { plain: true } as never))
|
||
console.log('len', css.length)
|
||
const hits = css.replace(/\s+/g, ' ').split('}').filter(r => /-vertical/.test(r))
|
||
console.log('vertical rules:', hits.length)
|
||
console.log(hits.slice(0, 6).join('\n}\n'))
|