@typestyles/react 0.0.0-unstable.dc32065699a4 → 0.0.0-unstable.dce5dc80213a

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.
Files changed (62) hide show
  1. package/README.md +16 -16
  2. package/dist/babel-plugin.cjs +14223 -152
  3. package/dist/babel-plugin.cjs.map +1 -1
  4. package/dist/babel-plugin.d.cts +10 -10
  5. package/dist/babel-plugin.d.cts.map +1 -0
  6. package/dist/babel-plugin.d.ts +10 -10
  7. package/dist/babel-plugin.d.ts.map +1 -0
  8. package/dist/babel-plugin.js +14223 -130
  9. package/dist/babel-plugin.js.map +1 -1
  10. package/dist/css-prop-DMDmFKhu.js +21 -0
  11. package/dist/css-prop-DMDmFKhu.js.map +1 -0
  12. package/dist/css-prop-DOMoNwJN.cjs +38 -0
  13. package/dist/css-prop-DOMoNwJN.cjs.map +1 -0
  14. package/dist/css-prop-runtime-zKybLO8E.d.cts +14 -0
  15. package/dist/css-prop-runtime-zKybLO8E.d.cts.map +1 -0
  16. package/dist/css-prop-runtime-zKybLO8E.d.ts +14 -0
  17. package/dist/css-prop-runtime-zKybLO8E.d.ts.map +1 -0
  18. package/dist/css-prop-runtime.cjs +7 -7
  19. package/dist/css-prop-runtime.cjs.map +1 -1
  20. package/dist/css-prop-runtime.d.cts +2 -7
  21. package/dist/css-prop-runtime.d.ts +2 -7
  22. package/dist/css-prop-runtime.js +8 -2
  23. package/dist/css-prop-runtime.js.map +1 -1
  24. package/dist/index.cjs +75 -99
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +25 -21
  27. package/dist/index.d.cts.map +1 -0
  28. package/dist/index.d.ts +25 -21
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +69 -75
  31. package/dist/index.js.map +1 -1
  32. package/dist/jsx-dev-runtime.cjs +20 -38
  33. package/dist/jsx-dev-runtime.cjs.map +1 -1
  34. package/dist/jsx-dev-runtime.d.cts +9 -11
  35. package/dist/jsx-dev-runtime.d.cts.map +1 -0
  36. package/dist/jsx-dev-runtime.d.ts +9 -11
  37. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  38. package/dist/jsx-dev-runtime.js +19 -25
  39. package/dist/jsx-dev-runtime.js.map +1 -1
  40. package/dist/jsx-runtime.cjs +23 -41
  41. package/dist/jsx-runtime.cjs.map +1 -1
  42. package/dist/jsx-runtime.d.cts +10 -12
  43. package/dist/jsx-runtime.d.cts.map +1 -0
  44. package/dist/jsx-runtime.d.ts +10 -12
  45. package/dist/jsx-runtime.d.ts.map +1 -0
  46. package/dist/jsx-runtime.js +20 -27
  47. package/dist/jsx-runtime.js.map +1 -1
  48. package/dist/resolve-hash-class-DuqLJq6S.cjs +14 -0
  49. package/dist/resolve-hash-class-DuqLJq6S.cjs.map +1 -0
  50. package/dist/resolve-hash-class-Rs_7aMMQ.js +9 -0
  51. package/dist/resolve-hash-class-Rs_7aMMQ.js.map +1 -0
  52. package/dist/types-DcDsqg2q.d.cts +10 -0
  53. package/dist/types-DcDsqg2q.d.cts.map +1 -0
  54. package/dist/types-DcDsqg2q.d.ts +10 -0
  55. package/dist/types-DcDsqg2q.d.ts.map +1 -0
  56. package/package.json +9 -11
  57. package/dist/chunk-3YCUQVCM.js +0 -8
  58. package/dist/chunk-3YCUQVCM.js.map +0 -1
  59. package/dist/chunk-4BYX2HZ7.js +0 -22
  60. package/dist/chunk-4BYX2HZ7.js.map +0 -1
  61. package/dist/types-_vEO6H8X.d.cts +0 -9
  62. package/dist/types-_vEO6H8X.d.ts +0 -9
