@hypergood/css-core 0.0.4 → 0.1.0
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/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -3
- package/dist/index.d.ts +49 -3
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +286 -66976
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +2 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +278 -67002
- package/dist/plugin.js.map +1 -1
- package/package.json +33 -23
- package/src/atomizer/css-tree.ts +1 -1
- package/src/css-properties.ts +43 -0
- package/src/plugin.ts +266 -15
- package/src/runtime.ts +25 -2
- package/tsconfig.json +2 -1
- package/tsup.config.ts +3 -1
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
css: () => css,
|
|
24
24
|
keyframes: () => keyframes,
|
|
25
|
-
mergeClassNames: () => mergeClassNames
|
|
25
|
+
mergeClassNames: () => mergeClassNames,
|
|
26
|
+
styled: () => styled,
|
|
27
|
+
variants: () => variants
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(index_exports);
|
|
28
30
|
|
|
@@ -33,6 +35,12 @@ function css(styleObject) {
|
|
|
33
35
|
function keyframes(styleObject) {
|
|
34
36
|
throw new Error("RAHHH");
|
|
35
37
|
}
|
|
38
|
+
function styled(component, styleObject) {
|
|
39
|
+
throw new Error("RAHHH");
|
|
40
|
+
}
|
|
41
|
+
function variants(variantsObject) {
|
|
42
|
+
throw new Error("RAHHH");
|
|
43
|
+
}
|
|
36
44
|
function mergeClassNames(classNames) {
|
|
37
45
|
let cleanNames = classNames.filter((element) => typeof element === "string").join(" ").split(/\s+/);
|
|
38
46
|
let classMap = /* @__PURE__ */ Object.create(null);
|
|
@@ -49,6 +57,8 @@ function mergeClassNames(classNames) {
|
|
|
49
57
|
0 && (module.exports = {
|
|
50
58
|
css,
|
|
51
59
|
keyframes,
|
|
52
|
-
mergeClassNames
|
|
60
|
+
mergeClassNames,
|
|
61
|
+
styled,
|
|
62
|
+
variants
|
|
53
63
|
});
|
|
54
64
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/runtime.ts"],"sourcesContent":["export * from \"./runtime.js\";\n","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/runtime.ts"],"sourcesContent":["export * from \"./runtime.js\";\n","import type { CSSProperties } from \"./css-properties.js\";\n\nexport type { CSSProperties, CSSValue } from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as CSS from 'csstype';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A value allowed inside a {@link CSSProperties} object: a string, a number, an
|
|
5
|
+
* array of strings/numbers (e.g. for fallback values), or a nested
|
|
6
|
+
* {@link CSSProperties} object (e.g. for selectors, media queries, or
|
|
7
|
+
* at-rules).
|
|
8
|
+
*/
|
|
9
|
+
type CSSValue = string | number | Array<string | number> | CSSProperties;
|
|
10
|
+
/**
|
|
11
|
+
* The value type for a *known* CSS property.
|
|
12
|
+
*
|
|
13
|
+
* We deliberately do NOT union in a bare `string` here: csstype's own property
|
|
14
|
+
* types already permit any string via the `(string & {})` trick, which keeps
|
|
15
|
+
* the literal value suggestions (e.g. `"center"` for `alignItems`) visible in
|
|
16
|
+
* IntelliSense. Adding a bare `string` would collapse that union and suppress
|
|
17
|
+
* the autocomplete. We still allow numbers, fallback arrays, and nested objects.
|
|
18
|
+
*/
|
|
19
|
+
type KnownCSSValue<K extends keyof CSS.Properties> = CSS.Properties[K] | number | Array<string | number> | CSSProperties;
|
|
20
|
+
/**
|
|
21
|
+
* The shape of the style objects passed to `css()`, `variants()`, and
|
|
22
|
+
* `styled()`.
|
|
23
|
+
*
|
|
24
|
+
* Known camelCase CSS properties (sourced from `csstype`) offer autocomplete
|
|
25
|
+
* for both the property name and its value, but any other key is accepted
|
|
26
|
+
* without a type error so that selectors, media queries, custom properties, and
|
|
27
|
+
* other arbitrary keys can be used freely.
|
|
28
|
+
*/
|
|
29
|
+
type CSSProperties = {
|
|
30
|
+
[K in keyof CSS.Properties]?: KnownCSSValue<K>;
|
|
31
|
+
} & {
|
|
32
|
+
[key: string]: CSSValue;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The style object accepted by `styled()`: top-level CSS properties plus the
|
|
37
|
+
* optional `variants` and `defaultVariants` keys.
|
|
38
|
+
*/
|
|
39
|
+
type StyledStyleObject = CSSProperties & {
|
|
40
|
+
variants?: Record<string, Record<string, CSSProperties>>;
|
|
41
|
+
defaultVariants?: Record<string, string | number | boolean>;
|
|
42
|
+
};
|
|
43
|
+
declare function css(styleObject: CSSProperties): string;
|
|
44
|
+
declare function keyframes(styleObject: Record<string, CSSProperties>): string;
|
|
45
|
+
declare function styled(component: any, styleObject: StyledStyleObject): any;
|
|
46
|
+
declare function variants<T extends Record<string, Record<string, CSSProperties>>>(variantsObject: T): {
|
|
47
|
+
[K in keyof T]: string;
|
|
48
|
+
};
|
|
3
49
|
declare function mergeClassNames(classNames: Array<string | boolean | null | undefined>): string;
|
|
4
50
|
|
|
5
|
-
export { css, keyframes, mergeClassNames };
|
|
51
|
+
export { type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as CSS from 'csstype';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A value allowed inside a {@link CSSProperties} object: a string, a number, an
|
|
5
|
+
* array of strings/numbers (e.g. for fallback values), or a nested
|
|
6
|
+
* {@link CSSProperties} object (e.g. for selectors, media queries, or
|
|
7
|
+
* at-rules).
|
|
8
|
+
*/
|
|
9
|
+
type CSSValue = string | number | Array<string | number> | CSSProperties;
|
|
10
|
+
/**
|
|
11
|
+
* The value type for a *known* CSS property.
|
|
12
|
+
*
|
|
13
|
+
* We deliberately do NOT union in a bare `string` here: csstype's own property
|
|
14
|
+
* types already permit any string via the `(string & {})` trick, which keeps
|
|
15
|
+
* the literal value suggestions (e.g. `"center"` for `alignItems`) visible in
|
|
16
|
+
* IntelliSense. Adding a bare `string` would collapse that union and suppress
|
|
17
|
+
* the autocomplete. We still allow numbers, fallback arrays, and nested objects.
|
|
18
|
+
*/
|
|
19
|
+
type KnownCSSValue<K extends keyof CSS.Properties> = CSS.Properties[K] | number | Array<string | number> | CSSProperties;
|
|
20
|
+
/**
|
|
21
|
+
* The shape of the style objects passed to `css()`, `variants()`, and
|
|
22
|
+
* `styled()`.
|
|
23
|
+
*
|
|
24
|
+
* Known camelCase CSS properties (sourced from `csstype`) offer autocomplete
|
|
25
|
+
* for both the property name and its value, but any other key is accepted
|
|
26
|
+
* without a type error so that selectors, media queries, custom properties, and
|
|
27
|
+
* other arbitrary keys can be used freely.
|
|
28
|
+
*/
|
|
29
|
+
type CSSProperties = {
|
|
30
|
+
[K in keyof CSS.Properties]?: KnownCSSValue<K>;
|
|
31
|
+
} & {
|
|
32
|
+
[key: string]: CSSValue;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The style object accepted by `styled()`: top-level CSS properties plus the
|
|
37
|
+
* optional `variants` and `defaultVariants` keys.
|
|
38
|
+
*/
|
|
39
|
+
type StyledStyleObject = CSSProperties & {
|
|
40
|
+
variants?: Record<string, Record<string, CSSProperties>>;
|
|
41
|
+
defaultVariants?: Record<string, string | number | boolean>;
|
|
42
|
+
};
|
|
43
|
+
declare function css(styleObject: CSSProperties): string;
|
|
44
|
+
declare function keyframes(styleObject: Record<string, CSSProperties>): string;
|
|
45
|
+
declare function styled(component: any, styleObject: StyledStyleObject): any;
|
|
46
|
+
declare function variants<T extends Record<string, Record<string, CSSProperties>>>(variantsObject: T): {
|
|
47
|
+
[K in keyof T]: string;
|
|
48
|
+
};
|
|
3
49
|
declare function mergeClassNames(classNames: Array<string | boolean | null | undefined>): string;
|
|
4
50
|
|
|
5
|
-
export { css, keyframes, mergeClassNames };
|
|
51
|
+
export { type CSSProperties, type CSSValue, type StyledStyleObject, css, keyframes, mergeClassNames, styled, variants };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,12 @@ function css(styleObject) {
|
|
|
5
5
|
function keyframes(styleObject) {
|
|
6
6
|
throw new Error("RAHHH");
|
|
7
7
|
}
|
|
8
|
+
function styled(component, styleObject) {
|
|
9
|
+
throw new Error("RAHHH");
|
|
10
|
+
}
|
|
11
|
+
function variants(variantsObject) {
|
|
12
|
+
throw new Error("RAHHH");
|
|
13
|
+
}
|
|
8
14
|
function mergeClassNames(classNames) {
|
|
9
15
|
let cleanNames = classNames.filter((element) => typeof element === "string").join(" ").split(/\s+/);
|
|
10
16
|
let classMap = /* @__PURE__ */ Object.create(null);
|
|
@@ -20,6 +26,8 @@ function mergeClassNames(classNames) {
|
|
|
20
26
|
export {
|
|
21
27
|
css,
|
|
22
28
|
keyframes,
|
|
23
|
-
mergeClassNames
|
|
29
|
+
mergeClassNames,
|
|
30
|
+
styled,
|
|
31
|
+
variants
|
|
24
32
|
};
|
|
25
33
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type { CSSProperties } from \"./css-properties.js\";\n\nexport type { CSSProperties, CSSValue } from \"./css-properties.js\";\n\n/**\n * The style object accepted by `styled()`: top-level CSS properties plus the\n * optional `variants` and `defaultVariants` keys.\n */\nexport type StyledStyleObject = CSSProperties & {\n variants?: Record<string, Record<string, CSSProperties>>;\n defaultVariants?: Record<string, string | number | boolean>;\n};\n\nexport function css(styleObject: CSSProperties): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function keyframes(styleObject: Record<string, CSSProperties>): string {\n throw new Error(\"RAHHH\");\n}\n\nexport function styled(component: any, styleObject: StyledStyleObject): any {\n throw new Error(\"RAHHH\");\n}\n\nexport function variants<\n T extends Record<string, Record<string, CSSProperties>>,\n>(variantsObject: T): { [K in keyof T]: string } {\n throw new Error(\"RAHHH\");\n}\n\nexport function mergeClassNames(\n classNames: Array<string | boolean | null | undefined>,\n): string {\n let cleanNames = classNames\n .filter((element) => typeof element === \"string\")\n .join(\" \")\n .split(/\\s+/);\n\n let classMap = Object.create(null) as Record<string, string>;\n for (let className of cleanNames) {\n if (className.startsWith(\"x\") && className.includes(\"-\")) {\n classMap[className.split(\"-\")[0]!] = className;\n } else {\n classMap[className] = className;\n }\n }\n\n return Object.values(classMap).join(\" \");\n}\n"],"mappings":";AAaO,SAAS,IAAI,aAAoC;AACtD,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,UAAU,aAAoD;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,OAAO,WAAgB,aAAqC;AAC1E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,SAEd,gBAA+C;AAC/C,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,gBACd,YACQ;AACR,MAAI,aAAa,WACd,OAAO,CAAC,YAAY,OAAO,YAAY,QAAQ,EAC/C,KAAK,GAAG,EACR,MAAM,KAAK;AAEd,MAAI,WAAW,uBAAO,OAAO,IAAI;AACjC,WAAS,aAAa,YAAY;AAChC,QAAI,UAAU,WAAW,GAAG,KAAK,UAAU,SAAS,GAAG,GAAG;AACxD,eAAS,UAAU,MAAM,GAAG,EAAE,CAAC,CAAE,IAAI;AAAA,IACvC,OAAO;AACL,eAAS,SAAS,IAAI;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,QAAQ,EAAE,KAAK,GAAG;AACzC;","names":[]}
|