Skip to content

Commit

Permalink
Update dependencies in package.json and styled.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Jan 17, 2024
1 parent ae403a6 commit 069d3e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
6 changes: 3 additions & 3 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
},
"dependencies": {
"@master/css-runtime": "workspace:^",
"@techor/one-liner": "^2.2.10",
"@techor/extend": "^2.5.24",
"class-variant": "workspace:^",
"theme-service": "workspace:^",
"@techor/extend": "^2.5.24"
"clsx": "^2.1.0",
"theme-service": "workspace:^"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
Expand Down
32 changes: 16 additions & 16 deletions packages/vue/src/styled.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { h, defineComponent, type VNode } from 'vue'
import cv from 'class-variant'
import line from '@techor/one-liner'
import { extend } from '@techor/extend'
import clsx from 'clsx'

type IfEquals<X, Y, A=X, B=never> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2)
? A
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2)
? A
: B
type WritableKeys<T> = {
[P in keyof T]-?: IfEquals<
{ [Q in P]: T[P];},
{ -readonly [Q in P]: T[P] },
{ [Q in P]: T[P]; },
{ -readonly [Q in P]: T[P] },
P
>
}[keyof T];
Expand All @@ -24,21 +24,21 @@ type BaseType<E> = string
| Record<string, boolean>
| (
E extends Array<any>
? never
: [string, { [key in keyof E]?: E[key] }]
| { [key in keyof E]?: E[key] extends boolean | undefined ? string : Record<string, string> }
? never
: [string, { [key in keyof E]?: E[key] }]
| { [key in keyof E]?: E[key] extends boolean | undefined ? string : Record<string, string> }
)
type BaseLoopType<E> = BaseType<E> | Array<BaseType<E>>
type TagParams = Array<[TemplateStringsArray, any[]]>;
type ParamType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = ((props: MasterComponentProps<K, E>) => BaseLoopType<MasterComponentProps<K, E>> | undefined) | BaseLoopType<MasterComponentProps<K, E>>
type ParamsType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = Array<ParamType<K, E>>;
type MasterComponentProps<K extends HTMLElementTagNameKeys | VNode, E extends object = object> =
type MasterComponentProps<K extends HTMLElementTagNameKeys | VNode, E extends object = object> =
Partial<E>
& { className?: BaseLoopType<E> | undefined, [key: string]: any }
& (
K extends HTMLElementTagNameKeys
? Partial<Omit<WritableObject<HTMLElementTagNameMap[K]>, 'className'>>
: object
K extends HTMLElementTagNameKeys
? Partial<Omit<WritableObject<HTMLElementTagNameMap[K]>, 'className'>>
: object
)
type MasterComponent<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = ((props: MasterComponentProps<K, E>) => any) & { setup?: any, tag?: K, params: TagParams };
type ReturnType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = <F extends TemplateStringsArray | MasterComponent<any> | VNode | BaseType<E>>(
Expand Down Expand Up @@ -67,8 +67,8 @@ export const styled: {
// @ts-ignore
((firstParam, ...params) => {
return (
Array.isArray(firstParam) && 'raw' in firstParam
|| typeof firstParam !== 'object'
Array.isArray(firstParam) && 'raw' in firstParam
|| typeof firstParam !== 'object'
|| !('setup' in firstParam) && !('__v_isVNode' in firstParam)
)
? styled.div(firstParam as any, ...params)
Expand Down Expand Up @@ -97,7 +97,7 @@ function handle<K extends string | VNode, E extends object = object>(tag: K, tag
let valuesByProp: Record<string, string | Record<string, string>>
const unhandledTagParams: TagParams = []
const mergedProps = Object.assign({}, typeof tag === 'string' ? {} : tag.props, attrs)

const handleParam = (param: any) => {
switch (typeof param) {
case 'object':
Expand Down Expand Up @@ -192,7 +192,7 @@ function handle<K extends string | VNode, E extends object = object>(tag: K, tag
}
}

return h(tag, { ...props, ...newAttrs, class: line(classNames, attrs.class) }, slots.default?.())
return h(tag, { ...props, ...newAttrs, class: clsx(classNames, attrs.class) }, slots.default?.())
}
}
) as any as MasterComponent<any, E>
Expand Down
13 changes: 4 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 069d3e6

Please sign in to comment.