@cck-ui/core 0.20.0 → 0.20.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/cjs/components/action-icon/action-icon-group/action-icon-group.cjs +9 -6
- package/cjs/components/action-icon/action-icon-group/action-icon-group.cjs.map +1 -1
- package/cjs/components/action-icon/action-icon-group-section/action-icon-group-section.cjs +10 -8
- package/cjs/components/action-icon/action-icon-group-section/action-icon-group-section.cjs.map +1 -1
- package/cjs/components/action-icon/action-icon.cjs +9 -6
- package/cjs/components/action-icon/action-icon.cjs.map +1 -1
- package/cjs/components/alert/alert.cjs +9 -6
- package/cjs/components/alert/alert.cjs.map +1 -1
- package/cjs/components/aspect-ratio/aspect-ratio.cjs +9 -6
- package/cjs/components/aspect-ratio/aspect-ratio.cjs.map +1 -1
- package/cjs/components/button/button-group/button-group.cjs +9 -6
- package/cjs/components/button/button-group/button-group.cjs.map +1 -1
- package/cjs/components/button/button-group-section/button-group-section.cjs +9 -6
- package/cjs/components/button/button-group-section/button-group-section.cjs.map +1 -1
- package/cjs/components/button/button.cjs +9 -6
- package/cjs/components/button/button.cjs.map +1 -1
- package/cjs/components/center/center.cjs +9 -6
- package/cjs/components/center/center.cjs.map +1 -1
- package/cjs/components/close-button/close-button.cjs +9 -6
- package/cjs/components/close-button/close-button.cjs.map +1 -1
- package/cjs/components/container/container.cjs +9 -6
- package/cjs/components/container/container.cjs.map +1 -1
- package/cjs/components/empty-state/empty-state.cjs +9 -6
- package/cjs/components/empty-state/empty-state.cjs.map +1 -1
- package/cjs/components/flex/flex.cjs +9 -6
- package/cjs/components/flex/flex.cjs.map +1 -1
- package/cjs/components/grid/grid.cjs +9 -6
- package/cjs/components/grid/grid.cjs.map +1 -1
- package/cjs/components/group/group.cjs +9 -6
- package/cjs/components/group/group.cjs.map +1 -1
- package/cjs/components/image/image.cjs +9 -6
- package/cjs/components/image/image.cjs.map +1 -1
- package/cjs/components/loader/loader.cjs +9 -6
- package/cjs/components/loader/loader.cjs.map +1 -1
- package/cjs/components/paper/paper.cjs +9 -6
- package/cjs/components/paper/paper.cjs.map +1 -1
- package/cjs/components/semi-circle-progress/semi-circle-progress.cjs +9 -6
- package/cjs/components/semi-circle-progress/semi-circle-progress.cjs.map +1 -1
- package/cjs/components/simple-grid/simple-grid.cjs +9 -6
- package/cjs/components/simple-grid/simple-grid.cjs.map +1 -1
- package/cjs/components/skeleton/skeleton.cjs +10 -6
- package/cjs/components/skeleton/skeleton.cjs.map +1 -1
- package/cjs/components/space/space.cjs +9 -6
- package/cjs/components/space/space.cjs.map +1 -1
- package/cjs/components/splitter/splitter.cjs +9 -6
- package/cjs/components/splitter/splitter.cjs.map +1 -1
- package/cjs/components/stack/stack.cjs +9 -6
- package/cjs/components/stack/stack.cjs.map +1 -1
- package/cjs/components/text/text.cjs +9 -6
- package/cjs/components/text/text.cjs.map +1 -1
- package/cjs/components/unstyled-button/unstyled-button.cjs +9 -6
- package/cjs/components/unstyled-button/unstyled-button.cjs.map +1 -1
- package/cjs/core/styles-api/use-styles/use-styles.cjs +77 -70
- package/cjs/core/styles-api/use-styles/use-styles.cjs.map +1 -1
- package/cjs/core/styles-api/use-styles/use-transformed-styles.cjs +7 -4
- package/cjs/core/styles-api/use-styles/use-transformed-styles.cjs.map +1 -1
- package/esm/components/action-icon/action-icon-group/action-icon-group.mjs +9 -6
- package/esm/components/action-icon/action-icon-group/action-icon-group.mjs.map +1 -1
- package/esm/components/action-icon/action-icon-group-section/action-icon-group-section.mjs +10 -8
- package/esm/components/action-icon/action-icon-group-section/action-icon-group-section.mjs.map +1 -1
- package/esm/components/action-icon/action-icon.mjs +9 -6
- package/esm/components/action-icon/action-icon.mjs.map +1 -1
- package/esm/components/alert/alert.mjs +9 -6
- package/esm/components/alert/alert.mjs.map +1 -1
- package/esm/components/aspect-ratio/aspect-ratio.mjs +9 -6
- package/esm/components/aspect-ratio/aspect-ratio.mjs.map +1 -1
- package/esm/components/button/button-group/button-group.mjs +9 -6
- package/esm/components/button/button-group/button-group.mjs.map +1 -1
- package/esm/components/button/button-group-section/button-group-section.mjs +9 -6
- package/esm/components/button/button-group-section/button-group-section.mjs.map +1 -1
- package/esm/components/button/button.mjs +9 -6
- package/esm/components/button/button.mjs.map +1 -1
- package/esm/components/center/center.mjs +9 -6
- package/esm/components/center/center.mjs.map +1 -1
- package/esm/components/close-button/close-button.mjs +9 -6
- package/esm/components/close-button/close-button.mjs.map +1 -1
- package/esm/components/container/container.mjs +9 -6
- package/esm/components/container/container.mjs.map +1 -1
- package/esm/components/empty-state/empty-state.mjs +9 -6
- package/esm/components/empty-state/empty-state.mjs.map +1 -1
- package/esm/components/flex/flex.mjs +9 -6
- package/esm/components/flex/flex.mjs.map +1 -1
- package/esm/components/grid/grid.mjs +9 -6
- package/esm/components/grid/grid.mjs.map +1 -1
- package/esm/components/group/group.mjs +9 -6
- package/esm/components/group/group.mjs.map +1 -1
- package/esm/components/image/image.mjs +9 -6
- package/esm/components/image/image.mjs.map +1 -1
- package/esm/components/loader/loader.mjs +9 -6
- package/esm/components/loader/loader.mjs.map +1 -1
- package/esm/components/paper/paper.mjs +9 -6
- package/esm/components/paper/paper.mjs.map +1 -1
- package/esm/components/semi-circle-progress/semi-circle-progress.mjs +9 -6
- package/esm/components/semi-circle-progress/semi-circle-progress.mjs.map +1 -1
- package/esm/components/simple-grid/simple-grid.mjs +9 -6
- package/esm/components/simple-grid/simple-grid.mjs.map +1 -1
- package/esm/components/skeleton/skeleton.mjs +10 -6
- package/esm/components/skeleton/skeleton.mjs.map +1 -1
- package/esm/components/space/space.mjs +9 -6
- package/esm/components/space/space.mjs.map +1 -1
- package/esm/components/splitter/splitter.mjs +9 -6
- package/esm/components/splitter/splitter.mjs.map +1 -1
- package/esm/components/stack/stack.mjs +9 -6
- package/esm/components/stack/stack.mjs.map +1 -1
- package/esm/components/text/text.mjs +9 -6
- package/esm/components/text/text.mjs.map +1 -1
- package/esm/components/unstyled-button/unstyled-button.mjs +9 -6
- package/esm/components/unstyled-button/unstyled-button.mjs.map +1 -1
- package/esm/core/styles-api/use-styles/use-styles.mjs +77 -70
- package/esm/core/styles-api/use-styles/use-styles.mjs.map +1 -1
- package/esm/core/styles-api/use-styles/use-transformed-styles.mjs +7 -4
- package/esm/core/styles-api/use-styles/use-transformed-styles.mjs.map +1 -1
- package/lib/core/styles-api/use-styles/use-styles.d.ts +5 -4
- package/package.json +1 -1
|
@@ -332,15 +332,17 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
332
332
|
"style",
|
|
333
333
|
"attributes"
|
|
334
334
|
];
|
|
335
|
+
const styleProps = computed(() => ({
|
|
336
|
+
...props.value,
|
|
337
|
+
...attrs,
|
|
338
|
+
style: attrs.style ?? props.value.style
|
|
339
|
+
}));
|
|
335
340
|
const getStyles = useStyles({
|
|
336
341
|
name: props.value.__staticSelector,
|
|
337
|
-
props:
|
|
338
|
-
...props.value,
|
|
339
|
-
...attrs
|
|
340
|
-
},
|
|
342
|
+
props: styleProps,
|
|
341
343
|
classes: unstyled_button_module_default,
|
|
342
|
-
className: props.value.className,
|
|
343
|
-
style: props.value.style,
|
|
344
|
+
className: () => props.value.className,
|
|
345
|
+
style: () => props.value.style,
|
|
344
346
|
classNames: props.value.classNames,
|
|
345
347
|
styles: props.value.styles,
|
|
346
348
|
unstyled: props.value.unstyled,
|
|
@@ -364,6 +366,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
364
366
|
tag,
|
|
365
367
|
_root,
|
|
366
368
|
knownProps,
|
|
369
|
+
styleProps,
|
|
367
370
|
getStyles,
|
|
368
371
|
rootAttrs,
|
|
369
372
|
mergedAttrs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstyled-button.mjs","names":[],"sources":["../../../src/components/unstyled-button/unstyled-button.vue"],"sourcesContent":["<template>\n <c-box\n ref=\"_root\"\n v-bind=\"mergedAttrs\"\n :tag=\"tag\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n >\n <slot />\n </c-box>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue'\nimport { CBox, useComponentProps, useStyles } from '../../core'\nimport type { UnstyledButtonFactory, UnstyledButtonProps } from './unstyled-button.types'\nimport classes from './unstyled-button.module.css'\n\ndefineOptions({\n name: 'UnstyledButton',\n})\n\nconst attrs = useAttrs()\n\nconst rawProps = defineProps<UnstyledButtonProps>()\n\nconst props = useComponentProps({\n component: 'UnstyledButton',\n defaultProps: {\n __staticSelector: 'UnstyledButton',\n },\n props: rawProps,\n})\n\nconst { tag = 'button' } = props.value\n\nconst _root = ref<InstanceType<typeof CBox> | null>(null)\n\nconst knownProps = [\n 'className',\n 'tag',\n '__staticSelector',\n 'unstyled',\n 'classNames',\n 'styles',\n 'style',\n 'attributes',\n]\n\nconst getStyles = useStyles<UnstyledButtonFactory>({\n name: props.value.__staticSelector!,\n props:
|
|
1
|
+
{"version":3,"file":"unstyled-button.mjs","names":[],"sources":["../../../src/components/unstyled-button/unstyled-button.vue"],"sourcesContent":["<template>\n <c-box\n ref=\"_root\"\n v-bind=\"mergedAttrs\"\n :tag=\"tag\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n >\n <slot />\n </c-box>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, useAttrs } from 'vue'\nimport { CBox, CStyleProp, useComponentProps, useStyles } from '../../core'\nimport type { UnstyledButtonFactory, UnstyledButtonProps } from './unstyled-button.types'\nimport classes from './unstyled-button.module.css'\n\ndefineOptions({\n name: 'UnstyledButton',\n})\n\nconst attrs = useAttrs()\n\nconst rawProps = defineProps<UnstyledButtonProps>()\n\nconst props = useComponentProps({\n component: 'UnstyledButton',\n defaultProps: {\n __staticSelector: 'UnstyledButton',\n },\n props: rawProps,\n})\n\nconst { tag = 'button' } = props.value\n\nconst _root = ref<InstanceType<typeof CBox> | null>(null)\n\nconst knownProps = [\n 'className',\n 'tag',\n '__staticSelector',\n 'unstyled',\n 'classNames',\n 'styles',\n 'style',\n 'attributes',\n]\n\nconst styleProps = computed(() => ({\n ...props.value,\n ...attrs,\n style: (attrs.style ?? props.value.style) as CStyleProp,\n}))\n\nconst getStyles = useStyles<UnstyledButtonFactory>({\n name: props.value.__staticSelector!,\n props: styleProps,\n classes,\n className: () => props.value.className,\n style: () => props.value.style,\n classNames: props.value.classNames,\n styles: props.value.styles,\n unstyled: props.value.unstyled,\n attributes: props.value.attributes,\n})\n\nconst rootAttrs = computed(() => getStyles('root', { focusable: true }))\nconst mergedAttrs = computed(() => {\n const others: Record<string, any> = {}\n const propsValue = props.value\n for (const key in propsValue) {\n if (!knownProps.includes(key)) {\n others[key] = propsValue[key as keyof typeof propsValue]\n }\n }\n return { ...others, ...rootAttrs.value }\n})\n\ndefineExpose({\n root: computed(() => _root.value?.root ?? null),\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBA,MAAM,QAAQ,SAAS;EAEvB,MAAM,WAAW;EAEjB,MAAM,QAAQ,kBAAkB;GAC9B,WAAW;GACX,cAAc,EACZ,kBAAkB,iBACpB;GACA,OAAO;EACT,CAAC;EAED,MAAM,EAAE,MAAM,aAAa,MAAM;EAEjC,MAAM,QAAQ,IAAsC,IAAI;EAExD,MAAM,aAAa;GACjB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EAEA,MAAM,aAAa,gBAAgB;GACjC,GAAG,MAAM;GACT,GAAG;GACH,OAAQ,MAAM,SAAS,MAAM,MAAM;EACrC,EAAE;EAEF,MAAM,YAAY,UAAiC;GACjD,MAAM,MAAM,MAAM;GAClB,OAAO;GACP,SAAA;GACA,iBAAiB,MAAM,MAAM;GAC7B,aAAa,MAAM,MAAM;GACzB,YAAY,MAAM,MAAM;GACxB,QAAQ,MAAM,MAAM;GACpB,UAAU,MAAM,MAAM;GACtB,YAAY,MAAM,MAAM;EAC1B,CAAC;EAED,MAAM,YAAY,eAAe,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC,CAAC;EACvE,MAAM,cAAc,eAAe;GACjC,MAAM,SAA8B,CAAC;GACrC,MAAM,aAAa,MAAM;GACzB,KAAK,MAAM,OAAO,YAChB,IAAI,CAAC,WAAW,SAAS,GAAG,GAC1B,OAAO,OAAO,WAAW;GAG7B,OAAO;IAAE,GAAG;IAAQ,GAAG,UAAU;GAAM;EACzC,CAAC;EAED,SAAa,EACX,MAAM,eAAe,MAAM,OAAO,QAAQ,IAAI,EAChD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;qBA/EC,YAOQ,OAAA,SAPR,WAOQ,EANN,KAAI,QAAO,GACH,OAAA,aAAW;EAClB,KAAK,OAAA;EACL,MAAM,OAAA,QAAG,WAAA,WAA2B,KAAA;;yBAE7B,CAAR,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA"}
|
|
@@ -7,6 +7,7 @@ import { mergeVars } from "./get-style/resolve-vars/merge-vars.mjs";
|
|
|
7
7
|
import { resolveStyle } from "./get-style/resolve-style/resolve-style.mjs";
|
|
8
8
|
import { getClassName } from "./get-class-name/get-class-name.mjs";
|
|
9
9
|
import { getStyle } from "./get-style/get-style.mjs";
|
|
10
|
+
import { toValue } from "vue";
|
|
10
11
|
//#region packages/@cck-ui/core/src/core/styles-api/use-styles/use-styles.ts
|
|
11
12
|
function useStyles({ name, classes, props, stylesCtx, className, style, rootSelector = "root", unstyled, classNames, styles, vars, varsResolver, attributes }) {
|
|
12
13
|
const theme = useCckTheme().value;
|
|
@@ -20,80 +21,86 @@ function useStyles({ name, classes, props, stylesCtx, className, style, rootSele
|
|
|
20
21
|
themeName,
|
|
21
22
|
theme
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const resolvedThemeClassNames = themeName.map((n) => resolveClassNames({
|
|
30
|
-
theme,
|
|
31
|
-
classNames: theme.components?.[n]?.classNames,
|
|
32
|
-
props,
|
|
33
|
-
stylesCtx
|
|
34
|
-
}));
|
|
35
|
-
const resolvedComponentStyles = withStylesTransform ? {} : resolveStyles({
|
|
36
|
-
theme,
|
|
37
|
-
styles,
|
|
38
|
-
props,
|
|
39
|
-
stylesCtx
|
|
40
|
-
});
|
|
41
|
-
const resolvedThemeStyles = {};
|
|
42
|
-
if (!withStylesTransform) for (const n of themeName) {
|
|
43
|
-
const resolved = resolveStyles({
|
|
24
|
+
return (selector, options) => {
|
|
25
|
+
const currentProps = toValue(props);
|
|
26
|
+
const currentCtx = toValue(stylesCtx);
|
|
27
|
+
const currentStyle = toValue(style);
|
|
28
|
+
const currentClassName = toValue(className);
|
|
29
|
+
const resolvedClassNames = resolveClassNames({
|
|
44
30
|
theme,
|
|
45
|
-
|
|
46
|
-
props,
|
|
47
|
-
stylesCtx
|
|
31
|
+
classNames,
|
|
32
|
+
props: currentProps,
|
|
33
|
+
stylesCtx: currentCtx
|
|
48
34
|
});
|
|
49
|
-
|
|
50
|
-
...resolvedThemeStyles[key],
|
|
51
|
-
...resolved[key]
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const resolvedVars = mergeVars([
|
|
55
|
-
headless ? {} : varsResolver?.(theme, props, stylesCtx),
|
|
56
|
-
...themeName.map((n) => theme.components?.[n]?.vars?.(theme, props, stylesCtx)),
|
|
57
|
-
vars?.(theme, props, stylesCtx)
|
|
58
|
-
]);
|
|
59
|
-
const resolvedRootStyle = resolveStyle({
|
|
60
|
-
style,
|
|
61
|
-
theme
|
|
62
|
-
});
|
|
63
|
-
return (selector, options) => ({
|
|
64
|
-
...attributes?.[selector],
|
|
65
|
-
className: getClassName({
|
|
35
|
+
const resolvedThemeClassNames = themeName.map((n) => resolveClassNames({
|
|
66
36
|
theme,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
resolvedThemeClassNames,
|
|
73
|
-
classes,
|
|
74
|
-
unstyled,
|
|
75
|
-
className,
|
|
76
|
-
rootSelector,
|
|
77
|
-
props,
|
|
78
|
-
stylesCtx,
|
|
79
|
-
withStaticClasses,
|
|
80
|
-
headless,
|
|
81
|
-
transformedStyles: getTransformedStyles([options?.styles, styles])
|
|
82
|
-
}),
|
|
83
|
-
style: getStyle({
|
|
37
|
+
classNames: theme.components?.[n]?.classNames,
|
|
38
|
+
props: currentProps,
|
|
39
|
+
stylesCtx: currentCtx
|
|
40
|
+
}));
|
|
41
|
+
const resolvedComponentStyles = withStylesTransform ? {} : resolveStyles({
|
|
84
42
|
theme,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
43
|
+
styles,
|
|
44
|
+
props: currentProps,
|
|
45
|
+
stylesCtx: currentCtx
|
|
46
|
+
});
|
|
47
|
+
const resolvedThemeStyles = {};
|
|
48
|
+
if (!withStylesTransform) for (const n of themeName) {
|
|
49
|
+
const resolved = resolveStyles({
|
|
50
|
+
theme,
|
|
51
|
+
styles: theme.components?.[n]?.styles,
|
|
52
|
+
props: currentProps,
|
|
53
|
+
stylesCtx: currentCtx
|
|
54
|
+
});
|
|
55
|
+
for (const key of Object.keys(resolved)) resolvedThemeStyles[key] = {
|
|
56
|
+
...resolvedThemeStyles[key],
|
|
57
|
+
...resolved[key]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const resolvedVars = mergeVars([
|
|
61
|
+
headless ? {} : varsResolver?.(theme, currentProps, currentCtx),
|
|
62
|
+
...themeName.map((n) => theme.components?.[n]?.vars?.(theme, currentProps, currentCtx)),
|
|
63
|
+
vars?.(theme, currentProps, currentCtx)
|
|
64
|
+
]);
|
|
65
|
+
const resolvedRootStyle = resolveStyle({
|
|
66
|
+
style: currentStyle,
|
|
67
|
+
theme
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
...attributes?.[selector],
|
|
71
|
+
className: getClassName({
|
|
72
|
+
theme,
|
|
73
|
+
options,
|
|
74
|
+
themeName,
|
|
75
|
+
selector,
|
|
76
|
+
classNamesPrefix,
|
|
77
|
+
resolvedClassNames,
|
|
78
|
+
resolvedThemeClassNames,
|
|
79
|
+
classes,
|
|
80
|
+
unstyled,
|
|
81
|
+
className: currentClassName,
|
|
82
|
+
rootSelector,
|
|
83
|
+
props: currentProps,
|
|
84
|
+
stylesCtx: currentCtx,
|
|
85
|
+
withStaticClasses,
|
|
86
|
+
headless,
|
|
87
|
+
transformedStyles: getTransformedStyles([options?.styles, styles])
|
|
88
|
+
}),
|
|
89
|
+
style: getStyle({
|
|
90
|
+
theme,
|
|
91
|
+
selector,
|
|
92
|
+
options,
|
|
93
|
+
props: currentProps,
|
|
94
|
+
stylesCtx: currentCtx,
|
|
95
|
+
rootSelector,
|
|
96
|
+
withStylesTransform,
|
|
97
|
+
resolvedStyles: resolvedComponentStyles,
|
|
98
|
+
resolvedThemeStyles,
|
|
99
|
+
resolvedVars,
|
|
100
|
+
resolvedRootStyle
|
|
101
|
+
})
|
|
102
|
+
};
|
|
103
|
+
};
|
|
97
104
|
}
|
|
98
105
|
//#endregion
|
|
99
106
|
export { useStyles };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-styles.mjs","names":[],"sources":["../../../../src/core/styles-api/use-styles/use-styles.ts"],"sourcesContent":["import {\n Attributes,\n ClassNames,\n ClassNamesArray,\n GetStylesApiOptions,\n Styles,\n} from '../styles-api.types'\nimport { PartialVarsResolver, VarsResolver } from '../create-vars-resolver/create-vars-resolver'\nimport { useStylesTransform } from './use-transformed-styles'\nimport { resolveClassNames } from './get-class-name/resolve-class-names/resolve-class-names'\nimport { resolveStyles } from './get-style/resolve-styles/resolve-styles'\nimport { mergeVars } from './get-style/resolve-vars/merge-vars'\nimport { resolveStyle } from './get-style/resolve-style/resolve-style'\nimport { getClassName } from './get-class-name/get-class-name'\nimport { Properties } from 'csstype'\nimport { getStyle } from './get-style/get-style'\nimport { FactoryPayload } from '../../factory'\nimport { CStyleProp } from '../../box'\nimport {\n useCckClassNamesPrefix,\n useCckIsHeadless,\n useCckTheme,\n useCckWithStaticClasses,\n} from '../../config-provider'\n\nexport interface UseStylesInput<Payload extends FactoryPayload> {\n name: string | (string | undefined)[]\n classes: Payload['stylesNames'] extends string ? Record<string, string> : never\n props: Payload['props']
|
|
1
|
+
{"version":3,"file":"use-styles.mjs","names":[],"sources":["../../../../src/core/styles-api/use-styles/use-styles.ts"],"sourcesContent":["import {\n Attributes,\n ClassNames,\n ClassNamesArray,\n GetStylesApiOptions,\n Styles,\n} from '../styles-api.types'\nimport { PartialVarsResolver, VarsResolver } from '../create-vars-resolver/create-vars-resolver'\nimport { useStylesTransform } from './use-transformed-styles'\nimport { resolveClassNames } from './get-class-name/resolve-class-names/resolve-class-names'\nimport { resolveStyles } from './get-style/resolve-styles/resolve-styles'\nimport { mergeVars } from './get-style/resolve-vars/merge-vars'\nimport { resolveStyle } from './get-style/resolve-style/resolve-style'\nimport { getClassName } from './get-class-name/get-class-name'\nimport { Properties } from 'csstype'\nimport { getStyle } from './get-style/get-style'\nimport { FactoryPayload } from '../../factory'\nimport { CStyleProp } from '../../box'\nimport {\n useCckClassNamesPrefix,\n useCckIsHeadless,\n useCckTheme,\n useCckWithStaticClasses,\n} from '../../config-provider'\nimport { MaybeRefOrGetter, toValue } from 'vue'\n\nexport interface UseStylesInput<Payload extends FactoryPayload> {\n name: string | (string | undefined)[]\n classes: Payload['stylesNames'] extends string ? Record<string, string> : never\n props: MaybeRefOrGetter<Payload['props']>\n stylesCtx?: MaybeRefOrGetter<Payload['ctx'] | undefined>\n className?: MaybeRefOrGetter<string | undefined>\n style?: MaybeRefOrGetter<CStyleProp | undefined>\n rootSelector?: Payload['stylesNames']\n unstyled?: boolean\n classNames?: ClassNames<Payload> | ClassNamesArray<Payload>\n styles?: Styles<Payload>\n vars?: PartialVarsResolver<Payload>\n varsResolver?: VarsResolver<Payload>\n attributes?: Attributes<Payload>\n}\n\nexport type GetStylesApi<Payload extends FactoryPayload> = (\n selector: NonNullable<Payload['stylesNames']>,\n options?: GetStylesApiOptions\n) => {\n className: string\n style: Properties\n}\n\nexport function useStyles<Payload extends FactoryPayload>({\n name,\n classes,\n props,\n stylesCtx,\n className,\n style,\n rootSelector = 'root' as NonNullable<Payload['stylesNames']>,\n unstyled,\n classNames,\n styles,\n vars,\n varsResolver,\n attributes,\n}: UseStylesInput<Payload>): GetStylesApi<Payload> {\n const _theme = useCckTheme()\n const theme = _theme.value\n const classNamesPrefix = useCckClassNamesPrefix()\n const withStaticClasses = useCckWithStaticClasses()\n const headless = useCckIsHeadless()\n\n const themeNames = Array.isArray(name) ? name : [name]\n const themeName = themeNames.filter((n) => n) as string[]\n\n const { withStylesTransform, getTransformedStyles } = useStylesTransform({\n props,\n stylesCtx,\n themeName,\n theme,\n })\n\n return (selector, options) => {\n const currentProps = toValue(props) as Payload['props']\n const currentCtx = toValue(stylesCtx) as Payload['ctx'] | undefined\n const currentStyle = toValue(style) as CStyleProp | undefined\n const currentClassName = toValue(className)\n\n const resolvedClassNames = resolveClassNames({\n theme,\n classNames,\n props: currentProps,\n stylesCtx: currentCtx,\n })\n\n const resolvedThemeClassNames = themeName.map((n) =>\n resolveClassNames({\n theme,\n classNames: theme.components?.[n]?.classNames,\n props: currentProps,\n stylesCtx: currentCtx,\n })\n )\n\n const resolvedComponentStyles = withStylesTransform\n ? {}\n : resolveStyles({ theme, styles, props: currentProps, stylesCtx: currentCtx })\n\n const resolvedThemeStyles: Record<string, any> = {}\n if (!withStylesTransform) {\n for (const n of themeName) {\n const resolved = resolveStyles({\n theme,\n styles: theme.components?.[n]?.styles,\n props: currentProps,\n stylesCtx: currentCtx,\n })\n for (const key of Object.keys(resolved)) {\n resolvedThemeStyles[key] = {\n ...resolvedThemeStyles[key],\n ...resolved[key],\n }\n }\n }\n }\n\n const resolvedVars = mergeVars([\n headless ? {} : varsResolver?.(theme, currentProps, currentCtx),\n ...themeName.map((n) => theme.components?.[n]?.vars?.(theme, currentProps, currentCtx)),\n vars?.(theme, currentProps, currentCtx),\n ])\n\n const resolvedRootStyle = resolveStyle({ style: currentStyle, theme })\n\n return {\n ...attributes?.[selector],\n\n className: getClassName({\n theme,\n options,\n themeName,\n selector,\n classNamesPrefix,\n resolvedClassNames,\n resolvedThemeClassNames,\n classes,\n unstyled,\n className: currentClassName,\n rootSelector,\n props: currentProps,\n stylesCtx: currentCtx,\n withStaticClasses,\n headless,\n transformedStyles: getTransformedStyles([options?.styles, styles]),\n }),\n\n style: getStyle({\n theme,\n selector,\n options,\n props: currentProps,\n stylesCtx: currentCtx,\n rootSelector,\n withStylesTransform,\n resolvedStyles: resolvedComponentStyles,\n resolvedThemeStyles,\n resolvedVars,\n resolvedRootStyle,\n }),\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAkDA,SAAgB,UAA0C,EACxD,MACA,SACA,OACA,WACA,WACA,OACA,eAAe,QACf,UACA,YACA,QACA,MACA,cACA,cACiD;CAEjD,MAAM,QADS,YACI,CAAC,CAAC;CACrB,MAAM,mBAAmB,uBAAuB;CAChD,MAAM,oBAAoB,wBAAwB;CAClD,MAAM,WAAW,iBAAiB;CAGlC,MAAM,aADa,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,EAAA,CACxB,QAAQ,MAAM,CAAC;CAE5C,MAAM,EAAE,qBAAqB,yBAAyB,mBAAmB;EACvE;EACA;EACA;EACA;CACF,CAAC;CAED,QAAQ,UAAU,YAAY;EAC5B,MAAM,eAAe,QAAQ,KAAK;EAClC,MAAM,aAAa,QAAQ,SAAS;EACpC,MAAM,eAAe,QAAQ,KAAK;EAClC,MAAM,mBAAmB,QAAQ,SAAS;EAE1C,MAAM,qBAAqB,kBAAkB;GAC3C;GACA;GACA,OAAO;GACP,WAAW;EACb,CAAC;EAED,MAAM,0BAA0B,UAAU,KAAK,MAC7C,kBAAkB;GAChB;GACA,YAAY,MAAM,aAAa,EAAE,EAAE;GACnC,OAAO;GACP,WAAW;EACb,CAAC,CACH;EAEA,MAAM,0BAA0B,sBAC5B,CAAC,IACD,cAAc;GAAE;GAAO;GAAQ,OAAO;GAAc,WAAW;EAAW,CAAC;EAE/E,MAAM,sBAA2C,CAAC;EAClD,IAAI,CAAC,qBACH,KAAK,MAAM,KAAK,WAAW;GACzB,MAAM,WAAW,cAAc;IAC7B;IACA,QAAQ,MAAM,aAAa,EAAE,EAAE;IAC/B,OAAO;IACP,WAAW;GACb,CAAC;GACD,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,GACpC,oBAAoB,OAAO;IACzB,GAAG,oBAAoB;IACvB,GAAG,SAAS;GACd;EAEJ;EAGF,MAAM,eAAe,UAAU;GAC7B,WAAW,CAAC,IAAI,eAAe,OAAO,cAAc,UAAU;GAC9D,GAAG,UAAU,KAAK,MAAM,MAAM,aAAa,EAAE,EAAE,OAAO,OAAO,cAAc,UAAU,CAAC;GACtF,OAAO,OAAO,cAAc,UAAU;EACxC,CAAC;EAED,MAAM,oBAAoB,aAAa;GAAE,OAAO;GAAc;EAAM,CAAC;EAErE,OAAO;GACL,GAAG,aAAa;GAEhB,WAAW,aAAa;IACtB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,WAAW;IACX;IACA,OAAO;IACP,WAAW;IACX;IACA;IACA,mBAAmB,qBAAqB,CAAC,SAAS,QAAQ,MAAM,CAAC;GACnE,CAAC;GAED,OAAO,SAAS;IACd;IACA;IACA;IACA,OAAO;IACP,WAAW;IACX;IACA;IACA,gBAAgB;IAChB;IACA;IACA;GACF,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCckStylesTransform } from "../../config-provider/config-provider.context.mjs";
|
|
3
|
+
import { toValue } from "vue";
|
|
3
4
|
//#region packages/@cck-ui/core/src/core/styles-api/use-styles/use-transformed-styles.ts
|
|
4
5
|
function useStylesTransform({ props, stylesCtx, themeName, theme }) {
|
|
5
6
|
const stylesTransform = useCckStylesTransform()?.();
|
|
6
7
|
const getTransformedStyles = (styles) => {
|
|
7
8
|
if (!stylesTransform) return [];
|
|
9
|
+
const currentProps = toValue(props);
|
|
10
|
+
const currentCtx = toValue(stylesCtx);
|
|
8
11
|
return [...styles.map((style) => stylesTransform(style, {
|
|
9
|
-
props,
|
|
12
|
+
props: currentProps,
|
|
10
13
|
theme,
|
|
11
|
-
ctx:
|
|
14
|
+
ctx: currentCtx
|
|
12
15
|
})), ...themeName.map((n) => stylesTransform(theme.components[n]?.styles, {
|
|
13
|
-
props,
|
|
16
|
+
props: currentProps,
|
|
14
17
|
theme,
|
|
15
|
-
ctx:
|
|
18
|
+
ctx: currentCtx
|
|
16
19
|
}))].filter(Boolean);
|
|
17
20
|
};
|
|
18
21
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-transformed-styles.mjs","names":[],"sources":["../../../../src/core/styles-api/use-styles/use-transformed-styles.ts"],"sourcesContent":["import { CTheme, useCckStylesTransform } from '../../config-provider'\n\ninterface UseTransformedStylesInput {\n props: Record<string, any>\n stylesCtx: Record<string, any> | undefined\n themeName: string[]\n theme: CTheme\n}\n\nexport function useStylesTransform({\n props,\n stylesCtx,\n themeName,\n theme,\n}: UseTransformedStylesInput) {\n const stylesTransform = useCckStylesTransform()?.()\n\n const getTransformedStyles = (styles: any[]) => {\n if (!stylesTransform) {\n return []\n }\n\n const transformedStyles = styles.map((style) =>\n stylesTransform(style, { props, theme, ctx:
|
|
1
|
+
{"version":3,"file":"use-transformed-styles.mjs","names":[],"sources":["../../../../src/core/styles-api/use-styles/use-transformed-styles.ts"],"sourcesContent":["import { toValue } from 'vue'\nimport { CTheme, useCckStylesTransform } from '../../config-provider'\n\ninterface UseTransformedStylesInput {\n props: Record<string, any>\n stylesCtx: Record<string, any> | undefined\n themeName: string[]\n theme: CTheme\n}\n\nexport function useStylesTransform({\n props,\n stylesCtx,\n themeName,\n theme,\n}: UseTransformedStylesInput) {\n const stylesTransform = useCckStylesTransform()?.()\n\n const getTransformedStyles = (styles: any[]) => {\n if (!stylesTransform) {\n return []\n }\n\n const currentProps = toValue(props)\n const currentCtx = toValue(stylesCtx)\n\n const transformedStyles = styles.map((style) =>\n stylesTransform(style, { props: currentProps, theme, ctx: currentCtx })\n )\n\n return [\n ...transformedStyles,\n ...themeName.map((n) =>\n stylesTransform(theme.components[n]?.styles, {\n props: currentProps,\n theme,\n ctx: currentCtx,\n })\n ),\n ].filter(Boolean) as Record<string, string>[]\n }\n\n return {\n getTransformedStyles,\n withStylesTransform: !!stylesTransform,\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAmB,EACjC,OACA,WACA,WACA,SAC4B;CAC5B,MAAM,kBAAkB,sBAAsB,CAAC,GAAG;CAElD,MAAM,wBAAwB,WAAkB;EAC9C,IAAI,CAAC,iBACH,OAAO,CAAC;EAGV,MAAM,eAAe,QAAQ,KAAK;EAClC,MAAM,aAAa,QAAQ,SAAS;EAMpC,OAAO,CACL,GALwB,OAAO,KAAK,UACpC,gBAAgB,OAAO;GAAE,OAAO;GAAc;GAAO,KAAK;EAAW,CAAC,CAInD,GACnB,GAAG,UAAU,KAAK,MAChB,gBAAgB,MAAM,WAAW,EAAE,EAAE,QAAQ;GAC3C,OAAO;GACP;GACA,KAAK;EACP,CAAC,CACH,CACF,CAAC,CAAC,OAAO,OAAO;CAClB;CAEA,OAAO;EACL;EACA,qBAAqB,CAAC,CAAC;CACzB;AACF"}
|
|
@@ -3,13 +3,14 @@ import { PartialVarsResolver, VarsResolver } from '../create-vars-resolver/creat
|
|
|
3
3
|
import { Properties } from 'csstype';
|
|
4
4
|
import { FactoryPayload } from '../../factory';
|
|
5
5
|
import { CStyleProp } from '../../box';
|
|
6
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
6
7
|
export interface UseStylesInput<Payload extends FactoryPayload> {
|
|
7
8
|
name: string | (string | undefined)[];
|
|
8
9
|
classes: Payload['stylesNames'] extends string ? Record<string, string> : never;
|
|
9
|
-
props: Payload['props']
|
|
10
|
-
stylesCtx?: Payload['ctx']
|
|
11
|
-
className?: string | undefined
|
|
12
|
-
style?: CStyleProp
|
|
10
|
+
props: MaybeRefOrGetter<Payload['props']>;
|
|
11
|
+
stylesCtx?: MaybeRefOrGetter<Payload['ctx'] | undefined>;
|
|
12
|
+
className?: MaybeRefOrGetter<string | undefined>;
|
|
13
|
+
style?: MaybeRefOrGetter<CStyleProp | undefined>;
|
|
13
14
|
rootSelector?: Payload['stylesNames'];
|
|
14
15
|
unstyled?: boolean;
|
|
15
16
|
classNames?: ClassNames<Payload> | ClassNamesArray<Payload>;
|
package/package.json
CHANGED