Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit cbcc394

Browse files
committed
chore: attempt to resolve types
1 parent 7bdd60f commit cbcc394

File tree

12 files changed

+587
-359
lines changed

12 files changed

+587
-359
lines changed

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"@vue/eslint-config-typescript": "^5.1.0",
101101
"@vue/server-renderer": "^3.2.29",
102102
"@vue/test-utils": "^2.0.0-rc.6",
103+
"@vue/tsconfig": "^0.1.3",
103104
"@vuedx/typecheck": "^0.4.1",
104105
"@vuedx/typescript-plugin-vue": "^0.4.1",
105106
"@vueuse/core": "4.9.1",
@@ -150,11 +151,9 @@
150151
"lodash.camelcase": "^4.3.0",
151152
"lodash.kebabcase": "^4.1.1",
152153
"lodash.mergewith": "^4.6.2",
153-
"motion": "^10.12.0",
154154
"object-assign": "^4.1.1",
155155
"prettier": "^2.1.2",
156156
"pretty": "^2.0.0",
157-
"react": "^17.0.1",
158157
"recursive-readdir": "^2.2.2",
159158
"shelljs": "^0.8.4",
160159
"size-limit": "^5.0.3",
@@ -163,14 +162,14 @@
163162
"ts-node": "^9.0.0",
164163
"typescript": "4.6.4",
165164
"unplugin-vue-components": "^0.14.0",
166-
"vite": "^2.8.6",
165+
"vite": "^3.0.7",
167166
"vite-plugin-mdx-vue": "^1.6.0",
168167
"vite-plugin-pages": "^0.20.1",
169168
"vite-plugin-vue-layouts": "^0.5.0",
170169
"vite-ssg": "^0.17.2",
171-
"vitepress": "^0.20.9",
170+
"vitepress": "^1.0.0-draft.8",
172171
"vitest": "^0.18.0",
173-
"vue": "^3.2.29",
172+
"vue": "^3.2.37",
174173
"vue-jest": "^5.0.0-alpha.7",
175174
"vue-prism-editor": "^2.0.0-alpha.2",
176175
"vue-router": "^4.0.12",

packages/c-button/src/icon-button.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, defineComponent, PropType } from "vue"
1+
import { h, defineComponent, PropType, VNode } from "vue"
22
import CButton from "./button"
33
import { ButtonProps } from "./button.utils"
44
import { CIcon } from "@chakra-ui/c-icon"
@@ -50,3 +50,12 @@ const CIconButton: ComponentWithProps<DeepPartial<CIconButtonProps>> =
5050
})
5151

5252
export default CIconButton
53+
54+
export const Foo = defineComponent((props, { slots }) => {
55+
return () => (
56+
<div>
57+
<span data-foo>Hello</span>
58+
{slots}
59+
</div>
60+
)
61+
})

packages/c-button/src/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import { defineComponent } from "vue"
2+
13
export { default as CButton } from "./button"
24
export { default as CButtonGroup } from "./button-group"
35
export { default as CIconButton } from "./icon-button"
6+
import { Foo } from "./icon-button"
7+
export { Foo }
8+
9+
const Bar = defineComponent((_, { slots }) => {
10+
return () => <Foo>{slots}</Foo>
11+
})

packages/c-form-control/src/c-form-control.tsx

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,39 @@ export const formControlProps = {
4545
id: String as PropType<CFormControlProps["id"]>,
4646
}
4747

