@mantine/hooks 9.4.0 → 9.4.1

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,25 +1,25 @@
1
1
  "use client";
2
- const require_use_force_update = require("../use-force-update/use-force-update.cjs");
3
2
  let react = require("react");
4
3
  //#region packages/@mantine/hooks/src/use-map/use-map.ts
5
4
  function useMap(initialState) {
6
- const mapRef = (0, react.useRef)(new Map(initialState));
7
- const forceUpdate = require_use_force_update.useForceUpdate();
8
- mapRef.current.set = (...args) => {
5
+ const [map, setMap] = (0, react.useState)(() => new Map(initialState));
6
+ const mapRef = (0, react.useRef)(map);
7
+ mapRef.current = map;
8
+ map.set = (...args) => {
9
9
  Map.prototype.set.apply(mapRef.current, args);
10
- forceUpdate();
10
+ setMap(new Map(mapRef.current));
11
11
  return mapRef.current;
12
12
  };
13
- mapRef.current.clear = (...args) => {
13
+ map.clear = (...args) => {
14
14
  Map.prototype.clear.apply(mapRef.current, args);
15
- forceUpdate();
15
+ setMap(new Map(mapRef.current));
16
16
  };
17
- mapRef.current.delete = (...args) => {
17
+ map.delete = (...args) => {
18
18
  const res = Map.prototype.delete.apply(mapRef.current, args);
19
- forceUpdate();
19
+ setMap(new Map(mapRef.current));
20
20
  return res;
21
21
  };
22
- return mapRef.current;
22
+ return map;
23
23
  }
24
24
  //#endregion
25
25
  exports.useMap = useMap;
@@ -1 +1 @@
1
- {"version":3,"file":"use-map.cjs","names":["useForceUpdate"],"sources":["../../src/use-map/use-map.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function useMap<T, V>(initialState?: [T, V][]): Map<T, V> {\n const mapRef = useRef(new Map<T, V>(initialState));\n const forceUpdate = useForceUpdate();\n\n mapRef.current.set = (...args) => {\n Map.prototype.set.apply(mapRef.current, args);\n forceUpdate();\n return mapRef.current;\n };\n\n mapRef.current.clear = (...args) => {\n Map.prototype.clear.apply(mapRef.current, args);\n forceUpdate();\n };\n\n mapRef.current.delete = (...args) => {\n const res = Map.prototype.delete.apply(mapRef.current, args);\n forceUpdate();\n\n return res;\n };\n\n return mapRef.current;\n}\n"],"mappings":";;;;AAGA,SAAgB,OAAa,cAAoC;CAC/D,MAAM,UAAA,GAAA,MAAA,OAAA,CAAgB,IAAI,IAAU,YAAY,CAAC;CACjD,MAAM,cAAcA,yBAAAA,eAAe;CAEnC,OAAO,QAAQ,OAAO,GAAG,SAAS;EAChC,IAAI,UAAU,IAAI,MAAM,OAAO,SAAS,IAAI;EAC5C,YAAY;EACZ,OAAO,OAAO;CAChB;CAEA,OAAO,QAAQ,SAAS,GAAG,SAAS;EAClC,IAAI,UAAU,MAAM,MAAM,OAAO,SAAS,IAAI;EAC9C,YAAY;CACd;CAEA,OAAO,QAAQ,UAAU,GAAG,SAAS;EACnC,MAAM,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,SAAS,IAAI;EAC3D,YAAY;EAEZ,OAAO;CACT;CAEA,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"use-map.cjs","names":[],"sources":["../../src/use-map/use-map.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nexport function useMap<T, V>(initialState?: [T, V][]): Map<T, V> {\n const [map, setMap] = useState(() => new Map<T, V>(initialState));\n const mapRef = useRef(map);\n mapRef.current = map;\n\n map.set = (...args) => {\n Map.prototype.set.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n return mapRef.current;\n };\n\n map.clear = (...args) => {\n Map.prototype.clear.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n };\n\n map.delete = (...args) => {\n const res = Map.prototype.delete.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n\n return res;\n };\n\n return map;\n}\n"],"mappings":";;;AAEA,SAAgB,OAAa,cAAoC;CAC/D,MAAM,CAAC,KAAK,WAAA,GAAA,MAAA,SAAA,OAAyB,IAAI,IAAU,YAAY,CAAC;CAChE,MAAM,UAAA,GAAA,MAAA,OAAA,CAAgB,GAAG;CACzB,OAAO,UAAU;CAEjB,IAAI,OAAO,GAAG,SAAS;EACrB,IAAI,UAAU,IAAI,MAAM,OAAO,SAAS,IAAI;EAC5C,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAC9B,OAAO,OAAO;CAChB;CAEA,IAAI,SAAS,GAAG,SAAS;EACvB,IAAI,UAAU,MAAM,MAAM,OAAO,SAAS,IAAI;EAC9C,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;CAChC;CAEA,IAAI,UAAU,GAAG,SAAS;EACxB,MAAM,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,SAAS,IAAI;EAC3D,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAE9B,OAAO;CACT;CAEA,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- const require_use_force_update = require("../use-force-update/use-force-update.cjs");
3
2
  let react = require("react");
4
3
  //#region packages/@mantine/hooks/src/use-set/use-set.ts
5
4
  function readonlySetLikeToSet(input) {
@@ -14,28 +13,29 @@ function readonlySetLikeToSet(input) {
14
13
  return result;
15
14
  }
16
15
  function useSet(values) {
17
- const setRef = (0, react.useRef)(new Set(values));
18
- const forceUpdate = require_use_force_update.useForceUpdate();
19
- setRef.current.add = (...args) => {
16
+ const [set, setSet] = (0, react.useState)(() => new Set(values));
17
+ const setRef = (0, react.useRef)(set);
18
+ setRef.current = set;
19
+ set.add = (...args) => {
20
20
  const res = Set.prototype.add.apply(setRef.current, args);
21
- forceUpdate();
21
+ setSet(new Set(setRef.current));
22
22
  return res;
23
23
  };
24
- setRef.current.clear = (...args) => {
24
+ set.clear = (...args) => {
25
25
  Set.prototype.clear.apply(setRef.current, args);
26
- forceUpdate();
26
+ setSet(new Set(setRef.current));
27
27
  };
28
- setRef.current.delete = (...args) => {
28
+ set.delete = (...args) => {
29
29
  const res = Set.prototype.delete.apply(setRef.current, args);
30
- forceUpdate();
30
+ setSet(new Set(setRef.current));
31
31
  return res;
32
32
  };
33
- setRef.current.union = (other) => {
33
+ set.union = (other) => {
34
34
  const result = new Set(setRef.current);
35
35
  readonlySetLikeToSet(other).forEach((item) => result.add(item));
36
36
  return result;
37
37
  };
38
- setRef.current.intersection = (other) => {
38
+ set.intersection = (other) => {
39
39
  const result = /* @__PURE__ */ new Set();
40
40
  const otherSet = readonlySetLikeToSet(other);
41
41
  setRef.current.forEach((item) => {
@@ -43,7 +43,7 @@ function useSet(values) {
43
43
  });
44
44
  return result;
45
45
  };
46
- setRef.current.difference = (other) => {
46
+ set.difference = (other) => {
47
47
  const result = /* @__PURE__ */ new Set();
48
48
  const otherSet = readonlySetLikeToSet(other);
49
49
  setRef.current.forEach((item) => {
@@ -51,7 +51,7 @@ function useSet(values) {
51
51
  });
52
52
  return result;
53
53
  };
54
- setRef.current.symmetricDifference = (other) => {
54
+ set.symmetricDifference = (other) => {
55
55
  const result = /* @__PURE__ */ new Set();
56
56
  const otherSet = readonlySetLikeToSet(other);
57
57
  setRef.current.forEach((item) => {
@@ -62,7 +62,7 @@ function useSet(values) {
62
62
  });
63
63
  return result;
64
64
  };
65
- return setRef.current;
65
+ return set;
66
66
  }
67
67
  //#endregion
68
68
  exports.useSet = useSet;
@@ -1 +1 @@
1
- {"version":3,"file":"use-set.cjs","names":["useForceUpdate"],"sources":["../../src/use-set/use-set.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function readonlySetLikeToSet<T>(input: ReadonlySetLike<T>): Set<T> {\n if (input instanceof Set) {\n return input;\n }\n const result = new Set<T>();\n const iterator = input.keys();\n let next = iterator.next();\n while (!next.done) {\n result.add(next.value);\n next = iterator.next();\n }\n return result;\n}\n\nexport function useSet<T>(values?: T[]): Set<T> {\n const setRef = useRef(new Set(values));\n const forceUpdate = useForceUpdate();\n\n setRef.current.add = (...args) => {\n const res = Set.prototype.add.apply(setRef.current, args);\n forceUpdate();\n return res;\n };\n\n setRef.current.clear = (...args) => {\n Set.prototype.clear.apply(setRef.current, args);\n forceUpdate();\n };\n\n setRef.current.delete = (...args) => {\n const res = Set.prototype.delete.apply(setRef.current, args);\n forceUpdate();\n return res;\n };\n\n setRef.current.union = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>(setRef.current as Set<T>);\n readonlySetLikeToSet(other).forEach((item) => result.add(item));\n return result;\n };\n\n setRef.current.intersection = <U>(other: ReadonlySetLike<U>): Set<T & U> => {\n const result = new Set<T & U>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (otherSet.has(item as any)) {\n result.add(item as T & U);\n }\n });\n return result;\n };\n\n setRef.current.difference = <U>(other: ReadonlySetLike<U>): Set<T> => {\n const result = new Set<T>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n return result;\n };\n\n setRef.current.symmetricDifference = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>();\n const otherSet = readonlySetLikeToSet(other);\n\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n\n otherSet.forEach((item) => {\n if (!setRef.current.has(item as any)) {\n result.add(item);\n }\n });\n\n return result;\n };\n\n return setRef.current;\n}\n"],"mappings":";;;;AAGA,SAAgB,qBAAwB,OAAmC;CACzE,IAAI,iBAAiB,KACnB,OAAO;CAET,MAAM,yBAAS,IAAI,IAAO;CAC1B,MAAM,WAAW,MAAM,KAAK;CAC5B,IAAI,OAAO,SAAS,KAAK;CACzB,OAAO,CAAC,KAAK,MAAM;EACjB,OAAO,IAAI,KAAK,KAAK;EACrB,OAAO,SAAS,KAAK;CACvB;CACA,OAAO;AACT;AAEA,SAAgB,OAAU,QAAsB;CAC9C,MAAM,UAAA,GAAA,MAAA,OAAA,CAAgB,IAAI,IAAI,MAAM,CAAC;CACrC,MAAM,cAAcA,yBAAAA,eAAe;CAEnC,OAAO,QAAQ,OAAO,GAAG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EnB,CAAC;EAED,OAAO;CACT;CAEA,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"use-set.cjs","names":[],"sources":["../../src/use-set/use-set.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nexport function readonlySetLikeToSet<T>(input: ReadonlySetLike<T>): Set<T> {\n if (input instanceof Set) {\n return input;\n }\n const result = new Set<T>();\n const iterator = input.keys();\n let next = iterator.next();\n while (!next.done) {\n result.add(next.value);\n next = iterator.next();\n }\n return result;\n}\n\nexport function useSet<T>(values?: T[]): Set<T> {\n const [set, setSet] = useState(() => new Set(values));\n const setRef = useRef(set);\n setRef.current = set;\n\n set.add = (...args) => {\n const res = Set.prototype.add.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n return res;\n };\n\n set.clear = (...args) => {\n Set.prototype.clear.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n };\n\n set.delete = (...args) => {\n const res = Set.prototype.delete.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n return res;\n };\n\n set.union = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>(setRef.current as Set<T>);\n readonlySetLikeToSet(other).forEach((item) => result.add(item));\n return result;\n };\n\n set.intersection = <U>(other: ReadonlySetLike<U>): Set<T & U> => {\n const result = new Set<T & U>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (otherSet.has(item as any)) {\n result.add(item as T & U);\n }\n });\n return result;\n };\n\n set.difference = <U>(other: ReadonlySetLike<U>): Set<T> => {\n const result = new Set<T>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n return result;\n };\n\n set.symmetricDifference = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>();\n const otherSet = readonlySetLikeToSet(other);\n\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n\n otherSet.forEach((item) => {\n if (!setRef.current.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AAI,IAAW,GAC1B,OAAO,IAAI,IAAa;EAE5B,CAAC;EACD,OAAO;CACT;CAEA,IAAI,cAAiB,UAAsC;EACzD,MAAM,yBAAS,IAAI,IAAO;EAC1B,MAAM,WAAW,qBAAqB,KAAK;EAC3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EACD,OAAO;CACT;CAEA,IAAI,uBAA0B,UAA0C;EACtE,MAAM,yBAAS,IAAI,IAAW;EAC9B,MAAM,WAAW,qBAAqB,KAAK;EAE3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,SAAS,SAAS,SAAS;GACzB,IAAI,CAAC,OAAO,QAAQ,IAAI,IAAW,GACjC,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,OAAO;CACT;CAEA,OAAO;AACT"}
@@ -1,25 +1,25 @@
1
1
  "use client";
2
- import { useForceUpdate } from "../use-force-update/use-force-update.mjs";
3
- import { useRef } from "react";
2
+ import { useRef, useState } from "react";
4
3
  //#region packages/@mantine/hooks/src/use-map/use-map.ts
5
4
  function useMap(initialState) {
6
- const mapRef = useRef(new Map(initialState));
7
- const forceUpdate = useForceUpdate();
8
- mapRef.current.set = (...args) => {
5
+ const [map, setMap] = useState(() => new Map(initialState));
6
+ const mapRef = useRef(map);
7
+ mapRef.current = map;
8
+ map.set = (...args) => {
9
9
  Map.prototype.set.apply(mapRef.current, args);
10
- forceUpdate();
10
+ setMap(new Map(mapRef.current));
11
11
  return mapRef.current;
12
12
  };
13
- mapRef.current.clear = (...args) => {
13
+ map.clear = (...args) => {
14
14
  Map.prototype.clear.apply(mapRef.current, args);
15
- forceUpdate();
15
+ setMap(new Map(mapRef.current));
16
16
  };
17
- mapRef.current.delete = (...args) => {
17
+ map.delete = (...args) => {
18
18
  const res = Map.prototype.delete.apply(mapRef.current, args);
19
- forceUpdate();
19
+ setMap(new Map(mapRef.current));
20
20
  return res;
21
21
  };
22
- return mapRef.current;
22
+ return map;
23
23
  }
24
24
  //#endregion
25
25
  export { useMap };
@@ -1 +1 @@
1
- {"version":3,"file":"use-map.mjs","names":[],"sources":["../../src/use-map/use-map.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function useMap<T, V>(initialState?: [T, V][]): Map<T, V> {\n const mapRef = useRef(new Map<T, V>(initialState));\n const forceUpdate = useForceUpdate();\n\n mapRef.current.set = (...args) => {\n Map.prototype.set.apply(mapRef.current, args);\n forceUpdate();\n return mapRef.current;\n };\n\n mapRef.current.clear = (...args) => {\n Map.prototype.clear.apply(mapRef.current, args);\n forceUpdate();\n };\n\n mapRef.current.delete = (...args) => {\n const res = Map.prototype.delete.apply(mapRef.current, args);\n forceUpdate();\n\n return res;\n };\n\n return mapRef.current;\n}\n"],"mappings":";;;;AAGA,SAAgB,OAAa,cAAoC;CAC/D,MAAM,SAAS,OAAO,IAAI,IAAU,YAAY,CAAC;CACjD,MAAM,cAAc,eAAe;CAEnC,OAAO,QAAQ,OAAO,GAAG,SAAS;EAChC,IAAI,UAAU,IAAI,MAAM,OAAO,SAAS,IAAI;EAC5C,YAAY;EACZ,OAAO,OAAO;CAChB;CAEA,OAAO,QAAQ,SAAS,GAAG,SAAS;EAClC,IAAI,UAAU,MAAM,MAAM,OAAO,SAAS,IAAI;EAC9C,YAAY;CACd;CAEA,OAAO,QAAQ,UAAU,GAAG,SAAS;EACnC,MAAM,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,SAAS,IAAI;EAC3D,YAAY;EAEZ,OAAO;CACT;CAEA,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"use-map.mjs","names":[],"sources":["../../src/use-map/use-map.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nexport function useMap<T, V>(initialState?: [T, V][]): Map<T, V> {\n const [map, setMap] = useState(() => new Map<T, V>(initialState));\n const mapRef = useRef(map);\n mapRef.current = map;\n\n map.set = (...args) => {\n Map.prototype.set.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n return mapRef.current;\n };\n\n map.clear = (...args) => {\n Map.prototype.clear.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n };\n\n map.delete = (...args) => {\n const res = Map.prototype.delete.apply(mapRef.current, args);\n setMap(new Map(mapRef.current));\n\n return res;\n };\n\n return map;\n}\n"],"mappings":";;;AAEA,SAAgB,OAAa,cAAoC;CAC/D,MAAM,CAAC,KAAK,UAAU,eAAe,IAAI,IAAU,YAAY,CAAC;CAChE,MAAM,SAAS,OAAO,GAAG;CACzB,OAAO,UAAU;CAEjB,IAAI,OAAO,GAAG,SAAS;EACrB,IAAI,UAAU,IAAI,MAAM,OAAO,SAAS,IAAI;EAC5C,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAC9B,OAAO,OAAO;CAChB;CAEA,IAAI,SAAS,GAAG,SAAS;EACvB,IAAI,UAAU,MAAM,MAAM,OAAO,SAAS,IAAI;EAC9C,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;CAChC;CAEA,IAAI,UAAU,GAAG,SAAS;EACxB,MAAM,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,SAAS,IAAI;EAC3D,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAE9B,OAAO;CACT;CAEA,OAAO;AACT"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
- import { useForceUpdate } from "../use-force-update/use-force-update.mjs";
3
- import { useRef } from "react";
2
+ import { useRef, useState } from "react";
4
3
  //#region packages/@mantine/hooks/src/use-set/use-set.ts
5
4
  function readonlySetLikeToSet(input) {
6
5
  if (input instanceof Set) return input;
@@ -14,28 +13,29 @@ function readonlySetLikeToSet(input) {
14
13
  return result;
15
14
  }
16
15
  function useSet(values) {
17
- const setRef = useRef(new Set(values));
18
- const forceUpdate = useForceUpdate();
19
- setRef.current.add = (...args) => {
16
+ const [set, setSet] = useState(() => new Set(values));
17
+ const setRef = useRef(set);
18
+ setRef.current = set;
19
+ set.add = (...args) => {
20
20
  const res = Set.prototype.add.apply(setRef.current, args);
21
- forceUpdate();
21
+ setSet(new Set(setRef.current));
22
22
  return res;
23
23
  };
24
- setRef.current.clear = (...args) => {
24
+ set.clear = (...args) => {
25
25
  Set.prototype.clear.apply(setRef.current, args);
26
- forceUpdate();
26
+ setSet(new Set(setRef.current));
27
27
  };
28
- setRef.current.delete = (...args) => {
28
+ set.delete = (...args) => {
29
29
  const res = Set.prototype.delete.apply(setRef.current, args);
30
- forceUpdate();
30
+ setSet(new Set(setRef.current));
31
31
  return res;
32
32
  };
33
- setRef.current.union = (other) => {
33
+ set.union = (other) => {
34
34
  const result = new Set(setRef.current);
35
35
  readonlySetLikeToSet(other).forEach((item) => result.add(item));
36
36
  return result;
37
37
  };
38
- setRef.current.intersection = (other) => {
38
+ set.intersection = (other) => {
39
39
  const result = /* @__PURE__ */ new Set();
40
40
  const otherSet = readonlySetLikeToSet(other);
41
41
  setRef.current.forEach((item) => {
@@ -43,7 +43,7 @@ function useSet(values) {
43
43
  });
44
44
  return result;
45
45
  };
46
- setRef.current.difference = (other) => {
46
+ set.difference = (other) => {
47
47
  const result = /* @__PURE__ */ new Set();
48
48
  const otherSet = readonlySetLikeToSet(other);
49
49
  setRef.current.forEach((item) => {
@@ -51,7 +51,7 @@ function useSet(values) {
51
51
  });
52
52
  return result;
53
53
  };
54
- setRef.current.symmetricDifference = (other) => {
54
+ set.symmetricDifference = (other) => {
55
55
  const result = /* @__PURE__ */ new Set();
56
56
  const otherSet = readonlySetLikeToSet(other);
57
57
  setRef.current.forEach((item) => {
@@ -62,7 +62,7 @@ function useSet(values) {
62
62
  });
63
63
  return result;
64
64
  };
65
- return setRef.current;
65
+ return set;
66
66
  }
67
67
  //#endregion
68
68
  export { useSet };
@@ -1 +1 @@
1
- {"version":3,"file":"use-set.mjs","names":[],"sources":["../../src/use-set/use-set.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function readonlySetLikeToSet<T>(input: ReadonlySetLike<T>): Set<T> {\n if (input instanceof Set) {\n return input;\n }\n const result = new Set<T>();\n const iterator = input.keys();\n let next = iterator.next();\n while (!next.done) {\n result.add(next.value);\n next = iterator.next();\n }\n return result;\n}\n\nexport function useSet<T>(values?: T[]): Set<T> {\n const setRef = useRef(new Set(values));\n const forceUpdate = useForceUpdate();\n\n setRef.current.add = (...args) => {\n const res = Set.prototype.add.apply(setRef.current, args);\n forceUpdate();\n return res;\n };\n\n setRef.current.clear = (...args) => {\n Set.prototype.clear.apply(setRef.current, args);\n forceUpdate();\n };\n\n setRef.current.delete = (...args) => {\n const res = Set.prototype.delete.apply(setRef.current, args);\n forceUpdate();\n return res;\n };\n\n setRef.current.union = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>(setRef.current as Set<T>);\n readonlySetLikeToSet(other).forEach((item) => result.add(item));\n return result;\n };\n\n setRef.current.intersection = <U>(other: ReadonlySetLike<U>): Set<T & U> => {\n const result = new Set<T & U>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (otherSet.has(item as any)) {\n result.add(item as T & U);\n }\n });\n return result;\n };\n\n setRef.current.difference = <U>(other: ReadonlySetLike<U>): Set<T> => {\n const result = new Set<T>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n return result;\n };\n\n setRef.current.symmetricDifference = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>();\n const otherSet = readonlySetLikeToSet(other);\n\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n\n otherSet.forEach((item) => {\n if (!setRef.current.has(item as any)) {\n result.add(item);\n }\n });\n\n return result;\n };\n\n return setRef.current;\n}\n"],"mappings":";;;;A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C/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EACD,OAAO;CACT;CAEA,OAAO,QAAQ,uBAA0B,UAA0C;EACjF,MAAM,yBAAS,IAAI,IAAW;EAC9B,MAAM,WAAW,qBAAqB,KAAK;EAE3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,SAAS,SAAS,SAAS;GACzB,IAAI,CAAC,OAAO,QAAQ,IAAI,IAAW,GACjC,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,OAAO;CACT;CAEA,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"use-set.mjs","names":[],"sources":["../../src/use-set/use-set.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nexport function readonlySetLikeToSet<T>(input: ReadonlySetLike<T>): Set<T> {\n if (input instanceof Set) {\n return input;\n }\n const result = new Set<T>();\n const iterator = input.keys();\n let next = iterator.next();\n while (!next.done) {\n result.add(next.value);\n next = iterator.next();\n }\n return result;\n}\n\nexport function useSet<T>(values?: T[]): Set<T> {\n const [set, setSet] = useState(() => new Set(values));\n const setRef = useRef(set);\n setRef.current = set;\n\n set.add = (...args) => {\n const res = Set.prototype.add.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n return res;\n };\n\n set.clear = (...args) => {\n Set.prototype.clear.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n };\n\n set.delete = (...args) => {\n const res = Set.prototype.delete.apply(setRef.current, args);\n setSet(new Set(setRef.current));\n return res;\n };\n\n set.union = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>(setRef.current as Set<T>);\n readonlySetLikeToSet(other).forEach((item) => result.add(item));\n return result;\n };\n\n set.intersection = <U>(other: ReadonlySetLike<U>): Set<T & U> => {\n const result = new Set<T & U>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (otherSet.has(item as any)) {\n result.add(item as T & U);\n }\n });\n return result;\n };\n\n set.difference = <U>(other: ReadonlySetLike<U>): Set<T> => {\n const result = new Set<T>();\n const otherSet = readonlySetLikeToSet(other);\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n return result;\n };\n\n set.symmetricDifference = <U>(other: ReadonlySetLike<U>): Set<T | U> => {\n const result = new Set<T | U>();\n const otherSet = readonlySetLikeToSet(other);\n\n setRef.current.forEach((item) => {\n if (!otherSet.has(item as any)) {\n result.add(item);\n }\n });\n\n otherSet.forEach((item) => {\n if (!setRef.current.has(item as any)) {\n result.add(item);\n }\n });\n\n return result;\n };\n\n return set;\n}\n"],"mappings":";;;AAEA,SAAgB,qBAAwB,OAAmC;CACzE,IAAI,iBAAiB,KACnB,OAAO;CAET,MAAM,yBAAS,IAAI,IAAO;CAC1B,MAAM,WAAW,MAAM,KAAK;CAC5B,IAAI,OAAO,SAAS,KAAK;CACzB,OAAO,CAAC,KAAK,MAAM;EACjB,OAAO,IAAI,KAAK,KAAK;EACrB,OAAO,SAAS,KAAK;CACvB;CACA,OAAO;AACT;AAEA,SAAgB,OAAU,QAAsB;CAC9C,MAAM,CAAC,KAAK,UAAU,eAAe,IAAI,IAAI,MAAM,CAAC;CACpD,MAAM,SAAS,OAAO,GAAG;CACzB,OAAO,UAAU;CAEjB,IAAI,OAAO,GAAG,SAAS;EACrB,MAAM,MAAM,IAAI,UAAU,IAAI,MAAM,OAAO,SAAS,IAAI;EACxD,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAC9B,OAAO;CACT;CAEA,IAAI,SAAS,GAAG,SAAS;EACvB,IAAI,UAAU,MAAM,MAAM,OAAO,SAAS,IAAI;EAC9C,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;CAChC;CAEA,IAAI,UAAU,GAAG,SAAS;EACxB,MAAM,MAAM,IAAI,UAAU,OAAO,MAAM,OAAO,SAAS,IAAI;EAC3D,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC;EAC9B,OAAO;CACT;CAEA,IAAI,SAAY,UAA0C;EACxD,MAAM,SAAS,IAAI,IAAW,OAAO,OAAiB;EACtD,qBAAqB,KAAK,CAAC,CAAC,SAAS,SAAS,OAAO,IAAI,IAAI,CAAC;EAC9D,OAAO;CACT;CAEA,IAAI,gBAAmB,UAA0C;EAC/D,MAAM,yBAAS,IAAI,IAAW;EAC9B,MAAM,WAAW,qBAAqB,KAAK;EAC3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,SAAS,IAAI,IAAW,GAC1B,OAAO,IAAI,IAAa;EAE5B,CAAC;EACD,OAAO;CACT;CAEA,IAAI,cAAiB,UAAsC;EACzD,MAAM,yBAAS,IAAI,IAAO;EAC1B,MAAM,WAAW,qBAAqB,KAAK;EAC3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EACD,OAAO;CACT;CAEA,IAAI,uBAA0B,UAA0C;EACtE,MAAM,yBAAS,IAAI,IAAW;EAC9B,MAAM,WAAW,qBAAqB,KAAK;EAE3C,OAAO,QAAQ,SAAS,SAAS;GAC/B,IAAI,CAAC,SAAS,IAAI,IAAW,GAC3B,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,SAAS,SAAS,SAAS;GACzB,IAAI,CAAC,OAAO,QAAQ,IAAI,IAAW,GACjC,OAAO,IAAI,IAAI;EAEnB,CAAC;EAED,OAAO;CACT;CAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/hooks",
3
- "version": "9.4.0",
3
+ "version": "9.4.1",
4
4
  "description": "A collection of 50+ hooks for state and UI management",
5
5
  "homepage": "https://mantine.dev",
6
6
  "license": "MIT",