@tamagui/use-controllable-state 1.135.4-1761749240853 → 1.135.4
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/cjs/index.native.js +12 -13
- package/dist/cjs/index.native.js.map +6 -1
- package/dist/cjs/useControllableState.cjs +1 -1
- package/dist/cjs/useControllableState.js +1 -1
- package/dist/cjs/useControllableState.js.map +1 -1
- package/dist/cjs/useControllableState.native.js +46 -56
- package/dist/cjs/useControllableState.native.js.map +6 -1
- package/package.json +4 -5
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
6
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: !0
|
|
17
|
-
}), mod);
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
18
13
|
var index_exports = {};
|
|
19
14
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./useControllableState
|
|
21
|
-
|
|
15
|
+
__reExport(index_exports, require("./useControllableState"), module.exports);
|
|
16
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
17
|
+
0 && (module.exports = {
|
|
18
|
+
...require("./useControllableState")
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,mCAAd;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -35,7 +35,7 @@ __export(useControllableState_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(useControllableState_exports);
|
|
37
37
|
var import_use_event = require("@tamagui/use-event"),
|
|
38
|
-
React = __toESM(require("react")
|
|
38
|
+
React = __toESM(require("react")),
|
|
39
39
|
import_start_transition = require("@tamagui/start-transition");
|
|
40
40
|
const emptyCallbackFn = _ => _();
|
|
41
41
|
function useControllableState({
|
|
@@ -25,7 +25,7 @@ __export(useControllableState_exports, {
|
|
|
25
25
|
useControllableState: () => useControllableState
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(useControllableState_exports);
|
|
28
|
-
var import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")
|
|
28
|
+
var import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_start_transition = require("@tamagui/start-transition");
|
|
29
29
|
const emptyCallbackFn = (_) => _();
|
|
30
30
|
function useControllableState({
|
|
31
31
|
prop,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useControllableState.ts"],
|
|
4
|
-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strict";
|
|
2
|
-
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
22
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
17
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
18
|
// file that has been converted to a CommonJS file using a Babel-
|
|
25
19
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
20
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}) : target, mod)),
|
|
31
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: !0
|
|
33
|
-
}), mod);
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
34
24
|
var useControllableState_exports = {};
|
|
35
25
|
__export(useControllableState_exports, {
|
|
36
26
|
useControllableState: () => useControllableState
|
|
37
27
|
});
|
|
38
28
|
module.exports = __toCommonJS(useControllableState_exports);
|
|
39
|
-
var import_use_event = require("@tamagui/use-event"),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
emptyCallbackFn = function (_) {
|
|
43
|
-
return _();
|
|
44
|
-
};
|
|
29
|
+
var import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_start_transition = require("@tamagui/start-transition"), emptyCallbackFn = function(_) {
|
|
30
|
+
return _();
|
|
31
|
+
};
|
|
45
32
|
function useControllableState(param) {
|
|
46
|
-
var {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onChange,
|
|
50
|
-
strategy = "prop-wins",
|
|
51
|
-
preventUpdate,
|
|
52
|
-
transition
|
|
53
|
-
} = param,
|
|
54
|
-
[state, setState] = React.useState(prop ?? defaultProp),
|
|
55
|
-
previous = React.useRef(state),
|
|
56
|
-
propWins = strategy === "prop-wins" && prop !== void 0,
|
|
57
|
-
value = propWins ? prop : state,
|
|
58
|
-
onChangeCb = (0, import_use_event.useEvent)(onChange || idFn),
|
|
59
|
-
transitionFn = transition ? import_start_transition.startTransition : emptyCallbackFn;
|
|
60
|
-
React.useEffect(function () {
|
|
61
|
-
prop !== void 0 && (previous.current = prop, transitionFn(function () {
|
|
33
|
+
var { prop, defaultProp, onChange, strategy = "prop-wins", preventUpdate, transition } = param, [state, setState] = React.useState(prop ?? defaultProp), previous = React.useRef(state), propWins = strategy === "prop-wins" && prop !== void 0, value = propWins ? prop : state, onChangeCb = (0, import_use_event.useEvent)(onChange || idFn), transitionFn = transition ? import_start_transition.startTransition : emptyCallbackFn;
|
|
34
|
+
React.useEffect(function() {
|
|
35
|
+
prop !== void 0 && (previous.current = prop, transitionFn(function() {
|
|
62
36
|
setState(prop);
|
|
63
37
|
}));
|
|
64
|
-
}, [
|
|
38
|
+
}, [
|
|
39
|
+
prop
|
|
40
|
+
]), React.useEffect(function() {
|
|
65
41
|
propWins || state !== previous.current && (previous.current = state, onChangeCb(state));
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
42
|
+
}, [
|
|
43
|
+
onChangeCb,
|
|
44
|
+
state,
|
|
45
|
+
propWins
|
|
46
|
+
]);
|
|
47
|
+
var setter = (0, import_use_event.useEvent)(function(next) {
|
|
48
|
+
if (!preventUpdate)
|
|
49
|
+
if (propWins) {
|
|
50
|
+
var nextValue = typeof next == "function" ? next(previous.current) : next;
|
|
51
|
+
onChangeCb(nextValue);
|
|
52
|
+
} else
|
|
53
|
+
transitionFn(function() {
|
|
54
|
+
setState(next);
|
|
55
|
+
});
|
|
74
56
|
});
|
|
75
|
-
return [
|
|
57
|
+
return [
|
|
58
|
+
value,
|
|
59
|
+
setter
|
|
60
|
+
];
|
|
76
61
|
}
|
|
77
|
-
var idFn = function
|
|
78
|
-
|
|
62
|
+
var idFn = function() {
|
|
63
|
+
};
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
useControllableState
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=useControllableState.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useControllableState.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,+BACzB,QAAuB,2BACvB,0BAAgC,sCAG5B,kBAAkB,SAAS,GAAG;AAC9B,SAAO,EAAE;AACb;AACO,SAAS,qBAAqB,OAAO;AACxC,MAAI,EAAE,MAAM,aAAa,UAAU,WAAW,aAAa,eAAe,WAAW,IAAI,OACrF,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,QAA0C,WAAW,GACxF,WAAW,MAAM,OAAO,KAAK,GAC7B,WAAW,aAAa,eAAe,SAAS,QAChD,QAAQ,WAAW,OAAO,OAC1B,iBAAa,2BAAS,YAAY,IAAI,GACtC,eAAe,aAAa,0CAAkB;AAClD,QAAM,UAAU,WAAW;AACvB,IAAI,SAAS,WACb,SAAS,UAAU,MACnB,aAAa,WAAW;AACpB,eAAS,IAAI;AAAA,IACjB,CAAC;AAAA,EACL,GAAG;AAAA,IACC;AAAA,EACJ,CAAC,GACD,MAAM,UAAU,WAAW;AACvB,IAAI,YACA,UAAU,SAAS,YACnB,SAAS,UAAU,OACnB,WAAW,KAAK;AAAA,EAExB,GAAG;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACD,MAAI,aAAS,2BAAS,SAAS,MAAM;AACjC,QAAI;AACJ,UAAI,UAAU;AACV,YAAI,YAAY,OAAO,QAAS,aAAa,KAAK,SAAS,OAAO,IAAI;AACtE,mBAAW,SAAS;AAAA,MACxB;AACI,qBAAa,WAAW;AACpB,mBAAS,IAAI;AAAA,QACjB,CAAC;AAAA,EAET,CAAC;AACD,SAAO;AAAA,IACH;AAAA,IACA;AAAA,EACJ;AACJ;AACA,IAAI,OAAO,WAAW;AAAC;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-controllable-state",
|
|
3
|
-
"version": "1.135.4
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "1.135.4",
|
|
5
4
|
"sideEffects": false,
|
|
6
5
|
"source": "src/index.ts",
|
|
7
6
|
"types": "./types/index.d.ts",
|
|
@@ -34,11 +33,11 @@
|
|
|
34
33
|
}
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@tamagui/start-transition": "1.135.4
|
|
38
|
-
"@tamagui/use-event": "1.135.4
|
|
36
|
+
"@tamagui/start-transition": "1.135.4",
|
|
37
|
+
"@tamagui/use-event": "1.135.4"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "1.135.4
|
|
40
|
+
"@tamagui/build": "1.135.4",
|
|
42
41
|
"react": "*"
|
|
43
42
|
},
|
|
44
43
|
"publishConfig": {
|