@@ -0,0 +1,21 @@
1
+ import { createContext } from "react";
2
+ import { cx } from "typestyles";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/context.tsx
5
+ const TypeStylesContext = createContext(null);
6
+ function TypeStylesProvider({ styles, children }) {
7
+ return jsx(TypeStylesContext.Provider, {
8
+ value: styles,
9
+ children
10
+ });
11
+ }
12
+ //#endregion
13
+ //#region src/css-prop.ts
14
+ function resolveCssPropClass(hashClass, css, className) {
15
+ if (css && typeof css === "object") return cx(hashClass(css), className);
16
+ return cx(className);
17
+ }
18
+ //#endregion
19
+ export { TypeStylesContext as n, TypeStylesProvider as r, resolveCssPropClass as t };
20
+
21
+ //# sourceMappingURL=css-prop-DMDmFKhu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-prop-DMDmFKhu.js","names":[],"sources":["../src/context.tsx","../src/css-prop.ts"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { CssStylesHost } from './resolve-hash-class';\n\nexport const TypeStylesContext = createContext<CssStylesHost | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n /** Prefer a `createTypeStyles()` result; `createStyles()` instances also work. */\n styles: CssStylesHost;\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"],"mappings":";;;;AAGA,MAAa,oBAAoB,cAAoC,IAAI;AAEzE,SAAgB,mBAAmB,EACjC,QACA,YAKoB;CACpB,OAAO,IAAC,kBAAkB,UAAnB;EAA4B,OAAO;EAAS;CAAqC,CAAA;AAC1F;;;ACVA,SAAgB,oBACd,WACA,KACA,WACQ;CACR,IAAI,OAAO,OAAO,QAAQ,UACxB,OAAO,GAAG,UAAU,GAAG,GAAG,SAAS;CAErC,OAAO,GAAG,SAAS;AACrB"}
@@ -0,0 +1,38 @@
1
+ let react = require("react");
2
+ let typestyles = require("typestyles");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ //#region src/context.tsx
5
+ const TypeStylesContext = (0, react.createContext)(null);
6
+ function TypeStylesProvider({ styles, children }) {
7
+ return (0, react_jsx_runtime.jsx)(TypeStylesContext.Provider, {
8
+ value: styles,
9
+ children
10
+ });
11
+ }
12
+ //#endregion
13
+ //#region src/css-prop.ts
14
+ function resolveCssPropClass(hashClass, css, className) {
15
+ if (css && typeof css === "object") return (0, typestyles.cx)(hashClass(css), className);
16
+ return (0, typestyles.cx)(className);
17
+ }
18
+ //#endregion
19
+ Object.defineProperty(exports, "TypeStylesContext", {
20
+ enumerable: true,
21
+ get: function() {
22
+ return TypeStylesContext;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "TypeStylesProvider", {
26
+ enumerable: true,
27
+ get: function() {
28
+ return TypeStylesProvider;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "resolveCssPropClass", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return resolveCssPropClass;
35
+ }
36
+ });
37
+
38
+ //# sourceMappingURL=css-prop-DOMoNwJN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-prop-DOMoNwJN.cjs","names":["createContext","cx"],"sources":["../src/context.tsx","../src/css-prop.ts"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { CssStylesHost } from './resolve-hash-class';\n\nexport const TypeStylesContext = createContext<CssStylesHost | null>(null);\n\nexport function TypeStylesProvider({\n styles,\n children,\n}: {\n /** Prefer a `createTypeStyles()` result; `createStyles()` instances also work. */\n styles: CssStylesHost;\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"],"mappings":";;;;AAGA,MAAa,qBAAA,GAAoBA,MAAAA,cAAAA,CAAoC,IAAI;AAEzE,SAAgB,mBAAmB,EACjC,QACA,YAKoB;CACpB,QAAO,GAAA,kBAAA,IAAA,CAAC,kBAAkB,UAAnB;EAA4B,OAAO;EAAS;CAAqC,CAAA;AAC1F;;;ACVA,SAAgB,oBACd,WACA,KACA,WACQ;CACR,IAAI,OAAO,OAAO,QAAQ,UACxB,QAAA,GAAOC,WAAAA,GAAAA,CAAG,UAAU,GAAG,GAAG,SAAS;CAErC,QAAA,GAAOA,WAAAA,GAAAA,CAAG,SAAS;AACrB"}
@@ -0,0 +1,14 @@
1
+ import { CSSProperties, StylesApi, TypeStylesApi } from "typestyles";
2
+ //#region src/resolve-hash-class.d.ts
3
+ /** Styles host for the css prop / TypeStylesProvider. */
4
+ type CssStylesHost = Pick<TypeStylesApi, 'hash'> | StylesApi;
5
+ type HashClassFn = (properties: CSSProperties, label?: string) => string;
6
+ /** Normalize `hash` (createTypeStyles) and `hashClass` (createStyles). */
7
+ declare function resolveHashClass(api: CssStylesHost): HashClassFn;
8
+ //#endregion
9
+ //#region src/css-prop-runtime.d.ts
10
+ /** Runtime helper used by the Babel plugin for static `css` props. */
11
+ declare function cssProp(api: CssStylesHost, properties: CSSProperties): string;
12
+ //#endregion
13
+ export { resolveHashClass as i, CssStylesHost as n, HashClassFn as r, cssProp as t };
14
+ //# sourceMappingURL=css-prop-runtime-zKybLO8E.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-prop-runtime-zKybLO8E.d.cts","names":[],"sources":["../src/resolve-hash-class.ts","../src/css-prop-runtime.ts"],"mappings":";;;KAGY,gBAAgB,KAAK,yBAAyB;KAE9C,eAAe,YAAY,eAAe;;iBAGtC,iBAAiB,KAAK,gBAAgB;;;;iBCHtC,QAAQ,KAAK,eAAe,YAAY"}
@@ -0,0 +1,14 @@
1
+ import { CSSProperties, StylesApi, TypeStylesApi } from "typestyles";
2
+ //#region src/resolve-hash-class.d.ts
3
+ /** Styles host for the css prop / TypeStylesProvider. */
4
+ type CssStylesHost = Pick<TypeStylesApi, 'hash'> | StylesApi;
5
+ type HashClassFn = (properties: CSSProperties, label?: string) => string;
6
+ /** Normalize `hash` (createTypeStyles) and `hashClass` (createStyles). */
7
+ declare function resolveHashClass(api: CssStylesHost): HashClassFn;
8
+ //#endregion
9
+ //#region src/css-prop-runtime.d.ts
10
+ /** Runtime helper used by the Babel plugin for static `css` props. */
11
+ declare function cssProp(api: CssStylesHost, properties: CSSProperties): string;
12
+ //#endregion
13
+ export { resolveHashClass as i, CssStylesHost as n, HashClassFn as r, cssProp as t };
14
+ //# sourceMappingURL=css-prop-runtime-zKybLO8E.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-prop-runtime-zKybLO8E.d.ts","names":[],"sources":["../src/resolve-hash-class.ts","../src/css-prop-runtime.ts"],"mappings":";;;KAGY,gBAAgB,KAAK,yBAAyB;KAE9C,eAAe,YAAY,eAAe;;iBAGtC,iBAAiB,KAAK,gBAAgB;;;;iBCHtC,QAAQ,KAAK,eAAe,YAAY"}
@@ -1,10 +1,10 @@
1
- 'use strict';
2
-
3
- // src/css-prop-runtime.ts
4
- function cssProp(styles, properties) {
5
- return styles.hashClass(properties);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_resolve_hash_class = require("./resolve-hash-class-DuqLJq6S.cjs");
3
+ //#region src/css-prop-runtime.ts
4
+ function cssProp(api, properties) {
5
+ return require_resolve_hash_class.resolveHashClass(api)(properties);
6
6
  }
7
-
7
+ //#endregion
8
8
  exports.cssProp = cssProp;
9
- //# sourceMappingURL=css-prop-runtime.cjs.map
9
+
10
10
  //# sourceMappingURL=css-prop-runtime.cjs.map
@@ -1 +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"]}
1
+ {"version":3,"file":"css-prop-runtime.cjs","names":["resolveHashClass"],"sources":["../src/css-prop-runtime.ts"],"sourcesContent":["import type { CSSProperties } from 'typestyles';\nimport type { CssStylesHost } from './resolve-hash-class';\nimport { resolveHashClass } from './resolve-hash-class';\n\n/** Runtime helper used by the Babel plugin for static `css` props. */\nexport function cssProp(api: CssStylesHost, properties: CSSProperties): string {\n return resolveHashClass(api)(properties);\n}\n"],"mappings":";;;AAKA,SAAgB,QAAQ,KAAoB,YAAmC;CAC7E,OAAOA,2BAAAA,iBAAiB,GAAG,CAAC,CAAC,UAAU;AACzC"}
@@ -1,7 +1,2 @@
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 };
1
+ import { t as cssProp } from "./css-prop-runtime-zKybLO8E.cjs";
2
+ export { cssProp };
@@ -1,7 +1,2 @@
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 };
1
+ import { t as cssProp } from "./css-prop-runtime-zKybLO8E.js";
2
+ export { cssProp };
@@ -1,3 +1,9 @@
1
- export { cssProp } from './chunk-3YCUQVCM.js';
2
- //# sourceMappingURL=css-prop-runtime.js.map
1
+ import { t as resolveHashClass } from "./resolve-hash-class-Rs_7aMMQ.js";
2
+ //#region src/css-prop-runtime.ts
3
+ function cssProp(api, properties) {
4
+ return resolveHashClass(api)(properties);
5
+ }
6
+ //#endregion
7
+ export { cssProp };
8
+
3
9
  //# sourceMappingURL=css-prop-runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"css-prop-runtime.js"}
1
+ {"version":3,"file":"css-prop-runtime.js","names":[],"sources":["../src/css-prop-runtime.ts"],"sourcesContent":["import type { CSSProperties } from 'typestyles';\nimport type { CssStylesHost } from './resolve-hash-class';\nimport { resolveHashClass } from './resolve-hash-class';\n\n/** Runtime helper used by the Babel plugin for static `css` props. */\nexport function cssProp(api: CssStylesHost, properties: CSSProperties): string {\n return resolveHashClass(api)(properties);\n}\n"],"mappings":";;AAKA,SAAgB,QAAQ,KAAoB,YAAmC;CAC7E,OAAO,iBAAiB,GAAG,CAAC,CAAC,UAAU;AACzC"}
package/dist/index.cjs CHANGED
@@ -1,109 +1,85 @@
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"
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_css_prop = require("./css-prop-DOMoNwJN.cjs");
3
+ const require_resolve_hash_class = require("./resolve-hash-class-DuqLJq6S.cjs");
4
+ const require_css_prop_runtime = require("./css-prop-runtime.cjs");
5
+ let react = require("react");
6
+ let typestyles = require("typestyles");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ //#region src/split-props.ts
9
+ const RESERVED_CONFIG_KEYS = new Set([
10
+ "base",
11
+ "variants",
12
+ "compoundVariants",
13
+ "defaultVariants",
14
+ "slots"
16
15
  ]);
17
16
  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
- };
17
+ const variants = {};
18
+ const rest = { ...props };
19
+ for (const key of variantKeys) if (key in rest) {
20
+ variants[key] = rest[key];
21
+ delete rest[key];
22
+ }
23
+ delete rest.className;
24
+ delete rest.css;
25
+ return {
26
+ variants,
27
+ rest
28
+ };
32
29
  }
