@typestyles/react 0.2.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
+ {"version":3,"sources":["../src/babel-plugin.ts"],"names":[],"mappings":";;;;AAKA,IAAM,eAAA,GAAkB,iBAAA;AACxB,IAAM,uBAAA,GAA0B,oCAAA;AAChC,IAAM,SAAA,GAAY,YAAA;AASlB,SAAS,iBAAiB,IAAA,EAAyD;AACjF,EAAA,OAAS,CAAA,CAAA,kBAAA,CAAmB,IAAI,CAAA,IAAO,CAAA,CAAA,YAAA,CAAa,IAAI,CAAA;AAC1D;AAEA,SAAS,gCACP,KAAA,EACqB;AACrB,EAAA,IAAI,SAAS,IAAA,EAAM;AACjB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAM,CAAA,CAAA,wBAAA,CAAyB,KAAK,CAAA,EAAG;AACrC,IAAA,IAAM,CAAA,CAAA,oBAAA,CAAqB,KAAA,CAAM,UAAU,CAAA,EAAG;AAC5C,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA,CAAM,UAAA;AAAA,EACf;AACA,EAAA,IAAM,CAAA,CAAA,eAAA,CAAgB,KAAK,CAAA,EAAG;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,eAAA,CACP,SACA,iBAAA,EACc;AACd,EAAA,MAAM,YAAA,GAAe,gCAAgC,iBAAiB,CAAA;AACtE,EAAA,IAAI,gBAAgB,IAAA,EAAM;AACxB,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAS,iBAAiB,CAAA,CAAA,UAAA,CAAW,IAAI,GAAG,CAAC,OAAA,EAAS,YAAY,CAAC,CAAA;AACrE;AAEA,IAAO,uBAAQ,OAAA,CAAQ,CAAC,GAAA,EAAgB,OAAA,GAAwC,EAAC,KAAM;AACrF,EAAA,GAAA,CAAI,cAAc,CAAC,C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I,CAAA;AAC9B,QAAA,YAAA,CAAa,YAAY,IAAI,CAAA;AAE7B,QAAA,MAAM,aAAa,aAAA,CAAc,UAAA;AACjC,QAAA,IAAI,CAAC,UAAA,CAAW,mBAAA,EAAoB,EAAG;AACrC,UAAA;AAAA,QACF;AAEA,QAAA,MAAM,OAAA,GAAY,iBAAiB,CAAA,CAAA,UAAA,CAAW,eAAe,GAAG,CAAC,KAAA,CAAM,UAAU,CAAC,CAAA;AAElF,QAAA,IAAI,iBAAA;AACJ,QAAA,KAAA,MAAW,IAAA,IAAQ,UAAA,CAAW,IAAA,CAAK,UAAA,EAAY;AAC7C,UAAA,IAAM,CAAA,CAAA,cAAA,CAAe,IAAI,CAAA,IAAO,CAAA,CAAA,eAAA,CAAgB,IAAA,CAAK,MAAM,EAAE,IAAA,EAAM,WAAA,EAAa,CAAA,EAAG;AACjF,YAAA,iBAAA,GAAoB,IAAA;AACpB,YAAA;AAAA,UACF;AAAA,QACF;AAEA,QAAA,MAAM,cAAA,GAAiB,eAAA,CAAgB,OAAA,EAAS,iBAAA,EAAmB,SAAS,MAAS,CAAA;AAErF,QAAA,IAAI,iBAAA,EAAmB;AACrB,UAAA,iBAAA,CAAkB,KAAA,GAAU,yBAAuB,cAAc,CAAA;AAAA,QACnE,CAAA,MAAO;AACL,UAAA,UAAA,CAAW,KAAK,UAAA,CAAW,IAAA;AAAA,YACvB,eAAe,CAAA,CAAA,aAAA,CAAc,WAAW,CAAA,EAAK,CAAA,CAAA,sBAAA,CAAuB,cAAc,CAAC;AAAA,WACvF;AAAA,QACF;AAEA,QAAA,aAAA,CAAc,MAAA,EAAO;AAAA,MACvB;AAAA;AACF,GACF;AACF,CAAC","file":"babel-plugin.js","sourcesContent":["import { declare } from '@babel/helper-plugin-utils';\nimport type { ConfigAPI, PluginObj, NodePath } from '@babel/core';\nimport type { Program } from '@babel/types';\nimport * as t from '@babel/types';\n\nconst CSS_PROP_HELPER = '__typestylesCss';\nconst CSS_PROP_RUNTIME_IMPORT = '@typestyles/react/css-prop-runtime';\nconst CX_IMPORT = 'typestyles';\n\nexport type TypestylesReactPluginOptions = {\n /** Module path for the styles instance (default: `'./styles'`). */\n stylesImport?: string;\n /** Named export for styles (default: `'styles'`). */\n stylesExport?: string;\n};\n\nfunction isStaticCssValue(node: t.Node): node is t.ObjectExpression | t.Identifier {\n return t.isObjectExpression(node) || t.isIdentifier(node);\n}\n\nfunction expressionFromJsxAttributeValue(\n value: t.JSXAttribute['value'] | undefined,\n): t.Expression | null {\n if (value == null) {\n return null;\n }\n if (t.isJSXExpressionContainer(value)) {\n if (t.isJSXEmptyExpression(value.expression)) {\n return null;\n }\n return value.expression;\n }\n if (t.isStringLiteral(value)) {\n return value;\n }\n return null;\n}\n\nfunction mergeClassNames(\n cssCall: t.Expression,\n existingClassName: t.JSXAttribute['value'] | undefined,\n): t.Expression {\n const existingExpr = expressionFromJsxAttributeValue(existingClassName);\n if (existingExpr == null) {\n return cssCall;\n }\n\n return t.callExpression(t.identifier('cx'), [cssCall, existingExpr]);\n}\n\nexport default declare((api: ConfigAPI, options: TypestylesReactPluginOptions = {}) => {\n api.assertVersion(7);\n\n const stylesImportPath = options.stylesImport ?? './styles';\n const stylesExport = options.stylesExport ?? 'styles';\n\n let injectedHelper = false;\n let injectedImports = false;\n\n function ensureImports(program: Program): void {\n if (injectedImports) {\n return;\n }\n\n program.body.unshift(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('cssProp'), t.identifier('cssProp'))],\n t.stringLiteral(CSS_PROP_RUNTIME_IMPORT),\n ),\n t.importDeclaration(\n [t.importSpecifier(t.identifier('cx'), t.identifier('cx'))],\n t.stringLiteral(CX_IMPORT),\n ),\n t.importDeclaration(\n [t.importSpecifier(t.identifier(stylesExport), t.identifier(stylesExport))],\n t.stringLiteral(stylesImportPath),\n ),\n );\n\n injectedImports = true;\n }\n\n function ensureHelper(program: Program): void {\n if (injectedHelper) {\n return;\n }\n\n program.body.splice(\n injectedImports ? 3 : 0,\n 0,\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(CSS_PROP_HELPER),\n t.arrowFunctionExpression(\n [t.identifier('properties')],\n t.callExpression(t.identifier('cssProp'), [\n t.identifier(stylesExport),\n t.identifier('properties'),\n ]),\n ),\n ),\n ]),\n );\n\n injectedHelper = true;\n }\n\n return {\n name: '@typestyles/react/babel',\n visitor: {\n Program: {\n exit() {\n injectedHelper = false;\n injectedImports = false;\n },\n },\n JSXAttribute(attributePath: NodePath<t.JSXAttribute>) {\n const { node } = attributePath;\n if (!t.isJSXIdentifier(node.name, { name: 'css' })) {\n return;\n }\n\n const value = node.value;\n if (value == null || !t.isJSXExpressionContainer(value)) {\n return;\n }\n\n if (t.isJSXEmptyExpression(value.expression)) {\n return;\n }\n\n if (!isStaticCssValue(value.expression)) {\n return;\n }\n\n const programPath = attributePath.findParent((parent) => parent.isProgram());\n if (!programPath?.isProgram()) {\n return;\n }\n\n ensureImports(programPath.node);\n ensureHelper(programPath.node);\n\n const jsxElement = attributePath.parentPath;\n if (!jsxElement.isJSXOpeningElement()) {\n return;\n }\n\n const cssCall = t.callExpression(t.identifier(CSS_PROP_HELPER), [value.expression]);\n\n let existingClassName: t.JSXAttribute | undefined;\n for (const attr of jsxElement.node.attributes) {\n if (t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: 'className' })) {\n existingClassName = attr;\n break;\n }\n }\n\n const classNameValue = mergeClassNames(cssCall, existingClassName?.value ?? undefined);\n\n if (existingClassName) {\n existingClassName.value = t.jsxExpressionContainer(classNameValue);\n } else {\n jsxElement.node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(classNameValue)),\n );\n }\n\n attributePath.remove();\n },\n },\n } satisfies PluginObj;\n});\n"]}
@@ -0,0 +1,8 @@
1
+ // src/css-prop-runtime.ts
2
+ function cssProp(styles, properties) {
3
+ return styles.hashClass(properties);
4
+ }
5
+
6
+ export { cssProp };
7
+ //# sourceMappingURL=chunk-3YCUQVCM.js.map
8
+ //# sourceMappingURL=chunk-3YCUQVCM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css-prop-runtime.ts"],"names":[],"mappings":";AAEO,SAAS,OAAA,CACd,QACA,UAAA,EACQ;AACR,EAAA,OAAO,MAAA,CAAO,UAAU,UAAU,CAAA;AACpC","file":"chunk-3YCUQVCM.js","sourcesContent":["import type { CSSProperties } from 'typestyles';\n\nexport function cssProp(\n styles: { hashClass: (properties: CSSProperties, label?: string) => string },\n properties: CSSProperties,\n): string {\n return styles.hashClass(properties);\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { createContext } from 'react';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { cx } from 'typestyles';
4
+
5
+ // src/context.tsx
6
+ var TypeStylesContext = createContext(null);
7
+ function TypeStylesProvider({
8
+ styles,
9
+ children
10
+ }) {
11
+ return /* @__PURE__ */ jsx(TypeStylesContext.Provider, { value: styles, children });
12
+ }
13
+ function resolveCssPropClass(hashClass, css, className) {
14
+ if (css && typeof css === "object") {
15
+ return cx(hashClass(css), className);
16
+ }
17
+ return cx(className);
18
+ }
19
+
20
+ export { TypeStylesContext, TypeStylesProvider, resolveCssPropClass };
21
+ //# sourceMappingURL=chunk-4BYX2HZ7.js.map
22
+ //# sourceMappingURL=chunk-4BYX2HZ7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.tsx","../src/css-prop.ts"],"names":[],"mappings":";;;;;AAGO,IAAM,iBAAA,GAAoB,cAAgC,IAAI;AAE9D,SAAS,kBAAA,CAAmB;AAAA,EACjC,MAAA;AAAA,EACA;AACF,CAAA,EAGsB;AACpB,EAAA,2BAAQ,iBAAA,CAAkB,QAAA,EAAlB,EAA2B,KAAA,EAAO,QAAS,QAAA,EAAS,CAAA;AAC9D;ACTO,SAAS,mBAAA,CACd,SAAA,EACA,GAAA,EACA,SAAA,EACQ;AACR,EAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AAClC,IAAA,OAAO,EAAA,CAAG,SAAA,CAAU,GAAG,CAAA,EAAG,SAAS,CAAA;AAAA,EACrC;AACA,EAAA,OAAO,GAAG,SAAS,CAAA;AACrB","file":"chunk-4BYX2HZ7.js","sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { StylesApi } from 'typestyles';\n\nexport const TypeStylesContext = createContext<StylesApi | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n styles: StylesApi;\n children: ReactNode;\n}): React.JSX.Element {\n return <TypeStylesContext.Provider value={styles}>{children}</TypeStylesContext.Provider>;\n}\n","import type { CSSProperties } from 'typestyles';\nimport { cx } from 'typestyles';\nimport type { CssPropValue } from './types';\n\nexport function resolveCssPropClass(\n hashClass: (properties: CSSProperties, label?: string) => string,\n css: CssPropValue | undefined,\n className?: string,\n): string {\n if (css && typeof css === 'object') {\n return cx(hashClass(css), className);\n }\n return cx(className);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ // src/css-prop-runtime.ts
4
+ function cssProp(styles, properties) {
5
+ return styles.hashClass(properties);
6
+ }
7
+
8
+ exports.cssProp = cssProp;
9
+ //# sourceMappingURL=css-prop-runtime.cjs.map
10
+ //# sourceMappingURL=css-prop-runtime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css-prop-runtime.ts"],"names":[],"mappings":";;;AAEO,SAAS,OAAA,CACd,QACA,UAAA,EACQ;AACR,EAAA,OAAO,MAAA,CAAO,UAAU,UAAU,CAAA;AACpC","file":"css-prop-runtime.cjs","sourcesContent":["import type { CSSProperties } from 'typestyles';\n\nexport function cssProp(\n styles: { hashClass: (properties: CSSProperties, label?: string) => string },\n properties: CSSProperties,\n): string {\n return styles.hashClass(properties);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { CSSProperties } from 'typestyles';
2
+
3
+ declare function cssProp(styles: {
4
+ hashClass: (properties: CSSProperties, label?: string) => string;
5
+ }, properties: CSSProperties): string;
6
+
7
+ export { cssProp };
@@ -0,0 +1,7 @@
1
+ import { CSSProperties } from 'typestyles';
2
+
3
+ declare function cssProp(styles: {
4
+ hashClass: (properties: CSSProperties, label?: string) => string;
5
+ }, properties: CSSProperties): string;
6
+
7
+ export { cssProp };
@@ -0,0 +1,3 @@
1
+ export { cssProp } from './chunk-3YCUQVCM.js';
2
+ //# sourceMappingURL=css-prop-runtime.js.map
3
+ //# sourceMappingURL=css-prop-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"css-prop-runtime.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var typestyles = require('typestyles');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/create-styled.tsx
8
+
9
+ // src/split-props.ts
10
+ var RESERVED_CONFIG_KEYS = /* @__PURE__ */ new Set([
11
+ "base",
12
+ "variants",
13
+ "compoundVariants",
14
+ "defaultVariants",
15
+ "slots"
16
+ ]);
17
+ function splitVariantProps(props, variantKeys) {
18
+ const variants = {};
19
+ const rest = { ...props };
20
+ for (const key of variantKeys) {
21
+ if (key in rest) {
22
+ variants[key] = rest[key];
23
+ delete rest[key];
24
+ }
25
+ }
26
+ delete rest.className;
27
+ delete rest.css;
28
+ return {
29
+ variants,
30
+ rest
31
+ };
32
+ }
33
+ function getVariantKeysFromConfig(config) {
34
+ if (typeof config === "function") {
35
+ return [];
36
+ }
37
+ if ("variants" in config && config.variants && typeof config.variants === "object") {
38
+ return Object.keys(config.variants);
39
+ }
40
+ return Object.keys(config).filter((key) => !RESERVED_CONFIG_KEYS.has(key));
41
+ }
42
+ function resolveStyledArgs(tag, configOrNamespace, maybeConfig) {
43
+ if (typeof configOrNamespace === "string" && maybeConfig != null) {
44
+ return { tag, namespace: configOrNamespace, config: maybeConfig };
45
+ }
46
+ const namespace = typeof tag === "string" ? tag : "styled";
47
+ return {
48
+ tag,
49
+ namespace,
50
+ config: configOrNamespace
51
+ };
52
+ }
53
+ function createStyled(styles) {
54
+ function styled(tag, configOrNamespace, maybeConfig) {
55
+ const {
56
+ tag: element,
57
+ namespace,
58
+ config
59
+ } = resolveStyledArgs(tag, configOrNamespace, maybeConfig);
60
+ const recipe = styles.component(namespace, config);
61
+ const variantKeys = getVariantKeysFromConfig(
62
+ config
63
+ );
64
+ const Component = react.forwardRef(
65
+ function StyledComponent(props, ref) {
66
+ const { className, ...propsWithoutClassName } = props;
67
+ const { variants, rest } = splitVariantProps(
68
+ propsWithoutClassName,
69
+ variantKeys
70
+ );
71
+ const mergedClassName = typestyles.cx(
72
+ recipe(variants),
73
+ className
74
+ );
75
+ const Element = element;
76
+ return /* @__PURE__ */ jsxRuntime.jsx(Element, { ...rest, ref, className: mergedClassName });
77
+ }
78
+ );
79
+ Component.displayName = namespace.charAt(0).toUpperCase() + namespace.slice(1);
80
+ return Component;
81
+ }
82
+ return styled;
83
+ }
84
+ var TypeStylesContext = react.createContext(null);
85
+ function TypeStylesProvider({
86
+ styles,
87
+ children
88
+ }) {
89
+ return /* @__PURE__ */ jsxRuntime.jsx(TypeStylesContext.Provider, { value: styles, children });
90
+ }
91
+ function resolveCssPropClass(hashClass, css, className) {
92
+ if (css && typeof css === "object") {
93
+ return typestyles.cx(hashClass(css), className);
94
+ }
95
+ return typestyles.cx(className);
96
+ }
97
+
98
+ // src/css-prop-runtime.ts
99
+ function cssProp(styles, properties) {
100
+ return styles.hashClass(properties);
101
+ }
102
+
103
+ exports.TypeStylesContext = TypeStylesContext;
104
+ exports.TypeStylesProvider = TypeStylesProvider;
105
+ exports.createStyled = createStyled;
106
+ exports.cssProp = cssProp;
107
+ exports.resolveCssPropClass = resolveCssPropClass;
108
+ //# sourceMappingURL=index.cjs.map
109
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/split-props.ts","../src/create-styled.tsx","../src/context.tsx","../src/css-prop.ts","../src/css-prop-runtime.ts"],"names":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AM,CAAC,CAAA;AAE7E,IAAA,OAAO,SAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAA;AACT;AC7GO,IAAM,iBAAA,GAAoBC,oBAAgC,IAAI;AAE9D,SAAS,kBAAA,CAAmB;AAAA,EACjC,MAAA;AAAA,EACA;AACF,CAAA,EAGsB;AACpB,EAAA,uBAAOC,cAAAA,CAAC,iBAAA,CAAkB,UAAlB,EAA2B,KAAA,EAAO,QAAS,QAAA,EAAS,CAAA;AAC9D;ACTO,SAAS,mBAAA,CACd,SAAA,EACA,GAAA,EACA,SAAA,EACQ;AACR,EAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AAClC,IAAA,OAAOF,aAAAA,CAAG,SAAA,CAAU,GAAG,CAAA,EAAG,SAAS,CAAA;AAAA,EACrC;AACA,EAAA,OAAOA,cAAG,SAAS,CAAA;AACrB;;;ACXO,SAAS,OAAA,CACd,QACA,UAAA,EACQ;AACR,EAAA,OAAO,MAAA,CAAO,UAAU,UAAU,CAAA;AACpC","file":"index.cjs","sourcesContent":["const RESERVED_CONFIG_KEYS = new Set([\n 'base',\n 'variants',\n 'compoundVariants',\n 'defaultVariants',\n 'slots',\n]);\n\nexport function splitVariantProps<P extends Record<string, unknown>>(\n props: P,\n variantKeys: readonly string[],\n): {\n variants: Record<string, unknown>;\n rest: Omit<P, (typeof variantKeys)[number] | 'className' | 'css'>;\n} {\n const variants: Record<string, unknown> = {};\n const rest = { ...props } as Record<string, unknown>;\n\n for (const key of variantKeys) {\n if (key in rest) {\n variants[key] = rest[key];\n delete rest[key];\n }\n }\n\n delete rest.className;\n delete rest.css;\n\n return {\n variants,\n rest: rest as Omit<P, (typeof variantKeys)[number] | 'className' | 'css'>,\n };\n}\n\nexport function getVariantKeysFromConfig(\n config: Record<string, unknown> | ((ctx: unknown) => Record<string, unknown>),\n): readonly string[] {\n if (typeof config === 'function') {\n return [];\n }\n\n if ('variants' in config && config.variants && typeof config.variants === 'object') {\n return Object.keys(config.variants);\n }\n\n return Object.keys(config).filter((key) => !RESERVED_CONFIG_KEYS.has(key));\n}\n","import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardRefExoticComponent,\n type RefAttributes,\n} from 'react';\nimport type {\n ComponentConfigInput,\n ComponentReturn,\n ComponentVariants,\n FlatComponentConfigInput,\n FlatComponentReturn,\n StylesApi,\n VariantDefinitions,\n} from 'typestyles';\nimport { cx } from 'typestyles';\nimport { getVariantKeysFromConfig, splitVariantProps } from './split-props';\n\ntype StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<\n ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>\n>;\n\nexport type StyledFactory = {\n <Tag extends ElementType, const V extends VariantDefinitions>(\n tag: Tag,\n config: ComponentConfigInput<V>,\n ): StyledComponentType<Tag, ComponentReturn<V>>;\n <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(\n tag: Tag,\n namespace: N,\n config: ComponentConfigInput<V>,\n ): StyledComponentType<Tag, ComponentReturn<V>>;\n <Tag extends ElementType, const K extends string>(\n tag: Tag,\n config: FlatComponentConfigInput<K>,\n ): StyledComponentType<Tag, FlatComponentReturn<K>>;\n <Tag extends ElementType, const K extends string, const N extends string>(\n tag: Tag,\n namespace: N,\n config: FlatComponentConfigInput<K>,\n ): StyledComponentType<Tag, FlatComponentReturn<K>>;\n};\n\nfunction resolveStyledArgs(\n tag: ElementType,\n configOrNamespace:\n | string\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n maybeConfig?: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>,\n): {\n tag: ElementType;\n namespace: string;\n config: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>;\n} {\n if (typeof configOrNamespace === 'string' && maybeConfig != null) {\n return { tag, namespace: configOrNamespace, config: maybeConfig };\n }\n\n const namespace = typeof tag === 'string' ? tag : 'styled';\n return {\n tag,\n namespace,\n config: configOrNamespace as\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n };\n}\n\nexport function createStyled(styles: StylesApi): StyledFactory {\n function styled<Tag extends ElementType>(\n tag: Tag,\n configOrNamespace:\n | string\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n maybeConfig?: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>,\n ) {\n const {\n tag: element,\n namespace,\n config,\n } = resolveStyledArgs(tag, configOrNamespace, maybeConfig);\n const recipe = styles.component(namespace, config as ComponentConfigInput<VariantDefinitions>);\n const variantKeys = getVariantKeysFromConfig(\n config as Record<string, unknown> | ((ctx: unknown) => Record<string, unknown>),\n );\n\n const Component = forwardRef<Element, ComponentPropsWithoutRef<Tag> & Record<string, unknown>>(\n function StyledComponent(props, ref) {\n const { className, ...propsWithoutClassName } = props;\n const { variants, rest } = splitVariantProps(\n propsWithoutClassName as Record<string, unknown>,\n variantKeys,\n );\n const mergedClassName = cx(\n (recipe as (selections?: Record<string, unknown>) => string)(variants),\n className,\n );\n const Element = element;\n\n return <Element {...rest} ref={ref} className={mergedClassName} />;\n },\n );\n\n Component.displayName = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n return Component;\n }\n\n return styled as StyledFactory;\n}\n","import { createContext, type ReactNode } from 'react';\nimport type { StylesApi } from 'typestyles';\n\nexport const TypeStylesContext = createContext<StylesApi | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n styles: StylesApi;\n children: ReactNode;\n}): React.JSX.Element {\n return <TypeStylesContext.Provider value={styles}>{children}</TypeStylesContext.Provider>;\n}\n","import type { CSSProperties } from 'typestyles';\nimport { cx } from 'typestyles';\nimport type { CssPropValue } from './types';\n\nexport function resolveCssPropClass(\n hashClass: (properties: CSSProperties, label?: string) => string,\n css: CssPropValue | undefined,\n className?: string,\n): string {\n if (css && typeof css === 'object') {\n return cx(hashClass(css), className);\n }\n return cx(className);\n}\n","import type { CSSProperties } from 'typestyles';\n\nexport function cssProp(\n styles: { hashClass: (properties: CSSProperties, label?: string) => string },\n properties: CSSProperties,\n): string {\n return styles.hashClass(properties);\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import * as react from 'react';
2
+ import { ElementType, ForwardRefExoticComponent, ComponentPropsWithoutRef, RefAttributes, ReactNode } from 'react';
3
+ import { VariantDefinitions, ComponentConfigInput, ComponentVariants, ComponentReturn, FlatComponentConfigInput, FlatComponentReturn, StylesApi, CSSProperties } from 'typestyles';
4
+ import { C as CssPropValue } from './types-_vEO6H8X.cjs';
5
+ export { W as WithCssProp } from './types-_vEO6H8X.cjs';
6
+ export { cssProp } from './css-prop-runtime.cjs';
7
+
8
+ type StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>>;
9
+ type StyledFactory = {
10
+ <Tag extends ElementType, const V extends VariantDefinitions>(tag: Tag, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
11
+ <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(tag: Tag, namespace: N, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
12
+ <Tag extends ElementType, const K extends string>(tag: Tag, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
13
+ <Tag extends ElementType, const K extends string, const N extends string>(tag: Tag, namespace: N, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
14
+ };
15
+ declare function createStyled(styles: StylesApi): StyledFactory;
16
+
17
+ declare const TypeStylesContext: react.Context<StylesApi | null>;
18
+ declare function TypeStylesProvider({ styles, children, }: {
19
+ styles: StylesApi;
20
+ children: ReactNode;
21
+ }): React.JSX.Element;
22
+
23
+ declare function resolveCssPropClass(hashClass: (properties: CSSProperties, label?: string) => string, css: CssPropValue | undefined, className?: string): string;
24
+
25
+ export { CssPropValue, type StyledFactory, TypeStylesContext, TypeStylesProvider, createStyled, resolveCssPropClass };
@@ -0,0 +1,25 @@
1
+ import * as react from 'react';
2
+ import { ElementType, ForwardRefExoticComponent, ComponentPropsWithoutRef, RefAttributes, ReactNode } from 'react';
3
+ import { VariantDefinitions, ComponentConfigInput, ComponentVariants, ComponentReturn, FlatComponentConfigInput, FlatComponentReturn, StylesApi, CSSProperties } from 'typestyles';
4
+ import { C as CssPropValue } from './types-_vEO6H8X.js';
5
+ export { W as WithCssProp } from './types-_vEO6H8X.js';
6
+ export { cssProp } from './css-prop-runtime.js';
7
+
8
+ type StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>>;
9
+ type StyledFactory = {
10
+ <Tag extends ElementType, const V extends VariantDefinitions>(tag: Tag, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
11
+ <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(tag: Tag, namespace: N, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
12
+ <Tag extends ElementType, const K extends string>(tag: Tag, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
13
+ <Tag extends ElementType, const K extends string, const N extends string>(tag: Tag, namespace: N, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
14
+ };
15
+ declare function createStyled(styles: StylesApi): StyledFactory;
16
+
17
+ declare const TypeStylesContext: react.Context<StylesApi | null>;
18
+ declare function TypeStylesProvider({ styles, children, }: {
19
+ styles: StylesApi;
20
+ children: ReactNode;
21
+ }): React.JSX.Element;
22
+
23
+ declare function resolveCssPropClass(hashClass: (properties: CSSProperties, label?: string) => string, css: CssPropValue | undefined, className?: string): string;
24
+
25
+ export { CssPropValue, type StyledFactory, TypeStylesContext, TypeStylesProvider, createStyled, resolveCssPropClass };
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ export { TypeStylesContext, TypeStylesProvider, resolveCssPropClass } from './chunk-4BYX2HZ7.js';
2
+ export { cssProp } from './chunk-3YCUQVCM.js';
3
+ import { forwardRef } from 'react';
4
+ import { cx } from 'typestyles';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ // src/split-props.ts
8
+ var RESERVED_CONFIG_KEYS = /* @__PURE__ */ new Set([
9
+ "base",
10
+ "variants",
11
+ "compoundVariants",
12
+ "defaultVariants",
13
+ "slots"
14
+ ]);
15
+ function splitVariantProps(props, variantKeys) {
16
+ const variants = {};
17
+ const rest = { ...props };
18
+ for (const key of variantKeys) {
19
+ if (key in rest) {
20
+ variants[key] = rest[key];
21
+ delete rest[key];
22
+ }
23
+ }
24
+ delete rest.className;
25
+ delete rest.css;
26
+ return {
27
+ variants,
28
+ rest
29
+ };
30
+ }
31
+ function getVariantKeysFromConfig(config) {
32
+ if (typeof config === "function") {
33
+ return [];
34
+ }
35
+ if ("variants" in config && config.variants && typeof config.variants === "object") {
36
+ return Object.keys(config.variants);
37
+ }
38
+ return Object.keys(config).filter((key) => !RESERVED_CONFIG_KEYS.has(key));
39
+ }
40
+ function resolveStyledArgs(tag, configOrNamespace, maybeConfig) {
41
+ if (typeof configOrNamespace === "string" && maybeConfig != null) {
42
+ return { tag, namespace: configOrNamespace, config: maybeConfig };
43
+ }
44
+ const namespace = typeof tag === "string" ? tag : "styled";
45
+ return {
46
+ tag,
47
+ namespace,
48
+ config: configOrNamespace
49
+ };
50
+ }
51
+ function createStyled(styles) {
52
+ function styled(tag, configOrNamespace, maybeConfig) {
53
+ const {
54
+ tag: element,
55
+ namespace,
56
+ config
57
+ } = resolveStyledArgs(tag, configOrNamespace, maybeConfig);
58
+ const recipe = styles.component(namespace, config);
59
+ const variantKeys = getVariantKeysFromConfig(
60
+ config
61
+ );
62
+ const Component = forwardRef(
63
+ function StyledComponent(props, ref) {
64
+ const { className, ...propsWithoutClassName } = props;
65
+ const { variants, rest } = splitVariantProps(
66
+ propsWithoutClassName,
67
+ variantKeys
68
+ );
69
+ const mergedClassName = cx(
70
+ recipe(variants),
71
+ className
72
+ );
73
+ const Element = element;
74
+ return /* @__PURE__ */ jsx(Element, { ...rest, ref, className: mergedClassName });
75
+ }
76
+ );
77
+ Component.displayName = namespace.charAt(0).toUpperCase() + namespace.slice(1);
78
+ return Component;
79
+ }
80
+ return styled;
81
+ }
82
+
83
+ export { createStyled };
84
+ //# sourceMappingURL=index.js.map
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/split-props.ts","../src/create-styled.tsx"],"names":[],"mappings":";;;;;;;AAAA,IAAM,oBAAA,uBAA2B,GAAA,CAAI;AAAA,EACnC,MAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAEM,SAAS,iBAAA,CACd,OACA,WAAA,EAIA;AACA,EAAA,MAAM,WAAoC,EAAC;AAC3C,EAAA,MAAM,IAAA,GAAO,EAAE,GAAG,KAAA,EAAM;AAExB,EAAA,KAAA,MAAW,OAAO,WAAA,EAAa;AAC7B,IAAA,IAAI,OAAO,IAAA,EAAM;AACf,MAAA,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,CAAK,GAAG,CAAA;AACxB,MAAA,OAAO,KAAK,GAAG,CAAA;AAAA,IACjB;AAAA,EACF;AAEA,EAAA,OAAO,IAAA,CAAK,SAAA;AACZ,EAAA,OAAO,IAAA,CAAK,GAAA;AAEZ,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA;AAAA,GACF;AACF;AAEO,SAAS,yBACd,MAAA,EACmB;AACnB,EAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,IAAI,cAAc,MAAA,IAAU,MAAA,CAAO,YAAY,OAAO,MAAA,CAAO,aAAa,QAAA,EAAU;AAClF,IAAA,OAAO,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,QAAQ,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,GAAkB,EAAA;AAAA,UACrB,OAA4D,QAAQ,CAAA;AAAA,UACrE;AAAA,SACF;AACA,QAAA,MAAM,OAAA,GAAU,OAAA;AAEhB,QAAA,2BAAQ,OAAA,EAAA,EAAS,GAAG,IAAA,EAAM,GAAA,EAAU,WAAW,eAAA,EAAiB,CAAA;AAAA,MAClE;AAAA,KACF;AAEA,IAAA,SAAA,CAAU,WAAA,GAAc,UAAU,MAAA,CAAO,CAAC,EAAE,WAAA,EAAY,GAAI,SAAA,CAAU,KAAA,CAAM,CAAC,CAAA;AAE7E,IAAA,OAAO,SAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["const RESERVED_CONFIG_KEYS = new Set([\n 'base',\n 'variants',\n 'compoundVariants',\n 'defaultVariants',\n 'slots',\n]);\n\nexport function splitVariantProps<P extends Record<string, unknown>>(\n props: P,\n variantKeys: readonly string[],\n): {\n variants: Record<string, unknown>;\n rest: Omit<P, (typeof variantKeys)[number] | 'className' | 'css'>;\n} {\n const variants: Record<string, unknown> = {};\n const rest = { ...props } as Record<string, unknown>;\n\n for (const key of variantKeys) {\n if (key in rest) {\n variants[key] = rest[key];\n delete rest[key];\n }\n }\n\n delete rest.className;\n delete rest.css;\n\n return {\n variants,\n rest: rest as Omit<P, (typeof variantKeys)[number] | 'className' | 'css'>,\n };\n}\n\nexport function getVariantKeysFromConfig(\n config: Record<string, unknown> | ((ctx: unknown) => Record<string, unknown>),\n): readonly string[] {\n if (typeof config === 'function') {\n return [];\n }\n\n if ('variants' in config && config.variants && typeof config.variants === 'object') {\n return Object.keys(config.variants);\n }\n\n return Object.keys(config).filter((key) => !RESERVED_CONFIG_KEYS.has(key));\n}\n","import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardRefExoticComponent,\n type RefAttributes,\n} from 'react';\nimport type {\n ComponentConfigInput,\n ComponentReturn,\n ComponentVariants,\n FlatComponentConfigInput,\n FlatComponentReturn,\n StylesApi,\n VariantDefinitions,\n} from 'typestyles';\nimport { cx } from 'typestyles';\nimport { getVariantKeysFromConfig, splitVariantProps } from './split-props';\n\ntype StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<\n ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>\n>;\n\nexport type StyledFactory = {\n <Tag extends ElementType, const V extends VariantDefinitions>(\n tag: Tag,\n config: ComponentConfigInput<V>,\n ): StyledComponentType<Tag, ComponentReturn<V>>;\n <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(\n tag: Tag,\n namespace: N,\n config: ComponentConfigInput<V>,\n ): StyledComponentType<Tag, ComponentReturn<V>>;\n <Tag extends ElementType, const K extends string>(\n tag: Tag,\n config: FlatComponentConfigInput<K>,\n ): StyledComponentType<Tag, FlatComponentReturn<K>>;\n <Tag extends ElementType, const K extends string, const N extends string>(\n tag: Tag,\n namespace: N,\n config: FlatComponentConfigInput<K>,\n ): StyledComponentType<Tag, FlatComponentReturn<K>>;\n};\n\nfunction resolveStyledArgs(\n tag: ElementType,\n configOrNamespace:\n | string\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n maybeConfig?: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>,\n): {\n tag: ElementType;\n namespace: string;\n config: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>;\n} {\n if (typeof configOrNamespace === 'string' && maybeConfig != null) {\n return { tag, namespace: configOrNamespace, config: maybeConfig };\n }\n\n const namespace = typeof tag === 'string' ? tag : 'styled';\n return {\n tag,\n namespace,\n config: configOrNamespace as\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n };\n}\n\nexport function createStyled(styles: StylesApi): StyledFactory {\n function styled<Tag extends ElementType>(\n tag: Tag,\n configOrNamespace:\n | string\n | ComponentConfigInput<VariantDefinitions>\n | FlatComponentConfigInput<string>,\n maybeConfig?: ComponentConfigInput<VariantDefinitions> | FlatComponentConfigInput<string>,\n ) {\n const {\n tag: element,\n namespace,\n config,\n } = resolveStyledArgs(tag, configOrNamespace, maybeConfig);\n const recipe = styles.component(namespace, config as ComponentConfigInput<VariantDefinitions>);\n const variantKeys = getVariantKeysFromConfig(\n config as Record<string, unknown> | ((ctx: unknown) => Record<string, unknown>),\n );\n\n const Component = forwardRef<Element, ComponentPropsWithoutRef<Tag> & Record<string, unknown>>(\n function StyledComponent(props, ref) {\n const { className, ...propsWithoutClassName } = props;\n const { variants, rest } = splitVariantProps(\n propsWithoutClassName as Record<string, unknown>,\n variantKeys,\n );\n const mergedClassName = cx(\n (recipe as (selections?: Record<string, unknown>) => string)(variants),\n className,\n );\n const Element = element;\n\n return <Element {...rest} ref={ref} className={mergedClassName} />;\n },\n );\n\n Component.displayName = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n return Component;\n }\n\n return styled as StyledFactory;\n}\n"]}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxDevRuntime = require('react/jsx-dev-runtime');
5
+ var typestyles = require('typestyles');
6
+ require('react/jsx-runtime');
7
+
8
+ // src/jsx-dev-runtime.ts
9
+ function resolveCssPropClass(hashClass, css, className) {
10
+ if (css && typeof css === "object") {
11
+ return typestyles.cx(hashClass(css), className);
12
+ }
13
+ return typestyles.cx(className);
14
+ }
15
+ var TypeStylesContext = react.createContext(null);
16
+
17
+ // src/jsx-dev-runtime.ts
18
+ function processCssProp(props, styles) {
19
+ if (props.css == null) {
20
+ return props;
21
+ }
22
+ const { css, className, ...rest } = props;
23
+ const nextProps = {
24
+ ...rest,
25
+ className: resolveCssPropClass(styles.hashClass, css, className)
26
+ };
27
+ return nextProps;
28
+ }
29
+ var Fragment = jsxDevRuntime.Fragment;
30
+ function jsxDEV(type, props, key, isStaticChildren, source, self) {
31
+ const styles = react.useContext(TypeStylesContext);
32
+ if (props.css != null && styles == null) {
33
+ throw new Error(
34
+ "[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props."
35
+ );
36
+ }
37
+ const nextProps = styles ? processCssProp(props, styles) : props;
38
+ return jsxDevRuntime.jsxDEV(type, nextProps, key, isStaticChildren, source, self);
39
+ }
40
+
41
+ exports.Fragment = Fragment;
42
+ exports.jsxDEV = jsxDEV;
43
+ //# sourceMappingURL=jsx-dev-runtime.cjs.map
44
+ //# sourceMappingURL=jsx-dev-runtime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css-prop.ts","../src/context.tsx","../src/jsx-dev-runtime.ts"],"names":["cx","createContext","ReactFragment","useContext","reactJsxDEV"],"mappings":";;;;;;;;AAIO,SAAS,mBAAA,CACd,SAAA,EACA,GAAA,EACA,SAAA,EACQ;AACR,EAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AAClC,IAAA,OAAOA,aAAA,CAAG,SAAA,CAAU,GAAG,CAAA,EAAG,SAAS,CAAA;AAAA,EACrC;AACA,EAAA,OAAOA,cAAG,SAAS,CAAA;AACrB;ACVO,IAAM,iBAAA,GAAoBC,oBAAgC,IAAI,CAAA;;;ACGrE,SAAS,cAAA,CACP,OACA,MAAA,EACG;AACH,EAAA,IAAI,KAAA,CAAM,OAAO,IAAA,EAAM;AACrB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,EAAE,GAAA,EAAK,SAAA,EAAW,GAAG,MAAK,GAAI,KAAA;AACpC,EAAA,MAAM,SAAA,GAAY;AAAA,IAChB,GAAG,IAAA;AAAA,IACH,SAAA,EAAW,mBAAA,CAAoB,MAAA,CAAO,SAAA,EAAW,KAAK,SAAS;AAAA,GACjE;AAEA,EAAA,OAAO,SAAA;AACT;AAEO,IAAM,QAAA,GAAWC;AAEjB,SAAS,OACd,IAAA,EACA,KAAA,EACA,GAAA,EACA,gBAAA,EACA,QACA,IAAA,EACoB;AACpB,EAAA,MAAM,MAAA,GAASC,iBAAW,iBAAiB,CAAA;AAE3C,EAAA,IAAI,KAAA,CAAM,GAAA,IAAO,IAAA,IAAQ,MAAA,IAAU,IAAA,EAAM;AACvC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,GAAS,cAAA,CAAe,KAAA,EAAO,MAAM,CAAA,GAAK,KAAA;AAC5D,EAAA,OAAOC,qBAAY,IAAA,EAAM,SAAA,EAAW,GAAA,EAAK,gBAAA,EAAkB,QAAQ,IAAI,CAAA;AACzE","file":"jsx-dev-runtime.cjs","sourcesContent":["import type { CSSProperties } from 'typestyles';\nimport { cx } from 'typestyles';\nimport type { CssPropValue } from './types';\n\nexport function resolveCssPropClass(\n hashClass: (properties: CSSProperties, label?: string) => string,\n css: CssPropValue | undefined,\n className?: string,\n): string {\n if (css && typeof css === 'object') {\n return cx(hashClass(css), className);\n }\n return cx(className);\n}\n","import { createContext, type ReactNode } from 'react';\nimport type { StylesApi } from 'typestyles';\n\nexport const TypeStylesContext = createContext<StylesApi | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n styles: StylesApi;\n children: ReactNode;\n}): React.JSX.Element {\n return <TypeStylesContext.Provider value={styles}>{children}</TypeStylesContext.Provider>;\n}\n","import { useContext, type ElementType, type ReactNode } from 'react';\nimport { jsxDEV as reactJsxDEV, Fragment as ReactFragment } from 'react/jsx-dev-runtime';\nimport { resolveCssPropClass } from './css-prop';\nimport { TypeStylesContext } from './context';\nimport type { WithCssProp } from './types';\n\nfunction processCssProp<P extends Record<string, unknown>>(\n props: WithCssProp<P>,\n styles: NonNullable<React.ContextType<typeof TypeStylesContext>>,\n): P {\n if (props.css == null) {\n return props as P;\n }\n\n const { css, className, ...rest } = props;\n const nextProps = {\n ...rest,\n className: resolveCssPropClass(styles.hashClass, css, className),\n } as unknown as P;\n\n return nextProps;\n}\n\nexport const Fragment = ReactFragment;\n\nexport function jsxDEV<P extends Record<string, unknown>>(\n type: ElementType,\n props: WithCssProp<P>,\n key: React.Key | undefined,\n isStaticChildren: boolean,\n source: object | undefined,\n self: unknown,\n): React.ReactElement {\n const styles = useContext(TypeStylesContext);\n\n if (props.css != null && styles == null) {\n throw new Error(\n '[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. ' +\n 'Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props.',\n );\n }\n\n const nextProps = styles ? processCssProp(props, styles) : (props as P);\n return reactJsxDEV(type, nextProps, key, isStaticChildren, source, self);\n}\n\nexport type { ReactNode };\n"]}
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType } from 'react';
3
+ export { ReactNode } from 'react';
4
+ import { W as WithCssProp } from './types-_vEO6H8X.cjs';
5
+ import 'typestyles';
6
+
7
+ declare const Fragment: react.ExoticComponent<{
8
+ children?: ReactNode | undefined;
9
+ }>;
10
+ declare function jsxDEV<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key: React.Key | undefined, isStaticChildren: boolean, source: object | undefined, self: unknown): React.ReactElement;
11
+
12
+ export { Fragment, jsxDEV };
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType } from 'react';
3
+ export { ReactNode } from 'react';
4
+ import { W as WithCssProp } from './types-_vEO6H8X.js';
5
+ import 'typestyles';
6
+
7
+ declare const Fragment: react.ExoticComponent<{
8
+ children?: ReactNode | undefined;
9
+ }>;
10
+ declare function jsxDEV<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key: React.Key | undefined, isStaticChildren: boolean, source: object | undefined, self: unknown): React.ReactElement;
11
+
12
+ export { Fragment, jsxDEV };
@@ -0,0 +1,30 @@
1
+ import { TypeStylesContext, resolveCssPropClass } from './chunk-4BYX2HZ7.js';
2
+ import { useContext } from 'react';
3
+ import { Fragment as Fragment$1, jsxDEV as jsxDEV$1 } from 'react/jsx-dev-runtime';
4
+
5
+ function processCssProp(props, styles) {
6
+ if (props.css == null) {
7
+ return props;
8
+ }
9
+ const { css, className, ...rest } = props;
10
+ const nextProps = {
11
+ ...rest,
12
+ className: resolveCssPropClass(styles.hashClass, css, className)
13
+ };
14
+ return nextProps;
15
+ }
16
+ var Fragment = Fragment$1;
17
+ function jsxDEV(type, props, key, isStaticChildren, source, self) {
18
+ const styles = useContext(TypeStylesContext);
19
+ if (props.css != null && styles == null) {
20
+ throw new Error(
21
+ "[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props."
22
+ );
23
+ }
24
+ const nextProps = styles ? processCssProp(props, styles) : props;
25
+ return jsxDEV$1(type, nextProps, key, isStaticChildren, source, self);
26
+ }
27
+
28
+ export { Fragment, jsxDEV };
29
+ //# sourceMappingURL=jsx-dev-runtime.js.map
30
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-dev-runtime.ts"],"names":["ReactFragment","reactJsxDEV"],"mappings":";;;;AAMA,SAAS,cAAA,CACP,OACA,MAAA,EACG;AACH,EAAA,IAAI,KAAA,CAAM,OAAO,IAAA,EAAM;AACrB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,EAAE,GAAA,EAAK,SAAA,EAAW,GAAG,MAAK,GAAI,KAAA;AACpC,EAAA,MAAM,SAAA,GAAY;AAAA,IAChB,GAAG,IAAA;AAAA,IACH,SAAA,EAAW,mBAAA,CAAoB,MAAA,CAAO,SAAA,EAAW,KAAK,SAAS;AAAA,GACjE;AAEA,EAAA,OAAO,SAAA;AACT;AAEO,IAAM,QAAA,GAAWA;AAEjB,SAAS,OACd,IAAA,EACA,KAAA,EACA,GAAA,EACA,gBAAA,EACA,QACA,IAAA,EACoB;AACpB,EAAA,MAAM,MAAA,GAAS,WAAW,iBAAiB,CAAA;AAE3C,EAAA,IAAI,KAAA,CAAM,GAAA,IAAO,IAAA,IAAQ,MAAA,IAAU,IAAA,EAAM;AACvC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,GAAS,cAAA,CAAe,KAAA,EAAO,MAAM,CAAA,GAAK,KAAA;AAC5D,EAAA,OAAOC,SAAY,IAAA,EAAM,SAAA,EAAW,GAAA,EAAK,gBAAA,EAAkB,QAAQ,IAAI,CAAA;AACzE","file":"jsx-dev-runtime.js","sourcesContent":["import { useContext, type ElementType, type ReactNode } from 'react';\nimport { jsxDEV as reactJsxDEV, Fragment as ReactFragment } from 'react/jsx-dev-runtime';\nimport { resolveCssPropClass } from './css-prop';\nimport { TypeStylesContext } from './context';\nimport type { WithCssProp } from './types';\n\nfunction processCssProp<P extends Record<string, unknown>>(\n props: WithCssProp<P>,\n styles: NonNullable<React.ContextType<typeof TypeStylesContext>>,\n): P {\n if (props.css == null) {\n return props as P;\n }\n\n const { css, className, ...rest } = props;\n const nextProps = {\n ...rest,\n className: resolveCssPropClass(styles.hashClass, css, className),\n } as unknown as P;\n\n return nextProps;\n}\n\nexport const Fragment = ReactFragment;\n\nexport function jsxDEV<P extends Record<string, unknown>>(\n type: ElementType,\n props: WithCssProp<P>,\n key: React.Key | undefined,\n isStaticChildren: boolean,\n source: object | undefined,\n self: unknown,\n): React.ReactElement {\n const styles = useContext(TypeStylesContext);\n\n if (props.css != null && styles == null) {\n throw new Error(\n '[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. ' +\n 'Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props.',\n );\n }\n\n const nextProps = styles ? processCssProp(props, styles) : (props as P);\n return reactJsxDEV(type, nextProps, key, isStaticChildren, source, self);\n}\n\nexport type { ReactNode };\n"]}
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var typestyles = require('typestyles');
6
+
7
+ // src/jsx-runtime.ts
8
+ function resolveCssPropClass(hashClass, css, className) {
9
+ if (css && typeof css === "object") {
10
+ return typestyles.cx(hashClass(css), className);
11
+ }
12
+ return typestyles.cx(className);
13
+ }
14
+ var TypeStylesContext = react.createContext(null);
15
+
16
+ // src/jsx-runtime.ts
17
+ function processCssProp(props, styles) {
18
+ if (props.css == null) {
19
+ return props;
20
+ }
21
+ const { css, className, ...rest } = props;
22
+ const nextProps = {
23
+ ...rest,
24
+ className: resolveCssPropClass(styles.hashClass, css, className)
25
+ };
26
+ return nextProps;
27
+ }
28
+ function wrapJsx(factory, type, props, key) {
29
+ const styles = react.useContext(TypeStylesContext);
30
+ if (props.css != null && styles == null) {
31
+ throw new Error(
32
+ "[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props."
33
+ );
34
+ }
35
+ const nextProps = styles ? processCssProp(props, styles) : props;
36
+ return factory(type, nextProps, key);
37
+ }
38
+ var Fragment = jsxRuntime.Fragment;
39
+ function jsx2(type, props, key) {
40
+ return wrapJsx(jsxRuntime.jsx, type, props, key);
41
+ }
42
+ function jsxs(type, props, key) {
43
+ return wrapJsx(jsxRuntime.jsxs, type, props, key);
44
+ }
45
+
46
+ exports.Fragment = Fragment;
47
+ exports.jsx = jsx2;
48
+ exports.jsxs = jsxs;
49
+ //# sourceMappingURL=jsx-runtime.cjs.map
50
+ //# sourceMappingURL=jsx-runtime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css-prop.ts","../src/context.tsx","../src/jsx-runtime.ts"],"names":["cx","createContext","useContext","ReactFragment","jsx","reactJsx","reactJsxs"],"mappings":";;;;;;;AAIO,SAAS,mBAAA,CACd,SAAA,EACA,GAAA,EACA,SAAA,EACQ;AACR,EAAA,IAAI,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AACl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AW,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAC5C","file":"jsx-runtime.cjs","sourcesContent":["import type { CSSProperties } from 'typestyles';\nimport { cx } from 'typestyles';\nimport type { CssPropValue } from './types';\n\nexport function resolveCssPropClass(\n hashClass: (properties: CSSProperties, label?: string) => string,\n css: CssPropValue | undefined,\n className?: string,\n): string {\n if (css && typeof css === 'object') {\n return cx(hashClass(css), className);\n }\n return cx(className);\n}\n","import { createContext, type ReactNode } from 'react';\nimport type { StylesApi } from 'typestyles';\n\nexport const TypeStylesContext = createContext<StylesApi | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n styles: StylesApi;\n children: ReactNode;\n}): React.JSX.Element {\n return <TypeStylesContext.Provider value={styles}>{children}</TypeStylesContext.Provider>;\n}\n","import { useContext, type ElementType, type ReactNode } from 'react';\nimport { jsx as reactJsx, jsxs as reactJsxs, Fragment as ReactFragment } from 'react/jsx-runtime';\nimport { resolveCssPropClass } from './css-prop';\nimport { TypeStylesContext } from './context';\nimport type { WithCssProp } from './types';\n\nfunction processCssProp<P extends Record<string, unknown>>(\n props: WithCssProp<P>,\n styles: NonNullable<React.ContextType<typeof TypeStylesContext>>,\n): P {\n if (props.css == null) {\n return props as P;\n }\n\n const { css, className, ...rest } = props;\n const nextProps = {\n ...rest,\n className: resolveCssPropClass(styles.hashClass, css, className),\n } as unknown as P;\n\n return nextProps;\n}\n\nfunction wrapJsx<P extends Record<string, unknown>>(\n factory: typeof reactJsx,\n type: ElementType,\n props: WithCssProp<P>,\n key?: React.Key,\n): React.ReactElement {\n const styles = useContext(TypeStylesContext);\n\n if (props.css != null && styles == null) {\n throw new Error(\n '[@typestyles/react] The `css` prop requires a `TypeStylesProvider` with a `styles` instance. ' +\n 'Wrap your app in `<TypeStylesProvider styles={styles}>`, or use the Babel plugin for zero-runtime css props.',\n );\n }\n\n const nextProps = styles ? processCssProp(props, styles) : (props as P);\n return factory(type, nextProps, key);\n}\n\nexport const Fragment = ReactFragment;\n\nexport function jsx<P extends Record<string, unknown>>(\n type: ElementType,\n props: WithCssProp<P>,\n key?: React.Key,\n): React.ReactElement {\n return wrapJsx(reactJsx, type, props, key);\n}\n\nexport function jsxs<P extends Record<string, unknown>>(\n type: ElementType,\n props: WithCssProp<P>,\n key?: React.Key,\n): React.ReactElement {\n return wrapJsx(reactJsxs, type, props, key);\n}\n\nexport type { ReactNode };\n"]}
@@ -0,0 +1,13 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType } from 'react';
3
+ export { ReactNode } from 'react';
4
+ import { W as WithCssProp } from './types-_vEO6H8X.cjs';
5
+ import 'typestyles';
6
+
7
+ declare const Fragment: react.ExoticComponent<{
8
+ children?: ReactNode | undefined;
9
+ }>;
10
+ declare function jsx<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key?: React.Key): React.ReactElement;
11
+ declare function jsxs<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key?: React.Key): React.ReactElement;
12
+
13
+ export { Fragment, jsx, jsxs };
@@ -0,0 +1,13 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType } from 'react';
3
+ export { ReactNode } from 'react';
4
+ import { W as WithCssProp } from './types-_vEO6H8X.js';
5
+ import 'typestyles';
6
+
7
+ declare const Fragment: react.ExoticComponent<{
8
+ children?: ReactNode | undefined;
9
+ }>;
10
+ declare function jsx<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key?: React.Key): React.ReactElement;
11
+ declare function jsxs<P extends Record<string, unknown>>(type: ElementType, props: WithCssProp<P>, key?: React.Key): React.ReactElement;
12
+
13
+ export { Fragment, jsx, jsxs };