@fluentic/style 0.1.0-beta.0 → 0.1.0-beta.10
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 +154 -0
- package/README.md +181 -49
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +50 -12
- package/atomic/debug/className/className.ts +24 -8
- package/atomic/element.ts +5 -2
- package/atomic/rule.ts +11 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +44 -3
- package/atomic/token.ts +7 -4
- package/atomic/utils/cssIdent.ts +54 -0
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +14 -0
- package/atomic/utils/selector.ts +31 -1
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +491 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +41 -0
- package/builder/data/const.ts +8 -1
- package/builder/data/create.ts +52 -6
- package/builder/data/data.ts +33 -8
- package/builder/data/debug.ts +1 -0
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +26 -3
- package/builder/data/merge/scope.ts +38 -38
- package/builder/data/merge/style.ts +115 -20
- package/builder/data/state.ts +17 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +30 -0
- package/builder/extract/token.ts +30 -14
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +31 -0
- package/builder/selector_override_core.ts +79 -0
- package/builder/style_builder.ts +144 -20
- package/builder/style_data.ts +25 -0
- package/builder/style_fns.ts +57 -57
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/builder/types/alias.ts +44 -16
- package/builder/types/fns.ts +24 -16
- package/builder/types/types.ts +37 -7
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +88 -14
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +4 -1
- package/compiler/cssProp.ts +21 -0
- package/compiler/extract/extract.ts +42 -14
- package/compiler/extract/types.ts +2 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +93 -4
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +173 -32
- package/compiler/transform/evaluator/tracer.ts +48 -11
- package/compiler/transform/extract/chain/chain.ts +1370 -162
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +3 -1
- package/compiler/transform/extract/plugin.ts +64 -6
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +72 -2
- package/compiler/transform/extract/utils/state.ts +3 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +12 -5
- package/compiler/utils/file_resolver.ts +2 -0
- package/compiler/utils/import_source.ts +19 -8
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +9 -2
- package/config/config/check.ts +25 -0
- package/config/config/css.ts +18 -1
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +19 -2
- package/config/types.ts +7 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +152 -0
- package/css/styleTarget.ts +251 -0
- package/dev/config.ts +2 -3
- package/dev/utils.ts +3 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +153 -0
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-yhJCGT0F.js +304 -0
- package/dist/className-yhJCGT0F.js.map +1 -0
- package/dist/combine-Bww7VnSr.js +1254 -0
- package/dist/combine-Bww7VnSr.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-DweanHoB.mjs → compiler-C3CEGGtI.mjs} +2349 -647
- package/dist/compiler-C3CEGGtI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BAEzRmSJ.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
- package/dist/config-BKP5LOkt.js +35 -0
- package/dist/config-BKP5LOkt.js.map +1 -0
- package/dist/config-C5VWvTav.js +34 -0
- package/dist/config-C5VWvTav.js.map +1 -0
- package/dist/config-CB4lm2tM.js +1 -0
- package/dist/config-CDjbHwb-.js +6 -0
- package/dist/config-CDjbHwb-.js.map +1 -0
- package/dist/config-DNEnHEf3.js +36 -0
- package/dist/config-DNEnHEf3.js.map +1 -0
- package/dist/createTransformElement-D8fXZ3wA.js +34 -0
- package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
- package/dist/css-BDn0epJ8.js +1339 -0
- package/dist/css-BDn0epJ8.js.map +1 -0
- package/dist/css-CFxNrYt3.js +4040 -0
- package/dist/css-CFxNrYt3.js.map +1 -0
- package/dist/css-DEYgrj76.js +524 -0
- package/dist/css-DEYgrj76.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
- package/dist/css-DWBWsyxZ.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
- package/dist/data-CDrS1Bq4.js +785 -0
- package/dist/data-CDrS1Bq4.js.map +1 -0
- package/dist/debug-BkVbf0Cz.js +52 -0
- package/dist/debug-BkVbf0Cz.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
- package/dist/debug-YuhEIQVO.js.map +1 -0
- package/dist/dev/rsc.js +10 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
- package/dist/dev-0imWmSVb.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
- package/dist/elementMarker-kvpMjB49.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +13 -9
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +242 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -4
- package/dist/entry/prod.js +84 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +11 -13
- 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 +634 -713
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -4
- package/dist/entry/rsc-prod.js +242 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
- package/dist/env-Cz8frh6e.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js +545 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
- package/dist/getClassName-DGm-VNDo.js.map +1 -0
- package/dist/getClassName-Dtc4yyYI.js +47 -0
- package/dist/getClassName-Dtc4yyYI.js.map +1 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
- package/dist/getClassName-DtkplEIt.js.map +1 -0
- package/dist/global-CAc9OjKx.js +14 -0
- package/dist/global-CAc9OjKx.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +10 -8
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-CVxpkS04.js +39 -0
- package/dist/jsx-CVxpkS04.js.map +1 -0
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
- package/dist/{loader-DS61nRqr.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-B9kqEb2N.mjs → misc-B76PUnWe.mjs} +11 -6
- package/dist/misc-B76PUnWe.mjs.map +1 -0
- package/dist/namedTokens-5AayGokX.js +85 -0
- package/dist/namedTokens-5AayGokX.js.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +121 -17
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- 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 +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +13 -10
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +995 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/presets-DSanixJV.js +243 -0
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-CyIj8LYK.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-CyIj8LYK.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
- package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
- package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
- package/dist/rules-DaMaMHgb.js.map +1 -0
- package/dist/scope-CZdGAnl_.js +601 -0
- package/dist/scope-CZdGAnl_.js.map +1 -0
- package/dist/selector/index.js +2 -3
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CCpq1zqA.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CCpq1zqA.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-BAL9peIw.cjs → shared-PK52rW6T.cjs} +2352 -644
- package/dist/shared-PK52rW6T.cjs.map +1 -0
- package/dist/sheet-CxkO1Hwt.js +7 -0
- package/dist/sheet-CxkO1Hwt.js.map +1 -0
- package/dist/{sidecar-4u6GnlQG.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-4u6GnlQG.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
- package/dist/style-CAhAnRni.js +1129 -0
- package/dist/style-CAhAnRni.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
- package/dist/styleStore-BzLZwpwy.js.map +1 -0
- package/dist/styleStore-DaIJ4OPV.js +58 -0
- package/dist/styleStore-DaIJ4OPV.js.map +1 -0
- package/dist/token-D33mKTka.js +138 -0
- package/dist/token-D33mKTka.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
- package/dist/transform-DSpimwwC.js +23 -0
- package/dist/transform-DSpimwwC.js.map +1 -0
- package/dist/{utils-DMFgOOtA.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-DMFgOOtA.mjs.map → utils-DND33M6y.mjs.map} +1 -1
- package/dist/utils-DZK0mfmY.js +42 -0
- package/dist/utils-DZK0mfmY.js.map +1 -0
- package/dist/utils-D_XgtMtn.js +72 -0
- package/dist/utils-D_XgtMtn.js.map +1 -0
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
- package/dist/utils-H1VInWpd.js.map +1 -0
- package/dist/utils-NdisireF.mjs +182 -0
- package/dist/utils-NdisireF.mjs.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CK0-Xbov.js +160 -0
- package/dist/value-CK0-Xbov.js.map +1 -0
- package/dist/{webpack-CxS2FDYU.mjs → webpack-D7QO0bKN.mjs} +5 -5
- package/dist/webpack-D7QO0bKN.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +4 -2
- package/entry/rsc_dev/adapter/preact.ts +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -0
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +14 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/jsx/types/index.ts +1 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +118 -18
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +5 -9
- package/plugin/bundler/vite/state.ts +12 -7
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +208 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +121 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +15 -2
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +239 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +436 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/adapter/utils.ts +120 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +16 -31
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +55 -23
- package/runtime/extract/index.ts +4 -2
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/index.ts +8 -1
- package/runtime/rsc/getClassName.ts +4 -0
- package/runtime/rsc/observer.ts +4 -0
- package/runtime/rsc/styleStore.ts +18 -7
- package/runtime/sheet/rule.ts +16 -12
- package/runtime/sheet/rules.ts +8 -3
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +6 -4
- package/selector/assert.ts +24 -25
- package/selector/selector.ts +6 -0
- package/sheet/dev/dev_layer.ts +18 -7
- package/sheet/dev/dev_sort.ts +45 -11
- package/sheet/prod.ts +18 -7
- package/sheet/types.ts +2 -0
- package/sheet/utils/layer.ts +33 -0
- package/style/classname.ts +47 -0
- package/style/important.ts +19 -0
- package/style/index.ts +3 -0
- package/style/style.ts +47 -16
- package/style/theme.ts +4 -3
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +41 -2
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/hash.ts +4 -0
- package/utils/symbol.ts +3 -0
- package/atomic/layer/README.md +0 -116
- package/atomic/utils/css.ts +0 -49
- package/dist/assert-h_Zkqc4E.js +0 -105
- package/dist/assert-h_Zkqc4E.js.map +0 -1
- package/dist/className-C1Ht5Wvv.js +0 -144
- package/dist/className-C1Ht5Wvv.js.map +0 -1
- package/dist/className-DC2Cq8p3.js +0 -251
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DweanHoB.mjs.map +0 -1
- package/dist/config-BryWDfQX.js +0 -25
- package/dist/config-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js +0 -243
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js +0 -805
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js +0 -235
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/css_extra-DlOnsnR1.js +0 -8
- package/dist/css_extra-oIi3UEPK.js.map +0 -1
- package/dist/data-_te7t0M4.js +0 -473
- package/dist/data-_te7t0M4.js.map +0 -1
- package/dist/debug-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-CcphAa3R.js.map +0 -1
- package/dist/dev-DfBbuLeE.js +0 -71
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/global-CvfmFLsK.js.map +0 -1
- package/dist/jsx-CwTeyUxr.js +0 -39
- package/dist/jsx-CwTeyUxr.js.map +0 -1
- package/dist/jsx-D2BksHSv.js +0 -38
- package/dist/jsx-D2BksHSv.js.map +0 -1
- package/dist/layer-D1SaH07m.js +0 -94
- package/dist/layer-D1SaH07m.js.map +0 -1
- package/dist/loader-DS61nRqr.mjs.map +0 -1
- package/dist/misc-B9kqEb2N.mjs.map +0 -1
- package/dist/presets-Bye3ea2x.js +0 -139
- package/dist/presets-Bye3ea2x.js.map +0 -1
- package/dist/property-CnLFt5kx.js +0 -406
- package/dist/property-CnLFt5kx.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-BAL9peIw.cjs.map +0 -1
- package/dist/style-4rFUy-zW.js +0 -752
- package/dist/style-4rFUy-zW.js.map +0 -1
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-Cw3NtvR0.js +0 -5
- package/dist/style-DNqQ6H-7.js +0 -1255
- package/dist/style-DNqQ6H-7.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/styleStore-DyNXBcUK.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-u_tM-mtg.js +0 -204
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/utils-C7xfDxtM.mjs +0 -97
- package/dist/utils-C7xfDxtM.mjs.map +0 -1
- package/dist/utils-CWNHx4EC.js +0 -170
- package/dist/utils-CWNHx4EC.js.map +0 -1
- package/dist/utils-D7FAOyg6.js.map +0 -1
- package/dist/value-BR4e2MKt.js +0 -910
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
- package/dist/valueRef-lshFk1Cs.js +0 -16
- package/dist/valueRef-lshFk1Cs.js.map +0 -1
- package/dist/webpack-CxS2FDYU.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
package/sheet/dev/dev_sort.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { compareLayerPriority, getLayerOrderCss, type LayerPriority } from '../../atomic/layer';
|
|
2
|
-
import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../../config/config/css';
|
|
2
|
+
import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../../config/config/css';
|
|
3
3
|
import { DEV_CONFIG } from '../../config/config/dev';
|
|
4
4
|
import type { SheetOptions, SheetRule, StyleSheet } from '../types';
|
|
5
5
|
import {
|
|
6
6
|
createNoopSheet,
|
|
7
7
|
createStyleTag,
|
|
8
|
+
getSheetLayerName,
|
|
8
9
|
getSheetRulePriority,
|
|
9
10
|
getStyleLayerName,
|
|
10
11
|
insertStyleTagAfter,
|
|
@@ -18,12 +19,14 @@ type QueuedRule = {
|
|
|
18
19
|
css: string;
|
|
19
20
|
rule: SheetRule | null;
|
|
20
21
|
priority: LayerPriority;
|
|
22
|
+
layer: 'style' | 'sheet' | false;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
type SortGroup = {
|
|
24
26
|
key: string;
|
|
25
27
|
priority: LayerPriority;
|
|
26
28
|
tags: DevRuleTag[];
|
|
29
|
+
layer: 'style' | 'sheet' | false;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
@@ -36,12 +39,13 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
36
39
|
const inserted = new Set<string>();
|
|
37
40
|
const queued: QueuedRule[] = [];
|
|
38
41
|
const groups: SortGroup[] = [];
|
|
39
|
-
const shouldLayer =
|
|
42
|
+
const shouldLayer = isStyleLayerEnabled();
|
|
40
43
|
const layerName = getStyleLayerName();
|
|
41
44
|
const tagPrefix = options.tagName ? options.tagName + ' ' : '';
|
|
42
|
-
|
|
45
|
+
let layerTag = shouldLayer ? createStyleTag(document, tagPrefix + 'layers', options.nonce) : null;
|
|
43
46
|
let activeLayers: readonly string[] = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
|
|
44
47
|
let layerText = '';
|
|
48
|
+
let hasSheetLayer = false;
|
|
45
49
|
|
|
46
50
|
if (layerTag) {
|
|
47
51
|
if (options.top) {
|
|
@@ -68,12 +72,21 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
68
72
|
if (key && inserted.has(key)) return;
|
|
69
73
|
if (key) inserted.add(key);
|
|
70
74
|
|
|
75
|
+
const requestedLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
|
|
76
|
+
const layer = requestedLayer === 'style' && !shouldLayer ? false : requestedLayer;
|
|
77
|
+
if (layer === 'sheet') {
|
|
78
|
+
hasSheetLayer = true;
|
|
79
|
+
ensureLayerTag();
|
|
80
|
+
updateLayerText();
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
queued.push({
|
|
72
84
|
css,
|
|
73
85
|
rule: typeof rule === 'string' ? null : rule,
|
|
74
86
|
priority: getSheetRulePriority(
|
|
75
87
|
typeof rule === 'string' ? null : rule.priority,
|
|
76
88
|
),
|
|
89
|
+
layer,
|
|
77
90
|
});
|
|
78
91
|
},
|
|
79
92
|
|
|
@@ -104,7 +117,7 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
104
117
|
|
|
105
118
|
for (let i = 0, len = queued.length; i < len; i++) {
|
|
106
119
|
const item = queued[i];
|
|
107
|
-
const group = ensureGroup(groups, item.priority);
|
|
120
|
+
const group = ensureGroup(groups, item.priority, item.layer);
|
|
108
121
|
let active = group.tags[group.tags.length - 1] ?? null;
|
|
109
122
|
|
|
110
123
|
if (!active || active.count >= maxRules) {
|
|
@@ -113,7 +126,11 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
113
126
|
previous: layerTag,
|
|
114
127
|
className: tagPrefix + 'rules ' + group.key,
|
|
115
128
|
top: options.top,
|
|
116
|
-
layerName:
|
|
129
|
+
layerName: group.layer === 'style'
|
|
130
|
+
? layerName
|
|
131
|
+
: group.layer === 'sheet'
|
|
132
|
+
? getSheetLayerName()
|
|
133
|
+
: null,
|
|
117
134
|
sourcemap,
|
|
118
135
|
nonce: options.nonce,
|
|
119
136
|
});
|
|
@@ -146,41 +163,58 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
146
163
|
function updateLayerText() {
|
|
147
164
|
if (!layerTag) return;
|
|
148
165
|
|
|
149
|
-
const
|
|
166
|
+
const names = [shouldLayer ? layerName : '', hasSheetLayer ? getSheetLayerName() : ''].filter(Boolean);
|
|
167
|
+
const next = getLayerOrderCss(activeLayers, names);
|
|
150
168
|
|
|
151
169
|
if (next === layerText) return;
|
|
152
170
|
|
|
153
171
|
layerText = next;
|
|
154
172
|
layerTag.textContent = next;
|
|
155
173
|
}
|
|
174
|
+
|
|
175
|
+
function ensureLayerTag() {
|
|
176
|
+
if (layerTag) return;
|
|
177
|
+
|
|
178
|
+
layerTag = createStyleTag(document!, tagPrefix + 'layers', options.nonce);
|
|
179
|
+
if (options.top) {
|
|
180
|
+
insertStyleTagAtTop(document!, layerTag);
|
|
181
|
+
} else {
|
|
182
|
+
insertStyleTagAfter(document!, layerTag, null);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
156
185
|
}
|
|
157
186
|
|
|
158
187
|
function ensureGroup(
|
|
159
188
|
groups: SortGroup[],
|
|
160
189
|
priority: LayerPriority,
|
|
190
|
+
layer: 'style' | 'sheet' | false,
|
|
161
191
|
) {
|
|
162
|
-
const key = getPriorityKey(priority);
|
|
192
|
+
const key = (layer === 'sheet' ? 'sheet-' : '') + getPriorityKey(priority);
|
|
163
193
|
|
|
164
194
|
for (let i = 0, len = groups.length; i < len; i++) {
|
|
165
195
|
const group = groups[i];
|
|
166
|
-
const order = compareLayerPriority(priority, group.priority);
|
|
196
|
+
const order = getLayerRank(layer) - getLayerRank(group.layer) || compareLayerPriority(priority, group.priority);
|
|
167
197
|
|
|
168
|
-
if (order === 0) return group;
|
|
198
|
+
if (order === 0 && layer === group.layer) return group;
|
|
169
199
|
|
|
170
200
|
if (order < 0) {
|
|
171
|
-
const next = { key, priority, tags: [] };
|
|
201
|
+
const next = { key, priority, tags: [], layer };
|
|
172
202
|
groups.splice(i, 0, next);
|
|
173
203
|
return next;
|
|
174
204
|
}
|
|
175
205
|
}
|
|
176
206
|
|
|
177
|
-
const group = { key, priority, tags: [] };
|
|
207
|
+
const group = { key, priority, tags: [], layer };
|
|
178
208
|
|
|
179
209
|
groups.push(group);
|
|
180
210
|
|
|
181
211
|
return group;
|
|
182
212
|
}
|
|
183
213
|
|
|
214
|
+
function getLayerRank(layer: 'style' | 'sheet' | false) {
|
|
215
|
+
return layer === 'style' ? 0 : layer === 'sheet' ? 1 : 2;
|
|
216
|
+
}
|
|
217
|
+
|
|
184
218
|
function createGroupTag(
|
|
185
219
|
document: Document,
|
|
186
220
|
groups: SortGroup[],
|
package/sheet/prod.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getLayerBlockCss, getLayerOrderCss } from '../atomic/layer';
|
|
2
|
-
import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../config/config/css';
|
|
2
|
+
import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../config/config/css';
|
|
3
3
|
import type { SheetOptions, StyleSheet } from './types';
|
|
4
4
|
import {
|
|
5
5
|
createNoopSheet,
|
|
6
6
|
createSheetLayerState,
|
|
7
7
|
createStyleTag,
|
|
8
|
-
|
|
8
|
+
getSheetLayerName,
|
|
9
|
+
getSheetLayerNames,
|
|
10
|
+
getSheetRuleLayerPriority,
|
|
9
11
|
insertStyleTagAfter,
|
|
10
12
|
normalizeRule,
|
|
11
13
|
resolveDocument,
|
|
@@ -24,12 +26,13 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
24
26
|
let layerText = '';
|
|
25
27
|
let layerTag: HTMLStyleElement | null = null;
|
|
26
28
|
let ruleTag: HTMLStyleElement | null = null;
|
|
29
|
+
let hasSheetLayer = false;
|
|
27
30
|
|
|
28
31
|
return {
|
|
29
32
|
updateLayers(layers) {
|
|
30
33
|
activeLayers = layers;
|
|
31
34
|
|
|
32
|
-
const next = getLayerOrderCss(layers, layerState
|
|
35
|
+
const next = getLayerOrderCss(layers, getSheetLayerNames(layerState, hasSheetLayer));
|
|
33
36
|
if (next === layerText) return;
|
|
34
37
|
|
|
35
38
|
layerText = next;
|
|
@@ -43,12 +46,20 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
43
46
|
|
|
44
47
|
if (ruleKey && inserted.has(ruleKey)) return;
|
|
45
48
|
|
|
46
|
-
const priority = typeof rule === 'string'
|
|
47
|
-
|
|
49
|
+
const priority = typeof rule === 'string'
|
|
50
|
+
? getSheetRuleLayerPriority(null, false)
|
|
51
|
+
: getSheetRuleLayerPriority(rule.priority, rule.important);
|
|
52
|
+
const ruleLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
|
|
53
|
+
if (ruleLayer === 'sheet') hasSheetLayer = true;
|
|
54
|
+
const layerName = ruleLayer === 'sheet'
|
|
55
|
+
? getSheetLayerName()
|
|
56
|
+
: ruleLayer === false || !isStyleLayerEnabled()
|
|
57
|
+
? null
|
|
58
|
+
: layerState.getName(priority);
|
|
48
59
|
|
|
49
60
|
const nextLayerText = getLayerOrderCss(
|
|
50
61
|
activeLayers,
|
|
51
|
-
layerState
|
|
62
|
+
getSheetLayerNames(layerState, hasSheetLayer),
|
|
52
63
|
);
|
|
53
64
|
|
|
54
65
|
if (nextLayerText !== layerText) {
|
|
@@ -57,7 +68,7 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
57
68
|
layerTag.textContent = nextLayerText;
|
|
58
69
|
}
|
|
59
70
|
|
|
60
|
-
const css = getLayerBlockCss(layerName, rawCss);
|
|
71
|
+
const css = layerName ? getLayerBlockCss(layerName, rawCss) : rawCss;
|
|
61
72
|
const key = typeof rule === 'string' ? css : ruleKey;
|
|
62
73
|
|
|
63
74
|
if (key && inserted.has(key)) return;
|
package/sheet/types.ts
CHANGED
package/sheet/utils/layer.ts
CHANGED
|
@@ -9,6 +9,39 @@ export function getSheetRulePriority(priority: LayerPriority | null | undefined)
|
|
|
9
9
|
return priority ?? LayerDefaultPriority;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function getSheetRuleLayerPriority(
|
|
13
|
+
priority: LayerPriority | null | undefined,
|
|
14
|
+
important: boolean | null | undefined,
|
|
15
|
+
): LayerPriority {
|
|
16
|
+
const resolved = getSheetRulePriority(priority);
|
|
17
|
+
|
|
18
|
+
// Cascade layer order is reversed for important declarations. Mirror the
|
|
19
|
+
// atomic priority so a higher Fluentic priority still wins in that cascade.
|
|
20
|
+
return important
|
|
21
|
+
? [
|
|
22
|
+
-resolved[0],
|
|
23
|
+
-resolved[1],
|
|
24
|
+
-resolved[2],
|
|
25
|
+
-resolved[3],
|
|
26
|
+
-resolved[4],
|
|
27
|
+
-resolved[5],
|
|
28
|
+
-resolved[6],
|
|
29
|
+
]
|
|
30
|
+
: resolved;
|
|
31
|
+
}
|
|
32
|
+
|
|
12
33
|
export function getStyleLayerName() {
|
|
13
34
|
return CSS_CONFIG.layerNamespace || LayerDefaultNamespace;
|
|
14
35
|
}
|
|
36
|
+
|
|
37
|
+
export function getSheetLayerName() {
|
|
38
|
+
return getStyleLayerName() + '.sheet';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getSheetLayerNames(
|
|
42
|
+
layerState: ReturnType<typeof createSheetLayerState>,
|
|
43
|
+
hasSheetLayer: boolean,
|
|
44
|
+
) {
|
|
45
|
+
const names = layerState.getNames();
|
|
46
|
+
return hasSheetLayer ? names.concat(getSheetLayerName()) : names;
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClassNameFn,
|
|
3
|
+
createClassNameBuilder,
|
|
4
|
+
type ImportantClassName,
|
|
5
|
+
type WeightedClassName,
|
|
6
|
+
} from '../builder/classname';
|
|
7
|
+
import type { SelectorsRecord } from '../builder/types';
|
|
8
|
+
import { PrioritySelectors } from '../selector/presets';
|
|
9
|
+
import type { Type } from '../utils/type';
|
|
10
|
+
import { assignStyleFnMeta } from './style';
|
|
11
|
+
import type { ClassNameTransform } from './transform';
|
|
12
|
+
|
|
13
|
+
export type { ClassNameBuilder, ClassNameFn, ClassNameItem, WeightedClassName } from '../builder/classname';
|
|
14
|
+
export type { ClassNameTransform } from './transform';
|
|
15
|
+
|
|
16
|
+
type InferClassName<Transform> = Transform extends ClassNameTransform<infer ClassName> ? ClassName : never;
|
|
17
|
+
|
|
18
|
+
export function createClassNameFn<
|
|
19
|
+
const Selectors extends SelectorsRecord = typeof PrioritySelectors,
|
|
20
|
+
const Transform extends ClassNameTransform<any> = ClassNameTransform<string>,
|
|
21
|
+
ClassName extends string = InferClassName<Transform>,
|
|
22
|
+
>(args: {
|
|
23
|
+
className?: Type<ClassName>;
|
|
24
|
+
selectors: Selectors;
|
|
25
|
+
transform: Transform;
|
|
26
|
+
}) {
|
|
27
|
+
const { selectors, transform } = args;
|
|
28
|
+
|
|
29
|
+
const fnClassName = createClassNameBuilder<ClassName, Selectors>(selectors, transform);
|
|
30
|
+
const className = fnClassName as ClassNameFn<ClassName, Selectors>;
|
|
31
|
+
|
|
32
|
+
className.weight = (className, weight): WeightedClassName<ClassName> => {
|
|
33
|
+
return { className, weight };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
className.important = (className): ImportantClassName<ClassName> => {
|
|
37
|
+
return { className, important: true };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
assignStyleFnMeta(className, {
|
|
41
|
+
mode: 'ClassName',
|
|
42
|
+
selectors,
|
|
43
|
+
transform,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return { className };
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { symbol } from '../utils/symbol';
|
|
2
|
+
|
|
3
|
+
const STYLE_IMPORTANT: unique symbol = symbol('style.important');
|
|
4
|
+
|
|
5
|
+
export type StyleImportantValue<T = unknown> = {
|
|
6
|
+
readonly [STYLE_IMPORTANT]: true;
|
|
7
|
+
readonly value: T;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function importantValue<T>(value: T): StyleImportantValue<T> {
|
|
11
|
+
return {
|
|
12
|
+
[STYLE_IMPORTANT]: true,
|
|
13
|
+
value,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isStyleImportantValue(value: unknown): value is StyleImportantValue {
|
|
18
|
+
return !!value && typeof value === 'object' && (value as StyleImportantValue)[STYLE_IMPORTANT] === true;
|
|
19
|
+
}
|
package/style/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './classname';
|
|
2
|
+
export * from './important';
|
|
1
3
|
export * from './keyframes';
|
|
2
4
|
export * from './style';
|
|
3
5
|
export * from './theme';
|
|
@@ -7,3 +9,4 @@ export * from './transform';
|
|
|
7
9
|
export * from './types';
|
|
8
10
|
export * from './value';
|
|
9
11
|
export * from './valueRef';
|
|
12
|
+
export * from './weight';
|
package/style/style.ts
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createScopeBuilder,
|
|
3
|
+
createSelectorBuilder,
|
|
4
|
+
createSlotBuilder,
|
|
5
|
+
createStyleBuilder,
|
|
6
|
+
type SelectorsRecord,
|
|
7
|
+
} from '../builder';
|
|
8
|
+
import type { ClassNameFn } from '../builder/classname';
|
|
2
9
|
import { isStyleData } from '../builder/data';
|
|
3
10
|
import { mergeStyleData } from '../builder/style_data';
|
|
4
11
|
import { createDefaultFnResult } from '../builder/style_fns';
|
|
5
12
|
import type { typeAliases } from '../builder/types/alias';
|
|
6
13
|
import type { StableIdInput } from '../css/utils';
|
|
7
14
|
import { PrioritySelectors } from '../selector/presets';
|
|
8
|
-
import { symbol } from '../utils/
|
|
15
|
+
import { symbol } from '../utils/symbol';
|
|
9
16
|
import { type } from '../utils/type';
|
|
10
17
|
import type { Type } from '../utils/type';
|
|
18
|
+
import { importantValue } from './important';
|
|
11
19
|
import { createStyleKeyframes } from './keyframes';
|
|
12
|
-
import type { StyleTransform } from './transform';
|
|
20
|
+
import type { ClassNameTransform, StyleTransform } from './transform';
|
|
13
21
|
import type { CSSProperties } from './types';
|
|
22
|
+
import { weightValue } from './weight';
|
|
14
23
|
|
|
15
24
|
const META: unique symbol = symbol('style.fn:meta');
|
|
16
25
|
|
|
17
|
-
export type StyleFnMeta =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
export type StyleFnMeta =
|
|
27
|
+
| {
|
|
28
|
+
mode: 'StyleObject';
|
|
29
|
+
selectors: SelectorsRecord;
|
|
30
|
+
transform: StyleTransform | null;
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
mode: 'ClassName';
|
|
34
|
+
selectors: SelectorsRecord;
|
|
35
|
+
transform: ClassNameTransform;
|
|
36
|
+
};
|
|
21
37
|
|
|
22
38
|
export const { style } = createStyleFn({
|
|
23
39
|
style: type<CSSProperties>,
|
|
@@ -29,10 +45,10 @@ export type StyleFn<Style = any, Selectors extends SelectorsRecord = any> = Retu
|
|
|
29
45
|
>['style'];
|
|
30
46
|
|
|
31
47
|
export function createStyleFn<
|
|
32
|
-
Style,
|
|
33
|
-
const Selectors extends SelectorsRecord,
|
|
48
|
+
Style = CSSProperties,
|
|
49
|
+
const Selectors extends SelectorsRecord = typeof PrioritySelectors,
|
|
34
50
|
>(args: {
|
|
35
|
-
style
|
|
51
|
+
style?: Type<Style>;
|
|
36
52
|
selectors: Selectors;
|
|
37
53
|
transform?: StyleTransform<Style> | null;
|
|
38
54
|
}) {
|
|
@@ -42,11 +58,13 @@ export function createStyleFn<
|
|
|
42
58
|
|
|
43
59
|
const fnStyle = createStyleBuilder<Style, Selectors>(selectors, transform);
|
|
44
60
|
const fnSlot = createSlotBuilder<Style, Selectors>(selectors, transform);
|
|
45
|
-
const fnScope = createScopeBuilder<
|
|
61
|
+
const fnScope = createScopeBuilder<Selectors>(selectors);
|
|
62
|
+
const fnSelector = createSelectorBuilder<Style, Selectors>(selectors, transform);
|
|
46
63
|
|
|
47
|
-
const
|
|
48
|
-
return
|
|
64
|
+
const fnWeight: Types['ValueFn'] = (value, weight) => {
|
|
65
|
+
return weightValue(value, weight);
|
|
49
66
|
};
|
|
67
|
+
const fnImportant: Types['ImportantFn'] = (value) => importantValue(value);
|
|
50
68
|
const fnRaw: Types['RawFn'] = (style) => style;
|
|
51
69
|
const fnPlain: Types['PlainFn'] = (style) => style;
|
|
52
70
|
const fnKeyframes: Types['KeyframesFn'] =
|
|
@@ -67,18 +85,21 @@ export function createStyleFn<
|
|
|
67
85
|
|
|
68
86
|
style.slot = fnSlot;
|
|
69
87
|
style.scope = fnScope;
|
|
70
|
-
style.
|
|
88
|
+
style.weight = fnWeight;
|
|
89
|
+
style.important = fnImportant;
|
|
71
90
|
style.raw = fnRaw;
|
|
72
91
|
style.plain = fnPlain;
|
|
73
92
|
style.keyframes = fnKeyframes;
|
|
74
93
|
style.merge = fnMerge;
|
|
94
|
+
style.selector = fnSelector as Types['SelectorFn'];
|
|
75
95
|
|
|
76
96
|
const meta: StyleFnMeta = {
|
|
97
|
+
mode: 'StyleObject',
|
|
77
98
|
selectors,
|
|
78
99
|
transform: transform ?? null,
|
|
79
100
|
};
|
|
80
101
|
|
|
81
|
-
|
|
102
|
+
assignStyleFnMeta(style, meta);
|
|
82
103
|
|
|
83
104
|
return { style };
|
|
84
105
|
}
|
|
@@ -107,6 +128,16 @@ function mergeStyleResult(
|
|
|
107
128
|
return target;
|
|
108
129
|
}
|
|
109
130
|
|
|
110
|
-
export
|
|
131
|
+
export type StyleFnWithMeta = StyleFn | ClassNameFn<any, any>;
|
|
132
|
+
|
|
133
|
+
export function assignStyleFnMeta<T extends object>(
|
|
134
|
+
styleFn: T,
|
|
135
|
+
meta: StyleFnMeta,
|
|
136
|
+
) {
|
|
137
|
+
Object.assign(styleFn, { [META]: meta });
|
|
138
|
+
return styleFn;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function getStyleFnMeta(styleFn: StyleFnWithMeta) {
|
|
111
142
|
return (styleFn as any)[META] as StyleFnMeta;
|
|
112
143
|
}
|
package/style/theme.ts
CHANGED
|
@@ -8,19 +8,20 @@ import type { StyleTokenOverride } from './token';
|
|
|
8
8
|
|
|
9
9
|
const idCounter = createIdCounter('theme');
|
|
10
10
|
|
|
11
|
+
export type TokenTheme = ThemeData;
|
|
12
|
+
|
|
11
13
|
export function resetStyleThemeIdCounter() {
|
|
12
14
|
idCounter.value = 0;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export function createTheme(
|
|
16
18
|
tokens: readonly StyleTokenOverride[],
|
|
17
|
-
|
|
18
|
-
): ThemeData;
|
|
19
|
+
): TokenTheme;
|
|
19
20
|
export function createTheme(
|
|
20
21
|
tokens: readonly StyleTokenOverride[],
|
|
21
22
|
stableId?: StableId | string,
|
|
22
23
|
callsite?: BuilderCallsite | null,
|
|
23
|
-
):
|
|
24
|
+
): TokenTheme {
|
|
24
25
|
const normalizedStableId = typeof stableId === 'string'
|
|
25
26
|
? { name: stableId, id: stableId }
|
|
26
27
|
: stableId;
|
package/style/token.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import type { DebugData } from '../builder/data/debug';
|
|
2
|
-
import {
|
|
2
|
+
import { getStyleTokenId, getStyleTokenName, isStyleTokenData } from '../builder/token/data';
|
|
3
|
+
import { getStyleTokenNameFromId, normalizeStyleTokenName } from '../builder/token/name';
|
|
4
|
+
import { globalData } from '../utils/global';
|
|
5
|
+
import { symbol } from '../utils/symbol';
|
|
6
|
+
export {
|
|
7
|
+
getStyleTokenId,
|
|
8
|
+
getStyleTokenName,
|
|
9
|
+
getStyleTokenVarName,
|
|
10
|
+
isStyleTokenData,
|
|
11
|
+
isStyleTokenOverrideData,
|
|
12
|
+
} from '../builder/token/data';
|
|
13
|
+
export { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
|
|
14
|
+
import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
|
|
3
15
|
|
|
4
|
-
export const TOKEN_ID: unique symbol = symbol('style:token');
|
|
5
|
-
export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
|
|
6
16
|
export const TOKEN_DEBUG: unique symbol = symbol('style:token.debug');
|
|
7
17
|
|
|
8
18
|
export type StyleTokenData<T = unknown> = {
|
|
9
19
|
[TOKEN_ID]: string;
|
|
20
|
+
[TOKEN_NAME]?: string | null;
|
|
21
|
+
[TOKEN_VAR_NAME]?: string | null;
|
|
10
22
|
[TOKEN_OVERRIDE]?: false;
|
|
11
23
|
value: T;
|
|
12
24
|
ref: StyleTokenData<T> | null;
|
|
@@ -16,6 +28,8 @@ export type StyleTokenOverride<T = unknown> = {
|
|
|
16
28
|
[TOKEN_ID]: string;
|
|
17
29
|
[TOKEN_OVERRIDE]: true;
|
|
18
30
|
[TOKEN_DEBUG]?: DebugData | null;
|
|
31
|
+
[TOKEN_NAME]?: string | null;
|
|
32
|
+
[TOKEN_VAR_NAME]?: string | null;
|
|
19
33
|
value: T;
|
|
20
34
|
ref: StyleTokenData<T> | null;
|
|
21
35
|
};
|
|
@@ -30,12 +44,17 @@ export function resetStyleTokenIdCounter() {
|
|
|
30
44
|
idCounter.value = 0;
|
|
31
45
|
}
|
|
32
46
|
|
|
33
|
-
export function createStyleToken<T>(
|
|
47
|
+
export function createStyleToken<T>(
|
|
48
|
+
value: T | StyleToken<T>,
|
|
49
|
+
stableId?: string,
|
|
50
|
+
debugName?: string | null,
|
|
51
|
+
) {
|
|
34
52
|
const token: StyleToken<T> = (value, debug) => {
|
|
35
53
|
return createStyleTokenOverride(token, value, debug);
|
|
36
54
|
};
|
|
37
55
|
|
|
38
|
-
token[TOKEN_ID] =
|
|
56
|
+
token[TOKEN_ID] = stableId || String(idCounter.value++);
|
|
57
|
+
token[TOKEN_NAME] = debugName === undefined ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
|
|
39
58
|
|
|
40
59
|
if (isStyleTokenData<T>(value)) {
|
|
41
60
|
token.value = value.value;
|
|
@@ -57,12 +76,14 @@ export function createStyleTokenOverride<T>(
|
|
|
57
76
|
? {
|
|
58
77
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
59
78
|
[TOKEN_OVERRIDE]: true,
|
|
79
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
60
80
|
value: value.value,
|
|
61
81
|
ref: value,
|
|
62
82
|
}
|
|
63
83
|
: {
|
|
64
84
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
65
85
|
[TOKEN_OVERRIDE]: true,
|
|
86
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
66
87
|
value: value as T,
|
|
67
88
|
ref: null,
|
|
68
89
|
};
|
|
@@ -83,19 +104,3 @@ export function getStyleTokenOverrideDebug(
|
|
|
83
104
|
) {
|
|
84
105
|
return token[TOKEN_DEBUG] ?? null;
|
|
85
106
|
}
|
|
86
|
-
|
|
87
|
-
export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
|
|
88
|
-
return !!value &&
|
|
89
|
-
typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
|
|
90
|
-
(value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
|
|
94
|
-
return !!value &&
|
|
95
|
-
typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
|
|
96
|
-
(value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
|
|
100
|
-
return token[TOKEN_ID];
|
|
101
|
-
}
|
package/style/tokens.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { getChildStyleTokenName } from '../builder/token/name';
|
|
1
2
|
import type { StyleToken } from './token';
|
|
2
|
-
import {
|
|
3
|
+
import { createStyleToken } from './token';
|
|
4
|
+
import type { InferValue, ValueBase } from './value';
|
|
3
5
|
|
|
4
6
|
export type TokenTuple<T extends readonly ValueBase[]> = {
|
|
5
7
|
[P in T[number]]: StyleToken<InferValue<P>>;
|
|
@@ -14,25 +16,27 @@ export type TokenRecord<T extends object> = {
|
|
|
14
16
|
|
|
15
17
|
export function createTokens<const T extends readonly ValueBase[]>(
|
|
16
18
|
values: T,
|
|
17
|
-
debugId?: string,
|
|
18
19
|
): TokenTuple<T>;
|
|
19
20
|
export function createTokens<T extends object>(
|
|
20
21
|
values: T,
|
|
21
|
-
debugId?: string,
|
|
22
22
|
): TokenRecord<T>;
|
|
23
23
|
export function createTokens(
|
|
24
24
|
values: readonly ValueBase[] | Record<PropertyKey, unknown>,
|
|
25
|
-
|
|
25
|
+
stableId?: string,
|
|
26
26
|
): any {
|
|
27
27
|
const tokens: Record<PropertyKey, StyleToken> = {};
|
|
28
28
|
|
|
29
29
|
if (Array.isArray(values)) {
|
|
30
30
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
31
31
|
const value = values[i];
|
|
32
|
-
tokens[value] =
|
|
32
|
+
tokens[value] = createStyleToken(
|
|
33
|
+
value,
|
|
34
|
+
getChildStableId(stableId, String(i)),
|
|
35
|
+
getChildStyleTokenName(stableId, String(i)),
|
|
36
|
+
);
|
|
33
37
|
}
|
|
34
38
|
} else {
|
|
35
|
-
assignTokenRecord(tokens, values as Record<PropertyKey, unknown>,
|
|
39
|
+
assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, stableId, stableId ?? null);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
return tokens;
|
|
@@ -41,24 +45,26 @@ export function createTokens(
|
|
|
41
45
|
function assignTokenRecord(
|
|
42
46
|
target: Record<PropertyKey, unknown>,
|
|
43
47
|
values: Record<PropertyKey, unknown>,
|
|
44
|
-
|
|
48
|
+
stableId: string | undefined,
|
|
49
|
+
debugName: string | null,
|
|
45
50
|
) {
|
|
46
51
|
for (let key in values) {
|
|
47
52
|
const value = values[key];
|
|
53
|
+
const childName = getChildStyleTokenName(debugName, key);
|
|
48
54
|
|
|
49
55
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
50
56
|
const child: Record<PropertyKey, unknown> = {};
|
|
51
57
|
target[key] = child;
|
|
52
|
-
assignTokenRecord(child, value as Record<PropertyKey, unknown>,
|
|
58
|
+
assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildStableId(stableId, key), childName);
|
|
53
59
|
} else {
|
|
54
|
-
target[key] =
|
|
60
|
+
target[key] = createStyleToken(value, getChildStableId(stableId, key), childName);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
function
|
|
60
|
-
|
|
65
|
+
function getChildStableId(
|
|
66
|
+
stableId: string | undefined,
|
|
61
67
|
child: string,
|
|
62
68
|
) {
|
|
63
|
-
return
|
|
69
|
+
return stableId ? stableId + '--' + child : undefined;
|
|
64
70
|
}
|