33
30
  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
- };
31
+ if (typeof config === "function") return [];
32
+ if ("variants" in config && config.variants && typeof config.variants === "object") return Object.keys(config.variants);
33
+ return Object.keys(config).filter((key) => !RESERVED_CONFIG_KEYS.has(key));
52
34
  }
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;
35
+ //#endregion
36
+ //#region src/create-styled.tsx
37
+ function resolveRecipeFactory(api) {
38
+ if ("recipe" in api) return api.recipe;
39
+ return api.component;
83
40
  }
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);
41
+ function resolveStyledArgs(tag, configOrNamespace, maybeConfig) {
42
+ if (typeof configOrNamespace === "string" && maybeConfig != null) return {
43
+ tag,
44
+ namespace: configOrNamespace,
45
+ config: maybeConfig
46
+ };
47
+ return {
48
+ tag,
49
+ namespace: typeof tag === "string" ? tag : "styled",
50
+ config: configOrNamespace
51
+ };
96
52
  }
97
-
98
- // src/css-prop-runtime.ts
99
- function cssProp(styles, properties) {
100
- return styles.hashClass(properties);
53
+ function createStyled(api) {
54
+ const makeRecipe = resolveRecipeFactory(api);
55
+ function styled(tag, configOrNamespace, maybeConfig) {
56
+ const { tag: element, namespace, config } = resolveStyledArgs(tag, configOrNamespace, maybeConfig);
57
+ const recipe = makeRecipe({
58
+ name: namespace,
59
+ styles: config
60
+ });
61
+ const variantKeys = getVariantKeysFromConfig(config);
62
+ const Component = (0, react.forwardRef)(function StyledComponent(props, ref) {
63
+ const { className, ...propsWithoutClassName } = props;
64
+ const { variants, rest } = splitVariantProps(propsWithoutClassName, variantKeys);
65
+ const mergedClassName = (0, typestyles.cx)(recipe(variants), className);
66
+ return (0, react_jsx_runtime.jsx)(element, {
67
+ ...rest,
68
+ ref,
69
+ className: mergedClassName
70
+ });
71
+ });
72
+ Component.displayName = namespace.charAt(0).toUpperCase() + namespace.slice(1);
73
+ return Component;
74
+ }
75
+ return styled;
101
76
  }
102
-
103
- exports.TypeStylesContext = TypeStylesContext;
104
- exports.TypeStylesProvider = TypeStylesProvider;
77
+ //#endregion
78
+ exports.TypeStylesContext = require_css_prop.TypeStylesContext;
79
+ exports.TypeStylesProvider = require_css_prop.TypeStylesProvider;
105
80
  exports.createStyled = createStyled;
106
- exports.cssProp = cssProp;
107
- exports.resolveCssPropClass = resolveCssPropClass;
108
- //# sourceMappingURL=index.cjs.map
81
+ exports.cssProp = require_css_prop_runtime.cssProp;
82
+ exports.resolveCssPropClass = require_css_prop.resolveCssPropClass;
83
+ exports.resolveHashClass = require_resolve_hash_class.resolveHashClass;
84
+
109
85
  //# sourceMappingURL=index.cjs.map
@@ -1 +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":["forwardRef","cx","createContext","jsx"],"mappings":"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","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"]}
1
+ {"version":3,"file":"index.cjs","names":["forwardRef","cx","Element"],"sources":["../src/split-props.ts","../src/create-styled.tsx"],"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 TypeStylesApi,\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\ntype RecipeFactory = StylesApi['component'];\n\n/** Accepts `createTypeStyles()` (preferred) or a lower-level `createStyles()` instance. */\nexport type StyledApi = Pick<TypeStylesApi, 'recipe'> | StylesApi;\n\nfunction resolveRecipeFactory(api: StyledApi): RecipeFactory {\n if ('recipe' in api) return api.recipe;\n return api.component;\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(api: StyledApi): StyledFactory {\n const makeRecipe = resolveRecipeFactory(api);\n\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 // `styled` still takes the legacy config object (`base`, `variants`, flat keys).\n // The engine accepts that shape as `styles`; axes stay on `recipe()` itself.\n const recipe = (\n makeRecipe as (input: {\n name: string;\n styles: unknown;\n }) => (selections?: Record<string, unknown>) => { toString(): string }\n )({\n name: namespace,\n styles: config,\n });\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(recipe(variants), className);\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"],"mappings":";;;;;;;;AAAA,MAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,kBACd,OACA,aAIA;CACA,MAAM,WAAoC,CAAC;CAC3C,MAAM,OAAO,EAAE,GAAG,MAAM;CAExB,KAAK,MAAM,OAAO,aAChB,IAAI,OAAO,MAAM;EACf,SAAS,OAAO,KAAK;EACrB,OAAO,KAAK;CACd;CAGF,OAAO,KAAK;CACZ,OAAO,KAAK;CAEZ,OAAO;EACL;EACM;CACR;AACF;AAEA,SAAgB,yBACd,QACmB;CACnB,IAAI,OAAO,WAAW,YACpB,OAAO,CAAC;CAGV,IAAI,cAAc,UAAU,OAAO,YAAY,OAAO,OAAO,aAAa,UACxE,OAAO,OAAO,KAAK,OAAO,QAAQ;CAGpC,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,QAAQ,QAAQ,CAAC,qBAAqB,IAAI,GAAG,CAAC;AAC3E;;;ACIA,SAAS,qBAAqB,KAA+B;CAC3D,IAAI,YAAY,KAAK,OAAO,IAAI;CAChC,OAAO,IAAI;AACb;AAEA,SAAS,kBACP,KACA,mBAIA,aAKA;CACA,IAAI,OAAO,sBAAsB,YAAY,eAAe,MAC1D,OAAO;EAAE;EAAK,WAAW;EAAmB,QAAQ;CAAY;CAIlE,OAAO;EACL;EACA,WAHgB,OAAO,QAAQ,WAAW,MAAM;EAIhD,QAAQ;CAGV;AACF;AAEA,SAAgB,aAAa,KAA+B;CAC1D,MAAM,aAAa,qBAAqB,GAAG;CAE3C,SAAS,OACP,KACA,mBAIA,aACA;EACA,MAAM,EACJ,KAAK,SACL,WACA,WACE,kBAAkB,KAAK,mBAAmB,WAAW;EAGzD,MAAM,SACJ,WAIA;GACA,MAAM;GACN,QAAQ;EACV,CAAC;EACD,MAAM,cAAc,yBAClB,MACF;EAEA,MAAM,aAAA,GAAYA,MAAAA,WAAAA,CAChB,SAAS,gBAAgB,OAAO,KAAK;GACnC,MAAM,EAAE,WAAW,GAAG,0BAA0B;GAChD,MAAM,EAAE,UAAU,SAAS,kBACzB,uBACA,WACF;GACA,MAAM,mBAAA,GAAkBC,WAAAA,GAAAA,CAAG,OAAO,QAAQ,GAAG,SAAS;GAGtD,QAAO,GAAA,kBAAA,IAAA,CAACC,SAAD;IAAS,GAAI;IAAW;IAAK,WAAW;GAAkB,CAAA;EACnE,CACF;EAEA,UAAU,cAAc,UAAU,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU,MAAM,CAAC;EAE7E,OAAO;CACT;CAEA,OAAO;AACT"}
package/dist/index.d.cts CHANGED
@@ -1,25 +1,29 @@
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
-
1
+ import { i as resolveHashClass, n as CssStylesHost, r as HashClassFn, t as cssProp } from "./css-prop-runtime-zKybLO8E.cjs";
2
+ import { n as WithCssProp, t as CssPropValue } from "./types-DcDsqg2q.cjs";
3
+ import { CSSProperties, ComponentConfigInput, ComponentReturn, ComponentVariants, FlatComponentConfigInput, FlatComponentReturn, StylesApi, TypeStylesApi, VariantDefinitions } from "typestyles";
4
+ import { ComponentPropsWithoutRef, ElementType, ForwardRefExoticComponent, ReactNode, RefAttributes } from "react";
5
+ //#region src/create-styled.d.ts
8
6
  type StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>>;
