foxact 0.2.46 → 0.2.47
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/context-state/index.cjs +1 -1
- package/context-state/index.d.ts +16 -1
- package/context-state/index.mjs +1 -1
- package/package.json +19 -19
- package/sizes.json +1 -1
package/context-state/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime");require("client-only");var t=require("react"),r=require("../noop/index.cjs");exports.createContextState=function(n){const
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime");require("client-only");var t=require("react"),r=require("../noop/index.cjs");exports.createContextState=function(n){const i=t.createContext(n),o=t.createContext(r.noop);return[r=>{let{children:u,initialState:a}=r;const[c,s]=t.useState(null!=a?a:n);return e.jsx(i.Provider,{value:c,children:e.jsx(o.Provider,{value:s,children:u})})},()=>t.useContext(i),()=>t.useContext(o),i]};
|
package/context-state/index.d.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { Foxact } from '../types/index.js';
|
|
2
2
|
|
|
3
|
+
interface ProviderProps<T> {
|
|
4
|
+
initialState?: T | (() => T);
|
|
5
|
+
}
|
|
3
6
|
/** @see https://foxact.skk.moe/context-state */
|
|
4
7
|
declare function createContextState<T>(initialState: T): [
|
|
5
|
-
Provider: React.ComponentType<
|
|
8
|
+
Provider: React.ComponentType<ProviderProps<T>>,
|
|
9
|
+
useValue: () => T,
|
|
10
|
+
useSetValue: () => React.Dispatch<React.SetStateAction<T>>,
|
|
11
|
+
StateContext: React.Context<T>
|
|
12
|
+
];
|
|
13
|
+
declare function createContextState<T>(initialState: T): [
|
|
14
|
+
Provider: React.ComponentType<Foxact.PropsWithChildren<ProviderProps<T>>>,
|
|
15
|
+
useValue: () => T,
|
|
16
|
+
useSetValue: () => React.Dispatch<React.SetStateAction<T>>,
|
|
17
|
+
StateContext: React.Context<T>
|
|
18
|
+
];
|
|
19
|
+
declare function createContextState<T>(): [
|
|
20
|
+
Provider: React.ComponentType<Foxact.PropsWithChildren<Required<ProviderProps<T>>>>,
|
|
6
21
|
useValue: () => T,
|
|
7
22
|
useSetValue: () => React.Dispatch<React.SetStateAction<T>>,
|
|
8
23
|
StateContext: React.Context<T>
|
package/context-state/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import"client-only";import{useContext as r,createContext as e,useState as o}from"react";import{noop as n}from"../noop/index.mjs";function i(i){const l=e(i),c=e(n);return[r=>{let{children:e,initialState:n}=r;const[m,a]=o(null!=n?n:i);return t(l.Provider,{value:m,children:t(c.Provider,{value:a,children:e})})},()=>r(l),()=>r(c),l]}export{i as createContextState};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.47",
|
|
4
4
|
"description": "React Hooks/Utils done right. For browser, SSR, and React Server Components.",
|
|
5
5
|
"homepage": "https://foxact.skk.moe",
|
|
6
6
|
"repository": {
|
|
@@ -56,6 +56,15 @@
|
|
|
56
56
|
"require": "./compose-context-provider/index.cjs",
|
|
57
57
|
"default": "./compose-context-provider/index.cjs"
|
|
58
58
|
},
|
|
59
|
+
"./context-state": {
|
|
60
|
+
"types": "./context-state/index.d.ts",
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./context-state/index.d.ts",
|
|
63
|
+
"default": "./context-state/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"require": "./context-state/index.cjs",
|
|
66
|
+
"default": "./context-state/index.cjs"
|
|
67
|
+
},
|
|
59
68
|
"./create-context-state": {
|
|
60
69
|
"types": "./create-context-state/index.d.ts",
|
|
61
70
|
"import": {
|
|
@@ -101,15 +110,6 @@
|
|
|
101
110
|
"require": "./create-storage-hook/index.cjs",
|
|
102
111
|
"default": "./create-storage-hook/index.cjs"
|
|
103
112
|
},
|
|
104
|
-
"./context-state": {
|
|
105
|
-
"types": "./context-state/index.d.ts",
|
|
106
|
-
"import": {
|
|
107
|
-
"types": "./context-state/index.d.ts",
|
|
108
|
-
"default": "./context-state/index.mjs"
|
|
109
|
-
},
|
|
110
|
-
"require": "./context-state/index.cjs",
|
|
111
|
-
"default": "./context-state/index.cjs"
|
|
112
|
-
},
|
|
113
113
|
"./create-storage-state-factory": {
|
|
114
114
|
"types": "./create-storage-state-factory/index.d.ts",
|
|
115
115
|
"import": {
|
|
@@ -119,15 +119,6 @@
|
|
|
119
119
|
"require": "./create-storage-state-factory/index.cjs",
|
|
120
120
|
"default": "./create-storage-state-factory/index.cjs"
|
|
121
121
|
},
|
|
122
|
-
"./email-protection": {
|
|
123
|
-
"types": "./email-protection/index.d.ts",
|
|
124
|
-
"import": {
|
|
125
|
-
"types": "./email-protection/index.d.ts",
|
|
126
|
-
"default": "./email-protection/index.mjs"
|
|
127
|
-
},
|
|
128
|
-
"require": "./email-protection/index.cjs",
|
|
129
|
-
"default": "./email-protection/index.cjs"
|
|
130
|
-
},
|
|
131
122
|
"./current-year": {
|
|
132
123
|
"types": "./current-year/index.d.ts",
|
|
133
124
|
"import": {
|
|
@@ -137,6 +128,15 @@
|
|
|
137
128
|
"require": "./current-year/index.cjs",
|
|
138
129
|
"default": "./current-year/index.cjs"
|
|
139
130
|
},
|
|
131
|
+
"./email-protection": {
|
|
132
|
+
"types": "./email-protection/index.d.ts",
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./email-protection/index.d.ts",
|
|
135
|
+
"default": "./email-protection/index.mjs"
|
|
136
|
+
},
|
|
137
|
+
"require": "./email-protection/index.cjs",
|
|
138
|
+
"default": "./email-protection/index.cjs"
|
|
139
|
+
},
|
|
140
140
|
"./fetch-jsonp": {
|
|
141
141
|
"types": "./fetch-jsonp/index.d.ts",
|
|
142
142
|
"import": {
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":23624,"gzip":14527,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":402,"gzip":259,"br":221},"create-local-storage-state":{"raw":328,"gzip":183,"br":154},"create-session-storage-state":{"raw":332,"gzip":182,"br":152},"create-storage-state-factory":{"raw":519,"gzip":309,"br":263},"current-year":{"raw":592,"gzip":400,"br":326},"email-protection":{"raw":426,"gzip":321,"br":272},"invariant":{"raw":178,"gzip":156,"br":118},"fetch-jsonp":{"raw":875,"gzip":533,"br":418},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"noop":{"raw":33,"gzip":53,"br":37},"is-safari":{"raw":248,"gzip":164,"br":117},"nullthrow":{"raw":187,"gzip":163,"br":121},"no-ssr":{"raw":474,"gzip":316,"br":260},"open-new-tab":{"raw":344,"gzip":260,"br":190},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"rem":{"raw":823,"gzip":395,"br":350},"create-storage-hook":{"raw":2073,"gzip":880,"br":764},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use":{"raw":283,"gzip":185,"br":154},"use-array":{"raw":322,"gzip":236,"br":202},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-is-online":{"raw":356,"gzip":212,"br":158},"use-is-client":{"raw":150,"gzip":145,"br":115},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":112},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-clipboard":{"raw":1177,"gzip":651,"br":552},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":290,"gzip":206,"br":154},"use-media-query":{"raw":725,"gzip":406,"br":332},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-react-router-is-match":{"raw":563,"gzip":372,"br":314},"use-next-link":{"raw":1673,"gzip":871,"br":744},"use-session-storage":{"raw":316,"gzip":181,"br":152},"use-singleton":{"raw":139,"gzip":130,"br":104},"use-set":{"raw":340,"gzip":238,"br":203},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-uncontrolled":{"raw":352,"gzip":258,"br":216},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":249},"use-url-hash-state":{"raw":1068,"gzip":616,"br":539}}}
|