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

circle-ihk

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circle-ihk - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

10

dist/hook/useQuery.d.ts
/// <reference types="react" />
import { Match } from '../interface';
interface IData {
start: number;
limit: number;
data: Array<any>;
}
interface IProps {

@@ -17,3 +22,4 @@ field?: string;

app: import("../interface").App;
data: any[];
data: IData;
done: boolean;
query: {

@@ -29,2 +35,3 @@ field?: string | undefined;

};
onDone: import("react").Dispatch<import("react").SetStateAction<boolean>>;
onQuery: import("react").Dispatch<import("react").SetStateAction<{

@@ -44,3 +51,4 @@ field?: string | undefined;

container: HTMLElement;
loadMore: (() => void) | null;
};
export {};

65

dist/hook/useQuery.js

@@ -1,2 +0,2 @@

import { useRef, useState, useEffect } from 'react';
import { useState, useEffect } from 'react';
import useApp from './useApp';

@@ -7,6 +7,10 @@ import { isUndefined, isFunction } from '../utils/is';

const { app, me, container } = useApp();
const done = useRef(false);
const [done, onDone] = useState(false);
const [loading, setLoading] = useState(false);
const [query, onQuery] = useState(prop);
const [data, setData] = useState([]);
const [data, setData] = useState({
data: [],
start: query.start || 1,
limit: query.limit || 10,
});
const refetch = (callback) => {

@@ -17,14 +21,15 @@ setLoading(true);

.list(reset, { start, limit }, table)
.then((results = []) => {
if (!Array.isArray(results)) {
return;
.then((res) => {
if (res.data.length <= 0 || res.data.length < limit) {
onDone(true);
}
if (results.length <= 0 || results.length < limit) {
done.current = true;
}
if (start <= 1) {
setData(results);
setData(res);
}
else {
setData((lastData) => [...lastData, ...results]);
setData((lastData) => ({
start: res.start,
limit: res.limit,
data: [...lastData.data, ...res.data],
}));
}

@@ -48,15 +53,16 @@ // @ts-ignore

.set(value, key, table)
.then((id) => {
app.get(id, table).then((val) => {
const index = data.findIndex((prop) => prop.id === key);
if (index >= 0) {
data[index] = val;
}
else {
data.push(val);
}
setData([...data]);
// @ts-ignore
isFunction(callback) && callback();
.then(() => {
const index = data.data.findIndex((prop) => prop.id === key);
if (index >= 0) {
data.data[index] = value;
}
else {
data.data.push(value);
}
setData({
...data,
data: [...data.data],
});
// @ts-ignore
isFunction(callback) && callback();
})

@@ -73,3 +79,5 @@ .catch((err) => {

data,
done,
query,
onDone,
onQuery,

@@ -80,3 +88,14 @@ onChange,

container,
loadMore: done
? null
: () => {
if (loading) {
return;
}
onQuery({
...query,
start: data.start,
});
},
};
}
{
"name": "circle-ihk",
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Circle Reader Component Library",

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