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

Commit cecd9c3

Browse files
committed
feat: improve rendering
1 parent 0a7efcf commit cecd9c3

File tree

14 files changed

+327
-116
lines changed

14 files changed

+327
-116
lines changed

components.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* This is a generated file. Do not edit it's contents.
88
*
9-
* This file was generated on 2021-12-21T13:56:02.197Z
9+
* This file was generated on 2021-12-21T17:13:01.320Z
1010
*/
1111

1212
import { ChakraProps, chakra } from "@chakra-ui/vue-system"
@@ -63,6 +63,11 @@ declare module "@vue/runtime-core" {
6363
CRequiredIndicator: typeof import("@chakra-ui/vue-next")["CRequiredIndicator"]
6464
CInput: typeof import("@chakra-ui/vue-next")["CInput"]
6565
CInputAddon: typeof import("@chakra-ui/vue-next")["CInputAddon"]
66+
CInputGroup: typeof import("@chakra-ui/vue-next")["CInputGroup"]
67+
CInputLeftAddon: typeof import("@chakra-ui/vue-next")["CInputLeftAddon"]
68+
CInputLeftElement: typeof import("@chakra-ui/vue-next")["CInputLeftElement"]
69+
CInputRightAddon: typeof import("@chakra-ui/vue-next")["CInputRightAddon"]
70+
CInputRightElement: typeof import("@chakra-ui/vue-next")["CInputRightElement"]
6671
CAspectRatio: typeof import("@chakra-ui/vue-next")["CAspectRatio"]
6772
CBadge: typeof import("@chakra-ui/vue-next")["CBadge"]
6873
CBox: typeof import("@chakra-ui/vue-next")["CBox"]

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"cy:open": "cypress open-ct",
3131
"cy:run": "cypress run-ct --quiet",
3232
"test:component": "yarn cy:run",
33-
"test": "jest && yarn cy:run",
33+
"test": "jest",
3434
"test:unit": "cross-env NODE_ENV=test jest --config jest.config.js",
3535
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
3636
"docs:dev:legacy": "vitepress dev docs",
@@ -95,7 +95,7 @@
9595
"@vuedx/typecheck": "^0.4.1",
9696
"@vuedx/typescript-plugin-vue": "^0.4.1",
9797
"@vueuse/core": "4.9.1",
98-
"@vueuse/head": "^0.6.0",
98+
"@vueuse/head": "^0.7.4",
9999
"@vueuse/integrations": "^4.8.1",
100100
"@vueuse/motion": "^1.5.4",
101101
"aria-hidden": "^1.1.2",
@@ -156,7 +156,7 @@
156156
"vite-plugin-mdx-vue": "^1.1.3",
157157
"vite-plugin-pages": "^0.18.2",
158158
"vite-plugin-vue-layouts": "^0.3.1",
159-
"vite-ssg": "^0.11.4",
159+
"vite-ssg": "^0.17.2",
160160
"vitepress": "^0.12.0",
161161
"vue": "^3.2.24",
162162
"vue-jest": "^5.0.0-alpha.7",

packages/c-input/src/c-input-addon.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineComponent, h, PropType, computed } from 'vue'
1+
import { defineComponent, h, PropType, computed } from "vue"
22
import { chakra, HTMLChakraProps, useStyles } from "@chakra-ui/vue-system"
3-
import { warn } from '@chakra-ui/utils'
3+
import { warn } from "@chakra-ui/utils"
44

55
type Placement = "left" | "right"
66

@@ -27,7 +27,7 @@ const CStyledAddon = chakra("div", {
2727
},
2828
})
2929

30-
export interface CInputAddonProps extends HTMLChakraProps<'div'> {
30+
export interface CInputAddonProps extends HTMLChakraProps<"div"> {
3131
placement?: Placement
3232
}
3333

@@ -37,37 +37,38 @@ export interface CInputAddonProps extends HTMLChakraProps<'div'> {
3737
* Element to append or prepend to an input
3838
*/
3939
export const CInputAddon = defineComponent({
40-
name: 'CInputAddon',
40+
name: "CInputAddon",
4141
props: {
4242
placement: {
4343
type: String as PropType<Placement>,
44-
default: 'left'
44+
default: "left",
4545
},
4646
},
4747
setup(props, { slots, attrs }) {
4848
try {
49-
const placementStyles = computed(() => placements[props.placement])
49+
const placementStyles = computed(() => placements[props.placement])
5050
const styles = useStyles()
5151
return () => (
5252
<CStyledAddon
5353
__css={{
54-
...styles.value.addon,
55-
...placementStyles.value
56-
}}
57-
{...attrs}
54+
...styles.value.addon,
55+
...placementStyles.value,
56+
}}
57+
{...attrs}
5858
>
5959
{slots}
6060
</CStyledAddon>
6161
)
6262
} catch (error: any) {
6363
warn({
6464
condition: !!error,
65-
message: "`CInputAddon` can only be used inside the `CInputGroup` component.",
65+
message:
66+
"`CInputAddon` can only be used inside the `CInputGroup` component.",
6667
})
6768
console.error(error)
6869
return () => null
6970
}
70-
}
71+
},
7172
})
7273

