Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 1b12d8d

Browse files
committed
fix(types): fix Pick<T, K> to T[K] and create Type name is changed.
1 parent 63ddb3b commit 1b12d8d

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

src/_internal/types/custom/classes-object-type.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { CustomCSSProperties } from './custom-css-properties';
2+
import { MediaQuery } from './custom-html-type';
3+
4+
export type CSSXStyleDefinition = Record<MediaQuery, Record<string, CustomCSSProperties>>;
5+
6+
export type CSSXTypedStyle<T> = {
7+
readonly [K in keyof T | string]: K extends keyof T ? T[K] : CustomCSSProperties;
8+
};
9+
10+
export type CSSXReturnStyle<T> = { [key in keyof T]: string };

src/_internal/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export * from './common/css-values';
44
export * from './common/css-variables';
55
export * from './common/nth-selectors';
66
export * from './common/pseudo-selectors';
7-
export * from './custom/classes-object-type';
7+
export * from './custom/create-type';
88
export * from './custom/custom-css-properties';
99
export * from './custom/custom-html-type';
1010
export * from './custom/property-type';

src/_internal/utils/sheet-compiler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { pseudo, camelToKebabCase, isClassesObjectType, applyCssValue } from '..';
2-
import type { PropertyType, ClassesObjectType, CustomCSSProperties, CustomHTMLType } from '..';
2+
import type { PropertyType, CSSXStyleDefinition, CustomCSSProperties, CustomHTMLType } from '..';
33

4-
export function sheetCompiler(object: ClassesObjectType | CustomHTMLType, base36Hash?: string, core?: string) {
4+
export function sheetCompiler(object: CSSXStyleDefinition | CustomCSSProperties | CustomHTMLType, base36Hash?: string, core?: string) {
55
let styleSheet = '';
66
let bigIndent = false;
77
const mediaQueries: { media: string; css: string }[] = [];
@@ -121,10 +121,10 @@ export function sheetCompiler(object: ClassesObjectType | CustomHTMLType, base36
121121
return classSelector;
122122
};
123123

124-
const createStyles = (styleObject: PropertyType | CustomCSSProperties | ClassesObjectType, indentLevel = 0): string => {
124+
const createStyles = (styleObject: PropertyType | CustomCSSProperties | CSSXStyleDefinition, indentLevel = 0): string => {
125125
let styleSheet = '';
126126

127-
const processStyles = (styles: PropertyType | CustomCSSProperties | ClassesObjectType, currentIndentLevel = 0): void => {
127+
const processStyles = (styles: PropertyType | CustomCSSProperties | CSSXStyleDefinition, currentIndentLevel = 0): void => {
128128
const indent = ' '.repeat(currentIndentLevel);
129129
for (const property in styles) {
130130
if (Object.prototype.hasOwnProperty.call(styles, property)) {

src/core/cssx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { ClassesObjectType, ExactClassesObjectType, ReturnStyleType, CustomHTMLType, ExtendedCSSProperties } from '../_internal';
1+
import type { CSSXStyleDefinition, CSSXTypedStyle, CSSXReturnStyle, CustomHTMLType, ExtendedCSSProperties } from '../_internal';
22
import { create } from './method/create';
33
import { set } from './method/set';
44
import { global } from './method/global';
55
import { root } from './method/root';
66
import { union } from './method/union';
77

88
class cssx {
9-
static create<T extends ClassesObjectType>(object: ExactClassesObjectType<T> | ClassesObjectType): ReturnStyleType<T> {
9+
static create<T extends CSSXStyleDefinition>(object: CSSXTypedStyle<T> | CSSXStyleDefinition): CSSXReturnStyle<T> {
1010
return create(object);
1111
}
1212

src/core/method/create.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { ReturnStyleType, ClassesObjectType, ExactClassesObjectType } from '../../_internal';
1+
import type { CSSXReturnStyle, CSSXTypedStyle, CSSXStyleDefinition } from '../../_internal';
22
import { isDevAndTest, sheetCompiler, injectServerCSS, genBase36Hash, isServer, injectClientCSS } from '../../_internal';
33
import { createGlobalStyleSheetPromise, globalStyleSheetPromise, resolveGlobalStyleSheet } from './create-build-in-helper';
44
import styles from '../styles/style.module.css';
55

6-
export function create<T extends ClassesObjectType>(object: ExactClassesObjectType<T> | ClassesObjectType): ReturnStyleType<T> {
6+
export function create<T extends CSSXStyleDefinition>(object: CSSXTypedStyle<T> | CSSXStyleDefinition): CSSXReturnStyle<T> {
77
const base36Hash = genBase36Hash(object, 6);
88
const { styleSheet } = sheetCompiler(object, base36Hash);
99
if (typeof globalStyleSheetPromise === 'undefined') createGlobalStyleSheetPromise();
@@ -19,5 +19,5 @@ export function create<T extends ClassesObjectType>(object: ExactClassesObjectTy
1919
},
2020
});
2121
});
22-
return object as ReturnStyleType<T>;
22+
return object as CSSXReturnStyle<T>;
2323
}

0 commit comments

Comments
 (0)