9
7
  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>>;
8
+ <Tag extends ElementType, const V extends VariantDefinitions>(tag: Tag, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
9
+ <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(tag: Tag, namespace: N, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
10
+ <Tag extends ElementType, const K extends string>(tag: Tag, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
11
+ <Tag extends ElementType, const K extends string, const N extends string>(tag: Tag, namespace: N, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
14
12
  };
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;
13
+ /** Accepts `createTypeStyles()` (preferred) or a lower-level `createStyles()` instance. */
14
+ type StyledApi = Pick<TypeStylesApi, 'recipe'> | StylesApi;
15
+ export declare function createStyled(api: StyledApi): StyledFactory;
16
+ //#endregion
17
+ //#region src/context.d.ts
18
+ export declare const TypeStylesContext: import("react").Context<CssStylesHost | null>;
19
+ export declare function TypeStylesProvider({ styles, children }: {
20
+ /** Prefer a `createTypeStyles()` result; `createStyles()` instances also work. */
21
+ styles: CssStylesHost;
22
+ children: ReactNode;
21
23
  }): 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 };
24
+ //#endregion
25
+ //#region src/css-prop.d.ts
26
+ export declare function resolveCssPropClass(hashClass: (properties: CSSProperties, label?: string) => string, css: CssPropValue | undefined, className?: string): string;
27
+ //#endregion
28
+ export { type CssPropValue, type CssStylesHost, type HashClassFn, type StyledApi, type StyledFactory, type WithCssProp, cssProp, resolveHashClass };
29
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/create-styled.tsx","../src/context.tsx","../src/css-prop.ts"],"mappings":";;;;;KAoBK,oBAAoB,YAAY,aAAa,UAAU,0BAC1D,yBAAyB,OAAO,kBAAkB,UAAU,cAAc;KAGhE;GACT,YAAY,mBAAmB,UAAU,oBACxC,KAAK,KACL,QAAQ,qBAAqB,KAC5B,oBAAoB,KAAK,gBAAgB;GAC3C,YAAY,mBAAmB,UAAU,0BAA0B,kBAClE,KAAK,KACL,WAAW,GACX,QAAQ,qBAAqB,KAC5B,oBAAoB,KAAK,gBAAgB;GAC3C,YAAY,mBAAmB,kBAC9B,KAAK,KACL,QAAQ,yBAAyB,KAChC,oBAAoB,KAAK,oBAAoB;GAC/C,YAAY,mBAAmB,wBAAwB,kBACtD,KAAK,KACL,WAAW,GACX,QAAQ,yBAAyB,KAChC,oBAAoB,KAAK,oBAAoB;;;KAMtC,YAAY,KAAK,2BAA2B;wBAiCxC,aAAa,KAAK,YAAY;;;qBC9EjC,mCAAiB,QAAA;wBAEd,qBACd,QACA;;EAGA,QAAQ;EACR,UAAU;IACR,MAAM,IAAI;;;wBCRE,oBACd,YAAY,YAAY,eAAe,2BACvC,KAAK,0BACL"}
package/dist/index.d.ts CHANGED
@@ -1,25 +1,29 @@
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
-
1
+ import { i as resolveHashClass, n as CssStylesHost, r as HashClassFn, t as cssProp } from "./css-prop-runtime-zKybLO8E.js";
2
+ import { n as WithCssProp, t as CssPropValue } from "./types-DcDsqg2q.js";
3
+ import { ComponentPropsWithoutRef, ElementType, ForwardRefExoticComponent, ReactNode, RefAttributes } from "react";
4
+ import { CSSProperties, ComponentConfigInput, ComponentReturn, ComponentVariants, FlatComponentConfigInput, FlatComponentReturn, StylesApi, TypeStylesApi, VariantDefinitions } from "typestyles";
5
+ //#region src/create-styled.d.ts
8
6
  type StyledComponentType<Tag extends ElementType, Recipe> = ForwardRefExoticComponent<ComponentPropsWithoutRef<Tag> & ComponentVariants<Recipe> & RefAttributes<Element>>;
9
7
  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>>;
8
+ <Tag extends ElementType, const V extends VariantDefinitions>(tag: Tag, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
9
+ <Tag extends ElementType, const V extends VariantDefinitions, const N extends string>(tag: Tag, namespace: N, config: ComponentConfigInput<V>): StyledComponentType<Tag, ComponentReturn<V>>;
10
+ <Tag extends ElementType, const K extends string>(tag: Tag, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
11
+ <Tag extends ElementType, const K extends string, const N extends string>(tag: Tag, namespace: N, config: FlatComponentConfigInput<K>): StyledComponentType<Tag, FlatComponentReturn<K>>;
14
12
  };
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;
13
+ /** Accepts `createTypeStyles()` (preferred) or a lower-level `createStyles()` instance. */
14
+ type StyledApi = Pick<TypeStylesApi, 'recipe'> | StylesApi;
15
+ export declare function createStyled(api: StyledApi): StyledFactory;
16
+ //#endregion
17
+ //#region src/context.d.ts
18
+ export declare const TypeStylesContext: import("react").Context<CssStylesHost | null>;
19
+ export declare function TypeStylesProvider({ styles, children }: {
20
+ /** Prefer a `createTypeStyles()` result; `createStyles()` instances also work. */
21
+ styles: CssStylesHost;
22
+ children: ReactNode;
21
23
  }): 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 };
24
+ //#endregion
25
+ //#region src/css-prop.d.ts
26
+ export declare function resolveCssPropClass(hashClass: (properties: CSSProperties, label?: string) => string, css: CssPropValue | undefined, className?: string): string;
27
+ //#endregion
28
+ export { type CssPropValue, type CssStylesHost, type HashClassFn, type StyledApi, type StyledFactory, type WithCssProp, cssProp, resolveHashClass };
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/create-styled.tsx","../src/context.tsx","../src/css-prop.ts"],"mappings":";;;;;KAoBK,oBAAoB,YAAY,aAAa,UAAU,0BAC1D,yBAAyB,OAAO,kBAAkB,UAAU,cAAc;KAGhE;GACT,YAAY,mBAAmB,UAAU,oBACxC,KAAK,KACL,QAAQ,qBAAqB,KAC5B,oBAAoB,KAAK,gBAAgB;GAC3C,YAAY,mBAAmB,UAAU,0BAA0B,kBAClE,KAAK,KACL,WAAW,GACX,QAAQ,qBAAqB,KAC5B,oBAAoB,KAAK,gBAAgB;GAC3C,YAAY,mBAAmB,kBAC9B,KAAK,KACL,QAAQ,yBAAyB,KAChC,oBAAoB,KAAK,oBAAoB;GAC/C,YAAY,mBAAmB,wBAAwB,kBACtD,KAAK,KACL,WAAW,GACX,QAAQ,yBAAyB,KAChC,oBAAoB,KAAK,oBAAoB;;;KAMtC,YAAY,KAAK,2BAA2B;wBAiCxC,aAAa,KAAK,YAAY;;;qBC9EjC,mCAAiB,QAAA;wBAEd,qBACd,QACA;;EAGA,QAAQ;EACR,UAAU;IACR,MAAM,IAAI;;;wBCRE,oBACd,YAAY,YAAY,eAAe,2BACvC,KAAK,0BACL"}