7374
/**
@@ -76,14 +77,14 @@ export const CInputAddon = defineComponent({
7677
* Element to prepend to the left of an input
7778
*/
7879
export const CInputLeftAddon = defineComponent({
79-
name: 'CInputLeftAddon',
80+
name: "CInputLeftAddon",
8081
setup(_, { slots, attrs }) {
8182
return () => (
8283
<CInputAddon placement="left" __label="input__left-addon" {...attrs}>
8384
{slots}
8485
</CInputAddon>
8586
)
86-
}
87+
},
8788
})
8889

8990
CInputLeftAddon.id = "CInputLeftAddon"
@@ -94,14 +95,14 @@ CInputLeftAddon.id = "CInputLeftAddon"
9495
* Element to append to the right of an input
9596
*/
9697
export const CInputRightAddon = defineComponent({
97-
name: 'CInputRightAddon',
98+
name: "CInputRightAddon",
9899
setup(_, { slots, attrs }) {
99100
return () => (
100101
<CInputAddon placement="right" __label="input__right-addon" {...attrs}>
101102
{slots}
102103
</CInputAddon>
103104
)
104-
}
105+
},
105106
})
106107

107-
CInputRightAddon.id = "CInputRightAddon"
108+
CInputRightAddon.id = "CInputRightAddon"

packages/c-input/src/c-input-element.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { computed, h, defineComponent, PropType } from 'vue';
2-
import { chakra, HTMLChakraProps, SystemStyleObject, useStyles } from '@chakra-ui/vue-system';
1+
import { computed, h, defineComponent, PropType } from "vue"
2+
import {
3+
chakra,
4+
HTMLChakraProps,
5+
SystemStyleObject,
6+
useStyles,
7+
} from "@chakra-ui/vue-system"
38

49
export interface CInputElementProps extends HTMLChakraProps<"div"> {
510
placement?: "left" | "right"
@@ -20,9 +25,9 @@ const CInputElement = defineComponent({
2025
name: "CInputElement",
2126
props: {
2227
placement: {
23-
type: String as PropType<CInputElementProps['placement']>,
24-
default: 'left'
25-
}
28+
type: String as PropType<CInputElementProps["placement"]>,
29+
default: "left",
30+
},
2631
},
2732
setup(props, { attrs, slots }) {
2833
const styles = useStyles()
@@ -34,42 +39,48 @@ const CInputElement = defineComponent({
3439
[attr]: "0",
3540
width: input?.height || input.h,
3641
height: input?.height || input?.h,
37-
fontSize: input?.fontSize
42+
fontSize: input?.fontSize,
3843
}
3944
})
4045

4146
return () => (
42-
<CStyledElement __css={elementStyles.value} {...attrs}>{slots}</CStyledElement>
47+
<CStyledElement __css={elementStyles.value} {...attrs}>
48+
{slots}
49+
</CStyledElement>
4350
)
44-
}
51+
},
4552
})
4653

4754
// This is used in `c-input-group.tsx`
4855
CInputElement.id = "CInputElement"
4956

5057
export const CInputLeftElement = defineComponent({
51-
name: 'CInputLeftElement',
58+
name: "CInputLeftElement",
5259
setup(_, { attrs, slots }) {
5360
return () => (
5461
<CInputElement placement="left" __label="input__left-element" {...attrs}>
5562
{slots}
5663
</CInputElement>
5764
)
58-
}
65+
},
5966
})
6067

6168
// This is used in `c-input-group.tsx`
6269
CInputLeftElement.id = "CInputLeftElement"
6370

6471
export const CInputRightElement = defineComponent({
65-
name: 'CInputRightElement',
72+
name: "CInputRightElement",
6673
setup(_, { attrs, slots }) {
6774
return () => (
68-
<CInputElement placement="right" __label="input__right-element" {...attrs}>
75+
<CInputElement
76+
placement="right"
77+
__label="input__right-element"
78+
{...attrs}
79+
>
6980
{slots}
7081
</CInputElement>
7182
)
72-
}
83+
},
7384
})
7485

7586
// This is used in `c-input-group.tsx`

packages/c-input/src/c-input-group.tsx

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
1-
import { filterUndefined } from '@chakra-ui/utils';
2-
import { chakra, HTMLChakraProps, omitThemingProps, StylesProvider, ThemingProps, useMultiStyleConfig } from '@chakra-ui/vue-system';
3-
import { getValidChildren, vueThemingProps } from '@chakra-ui/vue-utils';
4-
import { computed, h, Fragment, defineComponent, mergeProps, VNode, cloneVNode } from 'vue';
1+
import { filterUndefined } from "@chakra-ui/utils"
2+
import {
3+
chakra,
4+
HTMLChakraProps,
5+
omitThemingProps,
6+
StylesProvider,
7+
ThemingProps,
8+
useMultiStyleConfig,
9+
} from "@chakra-ui/vue-system"
10+
import { getValidChildren, vueThemingProps } from "@chakra-ui/vue-utils"
11+
import {
12+
computed,
13+
h,
14+
Fragment,
15+
defineComponent,
16+
mergeProps,
17+
VNode,
18+
cloneVNode,
19+
} from "vue"
520

