@tenphi/tasty 0.0.0-snapshot.056b911
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/LICENSE +21 -0
- package/README.md +635 -0
- package/dist/_virtual/_rolldown/runtime.js +7 -0
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +77 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +258 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/index.d.ts +1 -0
- package/dist/chunks/renderChunk.d.ts +1 -0
- package/dist/chunks/renderChunk.js +59 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/compute-styles.d.ts +31 -0
- package/dist/compute-styles.js +335 -0
- package/dist/compute-styles.js.map +1 -0
- package/dist/config.d.ts +409 -0
- package/dist/config.js +584 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +34 -0
- package/dist/core/index.js +27 -0
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +89 -0
- package/dist/debug.js +453 -0
- package/dist/debug.js.map +1 -0
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useCounterStyle.d.ts +36 -0
- package/dist/hooks/useCounterStyle.js +64 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +45 -0
- package/dist/hooks/useFontFace.js +66 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +46 -0
- package/dist/hooks/useGlobalStyles.js +88 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +58 -0
- package/dist/hooks/useKeyframes.js +54 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +81 -0
- package/dist/hooks/useProperty.js +96 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +22 -0
- package/dist/hooks/useRawCSS.js +103 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +40 -0
- package/dist/hooks/useStyles.js +31 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +36 -0
- package/dist/injector/index.d.ts +182 -0
- package/dist/injector/index.js +185 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +193 -0
- package/dist/injector/injector.js +564 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/sheet-manager.d.ts +132 -0
- package/dist/injector/sheet-manager.js +698 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/types.d.ts +228 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/const.js +60 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +115 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/types.d.ts +51 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/pipeline/conditions.d.ts +134 -0
- package/dist/pipeline/conditions.js +406 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/exclusive.js +230 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/index.d.ts +55 -0
- package/dist/pipeline/index.js +708 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/materialize.js +1103 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +15 -0
- package/dist/pipeline/parseStateKey.js +446 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/simplify.js +515 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +97 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +87 -0
- package/dist/properties/index.js +222 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +90 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/rsc-cache.js +81 -0
- package/dist/rsc-cache.js.map +1 -0
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +24 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +15 -0
- package/dist/ssr/astro-middleware.js +19 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +106 -0
- package/dist/ssr/astro.js +149 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +44 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +58 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +102 -0
- package/dist/ssr/collector.js +227 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.js +16 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +69 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +49 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +73 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +22 -0
- package/dist/ssr/hydrate.js +49 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +4 -0
- package/dist/ssr/index.js +10 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +45 -0
- package/dist/ssr/next.js +75 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +29 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.d.ts +49 -0
- package/dist/states/index.js +170 -0
- package/dist/states/index.js.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +4 -0
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +30 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +120 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +26 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/const.js +17 -0
- package/dist/styles/const.js.map +1 -0
- package/dist/styles/createStyle.js +79 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/dimension.js +109 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/directional.js +133 -0
- package/dist/styles/directional.js.map +1 -0
- package/dist/styles/display.d.ts +30 -0
- package/dist/styles/display.js +73 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +62 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fill.d.ts +42 -0
- package/dist/styles/fill.js +51 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +38 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +19 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +8 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/inset.d.ts +24 -0
- package/dist/styles/inset.js +34 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +100 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +24 -0
- package/dist/styles/margin.js +32 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +55 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/padding.d.ts +24 -0
- package/dist/styles/padding.js +32 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/placement.d.ts +37 -0
- package/dist/styles/placement.js +74 -0
- package/dist/styles/placement.js.map +1 -0
- package/dist/styles/predefined.d.ts +71 -0
- package/dist/styles/predefined.js +237 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/preset.d.ts +52 -0
- package/dist/styles/preset.js +127 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/radius.d.ts +12 -0
- package/dist/styles/radius.js +83 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/scrollMargin.d.ts +24 -0
- package/dist/styles/scrollMargin.js +32 -0
- package/dist/styles/scrollMargin.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +25 -0
- package/dist/styles/scrollbar.js +51 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +25 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/shared.js +17 -0
- package/dist/styles/shared.js.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +159 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/types.d.ts +564 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +19 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/tasty.d.ts +134 -0
- package/dist/tasty.js +243 -0
- package/dist/tasty.js.map +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/cache-wrapper.js +21 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +228 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +10 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/css-types.d.ts +7 -0
- package/dist/utils/deps-equal.js +15 -0
- package/dist/utils/deps-equal.js.map +1 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/has-keys.js +13 -0
- package/dist/utils/has-keys.js.map +1 -0
- package/dist/utils/hash.js +14 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-valid-element-type.js +15 -0
- package/dist/utils/is-valid-element-type.js.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +145 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/mod-attrs.d.ts +6 -0
- package/dist/utils/mod-attrs.js +20 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/process-tokens.d.ts +17 -0
- package/dist/utils/process-tokens.js +83 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +146 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/styles.d.ts +99 -0
- package/dist/utils/styles.js +220 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/typography.d.ts +58 -0
- package/dist/utils/typography.js +51 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.ts +195 -0
- package/dist/zero/babel.js +456 -0
- package/dist/zero/babel.js.map +1 -0
- package/dist/zero/css-writer.d.ts +45 -0
- package/dist/zero/css-writer.js +73 -0
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/zero/extractor.d.ts +24 -0
- package/dist/zero/extractor.js +266 -0
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/index.js +3 -0
- package/dist/zero/next.d.ts +86 -0
- package/dist/zero/next.js +143 -0
- package/dist/zero/next.js.map +1 -0
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +298 -0
- package/docs/comparison.md +419 -0
- package/docs/configuration.md +389 -0
- package/docs/debug.md +318 -0
- package/docs/design-system.md +436 -0
- package/docs/dsl.md +688 -0
- package/docs/getting-started.md +217 -0
- package/docs/injector.md +544 -0
- package/docs/methodology.md +616 -0
- package/docs/react-api.md +557 -0
- package/docs/ssr.md +440 -0
- package/docs/styles.md +596 -0
- package/docs/tasty-static.md +532 -0
- package/package.json +221 -0
- package/tasty.config.ts +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimension.js","names":[],"sources":["../../src/styles/dimension.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nconst DEFAULT_MIN_SIZE = 'var(--gap)';\nconst DEFAULT_MAX_SIZE = '100%';\n\n/**\n * Parse a dimension value (string, number, or boolean) into a CSS value\n */\nfunction parseDimensionValue(\n val: string | number | boolean | undefined,\n): string | null {\n if (val == null) return null;\n if (typeof val === 'number') return `${val}px`;\n if (val === true) return 'initial';\n\n const processed = parseStyle(String(val));\n return processed.groups[0]?.values[0] || null;\n}\n\ninterface DimensionProps {\n value?: string | number | boolean;\n min?: string | number | boolean;\n max?: string | number | boolean;\n}\n\n/**\n * Creates a dimension style handler for width or height.\n *\n * Supports:\n * - Main dimension prop (width/height) with syntax for min/max\n * - Separate min/max props (minWidth/maxWidth or minHeight/maxHeight)\n *\n * Priority: Individual min/max props override values from main prop syntax\n */\nexport function dimensionStyle(name: 'width' | 'height') {\n const minStyle = `min-${name}`;\n const maxStyle = `max-${name}`;\n\n return ({ value, min, max }: DimensionProps) => {\n if (value == null && min == null && max == null) return null;\n\n if (\n value != null &&\n typeof value === 'string' &&\n CSS_WIDE_KEYWORDS.has(value)\n ) {\n const styles: Record<string, string> = {\n [name]: value,\n [minStyle]: value,\n [maxStyle]: value,\n };\n\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n }\n\n if (value === true) {\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Apply individual min/max overrides\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n }\n\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Process main dimension value\n if (value != null) {\n let val = value;\n if (typeof val === 'number') {\n val = `${val}px`;\n }\n\n val = String(val);\n\n const processed = parseStyle(val);\n const { mods, values } = processed.groups[0] ?? makeEmptyDetails();\n\n let flag = false;\n\n for (const mod of mods) {\n switch (mod) {\n case 'min':\n styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;\n flag = true;\n break;\n case 'max':\n styles[maxStyle] = values[0] || DEFAULT_MAX_SIZE;\n flag = true;\n break;\n case 'fixed': {\n // Fixed modifier: set all three dimensions to the same value\n const fixedValue = values[0] || 'max-content';\n styles[minStyle] = fixedValue;\n styles[name] = fixedValue;\n styles[maxStyle] = fixedValue;\n flag = true;\n break;\n }\n default:\n break;\n }\n }\n\n if (!flag || !mods.length) {\n if (values.length === 2) {\n styles[minStyle] = values[0];\n styles[maxStyle] = values[1];\n } else if (values.length === 3) {\n styles[minStyle] = values[0];\n styles[name] = values[1];\n styles[maxStyle] = values[2];\n } else {\n styles[name] = values[0] || 'auto';\n }\n }\n\n if (styles[name] === 'stretch') {\n if (name === 'width') {\n styles[name] = [\n 'stretch',\n '-webkit-fill-available',\n '-moz-available',\n ];\n } else {\n styles[name] = 'auto';\n }\n }\n }\n\n // Apply individual min/max props (higher priority, override main prop syntax)\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n };\n}\n"],"mappings":";;;;AAIA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;AAKzB,SAAS,oBACP,KACe;AACf,KAAI,OAAO,KAAM,QAAO;AACxB,KAAI,OAAO,QAAQ,SAAU,QAAO,GAAG,IAAI;AAC3C,KAAI,QAAQ,KAAM,QAAO;AAGzB,QADkB,WAAW,OAAO,IAAI,CAAC,CACxB,OAAO,IAAI,OAAO,MAAM;;;;;;;;;;;AAkB3C,SAAgB,eAAe,MAA0B;CACvD,MAAM,WAAW,OAAO;CACxB,MAAM,WAAW,OAAO;AAExB,SAAQ,EAAE,OAAO,KAAK,UAA0B;AAC9C,MAAI,SAAS,QAAQ,OAAO,QAAQ,OAAO,KAAM,QAAO;AAExD,MACE,SAAS,QACT,OAAO,UAAU,YACjB,kBAAkB,IAAI,MAAM,EAC5B;GACA,MAAM,SAAiC;KACpC,OAAO;KACP,WAAW;KACX,WAAW;IACb;GAED,MAAM,SAAS,oBAAoB,IAAI;GACvC,MAAM,SAAS,oBAAoB,IAAI;AACvC,OAAI,OAAQ,QAAO,YAAY;AAC/B,OAAI,OAAQ,QAAO,YAAY;AAE/B,UAAO;;AAGT,MAAI,UAAU,MAAM;GAClB,MAAM,SAA4C;KAC/C,OAAO;KACP,WAAW;KACX,WAAW;IACb;GAGD,MAAM,SAAS,oBAAoB,IAAI;GACvC,MAAM,SAAS,oBAAoB,IAAI;AACvC,OAAI,OAAQ,QAAO,YAAY;AAC/B,OAAI,OAAQ,QAAO,YAAY;AAE/B,UAAO;;EAGT,MAAM,SAA4C;IAC/C,OAAO;IACP,WAAW;IACX,WAAW;GACb;AAGD,MAAI,SAAS,MAAM;GACjB,IAAI,MAAM;AACV,OAAI,OAAO,QAAQ,SACjB,OAAM,GAAG,IAAI;AAGf,SAAM,OAAO,IAAI;GAGjB,MAAM,EAAE,MAAM,WADI,WAAW,IAAI,CACE,OAAO,MAAM,kBAAkB;GAElE,IAAI,OAAO;AAEX,QAAK,MAAM,OAAO,KAChB,SAAQ,KAAR;IACE,KAAK;AACH,YAAO,YAAY,OAAO,MAAM;AAChC,YAAO;AACP;IACF,KAAK;AACH,YAAO,YAAY,OAAO,MAAM;AAChC,YAAO;AACP;IACF,KAAK,SAAS;KAEZ,MAAM,aAAa,OAAO,MAAM;AAChC,YAAO,YAAY;AACnB,YAAO,QAAQ;AACf,YAAO,YAAY;AACnB,YAAO;AACP;;IAEF,QACE;;AAIN,OAAI,CAAC,QAAQ,CAAC,KAAK,OACjB,KAAI,OAAO,WAAW,GAAG;AACvB,WAAO,YAAY,OAAO;AAC1B,WAAO,YAAY,OAAO;cACjB,OAAO,WAAW,GAAG;AAC9B,WAAO,YAAY,OAAO;AAC1B,WAAO,QAAQ,OAAO;AACtB,WAAO,YAAY,OAAO;SAE1B,QAAO,QAAQ,OAAO,MAAM;AAIhC,OAAI,OAAO,UAAU,UACnB,KAAI,SAAS,QACX,QAAO,QAAQ;IACb;IACA;IACA;IACD;OAED,QAAO,QAAQ;;EAMrB,MAAM,SAAS,oBAAoB,IAAI;EACvC,MAAM,SAAS,oBAAoB,IAAI;AACvC,MAAI,OAAQ,QAAO,YAAY;AAC/B,MAAI,OAAQ,QAAO,YAAY;AAE/B,SAAO"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
|
|
2
|
+
import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
|
|
3
|
+
import { extractCSSWideKeyword } from "./shared.js";
|
|
4
|
+
//#region src/styles/directional.ts
|
|
5
|
+
function parseSingleValue(val, defaultValue, trueValue) {
|
|
6
|
+
if (typeof val === "number") return `${val}px`;
|
|
7
|
+
if (!val) return null;
|
|
8
|
+
if (val === true) val = trueValue;
|
|
9
|
+
const strVal = String(val);
|
|
10
|
+
if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;
|
|
11
|
+
const { values } = parseStyle(strVal).groups[0] ?? { values: [] };
|
|
12
|
+
return values[0] || defaultValue;
|
|
13
|
+
}
|
|
14
|
+
function extractGroupData(group, defaultValue) {
|
|
15
|
+
const { values = [], mods = [] } = group;
|
|
16
|
+
return {
|
|
17
|
+
values: values.length ? values : [defaultValue],
|
|
18
|
+
directions: filterMods(mods, DIRECTIONS)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function applyGroup(dirs, values, directions) {
|
|
22
|
+
if (!values.length) return;
|
|
23
|
+
if (directions.length === 0) {
|
|
24
|
+
dirs.top = values[0];
|
|
25
|
+
dirs.right = values[1] || values[0];
|
|
26
|
+
dirs.bottom = values[2] || values[0];
|
|
27
|
+
dirs.left = values[3] || values[1] || values[0];
|
|
28
|
+
} else directions.forEach((dir, i) => {
|
|
29
|
+
dirs[dir] = values[i] ?? values[0];
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function optimizeShorthand(property, dirs) {
|
|
33
|
+
const { top, right, bottom, left } = dirs;
|
|
34
|
+
if (top === right && right === bottom && bottom === left) return { [property]: top };
|
|
35
|
+
if (top === bottom && left === right) return { [property]: `${top} ${left}` };
|
|
36
|
+
return { [property]: `${top} ${right} ${bottom} ${left}` };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Core directional style logic shared by padding, margin, inset, scrollMargin.
|
|
40
|
+
*/
|
|
41
|
+
function processDirectionalStyle(config, props) {
|
|
42
|
+
const { main, block, inline, top, right, bottom, left } = props;
|
|
43
|
+
if (main == null && block == null && inline == null && top == null && right == null && bottom == null && left == null) return null;
|
|
44
|
+
const { property, defaultValue, trueValue, defaultInit, individualOnly, directionProperty } = config;
|
|
45
|
+
const dirProp = directionProperty ?? ((dir) => `${property}-${dir}`);
|
|
46
|
+
if (individualOnly) {
|
|
47
|
+
if (main == null && block == null && inline == null) {
|
|
48
|
+
const result = {};
|
|
49
|
+
if (top != null) {
|
|
50
|
+
const val = parseSingleValue(top, defaultValue, trueValue);
|
|
51
|
+
if (val) result[dirProp("top")] = val;
|
|
52
|
+
}
|
|
53
|
+
if (right != null) {
|
|
54
|
+
const val = parseSingleValue(right, defaultValue, trueValue);
|
|
55
|
+
if (val) result[dirProp("right")] = val;
|
|
56
|
+
}
|
|
57
|
+
if (bottom != null) {
|
|
58
|
+
const val = parseSingleValue(bottom, defaultValue, trueValue);
|
|
59
|
+
if (val) result[dirProp("bottom")] = val;
|
|
60
|
+
}
|
|
61
|
+
if (left != null) {
|
|
62
|
+
const val = parseSingleValue(left, defaultValue, trueValue);
|
|
63
|
+
if (val) result[dirProp("left")] = val;
|
|
64
|
+
}
|
|
65
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const dirs = {
|
|
69
|
+
top: defaultInit,
|
|
70
|
+
right: defaultInit,
|
|
71
|
+
bottom: defaultInit,
|
|
72
|
+
left: defaultInit
|
|
73
|
+
};
|
|
74
|
+
let useLonghand = false;
|
|
75
|
+
if (main != null) if (typeof main === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${main}px`;
|
|
76
|
+
else {
|
|
77
|
+
const strMain = main === true ? trueValue : String(main);
|
|
78
|
+
if (strMain) {
|
|
79
|
+
const keyword = CSS_WIDE_KEYWORDS.has(strMain) ? strMain : null;
|
|
80
|
+
if (keyword) dirs.top = dirs.right = dirs.bottom = dirs.left = keyword;
|
|
81
|
+
else {
|
|
82
|
+
const groups = parseStyle(strMain).groups ?? [];
|
|
83
|
+
for (const group of groups) {
|
|
84
|
+
if (group.mods.includes("longhand")) useLonghand = true;
|
|
85
|
+
const kw = extractCSSWideKeyword(group);
|
|
86
|
+
if (kw) {
|
|
87
|
+
const groupDirs = filterMods(group.mods, DIRECTIONS);
|
|
88
|
+
if (groupDirs.length === 0) dirs.top = dirs.right = dirs.bottom = dirs.left = kw;
|
|
89
|
+
else for (const dir of groupDirs) dirs[dir] = kw;
|
|
90
|
+
} else {
|
|
91
|
+
const { values, directions } = extractGroupData(group, defaultValue);
|
|
92
|
+
applyGroup(dirs, values, directions);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (block != null) {
|
|
99
|
+
const val = parseSingleValue(block, defaultValue, trueValue);
|
|
100
|
+
if (val) dirs.top = dirs.bottom = val;
|
|
101
|
+
}
|
|
102
|
+
if (inline != null) {
|
|
103
|
+
const val = parseSingleValue(inline, defaultValue, trueValue);
|
|
104
|
+
if (val) dirs.left = dirs.right = val;
|
|
105
|
+
}
|
|
106
|
+
if (top != null) {
|
|
107
|
+
const val = parseSingleValue(top, defaultValue, trueValue);
|
|
108
|
+
if (val) dirs.top = val;
|
|
109
|
+
}
|
|
110
|
+
if (right != null) {
|
|
111
|
+
const val = parseSingleValue(right, defaultValue, trueValue);
|
|
112
|
+
if (val) dirs.right = val;
|
|
113
|
+
}
|
|
114
|
+
if (bottom != null) {
|
|
115
|
+
const val = parseSingleValue(bottom, defaultValue, trueValue);
|
|
116
|
+
if (val) dirs.bottom = val;
|
|
117
|
+
}
|
|
118
|
+
if (left != null) {
|
|
119
|
+
const val = parseSingleValue(left, defaultValue, trueValue);
|
|
120
|
+
if (val) dirs.left = val;
|
|
121
|
+
}
|
|
122
|
+
if (useLonghand) return {
|
|
123
|
+
[dirProp("top")]: dirs.top,
|
|
124
|
+
[dirProp("right")]: dirs.right,
|
|
125
|
+
[dirProp("bottom")]: dirs.bottom,
|
|
126
|
+
[dirProp("left")]: dirs.left
|
|
127
|
+
};
|
|
128
|
+
return optimizeShorthand(property, dirs);
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
export { processDirectionalStyle };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=directional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directional.js","names":[],"sources":["../../src/styles/directional.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\nimport { extractCSSWideKeyword } from './shared';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\nexport interface DirectionalConfig {\n /** CSS property name (e.g. 'padding', 'margin', 'inset', 'scroll-margin') */\n property: string;\n /** Default value when parsing yields empty (e.g. 'var(--gap)', '0') */\n defaultValue: string;\n /** Value used when the prop is `true` (e.g. '1x', '0') */\n trueValue: string;\n /** Default per-direction init value (e.g. '0', 'auto') */\n defaultInit: string;\n /**\n * When true, if only individual direction props are set (no shorthand,\n * no block/inline), output individual CSS properties instead of the\n * shorthand. Needed by inset for correct CSS cascade with modifiers.\n */\n individualOnly?: boolean;\n /**\n * Maps individual direction CSS property names. Defaults to\n * `${property}-top`, `${property}-right`, etc. For inset this is\n * `top`, `right`, `bottom`, `left`.\n */\n directionProperty?: (dir: Direction) => string;\n}\n\nexport function parseSingleValue(\n val: string | number | boolean,\n defaultValue: string,\n trueValue: string,\n): string | null {\n if (typeof val === 'number') return `${val}px`;\n if (!val) return null;\n if (val === true) val = trueValue;\n\n const strVal = String(val);\n\n if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;\n\n const { values } = parseStyle(strVal).groups[0] ?? { values: [] };\n\n return values[0] || defaultValue;\n}\n\nfunction extractGroupData(\n group: StyleDetails,\n defaultValue: string,\n): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n\n return {\n values: values.length ? values : [defaultValue],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\nfunction optimizeShorthand(\n property: string,\n dirs: Record<Direction, string>,\n): Record<string, string> {\n const { top, right, bottom, left } = dirs;\n\n if (top === right && right === bottom && bottom === left) {\n return { [property]: top };\n }\n if (top === bottom && left === right) {\n return { [property]: `${top} ${left}` };\n }\n\n return { [property]: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport interface DirectionalProps {\n main?: string | number | boolean;\n block?: string | number | boolean;\n inline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}\n\n/**\n * Core directional style logic shared by padding, margin, inset, scrollMargin.\n */\nexport function processDirectionalStyle(\n config: DirectionalConfig,\n props: DirectionalProps,\n): Record<string, string> | null {\n const { main, block, inline, top, right, bottom, left } = props;\n\n if (\n main == null &&\n block == null &&\n inline == null &&\n top == null &&\n right == null &&\n bottom == null &&\n left == null\n ) {\n return null;\n }\n\n const {\n property,\n defaultValue,\n trueValue,\n defaultInit,\n individualOnly,\n directionProperty,\n } = config;\n const dirProp =\n directionProperty ?? ((dir: Direction) => `${property}-${dir}`);\n\n if (individualOnly) {\n const onlyIndividualProps = main == null && block == null && inline == null;\n\n if (onlyIndividualProps) {\n const result: Record<string, string> = {};\n\n if (top != null) {\n const val = parseSingleValue(top, defaultValue, trueValue);\n if (val) result[dirProp('top')] = val;\n }\n if (right != null) {\n const val = parseSingleValue(right, defaultValue, trueValue);\n if (val) result[dirProp('right')] = val;\n }\n if (bottom != null) {\n const val = parseSingleValue(bottom, defaultValue, trueValue);\n if (val) result[dirProp('bottom')] = val;\n }\n if (left != null) {\n const val = parseSingleValue(left, defaultValue, trueValue);\n if (val) result[dirProp('left')] = val;\n }\n\n return Object.keys(result).length > 0 ? result : null;\n }\n }\n\n const dirs: Record<Direction, string> = {\n top: defaultInit,\n right: defaultInit,\n bottom: defaultInit,\n left: defaultInit,\n };\n\n let useLonghand = false;\n\n if (main != null) {\n if (typeof main === 'number') {\n const v = `${main}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else {\n const strMain = main === true ? trueValue : String(main);\n\n if (strMain) {\n const keyword = CSS_WIDE_KEYWORDS.has(strMain) ? strMain : null;\n\n if (keyword) {\n dirs.top = dirs.right = dirs.bottom = dirs.left = keyword;\n } else {\n const processed = parseStyle(strMain);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n if (group.mods.includes('longhand')) {\n useLonghand = true;\n }\n\n const kw = extractCSSWideKeyword(group);\n\n if (kw) {\n const groupDirs = filterMods(\n group.mods,\n DIRECTIONS,\n ) as Direction[];\n\n if (groupDirs.length === 0) {\n dirs.top = dirs.right = dirs.bottom = dirs.left = kw;\n } else {\n for (const dir of groupDirs) {\n dirs[dir] = kw;\n }\n }\n } else {\n const { values, directions } = extractGroupData(\n group,\n defaultValue,\n );\n applyGroup(dirs, values, directions);\n }\n }\n }\n }\n }\n }\n\n if (block != null) {\n const val = parseSingleValue(block, defaultValue, trueValue);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (inline != null) {\n const val = parseSingleValue(inline, defaultValue, trueValue);\n if (val) dirs.left = dirs.right = val;\n }\n\n if (top != null) {\n const val = parseSingleValue(top, defaultValue, trueValue);\n if (val) dirs.top = val;\n }\n if (right != null) {\n const val = parseSingleValue(right, defaultValue, trueValue);\n if (val) dirs.right = val;\n }\n if (bottom != null) {\n const val = parseSingleValue(bottom, defaultValue, trueValue);\n if (val) dirs.bottom = val;\n }\n if (left != null) {\n const val = parseSingleValue(left, defaultValue, trueValue);\n if (val) dirs.left = val;\n }\n\n if (useLonghand) {\n return {\n [dirProp('top')]: dirs.top,\n [dirProp('right')]: dirs.right,\n [dirProp('bottom')]: dirs.bottom,\n [dirProp('left')]: dirs.left,\n };\n }\n\n return optimizeShorthand(property, dirs);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/styles/display.d.ts
|
|
2
|
+
interface DisplayStyleProps {
|
|
3
|
+
display?: string;
|
|
4
|
+
hide?: boolean;
|
|
5
|
+
textOverflow?: string | boolean;
|
|
6
|
+
overflow?: string;
|
|
7
|
+
whiteSpace?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Handles display, hide, textOverflow, overflow, and whiteSpace styles.
|
|
11
|
+
*
|
|
12
|
+
* Priority:
|
|
13
|
+
* 1. `hide` takes precedence (display: none)
|
|
14
|
+
* 2. Multi-line `textOverflow` forces display: -webkit-box
|
|
15
|
+
* 3. Single-line `textOverflow` defaults white-space to nowrap
|
|
16
|
+
* 4. Explicit `whiteSpace` overrides the default from `textOverflow`
|
|
17
|
+
*/
|
|
18
|
+
declare function displayStyle({
|
|
19
|
+
display,
|
|
20
|
+
hide,
|
|
21
|
+
textOverflow,
|
|
22
|
+
overflow,
|
|
23
|
+
whiteSpace
|
|
24
|
+
}: DisplayStyleProps): Record<string, string | number> | null;
|
|
25
|
+
declare namespace displayStyle {
|
|
26
|
+
var __lookupStyles: string[];
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { displayStyle };
|
|
30
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { parseStyle } from "../utils/styles.js";
|
|
2
|
+
//#region src/styles/display.ts
|
|
3
|
+
/**
|
|
4
|
+
* Process textOverflow into CSS properties for truncation/clamping.
|
|
5
|
+
*
|
|
6
|
+
* - `ellipsis` — single-line truncation with ellipsis
|
|
7
|
+
* - `ellipsis / 3` — multi-line clamping (3 lines) with ellipsis
|
|
8
|
+
* - `clip` — single-line truncation with clip
|
|
9
|
+
* - `clip / 2` — multi-line clip (2 lines)
|
|
10
|
+
* - `true` or `initial` — reset to initial
|
|
11
|
+
*/
|
|
12
|
+
function processTextOverflow(textOverflow, whiteSpace) {
|
|
13
|
+
if (textOverflow === true || textOverflow === "initial") return { "text-overflow": "initial" };
|
|
14
|
+
const group = parseStyle(String(textOverflow)).groups[0];
|
|
15
|
+
if (!group) return null;
|
|
16
|
+
const { parts } = group;
|
|
17
|
+
const modePart = parts[0];
|
|
18
|
+
const clampPart = parts[1];
|
|
19
|
+
const hasEllipsis = modePart?.mods.includes("ellipsis");
|
|
20
|
+
const hasClip = modePart?.mods.includes("clip");
|
|
21
|
+
if (!hasEllipsis && !hasClip) return null;
|
|
22
|
+
let clamp = 1;
|
|
23
|
+
if (clampPart?.values[0]) {
|
|
24
|
+
const parsed = parseInt(clampPart.values[0], 10);
|
|
25
|
+
if (!isNaN(parsed) && parsed > 0) clamp = parsed;
|
|
26
|
+
}
|
|
27
|
+
const result = {
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
"text-overflow": hasEllipsis ? "ellipsis" : "clip"
|
|
30
|
+
};
|
|
31
|
+
if (clamp === 1) result["white-space"] = whiteSpace || "nowrap";
|
|
32
|
+
else {
|
|
33
|
+
result["display"] = "-webkit-box";
|
|
34
|
+
result["-webkit-box-orient"] = "vertical";
|
|
35
|
+
result["-webkit-line-clamp"] = clamp;
|
|
36
|
+
result["line-clamp"] = clamp;
|
|
37
|
+
result["white-space"] = whiteSpace || "initial";
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Handles display, hide, textOverflow, overflow, and whiteSpace styles.
|
|
43
|
+
*
|
|
44
|
+
* Priority:
|
|
45
|
+
* 1. `hide` takes precedence (display: none)
|
|
46
|
+
* 2. Multi-line `textOverflow` forces display: -webkit-box
|
|
47
|
+
* 3. Single-line `textOverflow` defaults white-space to nowrap
|
|
48
|
+
* 4. Explicit `whiteSpace` overrides the default from `textOverflow`
|
|
49
|
+
*/
|
|
50
|
+
function displayStyle({ display, hide, textOverflow, overflow, whiteSpace }) {
|
|
51
|
+
const result = {};
|
|
52
|
+
if (textOverflow != null && textOverflow !== false) {
|
|
53
|
+
const textResult = processTextOverflow(textOverflow, whiteSpace);
|
|
54
|
+
if (textResult) Object.assign(result, textResult);
|
|
55
|
+
}
|
|
56
|
+
if (overflow && !result["overflow"]) result["overflow"] = overflow;
|
|
57
|
+
if (whiteSpace && !result["white-space"]) result["white-space"] = whiteSpace;
|
|
58
|
+
if (hide) result["display"] = "none";
|
|
59
|
+
else if (!result["display"] && display) result["display"] = display;
|
|
60
|
+
if (Object.keys(result).length === 0) return null;
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
displayStyle.__lookupStyles = [
|
|
64
|
+
"display",
|
|
65
|
+
"hide",
|
|
66
|
+
"textOverflow",
|
|
67
|
+
"overflow",
|
|
68
|
+
"whiteSpace"
|
|
69
|
+
];
|
|
70
|
+
//#endregion
|
|
71
|
+
export { displayStyle };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","names":[],"sources":["../../src/styles/display.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\ninterface DisplayStyleProps {\n display?: string;\n hide?: boolean;\n textOverflow?: string | boolean;\n overflow?: string;\n whiteSpace?: string;\n}\n\n/**\n * Process textOverflow into CSS properties for truncation/clamping.\n *\n * - `ellipsis` — single-line truncation with ellipsis\n * - `ellipsis / 3` — multi-line clamping (3 lines) with ellipsis\n * - `clip` — single-line truncation with clip\n * - `clip / 2` — multi-line clip (2 lines)\n * - `true` or `initial` — reset to initial\n */\nfunction processTextOverflow(\n textOverflow: string | boolean,\n whiteSpace?: string,\n): Record<string, string | number> | null {\n if (textOverflow === true || textOverflow === 'initial') {\n return { 'text-overflow': 'initial' };\n }\n\n const processed = parseStyle(String(textOverflow));\n const group = processed.groups[0];\n\n if (!group) return null;\n\n const { parts } = group;\n const modePart = parts[0];\n const clampPart = parts[1];\n\n const hasEllipsis = modePart?.mods.includes('ellipsis');\n const hasClip = modePart?.mods.includes('clip');\n\n if (!hasEllipsis && !hasClip) return null;\n\n let clamp = 1;\n\n if (clampPart?.values[0]) {\n const parsed = parseInt(clampPart.values[0], 10);\n\n if (!isNaN(parsed) && parsed > 0) {\n clamp = parsed;\n }\n }\n\n const result: Record<string, string | number> = {\n overflow: 'hidden',\n 'text-overflow': hasEllipsis ? 'ellipsis' : 'clip',\n };\n\n if (clamp === 1) {\n result['white-space'] = whiteSpace || 'nowrap';\n } else {\n result['display'] = '-webkit-box';\n result['-webkit-box-orient'] = 'vertical';\n result['-webkit-line-clamp'] = clamp;\n result['line-clamp'] = clamp;\n result['white-space'] = whiteSpace || 'initial';\n }\n\n return result;\n}\n\n/**\n * Handles display, hide, textOverflow, overflow, and whiteSpace styles.\n *\n * Priority:\n * 1. `hide` takes precedence (display: none)\n * 2. Multi-line `textOverflow` forces display: -webkit-box\n * 3. Single-line `textOverflow` defaults white-space to nowrap\n * 4. Explicit `whiteSpace` overrides the default from `textOverflow`\n */\nexport function displayStyle({\n display,\n hide,\n textOverflow,\n overflow,\n whiteSpace,\n}: DisplayStyleProps) {\n const result: Record<string, string | number> = {};\n\n if (textOverflow != null && textOverflow !== false) {\n const textResult = processTextOverflow(textOverflow, whiteSpace);\n\n if (textResult) Object.assign(result, textResult);\n }\n\n if (overflow && !result['overflow']) {\n result['overflow'] = overflow;\n }\n if (whiteSpace && !result['white-space']) {\n result['white-space'] = whiteSpace;\n }\n\n if (hide) {\n result['display'] = 'none';\n } else if (!result['display'] && display) {\n result['display'] = display;\n }\n\n if (Object.keys(result).length === 0) {\n return null;\n }\n\n return result;\n}\n\ndisplayStyle.__lookupStyles = [\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow',\n 'whiteSpace',\n];\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,oBACP,cACA,YACwC;AACxC,KAAI,iBAAiB,QAAQ,iBAAiB,UAC5C,QAAO,EAAE,iBAAiB,WAAW;CAIvC,MAAM,QADY,WAAW,OAAO,aAAa,CAAC,CAC1B,OAAO;AAE/B,KAAI,CAAC,MAAO,QAAO;CAEnB,MAAM,EAAE,UAAU;CAClB,MAAM,WAAW,MAAM;CACvB,MAAM,YAAY,MAAM;CAExB,MAAM,cAAc,UAAU,KAAK,SAAS,WAAW;CACvD,MAAM,UAAU,UAAU,KAAK,SAAS,OAAO;AAE/C,KAAI,CAAC,eAAe,CAAC,QAAS,QAAO;CAErC,IAAI,QAAQ;AAEZ,KAAI,WAAW,OAAO,IAAI;EACxB,MAAM,SAAS,SAAS,UAAU,OAAO,IAAI,GAAG;AAEhD,MAAI,CAAC,MAAM,OAAO,IAAI,SAAS,EAC7B,SAAQ;;CAIZ,MAAM,SAA0C;EAC9C,UAAU;EACV,iBAAiB,cAAc,aAAa;EAC7C;AAED,KAAI,UAAU,EACZ,QAAO,iBAAiB,cAAc;MACjC;AACL,SAAO,aAAa;AACpB,SAAO,wBAAwB;AAC/B,SAAO,wBAAwB;AAC/B,SAAO,gBAAgB;AACvB,SAAO,iBAAiB,cAAc;;AAGxC,QAAO;;;;;;;;;;;AAYT,SAAgB,aAAa,EAC3B,SACA,MACA,cACA,UACA,cACoB;CACpB,MAAM,SAA0C,EAAE;AAElD,KAAI,gBAAgB,QAAQ,iBAAiB,OAAO;EAClD,MAAM,aAAa,oBAAoB,cAAc,WAAW;AAEhE,MAAI,WAAY,QAAO,OAAO,QAAQ,WAAW;;AAGnD,KAAI,YAAY,CAAC,OAAO,YACtB,QAAO,cAAc;AAEvB,KAAI,cAAc,CAAC,OAAO,eACxB,QAAO,iBAAiB;AAG1B,KAAI,KACF,QAAO,aAAa;UACX,CAAC,OAAO,cAAc,QAC/B,QAAO,aAAa;AAGtB,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC,QAAO;AAGT,QAAO;;AAGT,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/styles/fade.d.ts
|
|
2
|
+
declare function fadeStyle({
|
|
3
|
+
fade
|
|
4
|
+
}: {
|
|
5
|
+
fade?: string;
|
|
6
|
+
}): {
|
|
7
|
+
mask: string;
|
|
8
|
+
'mask-composite': string;
|
|
9
|
+
} | null;
|
|
10
|
+
declare namespace fadeStyle {
|
|
11
|
+
var __lookupStyles: string[];
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { fadeStyle };
|
|
15
|
+
//# sourceMappingURL=fade.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
|
|
2
|
+
import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
|
|
3
|
+
//#region src/styles/fade.ts
|
|
4
|
+
const DIRECTION_MAP = {
|
|
5
|
+
right: "to left",
|
|
6
|
+
left: "to right",
|
|
7
|
+
top: "to bottom",
|
|
8
|
+
bottom: "to top"
|
|
9
|
+
};
|
|
10
|
+
const DEFAULT_TRANSPARENT_COLOR = "rgb(0 0 0 / 0)";
|
|
11
|
+
const DEFAULT_OPAQUE_COLOR = "rgb(0 0 0 / 1)";
|
|
12
|
+
/**
|
|
13
|
+
* Process a single group and return gradient strings for its directions.
|
|
14
|
+
*/
|
|
15
|
+
function processGroup(group, isOnlyGroup) {
|
|
16
|
+
let { values } = group;
|
|
17
|
+
const { mods, colors } = group;
|
|
18
|
+
let directions = filterMods(mods, DIRECTIONS);
|
|
19
|
+
if (!values.length) values = ["calc(2 * var(--gap))"];
|
|
20
|
+
if (!directions.length) if (isOnlyGroup) directions = [
|
|
21
|
+
"top",
|
|
22
|
+
"right",
|
|
23
|
+
"bottom",
|
|
24
|
+
"left"
|
|
25
|
+
];
|
|
26
|
+
else return [];
|
|
27
|
+
const transparentColor = colors?.[0] || DEFAULT_TRANSPARENT_COLOR;
|
|
28
|
+
const opaqueColor = colors?.[1] || DEFAULT_OPAQUE_COLOR;
|
|
29
|
+
return directions.map((direction, index) => {
|
|
30
|
+
const size = values[index] || values[index % 2] || values[0];
|
|
31
|
+
return `linear-gradient(${DIRECTION_MAP[direction]}, ${transparentColor} 0%, ${opaqueColor} ${size})`;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function fadeStyle({ fade }) {
|
|
35
|
+
if (!fade) return null;
|
|
36
|
+
if (CSS_WIDE_KEYWORDS.has(fade)) return {
|
|
37
|
+
mask: fade,
|
|
38
|
+
"mask-composite": fade
|
|
39
|
+
};
|
|
40
|
+
const groups = parseStyle(fade).groups ?? [];
|
|
41
|
+
if (!groups.length) return null;
|
|
42
|
+
const isOnlyGroup = groups.length === 1;
|
|
43
|
+
const gradients = [];
|
|
44
|
+
for (const group of groups) {
|
|
45
|
+
const groupGradients = processGroup({
|
|
46
|
+
values: group.values ?? [],
|
|
47
|
+
mods: group.mods ?? [],
|
|
48
|
+
colors: group.colors ?? []
|
|
49
|
+
}, isOnlyGroup);
|
|
50
|
+
gradients.push(...groupGradients);
|
|
51
|
+
}
|
|
52
|
+
if (!gradients.length) return null;
|
|
53
|
+
return {
|
|
54
|
+
mask: gradients.join(", "),
|
|
55
|
+
"mask-composite": "intersect"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
fadeStyle.__lookupStyles = ["fade"];
|
|
59
|
+
//#endregion
|
|
60
|
+
export { fadeStyle };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=fade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fade.js","names":[],"sources":["../../src/styles/fade.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\nconst DIRECTION_MAP: Record<(typeof DIRECTIONS)[number], string> = {\n right: 'to left',\n left: 'to right',\n top: 'to bottom',\n bottom: 'to top',\n};\n\n// Default mask colors (standard black with alpha for gradient masks)\nconst DEFAULT_TRANSPARENT_COLOR = 'rgb(0 0 0 / 0)';\nconst DEFAULT_OPAQUE_COLOR = 'rgb(0 0 0 / 1)';\n\ninterface GroupData {\n values: string[];\n mods: string[];\n colors: string[];\n}\n\n/**\n * Process a single group and return gradient strings for its directions.\n */\nfunction processGroup(group: GroupData, isOnlyGroup: boolean): string[] {\n let { values } = group;\n const { mods, colors } = group;\n\n let directions = filterMods(\n mods,\n DIRECTIONS,\n ) as (typeof DIRECTIONS)[number][];\n\n if (!values.length) {\n values = ['calc(2 * var(--gap))'];\n }\n\n // If this is the only group and no directions specified, apply to all edges\n if (!directions.length) {\n if (isOnlyGroup) {\n directions = ['top', 'right', 'bottom', 'left'];\n } else {\n // For multi-group without explicit direction, skip this group\n return [];\n }\n }\n\n // Extract colors: first = transparent mask color, second = opaque mask color\n const transparentColor = colors?.[0] || DEFAULT_TRANSPARENT_COLOR;\n const opaqueColor = colors?.[1] || DEFAULT_OPAQUE_COLOR;\n\n return directions.map(\n (direction: (typeof DIRECTIONS)[number], index: number) => {\n const size = values[index] || values[index % 2] || values[0];\n\n return `linear-gradient(${DIRECTION_MAP[direction]}, ${transparentColor} 0%, ${opaqueColor} ${size})`;\n },\n );\n}\n\nexport function fadeStyle({ fade }: { fade?: string }) {\n if (!fade) return null;\n\n if (CSS_WIDE_KEYWORDS.has(fade)) {\n return { mask: fade, 'mask-composite': fade };\n }\n\n const processed = parseStyle(fade);\n const groups: GroupData[] = processed.groups ?? [];\n\n if (!groups.length) return null;\n\n const isOnlyGroup = groups.length === 1;\n\n // Process all groups and collect gradients\n const gradients: string[] = [];\n\n for (const group of groups) {\n const groupGradients = processGroup(\n {\n values: group.values ?? [],\n mods: group.mods ?? [],\n colors: group.colors ?? [],\n },\n isOnlyGroup,\n );\n gradients.push(...groupGradients);\n }\n\n if (!gradients.length) return null;\n\n return {\n mask: gradients.join(', '),\n 'mask-composite': 'intersect',\n };\n}\n\nfadeStyle.__lookupStyles = ['fade'];\n"],"mappings":";;;AAGA,MAAM,gBAA6D;CACjE,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACT;AAGD,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;;;;AAW7B,SAAS,aAAa,OAAkB,aAAgC;CACtE,IAAI,EAAE,WAAW;CACjB,MAAM,EAAE,MAAM,WAAW;CAEzB,IAAI,aAAa,WACf,MACA,WACD;AAED,KAAI,CAAC,OAAO,OACV,UAAS,CAAC,uBAAuB;AAInC,KAAI,CAAC,WAAW,OACd,KAAI,YACF,cAAa;EAAC;EAAO;EAAS;EAAU;EAAO;KAG/C,QAAO,EAAE;CAKb,MAAM,mBAAmB,SAAS,MAAM;CACxC,MAAM,cAAc,SAAS,MAAM;AAEnC,QAAO,WAAW,KACf,WAAwC,UAAkB;EACzD,MAAM,OAAO,OAAO,UAAU,OAAO,QAAQ,MAAM,OAAO;AAE1D,SAAO,mBAAmB,cAAc,WAAW,IAAI,iBAAiB,OAAO,YAAY,GAAG,KAAK;GAEtG;;AAGH,SAAgB,UAAU,EAAE,QAA2B;AACrD,KAAI,CAAC,KAAM,QAAO;AAElB,KAAI,kBAAkB,IAAI,KAAK,CAC7B,QAAO;EAAE,MAAM;EAAM,kBAAkB;EAAM;CAI/C,MAAM,SADY,WAAW,KAAK,CACI,UAAU,EAAE;AAElD,KAAI,CAAC,OAAO,OAAQ,QAAO;CAE3B,MAAM,cAAc,OAAO,WAAW;CAGtC,MAAM,YAAsB,EAAE;AAE9B,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,iBAAiB,aACrB;GACE,QAAQ,MAAM,UAAU,EAAE;GAC1B,MAAM,MAAM,QAAQ,EAAE;GACtB,QAAQ,MAAM,UAAU,EAAE;GAC3B,EACD,YACD;AACD,YAAU,KAAK,GAAG,eAAe;;AAGnC,KAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,QAAO;EACL,MAAM,UAAU,KAAK,KAAK;EAC1B,kBAAkB;EACnB;;AAGH,UAAU,iBAAiB,CAAC,OAAO"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/styles/fill.d.ts
|
|
2
|
+
declare function fillStyle({
|
|
3
|
+
fill,
|
|
4
|
+
backgroundColor,
|
|
5
|
+
image,
|
|
6
|
+
backgroundImage,
|
|
7
|
+
backgroundPosition,
|
|
8
|
+
backgroundSize,
|
|
9
|
+
backgroundRepeat,
|
|
10
|
+
backgroundAttachment,
|
|
11
|
+
backgroundOrigin,
|
|
12
|
+
backgroundClip,
|
|
13
|
+
background
|
|
14
|
+
}: {
|
|
15
|
+
fill?: string;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
image?: string;
|
|
18
|
+
backgroundImage?: string;
|
|
19
|
+
backgroundPosition?: string;
|
|
20
|
+
backgroundSize?: string;
|
|
21
|
+
backgroundRepeat?: string;
|
|
22
|
+
backgroundAttachment?: string;
|
|
23
|
+
backgroundOrigin?: string;
|
|
24
|
+
backgroundClip?: string;
|
|
25
|
+
background?: string;
|
|
26
|
+
}): Record<string, string> | null;
|
|
27
|
+
declare namespace fillStyle {
|
|
28
|
+
var __lookupStyles: string[];
|
|
29
|
+
}
|
|
30
|
+
declare function svgFillStyle({
|
|
31
|
+
svgFill
|
|
32
|
+
}: {
|
|
33
|
+
svgFill?: string;
|
|
34
|
+
}): {
|
|
35
|
+
fill: string;
|
|
36
|
+
} | null;
|
|
37
|
+
declare namespace svgFillStyle {
|
|
38
|
+
var __lookupStyles: string[];
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { fillStyle, svgFillStyle };
|
|
42
|
+
//# sourceMappingURL=fill.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { parseStyle } from "../utils/styles.js";
|
|
2
|
+
//#region src/styles/fill.ts
|
|
3
|
+
function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
|
|
4
|
+
if (background) return { background: parseStyle(background).output || background };
|
|
5
|
+
const result = {};
|
|
6
|
+
const colorValue = backgroundColor ?? fill;
|
|
7
|
+
if (colorValue) {
|
|
8
|
+
const parsed = parseStyle(colorValue);
|
|
9
|
+
const firstColor = parsed.groups[0]?.colors[0];
|
|
10
|
+
const secondColor = parsed.groups[0]?.colors[1];
|
|
11
|
+
result["background-color"] = firstColor || colorValue;
|
|
12
|
+
if (secondColor) result["--tasty-second-fill-color"] = secondColor;
|
|
13
|
+
}
|
|
14
|
+
const gradientLayer = result["--tasty-second-fill-color"] ? "linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))" : null;
|
|
15
|
+
const imageValue = backgroundImage ?? image;
|
|
16
|
+
if (imageValue) {
|
|
17
|
+
const imgCss = parseStyle(imageValue).output || imageValue;
|
|
18
|
+
result["background-image"] = gradientLayer ? `${imgCss}, ${gradientLayer}` : imgCss;
|
|
19
|
+
} else if (gradientLayer) result["background-image"] = gradientLayer;
|
|
20
|
+
if (backgroundPosition) result["background-position"] = parseStyle(backgroundPosition).output || backgroundPosition;
|
|
21
|
+
if (backgroundSize) result["background-size"] = parseStyle(backgroundSize).output || backgroundSize;
|
|
22
|
+
if (backgroundRepeat) result["background-repeat"] = backgroundRepeat;
|
|
23
|
+
if (backgroundAttachment) result["background-attachment"] = backgroundAttachment;
|
|
24
|
+
if (backgroundOrigin) result["background-origin"] = backgroundOrigin;
|
|
25
|
+
if (backgroundClip) result["background-clip"] = backgroundClip;
|
|
26
|
+
if (Object.keys(result).length === 0) return null;
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
fillStyle.__lookupStyles = [
|
|
30
|
+
"fill",
|
|
31
|
+
"backgroundColor",
|
|
32
|
+
"image",
|
|
33
|
+
"backgroundImage",
|
|
34
|
+
"backgroundPosition",
|
|
35
|
+
"backgroundSize",
|
|
36
|
+
"backgroundRepeat",
|
|
37
|
+
"backgroundAttachment",
|
|
38
|
+
"backgroundOrigin",
|
|
39
|
+
"backgroundClip",
|
|
40
|
+
"background"
|
|
41
|
+
];
|
|
42
|
+
function svgFillStyle({ svgFill }) {
|
|
43
|
+
if (!svgFill) return null;
|
|
44
|
+
svgFill = parseStyle(svgFill).groups[0]?.colors[0] || svgFill;
|
|
45
|
+
return { fill: svgFill };
|
|
46
|
+
}
|
|
47
|
+
svgFillStyle.__lookupStyles = ["svgFill"];
|
|
48
|
+
//#endregion
|
|
49
|
+
export { fillStyle, svgFillStyle };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.js","names":[],"sources":["../../src/styles/fill.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\nexport function fillStyle({\n fill,\n backgroundColor,\n image,\n backgroundImage,\n backgroundPosition,\n backgroundSize,\n backgroundRepeat,\n backgroundAttachment,\n backgroundOrigin,\n backgroundClip,\n background,\n}: {\n fill?: string;\n backgroundColor?: string;\n image?: string;\n backgroundImage?: string;\n backgroundPosition?: string;\n backgroundSize?: string;\n backgroundRepeat?: string;\n backgroundAttachment?: string;\n backgroundOrigin?: string;\n backgroundClip?: string;\n background?: string;\n}) {\n // If background is set, it overrides everything\n if (background) {\n const processed = parseStyle(background);\n return { background: processed.output || background };\n }\n\n const result: Record<string, string> = {};\n\n // Priority: backgroundColor > fill\n const colorValue = backgroundColor ?? fill;\n if (colorValue) {\n const parsed = parseStyle(colorValue);\n const firstColor = parsed.groups[0]?.colors[0];\n const secondColor = parsed.groups[0]?.colors[1];\n\n result['background-color'] = firstColor || colorValue;\n\n if (secondColor) {\n result['--tasty-second-fill-color'] = secondColor;\n }\n }\n\n const gradientLayer = result['--tasty-second-fill-color']\n ? 'linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))'\n : null;\n\n // Priority: backgroundImage > image\n const imageValue = backgroundImage ?? image;\n if (imageValue) {\n const parsed = parseStyle(imageValue);\n const imgCss = parsed.output || imageValue;\n\n result['background-image'] = gradientLayer\n ? `${imgCss}, ${gradientLayer}`\n : imgCss;\n } else if (gradientLayer) {\n result['background-image'] = gradientLayer;\n }\n\n // Other background properties (pass through with parseStyle for token support)\n if (backgroundPosition) {\n result['background-position'] =\n parseStyle(backgroundPosition).output || backgroundPosition;\n }\n if (backgroundSize) {\n result['background-size'] =\n parseStyle(backgroundSize).output || backgroundSize;\n }\n if (backgroundRepeat) {\n result['background-repeat'] = backgroundRepeat;\n }\n if (backgroundAttachment) {\n result['background-attachment'] = backgroundAttachment;\n }\n if (backgroundOrigin) {\n result['background-origin'] = backgroundOrigin;\n }\n if (backgroundClip) {\n result['background-clip'] = backgroundClip;\n }\n\n if (Object.keys(result).length === 0) return null;\n return result;\n}\n\nfillStyle.__lookupStyles = [\n 'fill',\n 'backgroundColor',\n 'image',\n 'backgroundImage',\n 'backgroundPosition',\n 'backgroundSize',\n 'backgroundRepeat',\n 'backgroundAttachment',\n 'backgroundOrigin',\n 'backgroundClip',\n 'background',\n];\n\nexport function svgFillStyle({ svgFill }: { svgFill?: string }) {\n if (!svgFill) return null;\n\n const processed = parseStyle(svgFill);\n svgFill = processed.groups[0]?.colors[0] || svgFill;\n\n return { fill: svgFill };\n}\n\nsvgFillStyle.__lookupStyles = ['svgFill'];\n"],"mappings":";;AAEA,SAAgB,UAAU,EACxB,MACA,iBACA,OACA,iBACA,oBACA,gBACA,kBACA,sBACA,kBACA,gBACA,cAaC;AAED,KAAI,WAEF,QAAO,EAAE,YADS,WAAW,WAAW,CACT,UAAU,YAAY;CAGvD,MAAM,SAAiC,EAAE;CAGzC,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EACd,MAAM,SAAS,WAAW,WAAW;EACrC,MAAM,aAAa,OAAO,OAAO,IAAI,OAAO;EAC5C,MAAM,cAAc,OAAO,OAAO,IAAI,OAAO;AAE7C,SAAO,sBAAsB,cAAc;AAE3C,MAAI,YACF,QAAO,+BAA+B;;CAI1C,MAAM,gBAAgB,OAAO,+BACzB,oFACA;CAGJ,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EAEd,MAAM,SADS,WAAW,WAAW,CACf,UAAU;AAEhC,SAAO,sBAAsB,gBACzB,GAAG,OAAO,IAAI,kBACd;YACK,cACT,QAAO,sBAAsB;AAI/B,KAAI,mBACF,QAAO,yBACL,WAAW,mBAAmB,CAAC,UAAU;AAE7C,KAAI,eACF,QAAO,qBACL,WAAW,eAAe,CAAC,UAAU;AAEzC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,qBACF,QAAO,2BAA2B;AAEpC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,eACF,QAAO,qBAAqB;AAG9B,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EAAG,QAAO;AAC7C,QAAO;;AAGT,UAAU,iBAAiB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,aAAa,EAAE,WAAiC;AAC9D,KAAI,CAAC,QAAS,QAAO;AAGrB,WADkB,WAAW,QAAQ,CACjB,OAAO,IAAI,OAAO,MAAM;AAE5C,QAAO,EAAE,MAAM,SAAS;;AAG1B,aAAa,iBAAiB,CAAC,UAAU"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/styles/flow.d.ts
|
|
2
|
+
declare function flowStyle({
|
|
3
|
+
display,
|
|
4
|
+
flow
|
|
5
|
+
}: {
|
|
6
|
+
display?: string;
|
|
7
|
+
flow?: string;
|
|
8
|
+
}): {
|
|
9
|
+
[x: string]: string | undefined;
|
|
10
|
+
} | null;
|
|
11
|
+
declare namespace flowStyle {
|
|
12
|
+
var __lookupStyles: string[];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { flowStyle };
|
|
16
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/styles/flow.ts
|
|
2
|
+
function flowStyle({ display = "block", flow }) {
|
|
3
|
+
let style;
|
|
4
|
+
if (display.includes("grid")) style = "grid-auto-flow";
|
|
5
|
+
else if (display.includes("flex")) style = "flex-flow";
|
|
6
|
+
return style ? { [style]: flow } : null;
|
|
7
|
+
}
|
|
8
|
+
flowStyle.__lookupStyles = ["display", "flow"];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { flowStyle };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.js","names":[],"sources":["../../src/styles/flow.ts"],"sourcesContent":["export function flowStyle({\n display = 'block',\n flow,\n}: {\n display?: string;\n flow?: string;\n}) {\n let style;\n\n if (display.includes('grid')) {\n style = 'grid-auto-flow';\n } else if (display.includes('flex')) {\n style = 'flex-flow';\n }\n\n return style ? { [style]: flow } : null;\n}\n\nflowStyle.__lookupStyles = ['display', 'flow'];\n"],"mappings":";AAAA,SAAgB,UAAU,EACxB,UAAU,SACV,QAIC;CACD,IAAI;AAEJ,KAAI,QAAQ,SAAS,OAAO,CAC1B,SAAQ;UACC,QAAQ,SAAS,OAAO,CACjC,SAAQ;AAGV,QAAO,QAAQ,GAAG,QAAQ,MAAM,GAAG;;AAGrC,UAAU,iBAAiB,CAAC,WAAW,OAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/styles/gap.d.ts
|
|
2
|
+
declare function gapStyle({
|
|
3
|
+
display,
|
|
4
|
+
flow,
|
|
5
|
+
gap
|
|
6
|
+
}: {
|
|
7
|
+
display?: string;
|
|
8
|
+
flow?: string;
|
|
9
|
+
gap?: string | number | boolean;
|
|
10
|
+
}): {
|
|
11
|
+
gap: string;
|
|
12
|
+
$?: undefined;
|
|
13
|
+
} | ({
|
|
14
|
+
'margin-right': string;
|
|
15
|
+
'margin-bottom': string;
|
|
16
|
+
$?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
$: string;
|
|
19
|
+
'margin-right': string;
|
|
20
|
+
'margin-bottom': string;
|
|
21
|
+
})[] | {
|
|
22
|
+
[x: string]: string;
|
|
23
|
+
$: string;
|
|
24
|
+
gap?: undefined;
|
|
25
|
+
} | null;
|
|
26
|
+
declare namespace gapStyle {
|
|
27
|
+
var __lookupStyles: string[];
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { gapStyle };
|
|
31
|
+
//# sourceMappingURL=gap.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
|
|
2
|
+
import { makeEmptyDetails } from "../parser/types.js";
|
|
3
|
+
import { parseStyle } from "../utils/styles.js";
|
|
4
|
+
//#region src/styles/gap.ts
|
|
5
|
+
function gapStyle({ display = "block", flow, gap }) {
|
|
6
|
+
if (typeof gap === "number") gap = `${gap}px`;
|
|
7
|
+
if (!gap) return null;
|
|
8
|
+
if (gap === true) gap = "1x";
|
|
9
|
+
if (CSS_WIDE_KEYWORDS.has(String(gap))) return { gap: String(gap) };
|
|
10
|
+
const isGrid = display.includes("grid");
|
|
11
|
+
const isFlex = display.includes("flex");
|
|
12
|
+
const isWrap = flow ? flow.includes("wrap") && !flow.includes("nowrap") : false;
|
|
13
|
+
if (!isGrid && flow == null) flow = isFlex ? "row" : "column";
|
|
14
|
+
const { values } = parseStyle(gap).groups[0] ?? makeEmptyDetails();
|
|
15
|
+
gap = values.join(" ");
|
|
16
|
+
if (isGrid || isFlex) return { gap };
|
|
17
|
+
const gapDir = flow?.includes("row") ? "right" : "bottom";
|
|
18
|
+
return isWrap ? [{
|
|
19
|
+
"margin-right": `calc(-1 * ${values[1] || values[0]})`,
|
|
20
|
+
"margin-bottom": `calc(-1 * ${values[0]})`
|
|
21
|
+
}, {
|
|
22
|
+
$: "& > *",
|
|
23
|
+
"margin-right": values[1] || values[0],
|
|
24
|
+
"margin-bottom": values[0]
|
|
25
|
+
}] : {
|
|
26
|
+
$: "& > *:not(:last-child)",
|
|
27
|
+
[`margin-${gapDir}`]: gap
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
gapStyle.__lookupStyles = [
|
|
31
|
+
"display",
|
|
32
|
+
"flow",
|
|
33
|
+
"gap"
|
|
34
|
+
];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { gapStyle };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=gap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gap.js","names":[],"sources":["../../src/styles/gap.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nexport function gapStyle({\n display = 'block',\n flow,\n gap,\n}: {\n display?: string;\n flow?: string;\n gap?: string | number | boolean;\n}) {\n if (typeof gap === 'number') {\n gap = `${gap}px`;\n }\n\n if (!gap) {\n return null;\n }\n\n if (gap === true) {\n gap = '1x';\n }\n\n if (CSS_WIDE_KEYWORDS.has(String(gap))) {\n return { gap: String(gap) };\n }\n\n const isGrid = display.includes('grid');\n const isFlex = display.includes('flex');\n const isWrap = flow\n ? flow.includes('wrap') && !flow.includes('nowrap')\n : false;\n\n if (!isGrid && flow == null) {\n flow = isFlex ? 'row' : 'column';\n }\n\n const processed = parseStyle(gap);\n const { values } = processed.groups[0] ?? makeEmptyDetails();\n\n gap = values.join(' ');\n\n if (isGrid || isFlex) {\n return { gap };\n }\n\n const gapDir = flow?.includes('row') ? 'right' : 'bottom';\n\n return isWrap\n ? [\n {\n 'margin-right': `calc(-1 * ${values[1] || values[0]})`,\n 'margin-bottom': `calc(-1 * ${values[0]})`,\n },\n {\n $: '& > *',\n 'margin-right': values[1] || values[0],\n 'margin-bottom': values[0],\n },\n ]\n : {\n $: '& > *:not(:last-child)',\n [`margin-${gapDir}`]: gap,\n };\n}\n\ngapStyle.__lookupStyles = ['display', 'flow', 'gap'];\n"],"mappings":";;;;AAIA,SAAgB,SAAS,EACvB,UAAU,SACV,MACA,OAKC;AACD,KAAI,OAAO,QAAQ,SACjB,OAAM,GAAG,IAAI;AAGf,KAAI,CAAC,IACH,QAAO;AAGT,KAAI,QAAQ,KACV,OAAM;AAGR,KAAI,kBAAkB,IAAI,OAAO,IAAI,CAAC,CACpC,QAAO,EAAE,KAAK,OAAO,IAAI,EAAE;CAG7B,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,OACX,KAAK,SAAS,OAAO,IAAI,CAAC,KAAK,SAAS,SAAS,GACjD;AAEJ,KAAI,CAAC,UAAU,QAAQ,KACrB,QAAO,SAAS,QAAQ;CAI1B,MAAM,EAAE,WADU,WAAW,IAAI,CACJ,OAAO,MAAM,kBAAkB;AAE5D,OAAM,OAAO,KAAK,IAAI;AAEtB,KAAI,UAAU,OACZ,QAAO,EAAE,KAAK;CAGhB,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG,UAAU;AAEjD,QAAO,SACH,CACE;EACE,gBAAgB,aAAa,OAAO,MAAM,OAAO,GAAG;EACpD,iBAAiB,aAAa,OAAO,GAAG;EACzC,EACD;EACE,GAAG;EACH,gBAAgB,OAAO,MAAM,OAAO;EACpC,iBAAiB,OAAO;EACzB,CACF,GACD;EACE,GAAG;GACF,UAAU,WAAW;EACvB;;AAGP,SAAS,iBAAiB;CAAC;CAAW;CAAQ;CAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/styles/height.d.ts
|
|
2
|
+
interface HeightStyleProps {
|
|
3
|
+
height?: string | number | boolean;
|
|
4
|
+
minHeight?: string | number | boolean;
|
|
5
|
+
maxHeight?: string | number | boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function heightStyle({
|
|
8
|
+
height,
|
|
9
|
+
minHeight,
|
|
10
|
+
maxHeight
|
|
11
|
+
}: HeightStyleProps): Record<string, string | string[]> | null;
|
|
12
|
+
declare namespace heightStyle {
|
|
13
|
+
var __lookupStyles: string[];
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { heightStyle };
|
|
17
|
+
//# sourceMappingURL=height.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { dimensionStyle } from "./dimension.js";
|
|
2
|
+
//#region src/styles/height.ts
|
|
3
|
+
const dimension = dimensionStyle("height");
|
|
4
|
+
function heightStyle({ height, minHeight, maxHeight }) {
|
|
5
|
+
return dimension({
|
|
6
|
+
value: height,
|
|
7
|
+
min: minHeight,
|
|
8
|
+
max: maxHeight
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
heightStyle.__lookupStyles = [
|
|
12
|
+
"height",
|
|
13
|
+
"minHeight",
|
|
14
|
+
"maxHeight"
|
|
15
|
+
];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { heightStyle };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=height.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"height.js","names":[],"sources":["../../src/styles/height.ts"],"sourcesContent":["import { dimensionStyle } from './dimension';\n\nconst dimension = dimensionStyle('height');\n\ninterface HeightStyleProps {\n height?: string | number | boolean;\n minHeight?: string | number | boolean;\n maxHeight?: string | number | boolean;\n}\n\nexport function heightStyle({\n height,\n minHeight,\n maxHeight,\n}: HeightStyleProps) {\n return dimension({ value: height, min: minHeight, max: maxHeight });\n}\n\nheightStyle.__lookupStyles = ['height', 'minHeight', 'maxHeight'];\n"],"mappings":";;AAEA,MAAM,YAAY,eAAe,SAAS;AAQ1C,SAAgB,YAAY,EAC1B,QACA,WACA,aACmB;AACnB,QAAO,UAAU;EAAE,OAAO;EAAQ,KAAK;EAAW,KAAK;EAAW,CAAC;;AAGrE,YAAY,iBAAiB;CAAC;CAAU;CAAa;CAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { styleHandlers } from "./predefined.js";
|