@fluentic/style 0.1.0-beta.5 → 0.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +105 -31
- package/atomic/className.ts +19 -2
- package/atomic/utils/hash.ts +1 -65
- package/compiler/compiler/compiler.ts +85 -8
- package/compiler/cssProp.ts +0 -14
- package/compiler/transform/cssProp/plugin.ts +33 -1
- package/compiler/transform/evaluator/evaluator.ts +1 -0
- package/compiler/transform/extract/chain/chain.ts +120 -11
- package/compiler/utils/import_source.ts +17 -7
- package/dist/{combine-Ca6LfFxv.js → combine-D0AXSTn-.js} +2 -2
- package/dist/{combine-Ca6LfFxv.js.map → combine-D0AXSTn-.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-OgDBuqfs.mjs → compiler-CCvRlaq0.mjs} +141 -89
- package/dist/compiler-CCvRlaq0.mjs.map +1 -0
- package/dist/{config-Barf8f4B.js → config-B-w6rOe0.js} +2 -2
- package/dist/{config-Barf8f4B.js.map → config-B-w6rOe0.js.map} +1 -1
- package/dist/{config-CsB4MuFI.js → config-B1WtpYar.js} +2 -2
- package/dist/{config-CsB4MuFI.js.map → config-B1WtpYar.js.map} +1 -1
- package/dist/{config-t76UljYv.js → config-CCMwA9Gm.js} +2 -2
- package/dist/{config-t76UljYv.js.map → config-CCMwA9Gm.js.map} +1 -1
- package/dist/{createTransformElement-DDqld3RF.js → createTransformElement-PCilcudP.js} +2 -2
- package/dist/{createTransformElement-DDqld3RF.js.map → createTransformElement-PCilcudP.js.map} +1 -1
- package/dist/{css-a9O5so0b.js → css-DirG7Jwu.js} +41 -7
- package/dist/css-DirG7Jwu.js.map +1 -0
- package/dist/{css-YfHN_8Nk.js → css-nmclCl2P.js} +8 -8
- package/dist/{css-YfHN_8Nk.js.map → css-nmclCl2P.js.map} +1 -1
- package/dist/{css-CZwrac6F.js → css-shX7_73D.js} +12 -41
- package/dist/css-shX7_73D.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{data-CzHJg147.js → data-DUvixly5.js} +14 -6
- package/dist/data-DUvixly5.js.map +1 -0
- package/dist/{debug-DkrxyknP.js → debug-DJRCBKhM.js} +2 -2
- package/dist/{debug-DkrxyknP.js.map → debug-DJRCBKhM.js.map} +1 -1
- package/dist/dev/rsc.js +5 -5
- package/dist/{dev-z4laBwlS.js → dev-Cwha8aAp.js} +4 -4
- package/dist/{dev-z4laBwlS.js.map → dev-Cwha8aAp.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CqhU_l_m.js → elementMarker-Cb46vtLU.js} +3 -3
- package/dist/{elementMarker-CqhU_l_m.js.map → elementMarker-Cb46vtLU.js.map} +1 -1
- package/dist/entry/dev/adapter/preact.js +2 -2
- package/dist/entry/dev/adapter/react.js +2 -2
- package/dist/entry/dev/adapter/solid.js +2 -2
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +8 -8
- package/dist/entry/prod/adapter/preact.js +1 -1
- package/dist/entry/prod/adapter/react.js +1 -1
- package/dist/entry/prod/adapter/solid.js +1 -1
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod.js +2 -2
- package/dist/entry/rsc-dev/adapter/preact.js +5 -4
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/react.js +5 -4
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/solid.js +5 -4
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +5 -6
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +5 -5
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod.js +2 -2
- package/dist/{env-Db2cRt-h.js → env-0Gu2Jh47.js} +2 -39
- package/dist/env-0Gu2Jh47.js.map +1 -0
- package/dist/{utils-CLnpwhJd.js → getClassName-CHZKhmde.js} +5 -43
- package/dist/getClassName-CHZKhmde.js.map +1 -0
- package/dist/{getClassName-DaZF5nfJ.js → getClassName-CHd0iCXp.js} +3 -3
- package/dist/{getClassName-DaZF5nfJ.js.map → getClassName-CHd0iCXp.js.map} +1 -1
- package/dist/global-Dg37z0lV.js +14 -0
- package/dist/global-Dg37z0lV.js.map +1 -0
- package/dist/{hash-BOlQThNz.js → hash-Cr-LCWDt.js} +2 -40
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +6 -6
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-C2pnWLcb.js → jsx-BMFC8_tA.js} +4 -4
- package/dist/{jsx-C2pnWLcb.js.map → jsx-BMFC8_tA.js.map} +1 -1
- package/dist/{jsx_runtime-XJSHujgI.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
- package/dist/{jsx_runtime-XJSHujgI.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
- package/dist/{loader-DHvgp0fK.mjs → loader-hNaefW-U.mjs} +13 -14
- package/dist/loader-hNaefW-U.mjs.map +1 -0
- package/dist/{misc-BuSLnvx0.mjs → misc-1OS0aeY1.mjs} +2 -2
- package/dist/{misc-BuSLnvx0.mjs.map → misc-1OS0aeY1.mjs.map} +1 -1
- package/dist/{namedTokens-D3tt-joz.js → namedTokens-mgRfd9hs.js} +3 -3
- package/dist/{namedTokens-D3tt-joz.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
- package/dist/plugin/farm/index.mjs +3 -3
- package/dist/plugin/nextjs/index.mjs +120 -16
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +1 -1
- package/dist/plugin/parcel/index.mjs +2 -2
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +2 -2
- package/dist/plugin/vite/index.mjs +3 -3
- package/dist/plugin/webpack/index.mjs +2 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +25 -3
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{registry-r3BKWqpI.mjs → registry-OA0niXJL.mjs} +2 -2
- package/dist/{registry-r3BKWqpI.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-D5a37GNr.js → resolveClassNameRuntime-BKXT1bmR.js} +2 -2
- package/dist/{resolveClassNameRuntime-D5a37GNr.js.map → resolveClassNameRuntime-BKXT1bmR.js.map} +1 -1
- package/dist/{rules-B0_rKPfB.js → rules-DgcCENkw.js} +5 -5
- package/dist/{rules-B0_rKPfB.js.map → rules-DgcCENkw.js.map} +1 -1
- package/dist/server.js +10 -10
- package/dist/{shared-8_Msr7Q5.cjs → shared-Bc9RwNNj.cjs} +140 -88
- package/dist/shared-Bc9RwNNj.cjs.map +1 -0
- package/dist/{shared-BGO_05rW.mjs → shared-COiLPdZ1.mjs} +4 -4
- package/dist/{shared-BGO_05rW.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
- package/dist/sheet-B87QCFWF.js +7 -0
- package/dist/{sheet-BpLZIIuO.js.map → sheet-B87QCFWF.js.map} +1 -1
- package/dist/{sidecar-Bu2x35JE.mjs → sidecar-ViZUL9B8.mjs} +3 -3
- package/dist/{sidecar-Bu2x35JE.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
- package/dist/{styleStore-BDy5TH6N.js → styleStore-BlC8Ax9f.js} +3 -3
- package/dist/{styleStore-BDy5TH6N.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
- package/dist/{styleStore-DX3z_UVK.js → styleStore-DHzH25A7.js} +2 -2
- package/dist/{styleStore-DX3z_UVK.js.map → styleStore-DHzH25A7.js.map} +1 -1
- package/dist/{token-BsW_S8fN.js → token-CAQWMtan.js} +2 -2
- package/dist/{token-BsW_S8fN.js.map → token-CAQWMtan.js.map} +1 -1
- package/dist/{trace-BdKEpgME.js → trace-D3yBmJad.js} +2 -2
- package/dist/{trace-BdKEpgME.js.map → trace-D3yBmJad.js.map} +1 -1
- package/dist/{trace-DcuMxR45.js → trace-DdXWjgAD.js} +3 -3
- package/dist/{trace-DcuMxR45.js.map → trace-DdXWjgAD.js.map} +1 -1
- package/dist/{types-BEUgXuu2.js → types-BhdAXX7z.js} +7 -7
- package/dist/{types-BEUgXuu2.js.map → types-BhdAXX7z.js.map} +1 -1
- package/dist/utils-B6HVRX10.js +42 -0
- package/dist/utils-B6HVRX10.js.map +1 -0
- package/dist/{utils-BPDxr-oc.mjs → utils-C7UalRKf.mjs} +41 -7
- package/dist/utils-C7UalRKf.mjs.map +1 -0
- package/dist/{utils-sBVZEq4u.js → utils-Cd4wqN56.js} +2 -39
- package/dist/utils-Cd4wqN56.js.map +1 -0
- package/dist/{utils-DZjLTV4D.mjs → utils-DjxH0zc7.mjs} +3 -3
- package/dist/{utils-DZjLTV4D.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/utils.js +2 -2
- package/dist/{webpack-DTKgR-HY.mjs → webpack-6et2ZVI6.mjs} +5 -5
- package/dist/{webpack-DTKgR-HY.mjs.map → webpack-6et2ZVI6.mjs.map} +1 -1
- package/entry/rsc_dev/adapter/preact.ts +9 -1
- package/entry/rsc_dev/adapter/react.ts +9 -1
- package/entry/rsc_dev/adapter/solid.ts +9 -1
- package/package.json +21 -11
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +205 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +50 -0
- package/presets/tailwind/classname/transform.ts +32 -1
- package/runtime/adapter/utils.ts +40 -14
- package/dist/compiler-OgDBuqfs.mjs.map +0 -1
- package/dist/css-CZwrac6F.js.map +0 -1
- package/dist/css-a9O5so0b.js.map +0 -1
- package/dist/css_extra-CXXZAylc.js +0 -8
- package/dist/css_extra-CXXZAylc.js.map +0 -1
- package/dist/data-CzHJg147.js.map +0 -1
- package/dist/env-Db2cRt-h.js.map +0 -1
- package/dist/getClassName-DKtQl5ZX.js +0 -32
- package/dist/getClassName-DKtQl5ZX.js.map +0 -1
- package/dist/global-zYTvWskP.js +0 -10
- package/dist/global-zYTvWskP.js.map +0 -1
- package/dist/hash-BOlQThNz.js.map +0 -1
- package/dist/loader-DHvgp0fK.mjs.map +0 -1
- package/dist/shared-8_Msr7Q5.cjs.map +0 -1
- package/dist/sheet-BpLZIIuO.js +0 -7
- package/dist/utils-BPDxr-oc.mjs.map +0 -1
- package/dist/utils-CLnpwhJd.js.map +0 -1
- package/dist/utils-okFWrQsg.js +0 -41
- package/dist/utils-okFWrQsg.js.map +0 -1
- package/dist/utils-sBVZEq4u.js.map +0 -1
package/plugin/nextjs/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
-
import type { PHASE_TYPE } from 'next/constants';
|
|
3
2
|
import type { OmitProps } from '../../utils/type';
|
|
4
3
|
import type { PluginOptions as BasePluginOptions } from '../utils';
|
|
5
4
|
|
|
@@ -12,7 +11,7 @@ export type NextConfigContext = {
|
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
export type NextConfigFunction = (
|
|
15
|
-
phase:
|
|
14
|
+
phase: string,
|
|
16
15
|
context: NextConfigContext,
|
|
17
16
|
) => MaybePromise<NextConfig>;
|
|
18
17
|
|
package/plugin/nextjs/utils.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';
|
|
5
5
|
import type { Compiler as PluginCompiler } from '../../compiler';
|
|
6
|
+
import type { ImportSource } from '../../compiler/utils/import_source';
|
|
6
7
|
import { normalizePath } from '../../compiler/utils/path';
|
|
7
8
|
import type { BuildConfig, BuildDevConfig } from '../../config/build';
|
|
9
|
+
import { getStyleFnMeta } from '../../style/style';
|
|
8
10
|
import { createWebpackRegistry } from '../bundler/webpack/shared/registry';
|
|
9
11
|
import type { FileCssCache } from '../utils/cache';
|
|
10
12
|
import type { PluginOptions as BasePluginOptions } from '../utils/compiler';
|
|
@@ -69,15 +71,63 @@ export function createNextBuildDevConfig(options: PluginOptions): BuildDevConfig
|
|
|
69
71
|
export function createNextConfigHash(
|
|
70
72
|
buildConfig: BuildConfig,
|
|
71
73
|
dev: boolean,
|
|
74
|
+
importSources?: readonly ImportSource[] | null,
|
|
72
75
|
) {
|
|
73
76
|
const values = [
|
|
74
77
|
dev ? 'dev' : 'prod',
|
|
75
78
|
buildConfig.hoist ? 'hoist' : 'no-hoist',
|
|
79
|
+
JSON.stringify(createSerializableImportSources(importSources)),
|
|
76
80
|
];
|
|
77
81
|
|
|
78
82
|
return createHash('sha256').update(values.join('\0')).digest('hex');
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
export function createSerializableImportSources(
|
|
86
|
+
importSources: readonly ImportSource[] | null | undefined,
|
|
87
|
+
): ImportSource[] | undefined {
|
|
88
|
+
if (!importSources?.length) return undefined;
|
|
89
|
+
|
|
90
|
+
const result: ImportSource[] = [];
|
|
91
|
+
|
|
92
|
+
for (const entry of importSources) {
|
|
93
|
+
if (entry.check) continue;
|
|
94
|
+
|
|
95
|
+
const source = serializeImportSourcePattern(entry.source);
|
|
96
|
+
const name = entry.name;
|
|
97
|
+
const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
|
|
98
|
+
|
|
99
|
+
if (!meta) continue;
|
|
100
|
+
if (entry.source !== undefined && source === undefined) continue;
|
|
101
|
+
|
|
102
|
+
result.push(removeUndefinedValues({
|
|
103
|
+
source,
|
|
104
|
+
name,
|
|
105
|
+
meta,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return result.length ? result : undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function serializeImportSourcePattern(
|
|
113
|
+
source: ImportSource['source'],
|
|
114
|
+
): string | string[] | undefined {
|
|
115
|
+
if (source === undefined) return undefined;
|
|
116
|
+
|
|
117
|
+
if (Array.isArray(source)) {
|
|
118
|
+
const result: string[] = [];
|
|
119
|
+
|
|
120
|
+
for (const item of source) {
|
|
121
|
+
if (typeof item !== 'string') return undefined;
|
|
122
|
+
result.push(item);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return typeof source === 'string' ? source : undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
81
131
|
export function resolveNextCompilerOptions(
|
|
82
132
|
options: PluginOptions,
|
|
83
133
|
sidecar: SourcemapSidecar | null,
|
|
@@ -127,7 +127,7 @@ function classNameToStyle(className: TailwindClassName, theme: TailwindTheme): R
|
|
|
127
127
|
if (className.startsWith('w-')) return { w: ref(className, 'w-', [theme.sizes, theme.spacing]) };
|
|
128
128
|
if (className.startsWith('h-')) return { h: ref(className, 'h-', [theme.sizes, theme.spacing]) };
|
|
129
129
|
if (className.startsWith('bg-')) return { bg: ref(className, 'bg-', theme.colors) };
|
|
130
|
-
if (className.startsWith('text-')) return
|
|
130
|
+
if (className.startsWith('text-')) return textStyle(className.slice('text-'.length), theme);
|
|
131
131
|
if (className.startsWith('font-')) return { font: ref(className, 'font-', theme.fontWeights) };
|
|
132
132
|
if (className.startsWith('leading-')) return { leading: ref(className, 'leading-', theme.lineHeights) };
|
|
133
133
|
if (className.startsWith('rounded-')) return { rounded: ref(className, 'rounded-', theme.radii) };
|
|
@@ -151,6 +151,37 @@ function borderStyle(value: string, theme: TailwindTheme): Record<string, unknow
|
|
|
151
151
|
return { borderColor: scaleRef(value, theme.colors) };
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
function textStyle(value: string, theme: TailwindTheme): Record<string, unknown> {
|
|
155
|
+
if (value.startsWith('[') && value.endsWith(']')) {
|
|
156
|
+
const arbitrary = value.slice(1, -1).replace(/_/g, ' ');
|
|
157
|
+
const hinted = parseArbitraryTextHint(arbitrary);
|
|
158
|
+
|
|
159
|
+
if (hinted) return hinted;
|
|
160
|
+
if (isLikelyFontSize(arbitrary)) return { textSize: arbitrary };
|
|
161
|
+
|
|
162
|
+
return { text: arbitrary };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return { text: scaleRef(value, [theme.fontSizes, theme.colors]) };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function parseArbitraryTextHint(value: string): Record<string, unknown> | null {
|
|
169
|
+
const splitAt = value.indexOf(':');
|
|
170
|
+
if (splitAt < 1) return null;
|
|
171
|
+
|
|
172
|
+
const hint = value.slice(0, splitAt);
|
|
173
|
+
const textValue = value.slice(splitAt + 1);
|
|
174
|
+
|
|
175
|
+
if (hint === 'length' || hint === 'size') return { textSize: textValue };
|
|
176
|
+
if (hint === 'color') return { text: textValue };
|
|
177
|
+
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isLikelyFontSize(value: string) {
|
|
182
|
+
return /^(?:-?\d*\.?\d+(?:px|r?em|lh|vh|vw|vmin|vmax|%|ch|ex|cap|ic)|(?:calc|clamp|min|max)\()/.test(value);
|
|
183
|
+
}
|
|
184
|
+
|
|
154
185
|
function scaleRef(value: string, scale?: TailwindScale | (TailwindScale | undefined)[]) {
|
|
155
186
|
const scales = Array.isArray(scale) ? scale : [scale];
|
|
156
187
|
const path = value.replace(/-/g, '.');
|
package/runtime/adapter/utils.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type JsxCssPropMergeOptions = {
|
|
|
7
7
|
classProp: 'class' | 'className';
|
|
8
8
|
styleProp: 'style';
|
|
9
9
|
styleMode: JsxCssPropStyleMode;
|
|
10
|
+
preserveResultProps?: boolean;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type JsxCssPropInput = Record<PropertyKey, unknown>;
|
|
@@ -22,22 +23,27 @@ export function createMergeJsxProps(
|
|
|
22
23
|
) {
|
|
23
24
|
return function mergeJsxProps(parts: readonly unknown[]) {
|
|
24
25
|
let props: JsxCssPropInput | null = null;
|
|
26
|
+
let cssProps: StyleProp[] | null = null;
|
|
25
27
|
|
|
26
28
|
for (let index = 0; index < parts.length; index++) {
|
|
27
|
-
|
|
29
|
+
const result = mergePart(props, parts[index]);
|
|
30
|
+
props = result.props;
|
|
31
|
+
|
|
32
|
+
if (result.css) {
|
|
33
|
+
if (!cssProps) cssProps = [];
|
|
34
|
+
cssProps.push(result.css);
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
return props ?? {};
|
|
38
|
+
return mergeCssProps(props ?? {}, cssProps, getClassName, options);
|
|
31
39
|
};
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
function mergePart(
|
|
35
43
|
props: JsxCssPropInput | null,
|
|
36
44
|
part: unknown,
|
|
37
|
-
getClassName: GetClassNameFn,
|
|
38
|
-
options: JsxCssPropMergeOptions,
|
|
39
45
|
) {
|
|
40
|
-
if (!part) return props;
|
|
46
|
+
if (!part) return { css: null, props };
|
|
41
47
|
|
|
42
48
|
const next = props ? { ...props } : {};
|
|
43
49
|
const attrs = part as JsxCssPropInput;
|
|
@@ -47,27 +53,47 @@ function mergePart(
|
|
|
47
53
|
if (key !== 'css') next[key] = attrs[key];
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
return {
|
|
57
|
+
css: css ? css as StyleProp : null,
|
|
58
|
+
props: next,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
51
61
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
function mergeCssProps(
|
|
63
|
+
props: JsxCssPropInput,
|
|
64
|
+
cssProps: StyleProp[] | null,
|
|
65
|
+
getClassName: GetClassNameFn,
|
|
66
|
+
options: JsxCssPropMergeOptions,
|
|
67
|
+
) {
|
|
68
|
+
if (!cssProps?.length) return props;
|
|
69
|
+
|
|
70
|
+
const className = getClassName(cssProps.length === 1 ? cssProps[0] : cssProps, {
|
|
71
|
+
className: getClassValue(props, options.classProp),
|
|
72
|
+
style: props[options.styleProp] as ClassNameProps['style'],
|
|
55
73
|
});
|
|
56
74
|
|
|
57
|
-
delete
|
|
58
|
-
delete
|
|
75
|
+
delete props.class;
|
|
76
|
+
delete props.className;
|
|
59
77
|
|
|
60
78
|
if (className.className !== undefined) {
|
|
61
|
-
|
|
79
|
+
props[options.classProp] = className.className;
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
if (className.style !== undefined) {
|
|
65
|
-
|
|
83
|
+
props[options.styleProp] = options.styleMode === 'solid'
|
|
66
84
|
? toSolidStyle(className.style as Record<string, unknown>)
|
|
67
85
|
: className.style;
|
|
68
86
|
}
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
if (options.preserveResultProps) {
|
|
89
|
+
for (const key in className) {
|
|
90
|
+
if (key === 'className' || key === 'style') continue;
|
|
91
|
+
|
|
92
|
+
props[key] = className[key as keyof ClassNameResult];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return props;
|
|
71
97
|
}
|
|
72
98
|
|
|
73
99
|
function getClassValue(
|