Socket
Socket
Sign inDemoInstall

zustand-fetching

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zustand-fetching - npm Package Compare versions

Comparing version 2.0.12 to 2.1.0

2

dist/helpers/controllers/hooks/useLeitenModals.d.ts

@@ -8,4 +8,4 @@ export type LeitenModalState = {

queue: string[];
readonly action: (key: string, value: boolean, queue?: boolean) => void;
}
export declare const useLeitenModalManager: import("zustand").UseBoundStore<import("zustand").StoreApi<LeitenModalManagerState>>;
export declare const leitenModalManagerAction: (key: string, value: boolean, replace?: boolean) => void;
import { produce } from "immer";
import { create } from "zustand";
export const useLeitenModalManager = create((set, get) => ({
export const useLeitenModalManager = create(() => ({
modals: {},
queue: [],
action: (key, value, replace) => {
const nextState = produce(get(), (draft) => {
draft.modals[key] = { open: value, hidden: false };
let queue = draft.queue.filter((modal) => modal !== key);
if (!replace) {
queue.forEach((item) => {
draft.modals[item].hidden = true;
});
}
else {
queue.forEach((item) => {
draft.modals[item].hidden = false;
draft.modals[item].open = false;
});
queue = [];
}
if (value) {
queue.push(key);
}
const last = queue[queue.length - 1];
if (last) {
draft.modals[last].open = true;
draft.modals[last].hidden = false;
}
draft.queue = queue;
});
set(nextState);
},
}));
export const leitenModalManagerAction = (key, value, replace) => {
const nextState = produce(useLeitenModalManager.getState(), (draft) => {
draft.modals[key] = { open: value, hidden: false };
let queue = draft.queue.filter((modal) => modal !== key);
if (!replace) {
queue.forEach((item) => {
draft.modals[item].hidden = true;
});
}
else {
queue.forEach((item) => {
draft.modals[item].hidden = false;
draft.modals[item].open = false;
});
queue = [];
}
if (value) {
queue.push(key);
}
const last = queue[queue.length - 1];
if (last) {
draft.modals[last].open = true;
draft.modals[last].hidden = false;
}
draft.queue = queue;
});
useLeitenModalManager.setState(nextState);
};

@@ -5,3 +5,3 @@ import { produce } from "immer";

import { shallow } from "zustand/shallow";
import { useLeitenModalManager } from "./hooks/useLeitenModals";
import { leitenModalManagerAction, useLeitenModalManager, } from "./hooks/useLeitenModals";
export const leitenModal = (store, path, extra) => {

@@ -13,3 +13,2 @@ const initialData = get(store.getState(), path, "_empty");

const key = nanoid(10);
useLeitenModalManager.getState().action(key, false);
const setContent = (value) => {

@@ -22,3 +21,3 @@ const nextState = produce(store.getState(), (draft) => {

const setState = (value, replace) => {
useLeitenModalManager.getState().action(key, value, replace);
leitenModalManagerAction(key, value, replace);
};

@@ -25,0 +24,0 @@ const getState = () => useLeitenModalManager.getState().modals[key];

{
"name": "zustand-fetching",
"version": "2.0.12",
"version": "2.1.0",
"private": false,

@@ -5,0 +5,0 @@ "description": "Zustand fetching helpers",

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