cck-ui 0.0.1 → 0.0.2
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/dist/index.full.js +39 -1448
- package/dist/index.full.min.js +3 -15
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +3 -15
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +7 -1414
- package/es/packages/components/button/src/button-custom.mjs +2 -2
- package/es/packages/components/button/src/button-custom.mjs.map +1 -1
- package/es/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.mjs +15 -15
- package/es/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/es/packages/components/button/src/use-button.mjs +3 -3
- package/es/packages/components/button/src/use-button.mjs.map +1 -1
- package/es/packages/components/form/src/hooks/use-form-common-props.mjs +4 -4
- package/es/packages/components/form/src/hooks/use-form-common-props.mjs.map +1 -1
- package/es/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.mjs +6 -6
- package/es/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/es/packages/hooks/use-namespace/index.mjs +4 -4
- package/es/packages/hooks/use-namespace/index.mjs.map +1 -1
- package/es/packages/hooks/use-prop/index.mjs +3 -3
- package/es/packages/hooks/use-prop/index.mjs.map +1 -1
- package/es/packages/hooks/use-theme/index.mjs +3 -3
- package/es/packages/hooks/use-theme/index.mjs.map +1 -1
- package/lib/_virtual/_rolldown/runtime.js +0 -33
- package/lib/packages/components/button/src/button-custom.js +4 -4
- package/lib/packages/components/button/src/button-custom.js.map +1 -1
- package/lib/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.js +19 -19
- package/lib/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/lib/packages/components/button/src/use-button.js +3 -3
- package/lib/packages/components/button/src/use-button.js.map +1 -1
- package/lib/packages/components/form/src/hooks/use-form-common-props.js +6 -6
- package/lib/packages/components/form/src/hooks/use-form-common-props.js.map +1 -1
- package/lib/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.js +8 -8
- package/lib/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/lib/packages/hooks/use-namespace/index.js +4 -4
- package/lib/packages/hooks/use-namespace/index.js.map +1 -1
- package/lib/packages/hooks/use-prop/index.js +3 -3
- package/lib/packages/hooks/use-prop/index.js.map +1 -1
- package/lib/packages/hooks/use-theme/index.js +3 -3
- package/lib/packages/hooks/use-theme/index.js.map +1 -1
- package/package.json +14 -6
- package/es/_virtual/_rolldown/runtime.mjs +0 -27
- package/es/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs +0 -22
- package/es/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs.map +0 -1
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.js +0 -66
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.js.map +0 -1
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.prod.js +0 -56
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.prod.js.map +0 -1
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index.js +0 -18
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index.js.map +0 -1
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index2.js +0 -14
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index2.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateColorShades, setColorAlpha } from "../../../utils/colors.mjs";
|
|
2
|
-
import { vue_runtime_esm_bundler_exports } from "../../../../node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
|
|
3
2
|
import { useColorScheme } from "../../../hooks/use-theme/index.mjs";
|
|
3
|
+
import { computed } from "vue";
|
|
4
4
|
//#region ../../packages/components/button/src/button-custom.ts
|
|
5
5
|
const PRESET_COLORS = [
|
|
6
6
|
"red",
|
|
@@ -40,7 +40,7 @@ const getShadeIndexes = (scheme) => {
|
|
|
40
40
|
};
|
|
41
41
|
function useButtonCustomStyle(props) {
|
|
42
42
|
const colorScheme = useColorScheme();
|
|
43
|
-
return
|
|
43
|
+
return computed(() => {
|
|
44
44
|
const styles = {};
|
|
45
45
|
const { color, gradient, justify, variant } = props;
|
|
46
46
|
const scheme = colorScheme.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-custom.mjs","names":[],"sources":["../../../../../../../packages/components/button/src/button-custom.ts"],"sourcesContent":["import { ColorScheme, useColorScheme } from '@cck-ui/hooks'\nimport { generateColorShades, setColorAlpha } from '@cck-ui/utils'\nimport { computed } from 'vue'\nimport { ButtonProps } from './button.types'\n\nconst PRESET_COLORS = [\n 'red',\n 'pink',\n 'grape',\n 'violet',\n 'indigo',\n 'blue',\n 'cyan',\n 'teal',\n 'green',\n 'lime',\n 'yellow',\n 'orange',\n 'gray',\n 'dark'\n]\n\nconst getShadeIndexes = (scheme: ColorScheme) => {\n if (scheme === 'light') {\n return {\n bg: 6,\n hover: 7,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 6,\n outlineHoverBgAlpha: 0.05\n }\n } else {\n return {\n bg: 8,\n hover: 9,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 4,\n outlineHoverBgAlpha: 0.05\n }\n }\n}\n\nexport function useButtonCustomStyle(props: ButtonProps) {\n const colorScheme = useColorScheme()\n\n return computed(() => {\n const styles: Record<string, string> = {}\n\n const { color, gradient, justify, variant } = props\n const scheme = colorScheme.value\n const idx = getShadeIndexes(scheme)\n\n if (justify) {\n styles['--button-justify'] = justify\n }\n\n switch (variant) {\n case 'default':\n break\n case 'filled':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-filled)`\n styles['--button-hover'] = `var(--c-color-${color}-filled-hover)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.bg]\n styles['--button-hover'] = shades[idx.hover]\n }\n }\n break\n case 'light':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-light)`\n styles['--button-hover'] = `var(--c-color-${color}-light-hover)`\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.lightBg]\n styles['--button-hover'] = shades[idx.lightHover]\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'outline':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid ${shades[idx.outlineColor]}`\n }\n }\n break\n case 'subtle':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n }\n }\n break\n case 'transparent':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'white':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-filled)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.bg]\n }\n }\n break\n case 'gradient':\n const from = gradient?.from || 'blue'\n const to = gradient?.to || 'cyan'\n const deg = gradient?.deg || '45'\n\n let finalFrom: string = from\n let finalTo: string = to\n if (PRESET_COLORS.includes(from)) {\n finalFrom = `var(--c-color-${from}-filled)`\n }\n if (PRESET_COLORS.includes(to)) {\n finalTo = `var(--c-color-${to}-filled)`\n }\n\n styles['--button-bg'] =\n `linear-gradient(${deg}deg, ${finalFrom} 0%, ${finalTo} 100%)`\n break\n default:\n break\n }\n\n return styles\n })\n}\n"],"mappings":";;;;AAKA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB,WAAwB;CAC/C,IAAI,WAAW,SACb,OAAO;EACL,IAAI;EACJ,OAAO;EACP,SAAS;EACT,YAAY;EACZ,YAAY;EACZ,cAAc;EACd,qBAAqB;CACvB;MAEA,OAAO;EACL,IAAI;EACJ,OAAO;EACP,SAAS;EACT,YAAY;EACZ,YAAY;EACZ,cAAc;EACd,qBAAqB;CACvB;AAEJ;AAEA,SAAgB,qBAAqB,OAAoB;CACvD,MAAM,cAAc,eAAe;CAEnC,
|
|
1
|
+
{"version":3,"file":"button-custom.mjs","names":[],"sources":["../../../../../../../packages/components/button/src/button-custom.ts"],"sourcesContent":["import { ColorScheme, useColorScheme } from '@cck-ui/hooks'\nimport { generateColorShades, setColorAlpha } from '@cck-ui/utils'\nimport { computed } from 'vue'\nimport { ButtonProps } from './button.types'\n\nconst PRESET_COLORS = [\n 'red',\n 'pink',\n 'grape',\n 'violet',\n 'indigo',\n 'blue',\n 'cyan',\n 'teal',\n 'green',\n 'lime',\n 'yellow',\n 'orange',\n 'gray',\n 'dark'\n]\n\nconst getShadeIndexes = (scheme: ColorScheme) => {\n if (scheme === 'light') {\n return {\n bg: 6,\n hover: 7,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 6,\n outlineHoverBgAlpha: 0.05\n }\n } else {\n return {\n bg: 8,\n hover: 9,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 4,\n outlineHoverBgAlpha: 0.05\n }\n }\n}\n\nexport function useButtonCustomStyle(props: ButtonProps) {\n const colorScheme = useColorScheme()\n\n return computed(() => {\n const styles: Record<string, string> = {}\n\n const { color, gradient, justify, variant } = props\n const scheme = colorScheme.value\n const idx = getShadeIndexes(scheme)\n\n if (justify) {\n styles['--button-justify'] = justify\n }\n\n switch (variant) {\n case 'default':\n break\n case 'filled':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-filled)`\n styles['--button-hover'] = `var(--c-color-${color}-filled-hover)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.bg]\n styles['--button-hover'] = shades[idx.hover]\n }\n }\n break\n case 'light':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-light)`\n styles['--button-hover'] = `var(--c-color-${color}-light-hover)`\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.lightBg]\n styles['--button-hover'] = shades[idx.lightHover]\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'outline':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid ${shades[idx.outlineColor]}`\n }\n }\n break\n case 'subtle':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n }\n }\n break\n case 'transparent':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'white':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-filled)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.bg]\n }\n }\n break\n case 'gradient':\n const from = gradient?.from || 'blue'\n const to = gradient?.to || 'cyan'\n const deg = gradient?.deg || '45'\n\n let finalFrom: string = from\n let finalTo: string = to\n if (PRESET_COLORS.includes(from)) {\n finalFrom = `var(--c-color-${from}-filled)`\n }\n if (PRESET_COLORS.includes(to)) {\n finalTo = `var(--c-color-${to}-filled)`\n }\n\n styles['--button-bg'] =\n `linear-gradient(${deg}deg, ${finalFrom} 0%, ${finalTo} 100%)`\n break\n default:\n break\n }\n\n return styles\n })\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { vue_runtime_esm_bundler_exports } from "../../../../node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
|
|
2
1
|
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
|
|
3
2
|
import { useButton } from "./use-button.mjs";
|
|
4
3
|
import { useButtonCustomStyle } from "./button-custom.mjs";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderSlot, resolveDynamicComponent, unref, useSlots, withCtx } from "vue";
|
|
5
5
|
//#region ../../packages/components/button/src/button.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
const _hoisted_1 = {
|
|
7
7
|
key: 0,
|
|
@@ -19,7 +19,7 @@ const _hoisted_4 = {
|
|
|
19
19
|
key: 3,
|
|
20
20
|
"data-position": "right"
|
|
21
21
|
};
|
|
22
|
-
var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
22
|
+
var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
23
23
|
name: "CButton",
|
|
24
24
|
__name: "button",
|
|
25
25
|
props: {
|
|
@@ -85,9 +85,9 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_r
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
setup(__props, { expose: __expose }) {
|
|
88
|
-
const slots =
|
|
89
|
-
const hasLeftSlot =
|
|
90
|
-
const hasRightSlot =
|
|
88
|
+
const slots = useSlots();
|
|
89
|
+
const hasLeftSlot = computed(() => !!slots["left-section"]);
|
|
90
|
+
const hasRightSlot = computed(() => !!slots["right-section"]);
|
|
91
91
|
const props = __props;
|
|
92
92
|
const { _disabled, _props, _ref, handleClick } = useButton(props, {
|
|
93
93
|
hasLeftSlot: hasLeftSlot.value,
|
|
@@ -95,14 +95,14 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_r
|
|
|
95
95
|
});
|
|
96
96
|
const buttonStyle = useButtonCustomStyle(props);
|
|
97
97
|
const ns = useNamespace("button");
|
|
98
|
-
const buttonClass =
|
|
98
|
+
const buttonClass = computed(() => [
|
|
99
99
|
useNamespace("focus").b("auto"),
|
|
100
100
|
!_disabled.value && useNamespace("active").b(),
|
|
101
101
|
ns.e("root"),
|
|
102
102
|
ns.is("loading", props.loading)
|
|
103
103
|
]);
|
|
104
|
-
const innerClass =
|
|
105
|
-
const labelClass =
|
|
104
|
+
const innerClass = computed(() => [ns.e("inner")]);
|
|
105
|
+
const labelClass = computed(() => [ns.e("label")]);
|
|
106
106
|
__expose({
|
|
107
107
|
/** @description if button is disabled */
|
|
108
108
|
disabled: _disabled.value,
|
|
@@ -114,15 +114,15 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_r
|
|
|
114
114
|
variant: props.variant
|
|
115
115
|
});
|
|
116
116
|
return (_ctx, _cache) => {
|
|
117
|
-
return
|
|
117
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), mergeProps(unref(_props), {
|
|
118
118
|
class: buttonClass.value,
|
|
119
|
-
style:
|
|
120
|
-
onClick:
|
|
119
|
+
style: unref(buttonStyle),
|
|
120
|
+
onClick: unref(handleClick)
|
|
121
121
|
}), {
|
|
122
|
-
default:
|
|
123
|
-
_ctx.$slots["left-section"] ? (
|
|
124
|
-
|
|
125
|
-
_ctx.$slots["right-section"] ? (
|
|
122
|
+
default: withCtx(() => [createElementVNode("span", { class: normalizeClass(innerClass.value) }, [
|
|
123
|
+
_ctx.$slots["left-section"] ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "left-section")])) : __props.leftSection ? (openBlock(), createElementBlock("span", _hoisted_2, [(openBlock(), createBlock(resolveDynamicComponent(__props.leftSection)))])) : createCommentVNode("v-if", true),
|
|
124
|
+
createElementVNode("span", { class: normalizeClass(labelClass.value) }, [renderSlot(_ctx.$slots, "default")], 2),
|
|
125
|
+
_ctx.$slots["right-section"] ? (openBlock(), createElementBlock("span", _hoisted_3, [renderSlot(_ctx.$slots, "right-section")])) : __props.rightSection ? (openBlock(), createElementBlock("span", _hoisted_4, [(openBlock(), createBlock(resolveDynamicComponent(__props.rightSection)))])) : createCommentVNode("v-if", true)
|
|
126
126
|
], 2)]),
|
|
127
127
|
_: 3
|
|
128
128
|
}, 16, [
|
package/es/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.vue_vue_type_script_setup_true_lang.mjs","names":["$slots"],"sources":["../../../../../../../packages/components/button/src/button.vue"
|
|
1
|
+
{"version":3,"file":"button.vue_vue_type_script_setup_true_lang.mjs","names":["$slots"],"sources":["../../../../../../../packages/components/button/src/button.vue"],"sourcesContent":["<template>\n <component\n v-bind=\"_props\"\n :class=\"buttonClass\"\n :is=\"tag\"\n :style=\"buttonStyle\"\n @click=\"handleClick\"\n >\n <span :class=\"innerClass\">\n <span data-position=\"left\" v-if=\"$slots['left-section']\">\n <slot name=\"left-section\"></slot>\n </span>\n <span data-position=\"left\" v-else-if=\"leftSection\">\n <component :is=\"leftSection\" />\n </span>\n <span :class=\"labelClass\">\n <slot />\n </span>\n <span data-position=\"right\" v-if=\"$slots['right-section']\">\n <slot name=\"right-section\"></slot>\n </span>\n <span data-position=\"right\" v-else-if=\"rightSection\">\n <component :is=\"rightSection\" />\n </span>\n </span>\n </component>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, useSlots } from 'vue'\nimport type { ButtonProps } from './button.types'\nimport { useNamespace } from '@cck-ui/hooks'\nimport { useButton } from './use-button'\nimport { useButtonCustomStyle } from './button-custom'\n\ndefineOptions({\n name: 'CButton'\n})\n\ndefineSlots<{\n 'left-section': any\n 'right-section': any\n default: any\n}>()\n\nconst slots = useSlots()\n\nconst hasLeftSlot = computed(() => !!slots['left-section'])\nconst hasRightSlot = computed(() => !!slots['right-section'])\n\nconst props = withDefaults(defineProps<ButtonProps>(), {\n radius: '4px',\n size: 'sm',\n tag: 'button',\n variant: 'default'\n})\n\nconst { _disabled, _props, _ref, handleClick } = useButton(props, {\n hasLeftSlot: hasLeftSlot.value,\n hasRightSlot: hasRightSlot.value\n})\n\nconst buttonStyle = useButtonCustomStyle(props)\nconst ns = useNamespace('button')\nconst buttonClass = computed(() => [\n useNamespace('focus').b('auto'),\n !_disabled.value && useNamespace('active').b(),\n ns.e('root'),\n ns.is('loading', props.loading)\n])\nconst innerClass = computed(() => [ns.e('inner')])\nconst labelClass = computed(() => [ns.e('label')])\n\ndefineExpose({\n /** @description if button is disabled */\n disabled: _disabled.value,\n /** @description button html element */\n ref: _ref,\n /** @description button size */\n size: props.size,\n /** @description button variant */\n variant: props.variant\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CA,MAAM,QAAQ,SAAS;EAEvB,MAAM,cAAc,eAAe,CAAC,CAAC,MAAM,eAAe;EAC1D,MAAM,eAAe,eAAe,CAAC,CAAC,MAAM,gBAAgB;EAE5D,MAAM,QAAQ;EAOd,MAAM,EAAE,WAAW,QAAQ,MAAM,gBAAgB,UAAU,OAAO;GAChE,aAAa,YAAY;GACzB,cAAc,aAAa;EAC7B,CAAC;EAED,MAAM,cAAc,qBAAqB,KAAK;EAC9C,MAAM,KAAK,aAAa,QAAQ;EAChC,MAAM,cAAc,eAAe;GACjC,aAAa,OAAO,CAAC,CAAC,EAAE,MAAM;GAC9B,CAAC,UAAU,SAAS,aAAa,QAAQ,CAAC,CAAC,EAAE;GAC7C,GAAG,EAAE,MAAM;GACX,GAAG,GAAG,WAAW,MAAM,OAAO;EAChC,CAAC;EACD,MAAM,aAAa,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;EACjD,MAAM,aAAa,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;EAEjD,SAAa;;GAEX,UAAU,UAAU;;GAEpB,KAAK;;GAEL,MAAM,MAAM;;GAEZ,SAAS,MAAM;EACjB,CAAC;;uBAjFC,YAwBY,wBArBL,QAAA,GAAG,GAHV,WACU,MAuBE,MAAA,GAvBI;IACb,OAAO,YAAA;IAEP,OAAO,MAAA,WAAA;IACP,SAAO,MAAA,WAAA;;2BAkBD,CAhBP,mBAgBO,QAAA,EAhBA,OAAK,eAAE,WAAA,KAAU,EAAA,GAAA;KACWA,KAAAA,OAAM,mBAAA,UAAA,GAAvC,mBAEO,QAFP,YAEO,CADL,WAAiC,KAAA,QAAA,cAAA,CAAA,CAAA,KAEG,QAAA,eAAA,UAAA,GAAtC,mBAEO,QAFP,YAEO,EAAA,UAAA,GADL,YAA+B,wBAAf,QAAA,WAAW,CAAA,EAAA,CAAA,KAAA,mBAAA,QAAA,IAAA;KAE7B,mBAEO,QAAA,EAFA,OAAK,eAAE,WAAA,KAAU,EAAA,GAAA,CACtB,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA;KAEwBA,KAAAA,OAAM,oBAAA,UAAA,GAAxC,mBAEO,QAFP,YAEO,CADL,WAAkC,KAAA,QAAA,eAAA,CAAA,CAAA,KAEG,QAAA,gBAAA,UAAA,GAAvC,mBAEO,QAFP,YAEO,EAAA,UAAA,GADL,YAAgC,wBAAhB,QAAA,YAAY,CAAA,EAAA,CAAA,KAAA,mBAAA,QAAA,IAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { vue_runtime_esm_bundler_exports } from "../../../../node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
|
|
2
1
|
import { useFormDisabled } from "../../form/src/hooks/use-form-common-props.mjs";
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
3
|
//#region ../../packages/components/button/src/use-button.ts
|
|
4
4
|
const useButton = (props, slots) => {
|
|
5
5
|
const _disabled = useFormDisabled();
|
|
6
|
-
const _ref =
|
|
6
|
+
const _ref = ref();
|
|
7
7
|
const { hasLeftSlot, hasRightSlot } = slots;
|
|
8
8
|
const hasLeftSection = hasLeftSlot || !!props.leftSection;
|
|
9
9
|
const hasRightSection = hasRightSlot || !!props.rightSection;
|
|
10
|
-
const _props =
|
|
10
|
+
const _props = computed(() => {
|
|
11
11
|
const _attrs = {
|
|
12
12
|
"data-disabled": _disabled.value || props.loading || void 0,
|
|
13
13
|
"data-block": props.fullWidth || void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-button.mjs","names":[],"sources":["../../../../../../../packages/components/button/src/use-button.ts"],"sourcesContent":["import {} from '@cck-ui/components'\nimport { computed, ref } from 'vue'\nimport { ButtonProps } from './button.types'\nimport { useFormDisabled } from '@cck-ui/components/form'\n\nexport const useButton = (\n props: ButtonProps,\n slots: {\n hasLeftSlot: boolean\n hasRightSlot: boolean\n }\n) => {\n const _disabled = useFormDisabled()\n const _ref = ref<HTMLButtonElement>()\n\n const { hasLeftSlot, hasRightSlot } = slots\n\n const hasLeftSection = hasLeftSlot || !!props.leftSection\n const hasRightSection = hasRightSlot || !!props.rightSection\n\n const _props = computed(() => {\n const _attrs: Record<string, any> = {\n 'data-disabled': _disabled.value || props.loading || undefined,\n 'data-block': props.fullWidth || undefined,\n 'data-size': props.size && props.size !== 'sm' ? props.size : undefined,\n 'data-with-left-section': hasLeftSection || undefined,\n 'data-with-right-section': hasRightSection || undefined,\n 'data-variant': props.variant || 'default'\n }\n if (props.tag === 'button') {\n _attrs['aria-disabled'] = _disabled.value || props.loading || undefined\n _attrs['disabled'] = _disabled.value || props.loading\n }\n return _attrs\n })\n\n const handleClick = (evt: MouseEvent) => {\n if (_disabled.value || props.loading) {\n evt.stopPropagation()\n return\n }\n }\n\n return {\n _disabled,\n _ref,\n _props,\n handleClick\n }\n}\n"],"mappings":";;;AAKA,MAAa,aACX,OACA,UAIG;CACH,MAAM,YAAY,gBAAgB;CAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"use-button.mjs","names":[],"sources":["../../../../../../../packages/components/button/src/use-button.ts"],"sourcesContent":["import {} from '@cck-ui/components'\nimport { computed, ref } from 'vue'\nimport { ButtonProps } from './button.types'\nimport { useFormDisabled } from '@cck-ui/components/form'\n\nexport const useButton = (\n props: ButtonProps,\n slots: {\n hasLeftSlot: boolean\n hasRightSlot: boolean\n }\n) => {\n const _disabled = useFormDisabled()\n const _ref = ref<HTMLButtonElement>()\n\n const { hasLeftSlot, hasRightSlot } = slots\n\n const hasLeftSection = hasLeftSlot || !!props.leftSection\n const hasRightSection = hasRightSlot || !!props.rightSection\n\n const _props = computed(() => {\n const _attrs: Record<string, any> = {\n 'data-disabled': _disabled.value || props.loading || undefined,\n 'data-block': props.fullWidth || undefined,\n 'data-size': props.size && props.size !== 'sm' ? props.size : undefined,\n 'data-with-left-section': hasLeftSection || undefined,\n 'data-with-right-section': hasRightSection || undefined,\n 'data-variant': props.variant || 'default'\n }\n if (props.tag === 'button') {\n _attrs['aria-disabled'] = _disabled.value || props.loading || undefined\n _attrs['disabled'] = _disabled.value || props.loading\n }\n return _attrs\n })\n\n const handleClick = (evt: MouseEvent) => {\n if (_disabled.value || props.loading) {\n evt.stopPropagation()\n return\n }\n }\n\n return {\n _disabled,\n _ref,\n _props,\n handleClick\n }\n}\n"],"mappings":";;;AAKA,MAAa,aACX,OACA,UAIG;CACH,MAAM,YAAY,gBAAgB;CAClC,MAAM,OAAO,IAAuB;CAEpC,MAAM,EAAE,aAAa,iBAAiB;CAEtC,MAAM,iBAAiB,eAAe,CAAC,CAAC,MAAM;CAC9C,MAAM,kBAAkB,gBAAgB,CAAC,CAAC,MAAM;CAEhD,MAAM,SAAS,eAAe;EAC5B,MAAM,SAA8B;GAClC,iBAAiB,UAAU,SAAS,MAAM,WAAW,KAAA;GACrD,cAAc,MAAM,aAAa,KAAA;GACjC,aAAa,MAAM,QAAQ,MAAM,SAAS,OAAO,MAAM,OAAO,KAAA;GAC9D,0BAA0B,kBAAkB,KAAA;GAC5C,2BAA2B,mBAAmB,KAAA;GAC9C,gBAAgB,MAAM,WAAW;EACnC;EACA,IAAI,MAAM,QAAQ,UAAU;GAC1B,OAAO,mBAAmB,UAAU,SAAS,MAAM,WAAW,KAAA;GAC9D,OAAO,cAAc,UAAU,SAAS,MAAM;EAChD;EACA,OAAO;CACT,CAAC;CAED,MAAM,eAAe,QAAoB;EACvC,IAAI,UAAU,SAAS,MAAM,SAAS;GACpC,IAAI,gBAAgB;GACpB;EACF;CACF;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { vue_runtime_esm_bundler_exports } from "../../../../../node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
|
|
2
1
|
import { useProp } from "../../../../hooks/use-prop/index.mjs";
|
|
3
2
|
import { formContextKey } from "../constants.mjs";
|
|
3
|
+
import { computed, inject, unref } from "vue";
|
|
4
4
|
//#region ../../packages/components/form/src/hooks/use-form-common-props.ts
|
|
5
5
|
const useFormDisabled = (fallback) => {
|
|
6
6
|
const disabled = useProp("disabled");
|
|
7
|
-
const form =
|
|
8
|
-
return
|
|
9
|
-
return disabled.value ??
|
|
7
|
+
const form = inject(formContextKey, void 0);
|
|
8
|
+
return computed(() => {
|
|
9
|
+
return disabled.value ?? unref(fallback) ?? form?.disabled ?? false;
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
const useDisabled = useFormDisabled;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-common-props.mjs","names":[],"sources":["../../../../../../../../packages/components/form/src/hooks/use-form-common-props.ts"],"sourcesContent":["import { useProp } from '@cck-ui/hooks'\nimport { computed, inject, MaybeRef, unref } from 'vue'\nimport { formContextKey } from '../constants'\n\nexport const useFormDisabled = (fallback?: MaybeRef<boolean | undefined>) => {\n const disabled = useProp<boolean>('disabled')\n const form = inject(formContextKey, undefined)\n\n return computed(() => {\n return disabled.value ?? unref(fallback) ?? form?.disabled ?? false\n })\n}\n\nexport const useDisabled = useFormDisabled\n"],"mappings":";;;;AAIA,MAAa,mBAAmB,aAA6C;CAC3E,MAAM,WAAW,QAAiB,UAAU;CAC5C,MAAM,
|
|
1
|
+
{"version":3,"file":"use-form-common-props.mjs","names":[],"sources":["../../../../../../../../packages/components/form/src/hooks/use-form-common-props.ts"],"sourcesContent":["import { useProp } from '@cck-ui/hooks'\nimport { computed, inject, MaybeRef, unref } from 'vue'\nimport { formContextKey } from '../constants'\n\nexport const useFormDisabled = (fallback?: MaybeRef<boolean | undefined>) => {\n const disabled = useProp<boolean>('disabled')\n const form = inject(formContextKey, undefined)\n\n return computed(() => {\n return disabled.value ?? unref(fallback) ?? form?.disabled ?? false\n })\n}\n\nexport const useDisabled = useFormDisabled\n"],"mappings":";;;;AAIA,MAAa,mBAAmB,aAA6C;CAC3E,MAAM,WAAW,QAAiB,UAAU;CAC5C,MAAM,OAAO,OAAO,gBAAgB,KAAA,CAAS;CAE7C,OAAO,eAAe;EACpB,OAAO,SAAS,SAAS,MAAM,QAAQ,KAAK,MAAM,YAAY;CAChE,CAAC;AACH;AAEA,MAAa,cAAc"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isUndefined } from "../../../utils/types.mjs";
|
|
2
2
|
import { addUnit } from "../../../utils/dom/style.mjs";
|
|
3
|
-
import { vue_runtime_esm_bundler_exports } from "../../../../node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
|
|
4
3
|
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
|
|
4
|
+
import { computed, createElementBlock, defineComponent, mergeProps, openBlock, renderSlot, unref } from "vue";
|
|
5
5
|
//#region ../../packages/components/icon/src/icon.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var icon_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
6
|
+
var icon_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
7
7
|
name: "CIcon",
|
|
8
8
|
inheritAttrs: false,
|
|
9
9
|
__name: "icon",
|
|
@@ -20,7 +20,7 @@ var icon_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_run
|
|
|
20
20
|
setup(__props) {
|
|
21
21
|
const props = __props;
|
|
22
22
|
const ns = useNamespace("icon");
|
|
23
|
-
const style =
|
|
23
|
+
const style = computed(() => {
|
|
24
24
|
const { size, color } = props;
|
|
25
25
|
if (!size && !color) return {};
|
|
26
26
|
return {
|
|
@@ -29,10 +29,10 @@ var icon_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_run
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
return (_ctx, _cache) => {
|
|
32
|
-
return
|
|
33
|
-
class:
|
|
32
|
+
return openBlock(), createElementBlock("i", mergeProps({
|
|
33
|
+
class: unref(ns).b(),
|
|
34
34
|
style: style.value
|
|
35
|
-
}, _ctx.$attrs), [
|
|
35
|
+
}, _ctx.$attrs), [renderSlot(_ctx.$slots, "default")], 16);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.vue_vue_type_script_setup_true_lang.mjs","names":["$attrs"],"sources":["../../../../../../../packages/components/icon/src/icon.vue"
|
|
1
|
+
{"version":3,"file":"icon.vue_vue_type_script_setup_true_lang.mjs","names":["$attrs"],"sources":["../../../../../../../packages/components/icon/src/icon.vue"],"sourcesContent":["<template>\n <i :class=\"ns.b()\" :style=\"style\" v-bind=\"$attrs\">\n <slot />\n </i>\n</template>\n\n<script setup lang=\"ts\">\nimport { type CSSProperties, computed } from 'vue'\nimport { useNamespace } from '@cck-ui/hooks'\nimport { addUnit, isUndefined } from '@cck-ui/utils'\nimport { type IconProps } from './icon.types'\n\ndefineOptions({\n name: 'CIcon',\n inheritAttrs: false\n})\nconst props = defineProps<IconProps>()\nconst ns = useNamespace('icon')\n\nconst style = computed<CSSProperties>(() => {\n const { size, color } = props\n if (!size && !color) return {}\n\n return {\n fontSize: isUndefined(size) ? undefined : addUnit(size),\n '--color': color\n }\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAgBA,MAAM,QAAQ;EACd,MAAM,KAAK,aAAa,MAAM;EAE9B,MAAM,QAAQ,eAA8B;GAC1C,MAAM,EAAE,MAAM,UAAU;GACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,OAAO,CAAC;GAE7B,OAAO;IACL,UAAU,YAAY,IAAI,IAAI,KAAA,IAAY,QAAQ,IAAI;IACtD,WAAW;GACb;EACF,CAAC;;uBA1BC,mBAEI,KAFJ,WAEI;IAFA,OAAO,MAAA,EAAA,CAAE,CAAC,EAAC;IAAK,OAAO,MAAA;MAAeA,KAAAA,MAAM,GAAA,CAC9C,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, getCurrentInstance, inject, ref, unref } from "vue";
|
|
2
2
|
//#region ../../packages/hooks/use-namespace/index.ts
|
|
3
3
|
const defaultNamespace = "c";
|
|
4
4
|
const statePrefix = "is-";
|
|
@@ -11,9 +11,9 @@ const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
|
11
11
|
};
|
|
12
12
|
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
13
13
|
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
14
|
-
const derivedNamespace = namespaceOverrides || (
|
|
15
|
-
return
|
|
16
|
-
return
|
|
14
|
+
const derivedNamespace = namespaceOverrides || (getCurrentInstance() ? inject(namespaceContextKey, ref("c")) : ref("c"));
|
|
15
|
+
return computed(() => {
|
|
16
|
+
return unref(derivedNamespace) || "c";
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
const useNamespace = (block, namespaceOverrides) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-namespace/index.ts"],"sourcesContent":["import { computed, getCurrentInstance, inject, ref, unref } from 'vue'\n\nimport type { InjectionKey, Ref } from 'vue'\n\nexport const defaultNamespace = 'c'\nconst statePrefix = 'is-'\n\nconst _bem = (\n namespace: string,\n block: string,\n blockSuffix: string,\n element: string,\n modifier: string\n) => {\n let cls = `${namespace}-${block}`\n if (blockSuffix) {\n cls += `-${blockSuffix}`\n }\n if (element) {\n cls += `__${element}`\n }\n if (modifier) {\n cls += `--${modifier}`\n }\n return cls\n}\n\nexport const namespaceContextKey: InjectionKey<Ref<string | undefined>> =\n Symbol('namespaceContextKey')\n\nexport const useGetDerivedNamespace = (\n namespaceOverrides?: Ref<string | undefined>\n) => {\n const derivedNamespace =\n namespaceOverrides ||\n (getCurrentInstance()\n ? inject(namespaceContextKey, ref(defaultNamespace))\n : ref(defaultNamespace))\n const namespace = computed(() => {\n return unref(derivedNamespace) || defaultNamespace\n })\n return namespace\n}\n\nexport const useNamespace = (\n block: string,\n namespaceOverrides?: Ref<string | undefined>\n) => {\n const namespace = useGetDerivedNamespace(namespaceOverrides)\n const b = (blockSuffix = '') =>\n _bem(namespace.value, block, blockSuffix, '', '')\n const e = (element?: string) =>\n element ? _bem(namespace.value, block, '', element, '') : ''\n const m = (modifier?: string) =>\n modifier ? _bem(namespace.value, block, '', '', modifier) : ''\n const be = (blockSuffix?: string, element?: string) =>\n blockSuffix && element\n ? _bem(namespace.value, block, blockSuffix, element, '')\n : ''\n const em = (element?: string, modifier?: string) =>\n element && modifier\n ? _bem(namespace.value, block, '', element, modifier)\n : ''\n const bm = (blockSuffix?: string, modifier?: string) =>\n blockSuffix && modifier\n ? _bem(namespace.value, block, blockSuffix, '', modifier)\n : ''\n const bem = (blockSuffix?: string, element?: string, modifier?: string) =>\n blockSuffix && element && modifier\n ? _bem(namespace.value, block, blockSuffix, element, modifier)\n : ''\n const is: {\n (name: string, state: boolean | undefined): string\n (name: string): string\n } = (name: string, ...args: [boolean | undefined] | []) => {\n const state = args.length >= 1 ? args[0]! : true\n return name && state ? `${statePrefix}${name}` : ''\n }\n\n // for css var\n // --el-xxx: value;\n const cssVar = (object: Record<string, string>) => {\n const styles: Record<string, string> = {}\n for (const key in object) {\n if (object[key]) {\n styles[`--${namespace.value}-${key}`] = object[key]\n }\n }\n return styles\n }\n // with block\n const cssVarBlock = (object: Record<string, string>) => {\n const styles: Record<string, string> = {}\n for (const key in object) {\n if (object[key]) {\n styles[`--${namespace.value}-${block}-${key}`] = object[key]\n }\n }\n return styles\n }\n\n const cssVarName = (name: string) => `--${namespace.value}-${name}`\n const cssVarBlockName = (name: string) =>\n `--${namespace.value}-${block}-${name}`\n\n return {\n namespace,\n b,\n e,\n m,\n be,\n em,\n bm,\n bem,\n is,\n // css\n cssVar,\n cssVarName,\n cssVarBlock,\n cssVarBlockName\n }\n}\n\nexport type UseNamespaceReturn = ReturnType<typeof useNamespace>\n"],"mappings":";;AAIA,MAAa,mBAAmB;AAChC,MAAM,cAAc;AAEpB,MAAM,QACJ,WACA,OACA,aACA,SACA,aACG;CACH,IAAI,MAAM,GAAG,UAAU,GAAG;CAC1B,IAAI,aACF,OAAO,IAAI;CAEb,IAAI,SACF,OAAO,KAAK;CAEd,IAAI,UACF,OAAO,KAAK;CAEd,OAAO;AACT;AAEA,MAAa,sBACX,OAAO,qBAAqB;AAE9B,MAAa,0BACX,uBACG;CACH,MAAM,mBACJ,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-namespace/index.ts"],"sourcesContent":["import { computed, getCurrentInstance, inject, ref, unref } from 'vue'\n\nimport type { InjectionKey, Ref } from 'vue'\n\nexport const defaultNamespace = 'c'\nconst statePrefix = 'is-'\n\nconst _bem = (\n namespace: string,\n block: string,\n blockSuffix: string,\n element: string,\n modifier: string\n) => {\n let cls = `${namespace}-${block}`\n if (blockSuffix) {\n cls += `-${blockSuffix}`\n }\n if (element) {\n cls += `__${element}`\n }\n if (modifier) {\n cls += `--${modifier}`\n }\n return cls\n}\n\nexport const namespaceContextKey: InjectionKey<Ref<string | undefined>> =\n Symbol('namespaceContextKey')\n\nexport const useGetDerivedNamespace = (\n namespaceOverrides?: Ref<string | undefined>\n) => {\n const derivedNamespace =\n namespaceOverrides ||\n (getCurrentInstance()\n ? inject(namespaceContextKey, ref(defaultNamespace))\n : ref(defaultNamespace))\n const namespace = computed(() => {\n return unref(derivedNamespace) || defaultNamespace\n })\n return namespace\n}\n\nexport const useNamespace = (\n block: string,\n namespaceOverrides?: Ref<string | undefined>\n) => {\n const namespace = useGetDerivedNamespace(namespaceOverrides)\n const b = (blockSuffix = '') =>\n _bem(namespace.value, block, blockSuffix, '', '')\n const e = (element?: string) =>\n element ? _bem(namespace.value, block, '', element, '') : ''\n const m = (modifier?: string) =>\n modifier ? _bem(namespace.value, block, '', '', modifier) : ''\n const be = (blockSuffix?: string, element?: string) =>\n blockSuffix && element\n ? _bem(namespace.value, block, blockSuffix, element, '')\n : ''\n const em = (element?: string, modifier?: string) =>\n element && modifier\n ? _bem(namespace.value, block, '', element, modifier)\n : ''\n const bm = (blockSuffix?: string, modifier?: string) =>\n blockSuffix && modifier\n ? _bem(namespace.value, block, blockSuffix, '', modifier)\n : ''\n const bem = (blockSuffix?: string, element?: string, modifier?: string) =>\n blockSuffix && element && modifier\n ? _bem(namespace.value, block, blockSuffix, element, modifier)\n : ''\n const is: {\n (name: string, state: boolean | undefined): string\n (name: string): string\n } = (name: string, ...args: [boolean | undefined] | []) => {\n const state = args.length >= 1 ? args[0]! : true\n return name && state ? `${statePrefix}${name}` : ''\n }\n\n // for css var\n // --el-xxx: value;\n const cssVar = (object: Record<string, string>) => {\n const styles: Record<string, string> = {}\n for (const key in object) {\n if (object[key]) {\n styles[`--${namespace.value}-${key}`] = object[key]\n }\n }\n return styles\n }\n // with block\n const cssVarBlock = (object: Record<string, string>) => {\n const styles: Record<string, string> = {}\n for (const key in object) {\n if (object[key]) {\n styles[`--${namespace.value}-${block}-${key}`] = object[key]\n }\n }\n return styles\n }\n\n const cssVarName = (name: string) => `--${namespace.value}-${name}`\n const cssVarBlockName = (name: string) =>\n `--${namespace.value}-${block}-${name}`\n\n return {\n namespace,\n b,\n e,\n m,\n be,\n em,\n bm,\n bem,\n is,\n // css\n cssVar,\n cssVarName,\n cssVarBlock,\n cssVarBlockName\n }\n}\n\nexport type UseNamespaceReturn = ReturnType<typeof useNamespace>\n"],"mappings":";;AAIA,MAAa,mBAAmB;AAChC,MAAM,cAAc;AAEpB,MAAM,QACJ,WACA,OACA,aACA,SACA,aACG;CACH,IAAI,MAAM,GAAG,UAAU,GAAG;CAC1B,IAAI,aACF,OAAO,IAAI;CAEb,IAAI,SACF,OAAO,KAAK;CAEd,IAAI,UACF,OAAO,KAAK;CAEd,OAAO;AACT;AAEA,MAAa,sBACX,OAAO,qBAAqB;AAE9B,MAAa,0BACX,uBACG;CACH,MAAM,mBACJ,uBACC,mBAAmB,IAChB,OAAO,qBAAqB,IAAA,GAAoB,CAAC,IACjD,IAAA,GAAoB;CAI1B,OAHkB,eAAe;EAC/B,OAAO,MAAM,gBAAgB,KAAA;CAC/B,CACe;AACjB;AAEA,MAAa,gBACX,OACA,uBACG;CACH,MAAM,YAAY,uBAAuB,kBAAkB;CAC3D,MAAM,KAAK,cAAc,OACvB,KAAK,UAAU,OAAO,OAAO,aAAa,IAAI,EAAE;CAClD,MAAM,KAAK,YACT,UAAU,KAAK,UAAU,OAAO,OAAO,IAAI,SAAS,EAAE,IAAI;CAC5D,MAAM,KAAK,aACT,WAAW,KAAK,UAAU,OAAO,OAAO,IAAI,IAAI,QAAQ,IAAI;CAC9D,MAAM,MAAM,aAAsB,YAChC,eAAe,UACX,KAAK,UAAU,OAAO,OAAO,aAAa,SAAS,EAAE,IACrD;CACN,MAAM,MAAM,SAAkB,aAC5B,WAAW,WACP,KAAK,UAAU,OAAO,OAAO,IAAI,SAAS,QAAQ,IAClD;CACN,MAAM,MAAM,aAAsB,aAChC,eAAe,WACX,KAAK,UAAU,OAAO,OAAO,aAAa,IAAI,QAAQ,IACtD;CACN,MAAM,OAAO,aAAsB,SAAkB,aACnD,eAAe,WAAW,WACtB,KAAK,UAAU,OAAO,OAAO,aAAa,SAAS,QAAQ,IAC3D;CACN,MAAM,MAGD,MAAc,GAAG,SAAqC;EACzD,MAAM,QAAQ,KAAK,UAAU,IAAI,KAAK,KAAM;EAC5C,OAAO,QAAQ,QAAQ,GAAG,cAAc,SAAS;CACnD;CAIA,MAAM,UAAU,WAAmC;EACjD,MAAM,SAAiC,CAAC;EACxC,KAAK,MAAM,OAAO,QAChB,IAAI,OAAO,MACT,OAAO,KAAK,UAAU,MAAM,GAAG,SAAS,OAAO;EAGnD,OAAO;CACT;CAEA,MAAM,eAAe,WAAmC;EACtD,MAAM,SAAiC,CAAC;EACxC,KAAK,MAAM,OAAO,QAChB,IAAI,OAAO,MACT,OAAO,KAAK,UAAU,MAAM,GAAG,MAAM,GAAG,SAAS,OAAO;EAG5D,OAAO;CACT;CAEA,MAAM,cAAc,SAAiB,KAAK,UAAU,MAAM,GAAG;CAC7D,MAAM,mBAAmB,SACvB,KAAK,UAAU,MAAM,GAAG,MAAM,GAAG;CAEnC,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, getCurrentInstance } from "vue";
|
|
2
2
|
//#region ../../packages/hooks/use-prop/index.ts
|
|
3
3
|
const useProp = (name) => {
|
|
4
|
-
const vm =
|
|
5
|
-
return
|
|
4
|
+
const vm = getCurrentInstance();
|
|
5
|
+
return computed(() => (vm?.proxy?.$props)?.[name]);
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
8
|
export { useProp };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-prop/index.ts"],"sourcesContent":["import { computed, getCurrentInstance } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nexport const useProp = <T>(name: string): ComputedRef<T | undefined> => {\n const vm = getCurrentInstance()\n return computed(() => (vm?.proxy?.$props as any)?.[name])\n}\n"],"mappings":";;AAGA,MAAa,WAAc,SAA6C;CACtE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-prop/index.ts"],"sourcesContent":["import { computed, getCurrentInstance } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nexport const useProp = <T>(name: string): ComputedRef<T | undefined> => {\n const vm = getCurrentInstance()\n return computed(() => (vm?.proxy?.$props as any)?.[name])\n}\n"],"mappings":";;AAGA,MAAa,WAAc,SAA6C;CACtE,MAAM,KAAK,mBAAmB;CAC9B,OAAO,gBAAgB,IAAI,OAAO,OAAA,GAAiB,KAAK;AAC1D"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readonly, ref } from "vue";
|
|
2
2
|
//#region ../../packages/hooks/use-theme/index.ts
|
|
3
3
|
const getCurrentScheme = () => {
|
|
4
4
|
if (typeof document === "undefined") return "light";
|
|
5
5
|
return document.documentElement.dataset.cColorScheme === "dark" ? "dark" : "light";
|
|
6
6
|
};
|
|
7
|
-
const colorScheme =
|
|
7
|
+
const colorScheme = ref(getCurrentScheme());
|
|
8
8
|
if (typeof window !== "undefined") new MutationObserver(() => {
|
|
9
9
|
const newScheme = getCurrentScheme();
|
|
10
10
|
if (newScheme !== colorScheme.value) colorScheme.value = newScheme;
|
|
@@ -12,7 +12,7 @@ if (typeof window !== "undefined") new MutationObserver(() => {
|
|
|
12
12
|
attributes: true,
|
|
13
13
|
attributeFilter: ["data-c-color-scheme"]
|
|
14
14
|
});
|
|
15
|
-
const useColorScheme = () =>
|
|
15
|
+
const useColorScheme = () => readonly(colorScheme);
|
|
16
16
|
//#endregion
|
|
17
17
|
export { useColorScheme };
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-theme/index.ts"],"sourcesContent":["import { readonly, ref } from 'vue'\n\nexport type ColorScheme = 'light' | 'dark'\n\nconst getCurrentScheme = (): ColorScheme => {\n if (typeof document === 'undefined') return 'light'\n const scheme = document.documentElement.dataset.cColorScheme\n return scheme === 'dark' ? 'dark' : 'light'\n}\n\nconst colorScheme = ref<ColorScheme>(getCurrentScheme())\n\nif (typeof window !== 'undefined') {\n const observer = new MutationObserver(() => {\n const newScheme = getCurrentScheme()\n if (newScheme !== colorScheme.value) {\n colorScheme.value = newScheme\n }\n })\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['data-c-color-scheme']\n })\n}\n\nexport const useColorScheme = () => readonly(colorScheme)\n"],"mappings":";;AAIA,MAAM,yBAAsC;CAC1C,IAAI,OAAO,aAAa,aAAa,OAAO;CAE5C,OADe,SAAS,gBAAgB,QAAQ,iBAC9B,SAAS,SAAS;AACtC;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../packages/hooks/use-theme/index.ts"],"sourcesContent":["import { readonly, ref } from 'vue'\n\nexport type ColorScheme = 'light' | 'dark'\n\nconst getCurrentScheme = (): ColorScheme => {\n if (typeof document === 'undefined') return 'light'\n const scheme = document.documentElement.dataset.cColorScheme\n return scheme === 'dark' ? 'dark' : 'light'\n}\n\nconst colorScheme = ref<ColorScheme>(getCurrentScheme())\n\nif (typeof window !== 'undefined') {\n const observer = new MutationObserver(() => {\n const newScheme = getCurrentScheme()\n if (newScheme !== colorScheme.value) {\n colorScheme.value = newScheme\n }\n })\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['data-c-color-scheme']\n })\n}\n\nexport const useColorScheme = () => readonly(colorScheme)\n"],"mappings":";;AAIA,MAAM,yBAAsC;CAC1C,IAAI,OAAO,aAAa,aAAa,OAAO;CAE5C,OADe,SAAS,gBAAgB,QAAQ,iBAC9B,SAAS,SAAS;AACtC;AAEA,MAAM,cAAc,IAAiB,iBAAiB,CAAC;AAEvD,IAAI,OAAO,WAAW,aAOpB,IANqB,uBAAuB;CAC1C,MAAM,YAAY,iBAAiB;CACnC,IAAI,cAAc,YAAY,OAC5B,YAAY,QAAQ;AAExB,CACO,CAAC,CAAC,QAAQ,SAAS,iBAAiB;CACzC,YAAY;CACZ,iBAAiB,CAAC,qBAAqB;AACzC,CAAC;AAGH,MAAa,uBAAuB,SAAS,WAAW"}
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
2
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
-
var __exportAll = (all, no_symbols) => {
|
|
10
|
-
let target = {};
|
|
11
|
-
for (var name in all) __defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
-
return target;
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
-
key = keys[i];
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
-
get: ((k) => from[k]).bind(null, key),
|
|
23
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
32
|
-
}) : target, mod));
|
|
33
3
|
//#endregion
|
|
34
4
|
exports.__commonJSMin = __commonJSMin;
|
|
35
|
-
exports.__exportAll = __exportAll;
|
|
36
|
-
exports.__reExport = __reExport;
|
|
37
|
-
exports.__toESM = __toESM;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_colors = require("../../../utils/colors.js");
|
|
3
|
-
const require_index = require("
|
|
4
|
-
|
|
3
|
+
const require_index = require("../../../hooks/use-theme/index.js");
|
|
4
|
+
let vue = require("vue");
|
|
5
5
|
//#region ../../packages/components/button/src/button-custom.ts
|
|
6
6
|
const PRESET_COLORS = [
|
|
7
7
|
"red",
|
|
@@ -40,8 +40,8 @@ const getShadeIndexes = (scheme) => {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
function useButtonCustomStyle(props) {
|
|
43
|
-
const colorScheme = require_index
|
|
44
|
-
return (0,
|
|
43
|
+
const colorScheme = require_index.useColorScheme();
|
|
44
|
+
return (0, vue.computed)(() => {
|
|
45
45
|
const styles = {};
|
|
46
46
|
const { color, gradient, justify, variant } = props;
|
|
47
47
|
const scheme = colorScheme.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-custom.js","names":["useColorScheme","generateColorShades","setColorAlpha"],"sources":["../../../../../../../packages/components/button/src/button-custom.ts"],"sourcesContent":["import { ColorScheme, useColorScheme } from '@cck-ui/hooks'\nimport { generateColorShades, setColorAlpha } from '@cck-ui/utils'\nimport { computed } from 'vue'\nimport { ButtonProps } from './button.types'\n\nconst PRESET_COLORS = [\n 'red',\n 'pink',\n 'grape',\n 'violet',\n 'indigo',\n 'blue',\n 'cyan',\n 'teal',\n 'green',\n 'lime',\n 'yellow',\n 'orange',\n 'gray',\n 'dark'\n]\n\nconst getShadeIndexes = (scheme: ColorScheme) => {\n if (scheme === 'light') {\n return {\n bg: 6,\n hover: 7,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 6,\n outlineHoverBgAlpha: 0.05\n }\n } else {\n return {\n bg: 8,\n hover: 9,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 4,\n outlineHoverBgAlpha: 0.05\n }\n }\n}\n\nexport function useButtonCustomStyle(props: ButtonProps) {\n const colorScheme = useColorScheme()\n\n return computed(() => {\n const styles: Record<string, string> = {}\n\n const { color, gradient, justify, variant } = props\n const scheme = colorScheme.value\n const idx = getShadeIndexes(scheme)\n\n if (justify) {\n styles['--button-justify'] = justify\n }\n\n switch (variant) {\n case 'default':\n break\n case 'filled':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-filled)`\n styles['--button-hover'] = `var(--c-color-${color}-filled-hover)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.bg]\n styles['--button-hover'] = shades[idx.hover]\n }\n }\n break\n case 'light':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-light)`\n styles['--button-hover'] = `var(--c-color-${color}-light-hover)`\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.lightBg]\n styles['--button-hover'] = shades[idx.lightHover]\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'outline':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid ${shades[idx.outlineColor]}`\n }\n }\n break\n case 'subtle':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n }\n }\n break\n case 'transparent':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'white':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-filled)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.bg]\n }\n }\n break\n case 'gradient':\n const from = gradient?.from || 'blue'\n const to = gradient?.to || 'cyan'\n const deg = gradient?.deg || '45'\n\n let finalFrom: string = from\n let finalTo: string = to\n if (PRESET_COLORS.includes(from)) {\n finalFrom = `var(--c-color-${from}-filled)`\n }\n if (PRESET_COLORS.includes(to)) {\n finalTo = `var(--c-color-${to}-filled)`\n }\n\n styles['--button-bg'] =\n `linear-gradient(${deg}deg, ${finalFrom} 0%, ${finalTo} 100%)`\n break\n default:\n break\n }\n\n return styles\n })\n}\n"],"mappings":";;;;;AAKA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB,WAAwB;CAC/C,IAAI,WAAW,SACb,OAAO;EACL,IAAI;EACJ,OAAO;EACP,SAAS;EACT,YAAY;EACZ,YAAY;EACZ,cAAc;EACd,qBAAqB;CACvB;MAEA,OAAO;EACL,IAAI;EACJ,OAAO;EACP,SAAS;EACT,YAAY;EACZ,YAAY;EACZ,cAAc;EACd,qBAAqB;CACvB;AAEJ;AAEA,SAAgB,qBAAqB,OAAoB;CACvD,MAAM,cAAcA,
|
|
1
|
+
{"version":3,"file":"button-custom.js","names":["useColorScheme","generateColorShades","setColorAlpha"],"sources":["../../../../../../../packages/components/button/src/button-custom.ts"],"sourcesContent":["import { ColorScheme, useColorScheme } from '@cck-ui/hooks'\nimport { generateColorShades, setColorAlpha } from '@cck-ui/utils'\nimport { computed } from 'vue'\nimport { ButtonProps } from './button.types'\n\nconst PRESET_COLORS = [\n 'red',\n 'pink',\n 'grape',\n 'violet',\n 'indigo',\n 'blue',\n 'cyan',\n 'teal',\n 'green',\n 'lime',\n 'yellow',\n 'orange',\n 'gray',\n 'dark'\n]\n\nconst getShadeIndexes = (scheme: ColorScheme) => {\n if (scheme === 'light') {\n return {\n bg: 6,\n hover: 7,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 6,\n outlineHoverBgAlpha: 0.05\n }\n } else {\n return {\n bg: 8,\n hover: 9,\n lightBg: 1,\n lightHover: 2,\n lightColor: 9,\n outlineColor: 4,\n outlineHoverBgAlpha: 0.05\n }\n }\n}\n\nexport function useButtonCustomStyle(props: ButtonProps) {\n const colorScheme = useColorScheme()\n\n return computed(() => {\n const styles: Record<string, string> = {}\n\n const { color, gradient, justify, variant } = props\n const scheme = colorScheme.value\n const idx = getShadeIndexes(scheme)\n\n if (justify) {\n styles['--button-justify'] = justify\n }\n\n switch (variant) {\n case 'default':\n break\n case 'filled':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-filled)`\n styles['--button-hover'] = `var(--c-color-${color}-filled-hover)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.bg]\n styles['--button-hover'] = shades[idx.hover]\n }\n }\n break\n case 'light':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-bg'] = `var(--c-color-${color}-light)`\n styles['--button-hover'] = `var(--c-color-${color}-light-hover)`\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-bg'] = shades[idx.lightBg]\n styles['--button-hover'] = shades[idx.lightHover]\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'outline':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n styles['--button-bd'] =\n `calc(0.0625rem * var(--c-scale)) solid ${shades[idx.outlineColor]}`\n }\n }\n break\n case 'subtle':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-hover'] = `var(--c-color-${color}-outline-hover)`\n styles['--button-color'] = `var(--c-color-${color}-outline)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-hover'] = setColorAlpha(\n shades[idx.outlineColor],\n idx.outlineHoverBgAlpha\n )\n styles['--button-color'] = shades[idx.outlineColor]\n }\n }\n break\n case 'transparent':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-light-color)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.lightColor]\n }\n }\n break\n case 'white':\n if (color) {\n if (PRESET_COLORS.includes(color)) {\n styles['--button-color'] = `var(--c-color-${color}-filled)`\n } else {\n const shades = generateColorShades(color)\n styles['--button-color'] = shades[idx.bg]\n }\n }\n break\n case 'gradient':\n const from = gradient?.from || 'blue'\n const to = gradient?.to || 'cyan'\n const deg = gradient?.deg || '45'\n\n let finalFrom: string = from\n let finalTo: string = to\n if (PRESET_COLORS.includes(from)) {\n finalFrom = `var(--c-color-${from}-filled)`\n }\n if (PRESET_COLORS.includes(to)) {\n finalTo = `var(--c-color-${to}-filled)`\n }\n\n styles['--button-bg'] =\n `linear-gradient(${deg}deg, ${finalFrom} 0%, ${finalTo} 100%)`\n break\n default:\n break\n }\n\n return styles\n })\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_index = require("
|
|
2
|
-
const require_index$1 = require("../../../hooks/use-namespace/index.js");
|
|
1
|
+
const require_index = require("../../../hooks/use-namespace/index.js");
|
|
3
2
|
const require_use_button = require("./use-button.js");
|
|
4
3
|
const require_button_custom = require("./button-custom.js");
|
|
4
|
+
let vue = require("vue");
|
|
5
5
|
//#region ../../packages/components/button/src/button.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
const _hoisted_1 = {
|
|
7
7
|
key: 0,
|
|
@@ -19,7 +19,7 @@ const _hoisted_4 = {
|
|
|
19
19
|
key: 3,
|
|
20
20
|
"data-position": "right"
|
|
21
21
|
};
|
|
22
|
-
var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0,
|
|
22
|
+
var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
23
23
|
name: "CButton",
|
|
24
24
|
__name: "button",
|
|
25
25
|
props: {
|
|
@@ -85,24 +85,24 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, requi
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
setup(__props, { expose: __expose }) {
|
|
88
|
-
const slots = (0,
|
|
89
|
-
const hasLeftSlot = (0,
|
|
90
|
-
const hasRightSlot = (0,
|
|
88
|
+
const slots = (0, vue.useSlots)();
|
|
89
|
+
const hasLeftSlot = (0, vue.computed)(() => !!slots["left-section"]);
|
|
90
|
+
const hasRightSlot = (0, vue.computed)(() => !!slots["right-section"]);
|
|
91
91
|
const props = __props;
|
|
92
92
|
const { _disabled, _props, _ref, handleClick } = require_use_button.useButton(props, {
|
|
93
93
|
hasLeftSlot: hasLeftSlot.value,
|
|
94
94
|
hasRightSlot: hasRightSlot.value
|
|
95
95
|
});
|
|
96
96
|
const buttonStyle = require_button_custom.useButtonCustomStyle(props);
|
|
97
|
-
const ns = require_index
|
|
98
|
-
const buttonClass = (0,
|
|
99
|
-
require_index
|
|
100
|
-
!_disabled.value && require_index
|
|
97
|
+
const ns = require_index.useNamespace("button");
|
|
98
|
+
const buttonClass = (0, vue.computed)(() => [
|
|
99
|
+
require_index.useNamespace("focus").b("auto"),
|
|
100
|
+
!_disabled.value && require_index.useNamespace("active").b(),
|
|
101
101
|
ns.e("root"),
|
|
102
102
|
ns.is("loading", props.loading)
|
|
103
103
|
]);
|
|
104
|
-
const innerClass = (0,
|
|
105
|
-
const labelClass = (0,
|
|
104
|
+
const innerClass = (0, vue.computed)(() => [ns.e("inner")]);
|
|
105
|
+
const labelClass = (0, vue.computed)(() => [ns.e("label")]);
|
|
106
106
|
__expose({
|
|
107
107
|
/** @description if button is disabled */
|
|
108
108
|
disabled: _disabled.value,
|
|
@@ -114,15 +114,15 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, requi
|
|
|
114
114
|
variant: props.variant
|
|
115
115
|
});
|
|
116
116
|
return (_ctx, _cache) => {
|
|
117
|
-
return (0,
|
|
117
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.tag), (0, vue.mergeProps)((0, vue.unref)(_props), {
|
|
118
118
|
class: buttonClass.value,
|
|
119
|
-
style: (0,
|
|
120
|
-
onClick: (0,
|
|
119
|
+
style: (0, vue.unref)(buttonStyle),
|
|
120
|
+
onClick: (0, vue.unref)(handleClick)
|
|
121
121
|
}), {
|
|
122
|
-
default: (0,
|
|
123
|
-
_ctx.$slots["left-section"] ? ((0,
|
|
124
|
-
(0,
|
|
125
|
-
_ctx.$slots["right-section"] ? ((0,
|
|
122
|
+
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(innerClass.value) }, [
|
|
123
|
+
_ctx.$slots["left-section"] ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1, [(0, vue.renderSlot)(_ctx.$slots, "left-section")])) : __props.leftSection ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_2, [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.leftSection)))])) : (0, vue.createCommentVNode)("v-if", true),
|
|
124
|
+
(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(labelClass.value) }, [(0, vue.renderSlot)(_ctx.$slots, "default")], 2),
|
|
125
|
+
_ctx.$slots["right-section"] ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_3, [(0, vue.renderSlot)(_ctx.$slots, "right-section")])) : __props.rightSection ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4, [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(__props.rightSection)))])) : (0, vue.createCommentVNode)("v-if", true)
|
|
126
126
|
], 2)]),
|
|
127
127
|
_: 3
|
|
128
128
|
}, 16, [
|