48-
export const CFormControl: ComponentWithProps<
49-
DeepPartial<CFormControlProps>
50-
> = defineComponent({
51-
props: {
52-
as: {
53-
type: [Object, String] as PropType<DOMElements>,
54-
default: "div",
48+
export const CFormControl: ComponentWithProps<DeepPartial<CFormControlProps>> =
49+
defineComponent({
50+
props: {
51+
as: {
52+
type: [Object, String] as PropType<DOMElements>,
53+
default: "div",
54+
},
55+
...formControlProps,
5556
},
56-
...formControlProps,
57-
},
58-
setup(_props, { slots, attrs }) {
59-
const { as, ...props } = toRefs(_props)
60-
const ownProps = computed(() => props)
61-
const styles = useMultiStyleConfig("Form", props)
62-
const { rootProps, ..._context } = useFormControlProvider(ownProps.value)
57+
setup(_props, { slots, attrs }) {
58+
const { as, ...props } = toRefs(_props)
59+
const ownProps = computed(() => props)
60+
const styles = useMultiStyleConfig("Form", props)
61+
const { rootProps, ..._context } = useFormControlProvider(ownProps.value)
6362

64-
const context: CFormControlProviderContext = computed(() => _context)
63+
const context: CFormControlProviderContext = computed(() => _context)
6564

66-
FormControlProvider(context)
67-
StylesProvider(styles)
65+
FormControlProvider(context)
66+
StylesProvider(styles)
6867

69-
return () => (
70-
<chakra.div
71-
as={as.value}
72-
{...rootProps.value}
73-
__css={styles.value.container}
74-
__label="form"
75-
{...attrs}
76-
>
77-
{slots}
78-
</chakra.div>
79-
)
80-
},
81-
})
68+
return () => (
69+
<chakra.div
70+
as={as.value}
71+
{...rootProps.value}
72+
__css={styles.value.container}
73+
__label="form"
74+
{...attrs}
75+
>
76+
{slots}
77+
</chakra.div>
78+
)
79+
},
80+
})
8281

8382
export interface CHelpTextProps extends HTMLChakraProps<"div"> {}
8483
/**
@@ -88,23 +87,22 @@ export interface CHelpTextProps extends HTMLChakraProps<"div"> {}
8887
* about the field, such as how it will be used and what
8988
* types in values should be provided.
9089
*/
91-
export const CFormHelperText: ComponentWithProps<
92-
DeepPartial<CHelpTextProps>
93-
> = defineComponent((props, { attrs, slots }) => {
94-
const field = useFormControlContext()
95-
const styles = useStyles()
96-
const handleVNodeMounted = () => {
97-
field.value.hasHelpText.value = true
98-
}
90+
export const CFormHelperText: ComponentWithProps<DeepPartial<CHelpTextProps>> =
91+
defineComponent((props, { attrs, slots }) => {
92+
const field = useFormControlContext()
93+
const styles = useStyles()
94+
const handleVNodeMounted = () => {
95+
field.value.hasHelpText.value = true
96+
}
9997

100-
return () => (
101-
<chakra.div
102-
__label="form__helper-text"
103-
onVnodeBeforeMount={handleVNodeMounted}
104-
{...field.value.helperTextProps.value}
105-
__css={styles.value.helperText}
106-
>
107-
{slots}
108-
</chakra.div>
109-
)
110-
})
98+
return () => (
99+
<chakra.div
100+
__label="form__helper-text"
101+
onVnodeBeforeMount={handleVNodeMounted}
102+
{...field.value.helperTextProps.value}
103+
__css={styles.value.helperText}
104+
>
105+
{slots}
106+
</chakra.div>
107+
)
108+
})

packages/c-form-control/src/c-form-label.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { defineComponent, computed, h } from "vue"
22
import {
33
chakra,
44
ComponentWithProps,
5-
DeepPartial,
65
HTMLChakraProps,
7-
omitThemingProps,
86
ThemingProps,
97
useStyleConfig,
108
useStyles,
@@ -21,7 +19,6 @@ export const CFormLabel = defineComponent({
2119
props: vueThemingProps,
2220
setup(props, { attrs, slots }) {
2321
const styles = useStyleConfig("FormLabel", props)
24-
const _props = omitThemingProps(props)
2522
const field = useFormControlContext()
2623
const requiredIndicator = computed(() => {
2724
if (slots.indicator) {
@@ -55,8 +52,8 @@ export interface CRequiredIndicatorProps extends HTMLChakraProps<"span"> {}
5552
* Used to show a "required" text or an asterisks (*) to indicate that
5653
* a field is required.
5754
*/
58-
export const CRequiredIndicator: ComponentWithProps<CRequiredIndicatorProps> = defineComponent(
59-
{
55+
export const CRequiredIndicator: ComponentWithProps<CRequiredIndicatorProps> =
56+
defineComponent({
6057
name: "CRequiredIndicator",
6158
setup(_, { attrs }) {
6259
const field = useFormControlContext()
@@ -75,5 +72,4 @@ export const CRequiredIndicator: ComponentWithProps<CRequiredIndicatorProps> = d
7572
</chakra.span>
7673
)
7774
},
78-
}
79-
)
75+
})

packages/core/src/helpers/css-reset.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { get, runIfFn } from "@chakra-ui/utils"
55
import { ColorModeRef } from "@chakra-ui/c-color-mode"
66
import { serializeStyles } from "@emotion/serialize"
77
import { StyleSheet } from "@emotion/sheet"
8-
import { computed, getCurrentInstance, ref, watch, watchEffect } from "vue"
8+
import { computed, ref, watch, watchEffect } from "vue"
99
import createCache, { EmotionCache } from "@emotion/cache"
1010
import { insertStyles, SerializedStyles } from "@emotion/utils"
1111

@@ -40,11 +40,8 @@ export function injectThemeGlobalStyles(
4040
serializeStyles([_globalStyles.value], cache.registered, theme)
4141
)
4242

43-
const id = ref(0)
4443
const sheetRef = ref<[sheet: StyleSheet, hydrating: boolean]>()
4544

46-
console.log(cache)
47-
4845
watch(
4946
() => cache,
5047
() => {
@@ -105,6 +102,7 @@ export function injectThemeGlobalStyles(
105102
sheet.flush()
106103
}
107104

105+
/* @ts-expect-error Sheet type not correctly assigned*/
108106
cache.insert(``, serializedStyles.value, sheet, false)
109107
})
110108
}

packages/system/src/chakra.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ import {
1717
SystemProps,
1818
SystemStyleObject,
1919
} from "@chakra-ui/styled-system"
20-
import _styled, { useEmotionTheme } from "@chakra-ui/vue-styled"
20+
import _styled from "@chakra-ui/vue-styled"
2121

2222
import {
2323
isFunction,
2424
objectFilter,
2525
isObject,
2626
memoizedGet as get,
27-
runIfFn,
28-
filterUndefined,
2927
Dict,
3028
} from "@chakra-ui/utils"
3129
import { cx, css as _css, CSSObject } from "@emotion/css"
@@ -398,12 +396,16 @@ export type ChakraFactoryProps = ChakraProps &
398396
type UserProvidedProps = { [key: string]: any }
399397

400398
type IChakraFactory = {
401-
[key in DOMElements]: DefineComponent | ComponentWithProps<ChakraFactoryProps>
399+
[key in DOMElements]:
400+
| DefineComponent<ChakraFactoryProps>
401+
| ComponentWithProps<ChakraFactoryProps>
402402
} & {
403403
(
404404
tag: ChakraTagOrComponent,
405405
options?: StyleResolverOptions & UserProvidedProps
406-
): DefineComponent | ComponentWithProps<ChakraFactoryProps>
406+
):
407+
| DefineComponent<ChakraFactoryProps>
408+
| ComponentWithProps<ChakraFactoryProps>
407409
}
408410

409411
domElements.forEach((tag) => {

packages/system/src/system.types.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ export type ComponentWithProps<P> = {
2727
new (): {
2828
$props: AllowedComponentProps &
2929
ComponentCustomProps &
30-
VNodeProps &
31-
{ props?: Record<keyof P, any> } &
32-
P & {
30+
VNodeProps & { props?: Record<keyof P, any> } & P & {
3331
[key: string]: unknown
3432
}
3533
}
@@ -44,18 +42,6 @@ export type Tag =
4442
| typeof Suspense
4543
| Component
4644

47-
export interface ThemingProps<ThemeComponent extends string = string> {
48-
variant?: ThemeComponent extends keyof ThemeTypings["components"]
49-
? ThemeTypings["components"][ThemeComponent]["variants"] | (string & {})
50-
: string
51-
size?: ThemeComponent extends keyof ThemeTypings["components"]
52-
? ThemeTypings["components"][ThemeComponent]["sizes"] | (string & {})
53-
: string
54-
colorScheme?: ThemeTypings["colorSchemes"] | (string & {})
55-
orientation?: "vertical" | "horizontal"
56-
styleConfig?: Dict
57-
}
58-
5945
export interface ChakraProps extends SystemProps, StyleResolverProps {
6046
/**
6147
* apply layer styles defined in `theme.layerStyles`

packages/system/src/system.utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,4 @@ export type ToPropType<T> = {
8282
[P in keyof T]?: PropType<T[P]>
8383
}
8484

85-
export function omitThemingProps<T extends ThemingProps>(props: T) {
86-
return omit(props, ["styleConfig", "size", "variant", "colorScheme"])
87-
}
88-
8985
export { keyframes, injectGlobal }

tsconfig.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
{
2+
"extends": "@vue/tsconfig/tsconfig.node.json",
23
"compilerOptions": {
34
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
45
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
56
"resolveJsonModule": true,
67
"preserveSymlinks": true,
8+
"composite": true,
79
"lib": [ "es5", "esnext", "dom" ],
8-
"types": ["node", "jest", "vite/client", "vite-plugin-pages/client", "vitest/globals", "cypress", "components.d.ts"],
10+
"types": ["node", "dom.iterable", "vue", "jest", "vite/client", "components.d.ts"],
911
"declaration": true,
1012
"declarationMap": true,
1113
"allowJs": true,
1214
"sourceMap": true,
1315
"moduleResolution": "node",
14-
"plugins": [{ "name": "@vuedx/typescript-plugin-vue" }],
1516
"jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
1617
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
17-
"strict": true, /* Enable all strict type-checking options. */
18-
"baseUrl": ".",
18+
"strict": true, /* Enable all strict type-checking options. */
19+
"baseUrl": ".",
1920
"noFallthroughCasesInSwitch": true,
2021
"suppressImplicitAnyIndexErrors": true,
2122
"strictFunctionTypes": true,
2223
"strictNullChecks": true,
24+
"importsNotUsedAsValues": "preserve",
2325
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
2426
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
2527
"skipLibCheck": true, /* Skip type checking of declaration files. */
2628
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
2729
},
2830
"include": [
2931
"./components.d.ts",
30-
"packages",
32+
"packages/**/*.ts",
33+
"packages/**/*.tsx",
3134
"playground/**/*.ts",
32-
"playground/**/*.d.ts",
3335
"playground/**/*.tsx",
36+
"playground/**/*.d.ts",
3437
"playground/**/*.vue",
3538
"tests/index.d.ts",
39+
"**/*.d.ts",
3640
"vite.config.ts",
3741
],
3842
"exclude": ["node_modules", "./@types", "dist", "packages/**/*.test.ts"],

0 commit comments

Comments
 (0)