dogu-utils 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -2
- package/dist/src/index.d.ts +2 -0
- package/dist/src/react/hooks/useOpenCloseState.d.ts +1 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/utils/createSafeContext.d.ts +7 -0
- package/dist/src/types/EmptyObject.d.ts +1 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/utils/EarlyReturn.d.ts +8 -0
- package/dist/src/utils/EarlyReturn.spec.d.ts +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/types/EmptyObject.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/EarlyReturn.d.ts +1 -1
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +6 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useState, useCallback,
|
1
|
+
import { useState, useCallback, useContext, createContext } from 'react';
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
3
3
|
|
4
4
|
var useOpenCloseState = function useOpenCloseState(initialState) {
|
@@ -38,4 +38,3 @@ var createSafeContext = function createSafeContext(defaultValue) {
|
|
38
38
|
};
|
39
39
|
|
40
40
|
export { createSafeContext, useOpenCloseState };
|
41
|
-
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useOpenCloseState: (initialState?: boolean) => readonly [boolean, () => void, () => void];
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ReactNode } from "react";
|
2
|
+
type ProviderProps<Value> = {
|
3
|
+
children: ReactNode;
|
4
|
+
value: Value;
|
5
|
+
};
|
6
|
+
export declare const createSafeContext: <Value>(defaultValue?: Value) => readonly [({ children, value }: ProviderProps<Value>) => import("react/jsx-runtime").JSX.Element, () => Value & ({} | undefined)];
|
7
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export type EmptyObject = Record<PropertyKey, never>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./EmptyObject";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./EarlyReturn";
|
@@ -0,0 +1 @@
|
|
1
|
+
export type EmptyObject = Record<PropertyKey, never>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./EmptyObject";
|
@@ -3,6 +3,6 @@ export declare class EarlyReturn<T> {
|
|
3
3
|
returnValue: T | undefined;
|
4
4
|
case(condition: boolean, func: Callback<T>): EarlyReturn<T>;
|
5
5
|
default(func: Callback<T>): T;
|
6
|
-
isAlreadyReturned
|
6
|
+
private isAlreadyReturned;
|
7
7
|
}
|
8
8
|
export {};
|
package/package.json
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "dogu-utils",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
7
7
|
],
|
8
|
+
"exports": {
|
9
|
+
".": "./dist/index.js",
|
10
|
+
"./react": "./dist/react/index.js",
|
11
|
+
"./utils": "./dist/utils/index.js"
|
12
|
+
},
|
8
13
|
"types": "./dist/index.d.ts",
|
9
14
|
"type": "module",
|
10
15
|
"devDependencies": {
|
package/dist/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/react/hooks/useOpenCloseState.ts","../src/react/utils/createSafeContext.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\"\n\nexport const useOpenCloseState = (initialState = false) => {\n const [isOpen, setIsOpen] = useState(initialState)\n\n const open = useCallback(() => setIsOpen(true), [])\n const close = useCallback(() => setIsOpen(false), [])\n\n return [isOpen, open, close] as const\n}\n","import { ReactNode, createContext, useContext } from \"react\"\n\ntype ProviderProps<Value> = {\n children: ReactNode\n value: Value\n}\n\nexport const createSafeContext = <Value,>(defaultValue?: Value) => {\n const Context = createContext<Value | null>(defaultValue ?? null)\n\n const Provider = ({ children, value }: ProviderProps<Value>) => {\n return <Context.Provider value={value}>{children}</Context.Provider>\n }\n\n const useSafeContext = () => {\n const context = useContext(Context)\n if (context === null) {\n throw new Error(\n \"useSafeContext must be used within a Provider, or give it a default value.\"\n )\n }\n return context\n }\n\n return [Provider, useSafeContext] as const\n}\n"],"names":["useOpenCloseState","initialState","_a","useState","isOpen","setIsOpen","open","useCallback","close","createSafeContext","defaultValue","Context","createContext","Provider","children","value","_jsx","useSafeContext","context","useContext","Error"],"mappings":";;;IAEaA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,YAAoB,EAAA;AAApB,EAAA,IAAAA,YAAA,KAAA,KAAA,CAAA,EAAA;AAAAA,IAAAA,YAAoB,GAAA,KAAA;AAAA;AAC9C,EAAA,IAAAC,EAAA,GAAsBC,QAAQ,CAACF,YAAY,CAAC;AAA3CG,IAAAA,MAAM,GAAAF,EAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,SAAS,GAAAH,EAAA,CAAA,CAAA,CAA0B;AAElD,EAAA,IAAMI,IAAI,GAAGC,WAAW,CAAC;IAAM,OAAAF,SAAS,CAAC,IAAI,CAAC;GAAA,EAAE,EAAE,CAAC;AACnD,EAAA,IAAMG,KAAK,GAAGD,WAAW,CAAC;IAAM,OAAAF,SAAS,CAAC,KAAK,CAAC;GAAA,EAAE,EAAE,CAAC;AAErD,EAAA,OAAO,CAACD,MAAM,EAAEE,IAAI,EAAEE,KAAK,CAAU;AACvC;;ICFaC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAYC,YAAoB,EAAA;AAC5D,EAAA,IAAMC,OAAO,gBAAGC,aAAa,CAAeF,YAAY,KAAA,IAAA,IAAZA,YAAY,KAAA,KAAA,CAAA,GAAZA,YAAY,GAAI,IAAI,CAAC;AAEjE,EAAA,IAAM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