621
export interface CInputGroupProps
722
extends HTMLChakraProps<"div">,
823
ThemingProps<"Input"> {}
924

1025
export const CInputGroup = defineComponent({
11-
name: 'CInputGroup',
26+
name: "CInputGroup",
1227
props: {
13-
...vueThemingProps
28+
...vueThemingProps,
1429
},
1530
setup(props, { slots, attrs }) {
1631
const styleAttrs = computed(() => mergeProps(attrs, props))
17-
const styles = useMultiStyleConfig('Input', styleAttrs.value);
32+
const styles = useMultiStyleConfig("Input", styleAttrs.value)
1833
const input = computed(() => styles.value?.field)
1934
const unthemedProps = computed(() => omitThemingProps(styleAttrs.value))
2035

2136
StylesProvider(styles)
2237

23-
return () => {
38+
return () => {
2439
const groupStyles = {} as CInputGroupProps
2540
const validChildren = getValidChildren(slots)
2641
validChildren.forEach((vnode) => {
@@ -51,17 +66,18 @@ export const CInputGroup = defineComponent({
5166
variant: vnode.props?.size || props.variant,
5267
})
5368

54-
5569
// @ts-ignore
5670
return vnode.type?.name !== "CInput"
5771
? cloneVNode(vnode, theming)
58-
: cloneVNode(vnode, Object.assign(
59-
theming,
60-
groupStyles,
61-
// vnode.props
62-
))
72+
: cloneVNode(
73+
vnode,
74+
Object.assign(
75+
theming,
76+
groupStyles
77+
// vnode.props
78+
)
79+
)
6380
})
64-
6581

6682
return (
6783
<chakra.div
@@ -77,5 +93,5 @@ export const CInputGroup = defineComponent({
7793
</chakra.div>
7894
)
7995
}
80-
}
81-
})
96+
},
97+
})

packages/c-input/src/c-input.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ export interface CInputProps
6969
export const CInput = defineComponent({
7070
name: "CInput",
7171
props: {
72-
as: {
73-
type: [Object, String] as PropType<DOMElements>,
74-
default: "input",
75-
},
7672
modelValue: String as PropType<string>,
7773
...formControlProps,
7874
focusBorderColor: SAO as PropType<CInputProps["focusBorderColor"]>,
@@ -81,8 +77,7 @@ export const CInput = defineComponent({
8177
...vueThemingProps,
8278
},
8379
emits: ["update:modelValue", "input", "change"],
84-
setup(_props, { slots, emit, attrs }) {
85-
const { as, ...props } = _props
80+
setup(props, { emit, attrs }) {
8681
const styles = useMultiStyleConfig("Input", props)
8782
const ownProps = computed(() =>
8883
toRefs(omitThemingProps(props as ThemingProps<"Input">))
@@ -109,4 +104,4 @@ export const CInput = defineComponent({
109104
},
110105
})
111106

112-
CInput.id = "CInput"
107+
CInput.id = "CInput"

packages/c-input/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from "./c-input"
22
export * from "./c-input-addon"
33
export * from "./c-input-group"
4-
export * from "./c-input-element"
4+
export * from "./c-input-element"

packages/c-input/tests/c-input.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { CInput, CInputGroup, CInputLeftElement, CInputRightElement } from "../src"
1+
import {
2+
CInput,
3+
CInputGroup,
4+
CInputLeftElement,
5+
CInputRightElement,
6+
} from "../src"
27
import { Component, defineComponent, h } from "vue"
38
import { render, screen, testA11y } from "../../test-utils/src"
49

@@ -56,5 +61,5 @@ describe("<CInput />", () => {
5661
it("Read-only input renders correctly", () => {
5762
render(() => <CInput isReadOnly />)
5863
expect(screen.getByRole("textbox")).toHaveAttribute("aria-readonly", "true")
59-
})
64+
})
6065
})

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { injectGlobal } from "@chakra-ui/vue-system"
1+
import { injectGlobal, css } from "@chakra-ui/vue-system"
22
import { cssResetStyles } from "@chakra-ui/c-reset"
33
import { ThemeOverride } from "../extend-theme"
44
import { get, runIfFn } from "@chakra-ui/utils"
5-
import { css } from "@chakra-ui/styled-system"
65
import { ColorModeRef } from "@chakra-ui/c-color-mode"
76
import { computed, ref, watch } from "vue"
87

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { computed, Plugin, ref, UnwrapRef } from "vue"
22
import defaultTheme from "@chakra-ui/vue-theme"
33
import type { ColorModeRef } from "@chakra-ui/c-color-mode"
44
import { toCSSVar, WithCSSVar } from "@chakra-ui/styled-system"
5-
import { chakra, injectGlobal, css } from "@chakra-ui/vue-system"
5+
import { chakra, injectGlobal } from "@chakra-ui/vue-system"
66
import internalIcons from "./icon.internals"
77
import { extendTheme, ThemeOverride } from "./extend-theme"
88
import { MergedIcons, parseIcons } from "./parse-icons"

0 commit comments

Comments
 (0)