Skip to content

Commit

Permalink
bump dependencies (#76)
Browse files Browse the repository at this point in the history
* bump dependencies

* fix types
  • Loading branch information
wolflu05 authored Apr 29, 2024
1 parent a0643a0 commit 22f3373
Show file tree
Hide file tree
Showing 7 changed files with 1,188 additions and 904 deletions.
2,015 changes: 1,149 additions & 866 deletions inventree_bulk_plugin/frontend/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions inventree_bulk_plugin/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
"lint": "eslint . && tsc"
},
"dependencies": {
"preact": "^10.19.3"
"preact": "^10.20.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.8.1",
"@preact/preset-vite": "^2.8.2",
"@types/jquery": "^3.5.29",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"eslint": "^8.57.0",
"eslint-config-preact": "^1.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jest": "^28.3.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"prettier": "^3.2.4",
"typescript": "^5.3.3",
"vite": "^5.0.12"
"prettier": "^3.2.5",
"typescript": "^5.4.5",
"vite": "^5.2.10"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSX } from "preact";
import { useState, useCallback, useEffect, useId, StateUpdater } from "preact/hooks";
import { useState, useCallback, useEffect, useId, StateUpdater, Dispatch } from "preact/hooks";

import { GenerateKeysObject } from "./GenerateKeys";
import { Input } from "./Input";
Expand All @@ -11,7 +11,7 @@ import "./BulkDefinitionChildSchemaBuilder.css";

interface BulkDefinitionChildSchemaBuilderProps {
childSchema: BulkDefinitionChild;
setChildSchema: StateUpdater<BulkDefinitionChild>;
setChildSchema: Dispatch<StateUpdater<BulkDefinitionChild>>;
bulkGenerateInfo: BulkGenerateInfo;
extendsKeys: Record<string, string>;
}
Expand Down Expand Up @@ -44,20 +44,21 @@ export function BulkDefinitionChildSchemaBuilder({
);

// set a generated value by key and event
const setGenerate: StateUpdater<Record<string, FieldType>> = useCallback(
const setGenerate: Dispatch<StateUpdater<Record<string, FieldType>>> = useCallback(
(value) => setChildSchema((s) => ({ ...s, generate: typeof value === "function" ? value(s.generate) : value })),
[setChildSchema],
);

// dimensions
const setDimension: (key: "dimensions" | "count") => (i: number) => StateUpdater<string | null> = useCallback(
(key) => (i) => (newValue) =>
setChildSchema((s) => {
s[key][i] = typeof newValue === "function" ? newValue(s[key][i]) : newValue;
return { ...s, [key]: s[key] };
}),
[setChildSchema],
);
const setDimension: (key: "dimensions" | "count") => (i: number) => Dispatch<StateUpdater<string | null>> =
useCallback(
(key) => (i) => (newValue) =>
setChildSchema((s) => {
s[key][i] = typeof newValue === "function" ? newValue(s[key][i]) : newValue;
return { ...s, [key]: s[key] };
}),
[setChildSchema],
);
const addDimension = useCallback(
() =>
setChildSchema((s) => {
Expand All @@ -78,7 +79,7 @@ export function BulkDefinitionChildSchemaBuilder({
);

// child's childs schemas
const setChildChildSchema: (i: number) => StateUpdater<BulkDefinitionChild> = useCallback(
const setChildChildSchema: (i: number) => Dispatch<StateUpdater<BulkDefinitionChild>> = useCallback(
(i) => (newValue) =>
setChildSchema((s) => {
if (!s.childs) s.childs = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSX } from "preact";
import { useState, useCallback, useEffect, useMemo, useId, useRef, StateUpdater } from "preact/hooks";
import { useState, useCallback, useEffect, useMemo, useId, useRef, StateUpdater, Dispatch } from "preact/hooks";

import { BulkDefinitionChildSchemaBuilder } from "./BulkDefinitionChildSchemaBuilder";
import { Input } from "./Input";
Expand All @@ -13,14 +13,14 @@ import {

interface BulkDefinitionSchemaBuilderProps {
schema: BulkDefinitionSchema;
setSchema: StateUpdater<BulkDefinitionSchema>;
setSchema: Dispatch<StateUpdater<BulkDefinitionSchema>>;
bulkGenerateInfo: BulkGenerateInfo;
}

export function BulkDefinitionSchemaBuilder({ schema, setSchema, bulkGenerateInfo }: BulkDefinitionSchemaBuilderProps) {
const firstUpdate = useRef(true);

const setChildSchema: StateUpdater<BulkDefinitionChild> = useCallback(
const setChildSchema: Dispatch<StateUpdater<BulkDefinitionChild>> = useCallback(
(newSchema) =>
setSchema((s) => ({ ...s, output: typeof newSchema === "function" ? newSchema(s.output) : newSchema })),
[setSchema],
Expand Down Expand Up @@ -54,7 +54,7 @@ export function BulkDefinitionSchemaBuilder({ schema, setSchema, bulkGenerateInf
}, [schema?.input, input, setInput]);

// template
const setTemplate: (i: number) => StateUpdater<BulkDefinitionChildTemplate> = useCallback(
const setTemplate: (i: number) => Dispatch<StateUpdater<BulkDefinitionChildTemplate>> = useCallback(
(i: number) => (newTemplate) =>
setSchema((s) => {
s.templates[i] = typeof newTemplate === "function" ? newTemplate(s.templates[i]) : newTemplate;
Expand Down Expand Up @@ -154,7 +154,7 @@ export function BulkDefinitionSchemaBuilder({ schema, setSchema, bulkGenerateInf
)}
<BulkDefinitionChildSchemaBuilder
childSchema={template}
setChildSchema={setTemplate(i) as unknown as StateUpdater<BulkDefinitionChild>}
setChildSchema={setTemplate(i) as unknown as Dispatch<StateUpdater<BulkDefinitionChild>>}
bulkGenerateInfo={bulkGenerateInfo}
extendsKeys={extendsKeys}
/>
Expand Down
14 changes: 7 additions & 7 deletions inventree_bulk_plugin/frontend/src/components/GenerateKeys.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSX } from "preact";
import { StateUpdater, useCallback, useId, useMemo, useState } from "preact/hooks";
import { Dispatch, StateUpdater, useCallback, useId, useMemo, useState } from "preact/hooks";

import { Input } from "./Input";
import { Tooltip } from "./Tooltip";
Expand Down Expand Up @@ -40,7 +40,7 @@ const getDefaultValue = (fieldDefinition: FieldDefinition): FieldType => {
interface GenerateKeysProps {
fieldDefinition: FieldDefinition;
field: FieldType;
setField: StateUpdater<FieldType>;
setField: Dispatch<StateUpdater<FieldType>>;
onDelete?: () => void;
}

Expand All @@ -50,7 +50,7 @@ export const GenerateKeys = ({ fieldDefinition, field, setField, onDelete }: Gen
<GenerateKeysObject
fieldsDefinition={fieldDefinition}
fields={field as Record<string, FieldType>}
setFields={setField as StateUpdater<Record<string, FieldType>>}
setFields={setField as Dispatch<StateUpdater<Record<string, FieldType>>>}
onDelete={onDelete}
/>
);
Expand All @@ -60,7 +60,7 @@ export const GenerateKeys = ({ fieldDefinition, field, setField, onDelete }: Gen
<GenerateKeysList
fieldsDefinition={fieldDefinition}
fields={field as FieldType[]}
setFields={setField as StateUpdater<FieldType[]>}
setFields={setField as Dispatch<StateUpdater<FieldType[]>>}
onDelete={onDelete}
/>
);
Expand All @@ -72,7 +72,7 @@ export const GenerateKeys = ({ fieldDefinition, field, setField, onDelete }: Gen
interface GenerateKeysListProps {
fieldsDefinition: FieldDefinitionList;
fields: FieldType[];
setFields: StateUpdater<FieldType[]>;
setFields: Dispatch<StateUpdater<FieldType[]>>;
onDelete?: () => void;
}
export const GenerateKeysList = ({ fieldsDefinition, fields, setFields, onDelete }: GenerateKeysListProps) => {
Expand Down Expand Up @@ -140,7 +140,7 @@ export const GenerateKeysList = ({ fieldsDefinition, fields, setFields, onDelete
interface GenerateKeysObjectProps {
fieldsDefinition: FieldDefinitionObject;
fields: Record<string, FieldType>;
setFields: StateUpdater<Record<string, FieldType>>;
setFields: Dispatch<StateUpdater<Record<string, FieldType>>>;
onDelete?: () => void;
showCard?: boolean;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ const detectUseTemplate = (
interface GenerateKeysSingleProps {
fieldDefinition: FieldDefinitionText | FieldDefinitionModel | FieldDefinitionSelect;
field: FieldType;
setField: StateUpdater<FieldType>;
setField: Dispatch<StateUpdater<FieldType>>;
onDelete?: () => void;
}
const GenerateKeysSingle = ({ fieldDefinition, field, setField, onDelete }: GenerateKeysSingleProps) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSX } from "preact";
import { StateUpdater, useCallback, useEffect, useState } from "preact/hooks";
import { Dispatch, StateUpdater, useCallback, useEffect, useState } from "preact/hooks";

import { Input } from "./Input";
import { PreviewTable } from "./PreviewTable";
Expand All @@ -14,7 +14,7 @@ interface PreviewCreateProps {
attachPreviewHandler?: (previewHandler: () => void) => void;
attachCreateHandler?: (createHandler: () => void) => void;
handleDoneCreate?: (ok: boolean) => void;
setIsBulkCreateLoading: StateUpdater<boolean>;
setIsBulkCreateLoading: Dispatch<StateUpdater<boolean>>;
}

interface InputType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSX } from "preact";
import { StateUpdater, useCallback, useEffect, useMemo, useState } from "preact/hooks";
import { Dispatch, StateUpdater, useCallback, useEffect, useMemo, useState } from "preact/hooks";

import { BulkDefinitionSchemaBuilder } from "./BulkDefinitionSchemaBuilder";
import { Dialog } from "./Dialog";
Expand Down Expand Up @@ -38,7 +38,7 @@ export const TemplateForm = ({
setTemplate((t) => (t ? { ...t, [k]: e.currentTarget.value } : null)),
[],
);
const updateTemplate: StateUpdater<BulkDefinitionSchema> = useCallback((v) => {
const updateTemplate: Dispatch<StateUpdater<BulkDefinitionSchema>> = useCallback((v) => {
setTemplate((t) => {
if (t === null) return t;
return {
Expand Down

0 comments on commit 22f3373

Please sign in to comment.