@hypergood/react-css 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.
@@ -0,0 +1 @@
1
+ dist
package/.prettierrc ADDED
@@ -0,0 +1 @@
1
+ {}
package/dist/index.cjs ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ css: () => import_css_core.css,
24
+ keyframes: () => import_css_core.keyframes,
25
+ mergeClassNames: () => import_css_core.mergeClassNames,
26
+ styled: () => styled,
27
+ variants: () => import_css_core.variants
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+ var import_css_core = require("@hypergood/css-core");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ function styled(component, styleObject) {
33
+ const {
34
+ base,
35
+ variants: variantClassNames = {},
36
+ defaultVariants = {}
37
+ } = styleObject;
38
+ const variantNames = Object.keys(variantClassNames);
39
+ return function StyledComponent({
40
+ as,
41
+ className,
42
+ ...props
43
+ }) {
44
+ const Comp = as ?? component;
45
+ const forwardedProps = {};
46
+ for (const key in props) {
47
+ if (!variantNames.includes(key)) {
48
+ forwardedProps[key] = props[key];
49
+ }
50
+ }
51
+ const selectedVariantClassNames = variantNames.map((variantName) => {
52
+ const value = props[variantName] ?? defaultVariants[variantName];
53
+ if (value == null) return void 0;
54
+ return variantClassNames[variantName]?.[String(value)];
55
+ });
56
+ const merged = (0, import_css_core.mergeClassNames)([
57
+ base,
58
+ ...selectedVariantClassNames,
59
+ className
60
+ ]);
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { ...forwardedProps, className: merged });
62
+ };
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ css,
67
+ keyframes,
68
+ mergeClassNames,
69
+ styled,
70
+ variants
71
+ });
72
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import {\n css,\n keyframes,\n mergeClassNames,\n variants,\n type CSSProperties,\n type CSSValue,\n type StyledStyleObject,\n} from \"@hypergood/css-core\";\nimport { ComponentPropsWithRef, ElementType } from \"react\";\n\ntype StyledComponentProps<T extends ElementType> = {\n as?: T;\n} & Omit<ComponentPropsWithRef<T>, \"as\">;\n\ntype CompiledStyleObject = {\n base?: string;\n variants?: Record<string, Record<string, string>>;\n defaultVariants?: Record<string, unknown>;\n};\n\nexport function styled<TBase extends ElementType>(\n component: TBase,\n styleObject: StyledStyleObject,\n): any {\n const {\n base,\n variants: variantClassNames = {},\n defaultVariants = {},\n } = styleObject as CompiledStyleObject;\n const variantNames = Object.keys(variantClassNames);\n\n return function StyledComponent<T extends ElementType = TBase>({\n as,\n className,\n ...props\n }: StyledComponentProps<T> & { className?: string }) {\n const Comp = (as ?? component) as ElementType;\n\n // Variant props are consumed here and not forwarded to the element.\n const forwardedProps: Record<string, unknown> = {};\n for (const key in props) {\n if (!variantNames.includes(key)) {\n forwardedProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n const selectedVariantClassNames = variantNames.map((variantName) => {\n const value =\n (props as Record<string, unknown>)[variantName] ??\n defaultVariants[variantName];\n if (value == null) return undefined;\n return variantClassNames[variantName]?.[String(value)];\n });\n\n const merged = mergeClassNames([\n base,\n ...selectedVariantClassNames,\n className,\n ]);\n\n return <Comp {...forwardedProps} className={merged} />;\n };\n}\n\nexport { css, keyframes, mergeClassNames, variants };\nexport type { CSSProperties, CSSValue, StyledStyleObject };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAQO;AAqDI;AAxCJ,SAAS,OACd,WACA,aACK;AACL,QAAM;AAAA,IACJ;AAAA,IACA,UAAU,oBAAoB,CAAC;AAAA,IAC/B,kBAAkB,CAAC;AAAA,EACrB,IAAI;AACJ,QAAM,eAAe,OAAO,KAAK,iBAAiB;AAElD,SAAO,SAAS,gBAA+C;AAAA,IAC7D;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAqD;AACnD,UAAM,OAAQ,MAAM;AAGpB,UAAM,iBAA0C,CAAC;AACjD,eAAW,OAAO,OAAO;AACvB,UAAI,CAAC,aAAa,SAAS,GAAG,GAAG;AAC/B,uBAAe,GAAG,IAAK,MAAkC,GAAG;AAAA,MAC9D;AAAA,IACF;AAEA,UAAM,4BAA4B,aAAa,IAAI,CAAC,gBAAgB;AAClE,YAAM,QACH,MAAkC,WAAW,KAC9C,gBAAgB,WAAW;AAC7B,UAAI,SAAS,KAAM,QAAO;AAC1B,aAAO,kBAAkB,WAAW,IAAI,OAAO,KAAK,CAAC;AAAA,IACvD,CAAC;AAED,UAAM,aAAS,iCAAgB;AAAA,MAC7B;AAAA,MACA,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,4CAAC,QAAM,GAAG,gBAAgB,WAAW,QAAQ;AAAA,EACtD;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { StyledStyleObject } from '@hypergood/css-core';
2
+ export { CSSProperties, CSSValue, StyledStyleObject, css, keyframes, mergeClassNames, variants } from '@hypergood/css-core';
3
+ import { ElementType } from 'react';
4
+
5
+ declare function styled<TBase extends ElementType>(component: TBase, styleObject: StyledStyleObject): any;
6
+
7
+ export { styled };
@@ -0,0 +1,7 @@
1
+ import { StyledStyleObject } from '@hypergood/css-core';
2
+ export { CSSProperties, CSSValue, StyledStyleObject, css, keyframes, mergeClassNames, variants } from '@hypergood/css-core';
3
+ import { ElementType } from 'react';
4
+
5
+ declare function styled<TBase extends ElementType>(component: TBase, styleObject: StyledStyleObject): any;
6
+
7
+ export { styled };
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ // src/index.tsx
2
+ import {
3
+ css,
4
+ keyframes,
5
+ mergeClassNames,
6
+ variants
7
+ } from "@hypergood/css-core";
8
+ import { jsx } from "react/jsx-runtime";
9
+ function styled(component, styleObject) {
10
+ const {
11
+ base,
12
+ variants: variantClassNames = {},
13
+ defaultVariants = {}
14
+ } = styleObject;
15
+ const variantNames = Object.keys(variantClassNames);
16
+ return function StyledComponent({
17
+ as,
18
+ className,
19
+ ...props
20
+ }) {
21
+ const Comp = as ?? component;
22
+ const forwardedProps = {};
23
+ for (const key in props) {
24
+ if (!variantNames.includes(key)) {
25
+ forwardedProps[key] = props[key];
26
+ }
27
+ }
28
+ const selectedVariantClassNames = variantNames.map((variantName) => {
29
+ const value = props[variantName] ?? defaultVariants[variantName];
30
+ if (value == null) return void 0;
31
+ return variantClassNames[variantName]?.[String(value)];
32
+ });
33
+ const merged = mergeClassNames([
34
+ base,
35
+ ...selectedVariantClassNames,
36
+ className
37
+ ]);
38
+ return /* @__PURE__ */ jsx(Comp, { ...forwardedProps, className: merged });
39
+ };
40
+ }
41
+ export {
42
+ css,
43
+ keyframes,
44
+ mergeClassNames,
45
+ styled,
46
+ variants
47
+ };
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import {\n css,\n keyframes,\n mergeClassNames,\n variants,\n type CSSProperties,\n type CSSValue,\n type StyledStyleObject,\n} from \"@hypergood/css-core\";\nimport { ComponentPropsWithRef, ElementType } from \"react\";\n\ntype StyledComponentProps<T extends ElementType> = {\n as?: T;\n} & Omit<ComponentPropsWithRef<T>, \"as\">;\n\ntype CompiledStyleObject = {\n base?: string;\n variants?: Record<string, Record<string, string>>;\n defaultVariants?: Record<string, unknown>;\n};\n\nexport function styled<TBase extends ElementType>(\n component: TBase,\n styleObject: StyledStyleObject,\n): any {\n const {\n base,\n variants: variantClassNames = {},\n defaultVariants = {},\n } = styleObject as CompiledStyleObject;\n const variantNames = Object.keys(variantClassNames);\n\n return function StyledComponent<T extends ElementType = TBase>({\n as,\n className,\n ...props\n }: StyledComponentProps<T> & { className?: string }) {\n const Comp = (as ?? component) as ElementType;\n\n // Variant props are consumed here and not forwarded to the element.\n const forwardedProps: Record<string, unknown> = {};\n for (const key in props) {\n if (!variantNames.includes(key)) {\n forwardedProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n const selectedVariantClassNames = variantNames.map((variantName) => {\n const value =\n (props as Record<string, unknown>)[variantName] ??\n defaultVariants[variantName];\n if (value == null) return undefined;\n return variantClassNames[variantName]?.[String(value)];\n });\n\n const merged = mergeClassNames([\n base,\n ...selectedVariantClassNames,\n className,\n ]);\n\n return <Comp {...forwardedProps} className={merged} />;\n };\n}\n\nexport { css, keyframes, mergeClassNames, variants };\nexport type { CSSProperties, CSSValue, StyledStyleObject };\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAqDI;AAxCJ,SAAS,OACd,WACA,aACK;AACL,QAAM;AAAA,IACJ;AAAA,IACA,UAAU,oBAAoB,CAAC;AAAA,IAC/B,kBAAkB,CAAC;AAAA,EACrB,IAAI;AACJ,QAAM,eAAe,OAAO,KAAK,iBAAiB;AAElD,SAAO,SAAS,gBAA+C;AAAA,IAC7D;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAqD;AACnD,UAAM,OAAQ,MAAM;AAGpB,UAAM,iBAA0C,CAAC;AACjD,eAAW,OAAO,OAAO;AACvB,UAAI,CAAC,aAAa,SAAS,GAAG,GAAG;AAC/B,uBAAe,GAAG,IAAK,MAAkC,GAAG;AAAA,MAC9D;AAAA,IACF;AAEA,UAAM,4BAA4B,aAAa,IAAI,CAAC,gBAAgB;AAClE,YAAM,QACH,MAAkC,WAAW,KAC9C,gBAAgB,WAAW;AAC7B,UAAI,SAAS,KAAM,QAAO;AAC1B,aAAO,kBAAkB,WAAW,IAAI,OAAO,KAAK,CAAC;AAAA,IACvD,CAAC;AAED,UAAM,SAAS,gBAAgB;AAAA,MAC7B;AAAA,MACA,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,oBAAC,QAAM,GAAG,gBAAgB,WAAW,QAAQ;AAAA,EACtD;AACF;","names":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/plugin.ts
21
+ var plugin_exports = {};
22
+ __export(plugin_exports, {
23
+ vitePluginCss: () => vitePluginCss
24
+ });
25
+ module.exports = __toCommonJS(plugin_exports);
26
+ var import_plugin = require("@hypergood/css-core/plugin");
27
+ var vitePluginCss = (config) => (0, import_plugin.vitePluginCss)({
28
+ ...config,
29
+ moduleName: "@hypergood/react-css",
30
+ jsxClassProp: "className"
31
+ });
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ vitePluginCss
35
+ });
36
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import {\n PluginConfig,\n vitePluginCss as vitePluginCssCore,\n} from \"@hypergood/css-core/plugin\";\n\ntype ReactPluginConfig = Omit<PluginConfig, \"moduleName\" | \"jsxClassProp\">;\nconst vitePluginCss = (config: ReactPluginConfig) =>\n vitePluginCssCore({\n ...config,\n moduleName: \"@hypergood/react-css\",\n jsxClassProp: \"className\",\n });\n\nexport { ReactPluginConfig, vitePluginCss };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAGP,IAAM,gBAAgB,CAAC,eACrB,cAAAA,eAAkB;AAAA,EAChB,GAAG;AAAA,EACH,YAAY;AAAA,EACZ,cAAc;AAChB,CAAC;","names":["vitePluginCssCore"]}
@@ -0,0 +1,7 @@
1
+ import * as vite from 'vite';
2
+ import { PluginConfig } from '@hypergood/css-core/plugin';
3
+
4
+ type ReactPluginConfig = Omit<PluginConfig, "moduleName" | "jsxClassProp">;
5
+ declare const vitePluginCss: (config: ReactPluginConfig) => vite.Plugin<any>[];
6
+
7
+ export { type ReactPluginConfig, vitePluginCss };
@@ -0,0 +1,7 @@
1
+ import * as vite from 'vite';
2
+ import { PluginConfig } from '@hypergood/css-core/plugin';
3
+
4
+ type ReactPluginConfig = Omit<PluginConfig, "moduleName" | "jsxClassProp">;
5
+ declare const vitePluginCss: (config: ReactPluginConfig) => vite.Plugin<any>[];
6
+
7
+ export { type ReactPluginConfig, vitePluginCss };
package/dist/plugin.js ADDED
@@ -0,0 +1,13 @@
1
+ // src/plugin.ts
2
+ import {
3
+ vitePluginCss as vitePluginCssCore
4
+ } from "@hypergood/css-core/plugin";
5
+ var vitePluginCss = (config) => vitePluginCssCore({
6
+ ...config,
7
+ moduleName: "@hypergood/react-css",
8
+ jsxClassProp: "className"
9
+ });
10
+ export {
11
+ vitePluginCss
12
+ };
13
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import {\n PluginConfig,\n vitePluginCss as vitePluginCssCore,\n} from \"@hypergood/css-core/plugin\";\n\ntype ReactPluginConfig = Omit<PluginConfig, \"moduleName\" | \"jsxClassProp\">;\nconst vitePluginCss = (config: ReactPluginConfig) =>\n vitePluginCssCore({\n ...config,\n moduleName: \"@hypergood/react-css\",\n jsxClassProp: \"className\",\n });\n\nexport { ReactPluginConfig, vitePluginCss };\n"],"mappings":";AAAA;AAAA,EAEE,iBAAiB;AAAA,OACZ;AAGP,IAAM,gBAAgB,CAAC,WACrB,kBAAkB;AAAA,EAChB,GAAG;AAAA,EACH,YAAY;AAAA,EACZ,cAAc;AAChB,CAAC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@hypergood/react-css",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "./plugin": {
19
+ "import": {
20
+ "types": "./dist/plugin.d.ts",
21
+ "default": "./dist/plugin.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/plugin.d.cts",
25
+ "default": "./dist/plugin.cjs"
26
+ }
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "author": "",
33
+ "license": "MIT",
34
+ "description": "",
35
+ "dependencies": {
36
+ "@hypergood/css-core": "0.1.0"
37
+ },
38
+ "peerDependencies": {
39
+ "react": "^18 || ^19",
40
+ "react-dom": "^18 || ^19",
41
+ "vite": "^8"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "^19.2.0",
45
+ "@types/react-dom": "^19.2.0"
46
+ },
47
+ "scripts": {
48
+ "dev": "tsup src/index.tsx src/plugin.ts --watch",
49
+ "build": "tsup src/index.tsx src/plugin.ts",
50
+ "test": "vitest"
51
+ }
52
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,67 @@
1
+ import {
2
+ css,
3
+ keyframes,
4
+ mergeClassNames,
5
+ variants,
6
+ type CSSProperties,
7
+ type CSSValue,
8
+ type StyledStyleObject,
9
+ } from "@hypergood/css-core";
10
+ import { ComponentPropsWithRef, ElementType } from "react";
11
+
12
+ type StyledComponentProps<T extends ElementType> = {
13
+ as?: T;
14
+ } & Omit<ComponentPropsWithRef<T>, "as">;
15
+
16
+ type CompiledStyleObject = {
17
+ base?: string;
18
+ variants?: Record<string, Record<string, string>>;
19
+ defaultVariants?: Record<string, unknown>;
20
+ };
21
+
22
+ export function styled<TBase extends ElementType>(
23
+ component: TBase,
24
+ styleObject: StyledStyleObject,
25
+ ): any {
26
+ const {
27
+ base,
28
+ variants: variantClassNames = {},
29
+ defaultVariants = {},
30
+ } = styleObject as CompiledStyleObject;
31
+ const variantNames = Object.keys(variantClassNames);
32
+
33
+ return function StyledComponent<T extends ElementType = TBase>({
34
+ as,
35
+ className,
36
+ ...props
37
+ }: StyledComponentProps<T> & { className?: string }) {
38
+ const Comp = (as ?? component) as ElementType;
39
+
40
+ // Variant props are consumed here and not forwarded to the element.
41
+ const forwardedProps: Record<string, unknown> = {};
42
+ for (const key in props) {
43
+ if (!variantNames.includes(key)) {
44
+ forwardedProps[key] = (props as Record<string, unknown>)[key];
45
+ }
46
+ }
47
+
48
+ const selectedVariantClassNames = variantNames.map((variantName) => {
49
+ const value =
50
+ (props as Record<string, unknown>)[variantName] ??
51
+ defaultVariants[variantName];
52
+ if (value == null) return undefined;
53
+ return variantClassNames[variantName]?.[String(value)];
54
+ });
55
+
56
+ const merged = mergeClassNames([
57
+ base,
58
+ ...selectedVariantClassNames,
59
+ className,
60
+ ]);
61
+
62
+ return <Comp {...forwardedProps} className={merged} />;
63
+ };
64
+ }
65
+
66
+ export { css, keyframes, mergeClassNames, variants };
67
+ export type { CSSProperties, CSSValue, StyledStyleObject };
package/src/plugin.ts ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ PluginConfig,
3
+ vitePluginCss as vitePluginCssCore,
4
+ } from "@hypergood/css-core/plugin";
5
+
6
+ type ReactPluginConfig = Omit<PluginConfig, "moduleName" | "jsxClassProp">;
7
+ const vitePluginCss = (config: ReactPluginConfig) =>
8
+ vitePluginCssCore({
9
+ ...config,
10
+ moduleName: "@hypergood/react-css",
11
+ jsxClassProp: "className",
12
+ });
13
+
14
+ export { ReactPluginConfig, vitePluginCss };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "module": "nodenext",
5
+ "strict": true,
6
+ "moduleResolution": "nodenext",
7
+ "ignoreDeprecations": "6.0"
8
+ }
9
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Options } from "tsup";
2
+
3
+ export const tsup: Options = {
4
+ clean: true,
5
+ dts: true,
6
+ minify: false,
7
+ sourcemap: true,
8
+ splitting: false,
9
+ format: ["cjs", "esm"],
10
+ target: "node20",
11
+ skipNodeModulesBundle: true,
12
+ };