You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
6.2 KiB

{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport { defineComponent, inject, computed, openBlock, createBlock, resolveDynamicComponent, normalizeClass, unref, normalizeStyle, withCtx, renderSlot } from 'vue';\nimport '../../../utils/index.mjs';\nimport '../../../hooks/index.mjs';\nimport '../../row/index.mjs';\nimport { colProps } from './col.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { rowContextKey } from '../../row/src/constants.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { isNumber } from '../../../utils/types.mjs';\nimport { isObject } from '@vue/shared';\nconst __default__ = defineComponent({\n name: \"ElCol\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: colProps,\n setup(__props) {\n const props = __props;\n const {\n gutter\n } = inject(rowContextKey, {\n gutter: computed(() => 0)\n });\n const ns = useNamespace(\"col\");\n const style = computed(() => {\n const styles = {};\n if (gutter.value) {\n styles.paddingLeft = styles.paddingRight = `${gutter.value / 2}px`;\n }\n return styles;\n });\n const colKls = computed(() => {\n const classes = [];\n const pos = [\"span\", \"offset\", \"pull\", \"push\"];\n pos.forEach(prop => {\n const size = props[prop];\n if (isNumber(size)) {\n if (prop === \"span\") classes.push(ns.b(`${props[prop]}`));else if (size > 0) classes.push(ns.b(`${prop}-${props[prop]}`));\n }\n });\n const sizes = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"];\n sizes.forEach(size => {\n if (isNumber(props[size])) {\n classes.push(ns.b(`${size}-${props[size]}`));\n } else if (isObject(props[size])) {\n Object.entries(props[size]).forEach(([prop, sizeProp]) => {\n classes.push(prop !== \"span\" ? ns.b(`${size}-${prop}-${sizeProp}`) : ns.b(`${size}-${sizeProp}`));\n });\n }\n });\n if (gutter.value) {\n classes.push(ns.is(\"guttered\"));\n }\n return [ns.b(), classes];\n });\n return (_ctx, _cache) => {\n return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {\n class: normalizeClass(unref(colKls)),\n style: normalizeStyle(unref(style))\n }, {\n default: withCtx(() => [renderSlot(_ctx.$slots, \"default\")]),\n _: 3\n }, 8, [\"class\", \"style\"]);\n };\n }\n});\nvar Col = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"col.vue\"]]);\nexport { Col as default };","map":{"version":3,"names":["name","gutter","inject","rowContextKey","computed","ns","useNamespace","style","styles","value","paddingLeft","paddingRight","colKls","classes","pos","forEach","prop","size","props","isNumber","push","b","sizes","isObject","Object","entries","sizeProp","is"],"sources":["../../../../../../packages/components/col/src/col.vue"],"sourcesContent":["<template>\n <component :is=\"tag\" :class=\"colKls\" :style=\"style\">\n <slot />\n </component>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, inject } from 'vue'\nimport { isNumber, isObject } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { rowContextKey } from '@element-plus/components/row'\nimport { colProps } from './col'\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'ElCol',\n})\n\nconst props = defineProps(colProps)\n\nconst { gutter } = inject(rowContextKey, { gutter: computed(() => 0) })\nconst ns = useNamespace('col')\n\nconst style = computed(() => {\n const styles: CSSProperties = {}\n if (gutter.value) {\n styles.paddingLeft = styles.paddingRight = `${gutter.value / 2}px`\n }\n return styles\n})\n\nconst colKls = computed(() => {\n const classes: string[] = []\n const pos = ['span', 'offset', 'pull', 'push'] as const\n\n pos.forEach((prop) => {\n const size = props[prop]\n if (isNumber(size)) {\n if (prop === 'span') classes.push(ns.b(`${props[prop]}`))\n else if (size > 0) classes.push(ns.b(`${prop}-${props[prop]}`))\n }\n })\n\n const sizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const\n sizes.forEach((size) => {\n if (isNumber(props[size])) {\n classes.push(ns.b(`${size}-${props[size]}`))\n } else if (isObject(props[size])) {\n Object.entries(props[size]).forEach(([prop, sizeProp]) => {\n classes.push(\n prop !== 'span'\n ? ns.b(`${size}-${prop}-${sizeProp}`)\n : ns.b(`${size}-${sizeProp}`)\n )\n })\n }\n })\n\n // this is for the fix\n if (gutter.value) {\n classes.push(ns.is('guttered'))\n }\n return [ns.b(), classes]\n})\n</script>\n"],"mappings":";;;;;;;;;;;mCAcc;EACZA,IAAM;AACR;;;;;;IAIM;MAAEC;IAAO,IAAIC,MAAO,CAAAC,aAAA,EAAe;MAAEF,MAAA,EAAQG,QAAS,OAAM,CAAC;IAAA,CAAG;IAChE,MAAAC,EAAA,GAAKC,YAAA,CAAa,KAAK;IAEvB,MAAAC,KAAA,GAAQH,QAAA,CAAS,MAAM;MAC3B,MAAMI,MAAA,GAAwB,EAAC;MAC/B,IAAIP,MAAA,CAAOQ,KAAO;QAChBD,MAAA,CAAOE,WAAA,GAAcF,MAAO,CAAAG,YAAA,GAAe,GAAGV,MAAA,CAAOQ,KAAA,GAAQ,CAAC;MAAA;MAEzD,OAAAD,MAAA;IAAA,CACR;IAEK,MAAAI,MAAA,GAASR,QAAA,CAAS,MAAM;MAC5B,MAAMS,OAAA,GAAoB,EAAC;MAC3B,MAAMC,GAAM,IAAC,MAAQ,YAAU,QAAQ,MAAM;MAEzCA,GAAA,CAAAC,OAAA,CAASC,IAAS;QACd,MAAAC,IAAA,GAAOC,KAAA,CAAMF,IAAI;QACnB,IAAAG,QAAA,CAASF,IAAI,CAAG;UACd,IAAAD,IAAA,KAAS,MAAQ,EAAmCH,OAC/C,CAAOO,IAAA,CAAAf,EAAA,CAAGgB,CAAQ,IAAAH,KAAA,CAAAF,IAAQ,IAAE,CAAG,MAC1C,IAAAC,IAAA,MACDJ,OAAA,CAAAO,IAAA,CAAAf,EAAA,CAAAgB,CAAA,IAAAL,IAAA,IAAAE,KAAA,CAAAF,IAAA;QAED;MACA,CAAM;MACJ,MAAIM,KAAS,UAAM,IAAI,EAAI;MACjBA,KAAA,CAAAP,OAAA,CAAAE,IAAQ,IAAK;QACvB,IAAWE,QAAA,CAAA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