Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tamagui/use-controllable-state

Package Overview
Dependencies
Maintainers
0
Versions
1124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tamagui/use-controllable-state - npm Package Compare versions

Comparing version 1.110.5 to 1.111.0

dist/esm/index.native.mjs

46

dist/cjs/useControllableState.native.js

@@ -29,49 +29,7 @@ "use strict";

module.exports = __toCommonJS(useControllableState_exports);
var import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_start_transition = require("@tamagui/start-transition");
function _array_like_to_array(arr, len) {
(len == null || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i != null) {
var _arr = [], _n = !0, _d = !1, _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
;
} catch (err) {
_d = !0, _e = err;
} finally {
try {
!_n && _i.return != null && _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (o) {
if (typeof o == "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
}
var emptyCallbackFn = function(_) {
var import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_start_transition = require("@tamagui/start-transition"), emptyCallbackFn = function(_) {
return _();
};
function useControllableState(param) {
var prop = param.prop, defaultProp = param.defaultProp, onChange = param.onChange, _param_strategy = param.strategy, strategy = _param_strategy === void 0 ? "prop-wins" : _param_strategy, preventUpdate = param.preventUpdate, transition = param.transition, _React_useState = _sliced_to_array(React.useState(prop ?? defaultProp), 2), state = _React_useState[0], setState = _React_useState[1], 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;
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;
React.useEffect(function() {

@@ -78,0 +36,0 @@ prop !== void 0 && (previous.current = prop, transitionFn(function() {

import { useEvent } from "@tamagui/use-event";
import * as React from "react";
import { startTransition } from "@tamagui/start-transition";
function _array_like_to_array(arr, len) {
(len == null || len > arr.length) && (len = arr.length);
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i != null) {
var _arr = [], _n = !0, _d = !1, _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
;
} catch (err) {
_d = !0, _e = err;
} finally {
try {
!_n && _i.return != null && _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (o) {
if (typeof o == "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
}
var emptyCallbackFn = function(_) {

@@ -49,3 +8,3 @@ return _();

function useControllableState(param) {
var prop = param.prop, defaultProp = param.defaultProp, onChange = param.onChange, _param_strategy = param.strategy, strategy = _param_strategy === void 0 ? "prop-wins" : _param_strategy, preventUpdate = param.preventUpdate, transition = param.transition, _React_useState = _sliced_to_array(React.useState(prop ?? defaultProp), 2), state = _React_useState[0], setState = _React_useState[1], previous = React.useRef(state), propWins = strategy === "prop-wins" && prop !== void 0, value = propWins ? prop : state, onChangeCb = useEvent(onChange || idFn), transitionFn = transition ? startTransition : emptyCallbackFn;
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 = useEvent(onChange || idFn), transitionFn = transition ? startTransition : emptyCallbackFn;
React.useEffect(function() {

@@ -52,0 +11,0 @@ prop !== void 0 && (previous.current = prop, transitionFn(function() {

{
"name": "@tamagui/use-controllable-state",
"version": "1.110.5",
"version": "1.111.0",
"sideEffects": false,

@@ -33,7 +33,7 @@ "source": "src/index.ts",

"dependencies": {
"@tamagui/start-transition": "1.110.5",
"@tamagui/use-event": "1.110.5"
"@tamagui/start-transition": "1.111.0",
"@tamagui/use-event": "1.111.0"
},
"devDependencies": {
"@tamagui/build": "1.110.5",
"@tamagui/build": "1.111.0",
"react": "^18.2.0 || ^19.0.0"

@@ -40,0 +40,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc