@mantine/hooks 4.0.4 → 4.0.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-list-state.js","sources":["../../src/use-list-state/use-list-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useListState<T>(initialValue: T[] = []) {\n const [state, setState] = useState(initialValue);\n\n const append = (...items: T[]) => setState((current) => [...current, ...items]);\n const prepend = (...items: T[]) => setState((current) => [...items, ...current]);\n\n const insert = (index: number, ...items: T[]) =>\n setState((current) => [...current.slice(0, index), ...items, ...current.slice(index)]);\n\n const apply = (fn: (item: T, index?: number) => T) =>\n setState((current) => current.map((item, index) => fn(item, index)));\n\n const remove = (...indices: number[]) =>\n setState((current) => current.filter((_, index) => !indices.includes(index)));\n\n const pop = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.pop();\n return cloned;\n });\n\n const shift = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.shift();\n return cloned;\n });\n\n const reorder = ({ from, to }: { from: number; to: number }) =>\n setState((current) => {\n const cloned = [...current];\n const item = current[from];\n\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return cloned;\n });\n\n const setItem = (index: number, item: T) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = item;\n return cloned;\n });\n\n const setItemProp = <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = { ...cloned[index], [prop]: value };\n return cloned;\n });\n\n const applyWhere = (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => setState((current) => current.map((item) => (condition(item) ? fn(item) : item)));\n\n return [\n state,\n {\n setState,\n append,\n prepend,\n insert,\n pop,\n shift,\n apply,\n applyWhere,\n remove,\n reorder,\n setItem,\n setItemProp,\n },\n ]
|
|
1
|
+
{"version":3,"file":"use-list-state.js","sources":["../../src/use-list-state/use-list-state.ts"],"sourcesContent":["import React, { useState } from 'react';\n\nexport interface UseListStateHandler<T> {\n setState: React.Dispatch<React.SetStateAction<T[]>>;\n append: (...items: T[]) => void;\n prepend: (...items: T[]) => void;\n insert: (index: number, ...items: T[]) => void;\n pop: () => void;\n shift: () => void;\n apply: (fn: (item: T, index?: number) => T) => void;\n applyWhere: (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => void;\n remove: (...indices: number[]) => void;\n reorder: ({ from, to }: { from: number; to: number }) => void;\n setItem: (index: number, item: T) => void;\n setItemProp: <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) => void;\n}\n\nexport type UseListState<T> = [T[], UseListStateHandler<T>];\n\nexport function useListState<T>(initialValue: T[] = []): UseListState<T> {\n const [state, setState] = useState(initialValue);\n\n const append = (...items: T[]) => setState((current) => [...current, ...items]);\n const prepend = (...items: T[]) => setState((current) => [...items, ...current]);\n\n const insert = (index: number, ...items: T[]) =>\n setState((current) => [...current.slice(0, index), ...items, ...current.slice(index)]);\n\n const apply = (fn: (item: T, index?: number) => T) =>\n setState((current) => current.map((item, index) => fn(item, index)));\n\n const remove = (...indices: number[]) =>\n setState((current) => current.filter((_, index) => !indices.includes(index)));\n\n const pop = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.pop();\n return cloned;\n });\n\n const shift = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.shift();\n return cloned;\n });\n\n const reorder = ({ from, to }: { from: number; to: number }) =>\n setState((current) => {\n const cloned = [...current];\n const item = current[from];\n\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return cloned;\n });\n\n const setItem = (index: number, item: T) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = item;\n return cloned;\n });\n\n const setItemProp = <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = { ...cloned[index], [prop]: value };\n return cloned;\n });\n\n const applyWhere = (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => setState((current) => current.map((item) => (condition(item) ? fn(item) : item)));\n\n return [\n state,\n {\n setState,\n append,\n prepend,\n insert,\n pop,\n shift,\n apply,\n applyWhere,\n remove,\n reorder,\n setItem,\n setItemProp,\n },\n ];\n}\n"],"names":["useState"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,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AAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,OAAO,KAAK;AACpE,IAAI,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;AAChC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC;AACxF,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,QAAQ,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACxH,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI;AACJ,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,GAAG;AACT,MAAM,KAAK;AACX,MAAM,KAAK;AACX,MAAM,UAAU;AAChB,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,WAAW;AACjB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-list-state.js","sources":["../../src/use-list-state/use-list-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useListState<T>(initialValue: T[] = []) {\n const [state, setState] = useState(initialValue);\n\n const append = (...items: T[]) => setState((current) => [...current, ...items]);\n const prepend = (...items: T[]) => setState((current) => [...items, ...current]);\n\n const insert = (index: number, ...items: T[]) =>\n setState((current) => [...current.slice(0, index), ...items, ...current.slice(index)]);\n\n const apply = (fn: (item: T, index?: number) => T) =>\n setState((current) => current.map((item, index) => fn(item, index)));\n\n const remove = (...indices: number[]) =>\n setState((current) => current.filter((_, index) => !indices.includes(index)));\n\n const pop = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.pop();\n return cloned;\n });\n\n const shift = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.shift();\n return cloned;\n });\n\n const reorder = ({ from, to }: { from: number; to: number }) =>\n setState((current) => {\n const cloned = [...current];\n const item = current[from];\n\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return cloned;\n });\n\n const setItem = (index: number, item: T) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = item;\n return cloned;\n });\n\n const setItemProp = <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = { ...cloned[index], [prop]: value };\n return cloned;\n });\n\n const applyWhere = (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => setState((current) => current.map((item) => (condition(item) ? fn(item) : item)));\n\n return [\n state,\n {\n setState,\n append,\n prepend,\n insert,\n pop,\n shift,\n apply,\n applyWhere,\n remove,\n reorder,\n setItem,\n setItemProp,\n },\n ]
|
|
1
|
+
{"version":3,"file":"use-list-state.js","sources":["../../src/use-list-state/use-list-state.ts"],"sourcesContent":["import React, { useState } from 'react';\n\nexport interface UseListStateHandler<T> {\n setState: React.Dispatch<React.SetStateAction<T[]>>;\n append: (...items: T[]) => void;\n prepend: (...items: T[]) => void;\n insert: (index: number, ...items: T[]) => void;\n pop: () => void;\n shift: () => void;\n apply: (fn: (item: T, index?: number) => T) => void;\n applyWhere: (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => void;\n remove: (...indices: number[]) => void;\n reorder: ({ from, to }: { from: number; to: number }) => void;\n setItem: (index: number, item: T) => void;\n setItemProp: <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) => void;\n}\n\nexport type UseListState<T> = [T[], UseListStateHandler<T>];\n\nexport function useListState<T>(initialValue: T[] = []): UseListState<T> {\n const [state, setState] = useState(initialValue);\n\n const append = (...items: T[]) => setState((current) => [...current, ...items]);\n const prepend = (...items: T[]) => setState((current) => [...items, ...current]);\n\n const insert = (index: number, ...items: T[]) =>\n setState((current) => [...current.slice(0, index), ...items, ...current.slice(index)]);\n\n const apply = (fn: (item: T, index?: number) => T) =>\n setState((current) => current.map((item, index) => fn(item, index)));\n\n const remove = (...indices: number[]) =>\n setState((current) => current.filter((_, index) => !indices.includes(index)));\n\n const pop = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.pop();\n return cloned;\n });\n\n const shift = () =>\n setState((current) => {\n const cloned = [...current];\n cloned.shift();\n return cloned;\n });\n\n const reorder = ({ from, to }: { from: number; to: number }) =>\n setState((current) => {\n const cloned = [...current];\n const item = current[from];\n\n cloned.splice(from, 1);\n cloned.splice(to, 0, item);\n\n return cloned;\n });\n\n const setItem = (index: number, item: T) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = item;\n return cloned;\n });\n\n const setItemProp = <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) =>\n setState((current) => {\n const cloned = [...current];\n cloned[index] = { ...cloned[index], [prop]: value };\n return cloned;\n });\n\n const applyWhere = (\n condition: (item: T, index?: number) => boolean,\n fn: (item: T, index?: number) => T\n ) => setState((current) => current.map((item) => (condition(item) ? fn(item) : item)));\n\n return [\n state,\n {\n setState,\n append,\n prepend,\n insert,\n pop,\n shift,\n apply,\n applyWhere,\n remove,\n reorder,\n setItem,\n setItemProp,\n },\n ];\n}\n"],"names":[],"mappings":";;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD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GAAG,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACxH,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI;AACJ,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,GAAG;AACT,MAAM,KAAK;AACX,MAAM,KAAK;AACX,MAAM,UAAU;AAChB,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,WAAW;AACjB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseListStateHandler<T> {
|
|
3
|
+
setState: React.Dispatch<React.SetStateAction<T[]>>;
|
|
4
|
+
append: (...items: T[]) => void;
|
|
5
|
+
prepend: (...items: T[]) => void;
|
|
6
|
+
insert: (index: number, ...items: T[]) => void;
|
|
7
|
+
pop: () => void;
|
|
8
|
+
shift: () => void;
|
|
9
|
+
apply: (fn: (item: T, index?: number) => T) => void;
|
|
10
|
+
applyWhere: (condition: (item: T, index?: number) => boolean, fn: (item: T, index?: number) => T) => void;
|
|
11
|
+
remove: (...indices: number[]) => void;
|
|
12
|
+
reorder: ({ from, to }: {
|
|
12
13
|
from: number;
|
|
13
14
|
to: number;
|
|
14
15
|
}) => void;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
setItem: (index: number, item: T) => void;
|
|
17
|
+
setItemProp: <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare type UseListState<T> = [T[], UseListStateHandler<T>];
|
|
20
|
+
export declare function useListState<T>(initialValue?: T[]): UseListState<T>;
|
|
18
21
|
//# sourceMappingURL=use-list-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-list-state.d.ts","sourceRoot":"","sources":["../../src/use-list-state/use-list-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-list-state.d.ts","sourceRoot":"","sources":["../../src/use-list-state/use-list-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACjC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/C,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC,KAAK,IAAI,CAAC;IACpD,UAAU,EAAE,CACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,EAC/C,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC,KAC/B,IAAI,CAAC;IACV,MAAM,EAAE,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;QA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