native-variants 0.1.56 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/create-nva.d.ts +2 -2
- package/dist/provider/create-provider.d.ts +1 -1
- package/dist/provider/create-provider.js +1 -25
- package/dist/provider/create-provider.jsx +24 -0
- package/dist/provider/create-provider.jsx.map +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/provider/create-provider.js.map +0 -1
package/dist/lib/create-nva.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Base, Config, DefaultVariants, DefineConfig, Theme, Variants } from "../types.js";
|
|
2
|
-
export declare function styled<S extends string, V extends Variants<S>>(config: Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
|
|
2
|
+
export declare function styled<const S extends string, V extends Variants<S>>(config: Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
|
|
3
3
|
export declare function createNVA<Tokens extends Theme>({ theme, }?: {
|
|
4
4
|
theme?: Tokens;
|
|
5
5
|
}): {
|
|
6
6
|
theme: Tokens;
|
|
7
7
|
styled: {
|
|
8
8
|
<S extends string, V extends Variants<S>>(config: Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
|
|
9
|
-
<S extends string, V extends Variants<S>>(configFactory: (defineConfig: DefineConfig, theme: Tokens) => Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
|
|
9
|
+
<const S extends string, V extends Variants<S>>(configFactory: (defineConfig: DefineConfig, theme: Tokens) => Config<S, V>): (props?: DefaultVariants<S, V>) => Base<S>;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
@@ -2,6 +2,6 @@ import { PropsWithChildren } from "react";
|
|
|
2
2
|
export declare const createCTX: <T>() => {
|
|
3
3
|
CTXProvider: ({ children, props, }: PropsWithChildren & {
|
|
4
4
|
props: T;
|
|
5
|
-
}) => import("react
|
|
5
|
+
}) => import("react").JSX.Element;
|
|
6
6
|
useCTX: () => T | undefined;
|
|
7
7
|
};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCTX = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const createCTX = () => {
|
|
7
|
-
const Context = (0, react_1.createContext)(undefined);
|
|
8
|
-
const CTXProvider = ({ children, props, }) => {
|
|
9
|
-
const value = (0, react_1.useMemo)(() => ({ props }), [props]);
|
|
10
|
-
return (0, jsx_runtime_1.jsx)(Context.Provider, { value: value, children: children });
|
|
11
|
-
};
|
|
12
|
-
const useCTX = () => {
|
|
13
|
-
const context = (0, react_1.useContext)(Context);
|
|
14
|
-
if (!context) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
return context.props;
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
CTXProvider,
|
|
21
|
-
useCTX,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.createCTX = createCTX;
|
|
25
|
-
//# sourceMappingURL=create-provider.js.map
|
|
1
|
+
import{createContext,useContext,useMemo}from"react";export const createCTX=()=>{const Context=createContext(undefined);const CTXProvider=({children,props})=>{const value=useMemo(()=>({props}),[props]);return React.createElement(Context.Provider,{value:value},children)};const useCTX=()=>{const context=useContext(Context);if(!context){return undefined}return context.props};return{CTXProvider,useCTX}};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCTX = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const createCTX = () => {
|
|
6
|
+
const Context = (0, react_1.createContext)(undefined);
|
|
7
|
+
const CTXProvider = ({ children, props, }) => {
|
|
8
|
+
const value = (0, react_1.useMemo)(() => ({ props }), [props]);
|
|
9
|
+
return <Context.Provider value={value}>{children}</Context.Provider>;
|
|
10
|
+
};
|
|
11
|
+
const useCTX = () => {
|
|
12
|
+
const context = (0, react_1.useContext)(Context);
|
|
13
|
+
if (!context) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return context.props;
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
CTXProvider,
|
|
20
|
+
useCTX,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.createCTX = createCTX;
|
|
24
|
+
//# sourceMappingURL=create-provider.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-provider.jsx","sourceRoot":"","sources":["../../src/provider/create-provider.tsx"],"names":[],"mappings":";;;AAAA,iCAA8E;AAMvE,MAAM,SAAS,GAAG,GAAO,EAAE;IAChC,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAgC,SAAS,CAAC,CAAC;IAExE,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,KAAK,GAGN,EAAE,EAAE;QACH,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAkB,EAAE;QACjC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,OAAO,CAAC,KAAU,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,SAAS,aA4BpB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type Variants<S extends string> = {
|
|
|
19
19
|
export type MappedVariants<V> = Partial<{
|
|
20
20
|
[K in keyof V]: keyof V[K];
|
|
21
21
|
}>;
|
|
22
|
-
export type DefineConfig = <S extends string, V extends Variants<S>>(config: Config<S, V>) => Config<S, V>;
|
|
22
|
+
export type DefineConfig = <const S extends string, V extends Variants<S>>(config: Config<S, V>) => Config<S, V>;
|
|
23
23
|
export type Config<S extends string, V extends Variants<S>> = {
|
|
24
24
|
slots: S[];
|
|
25
25
|
base?: Base<S>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src/provider/create-provider.tsx"],"names":[],"mappings":";;;;AAAA,iCAA8E;AAMvE,MAAM,SAAS,GAAG,GAAO,EAAE;IAChC,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAgC,SAAS,CAAC,CAAC;IAExE,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,KAAK,GAGN,EAAE,EAAE;QACH,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAElD,OAAO,uBAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoB,CAAC;IACvE,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAkB,EAAE;QACjC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,OAAO,CAAC,KAAU,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,SAAS,aA4BpB"}
|