@tedi-design-system/react 19.1.0-rc.18 → 19.1.0-rc.19
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.
- package/_virtual/index.es13.js +2 -2
- package/_virtual/index.es14.js +2 -2
- package/bundle-stats.html +1 -1
- package/community.cjs.js +1 -1
- package/community.es.js +146 -142
- package/external/@floating-ui/core/dist/floating-ui.core.es.js +1 -1
- package/external/@floating-ui/dom/dist/floating-ui.dom.es.js +2 -2
- package/external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js +5 -5
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/external/react-is/index.cjs.js +1 -1
- package/external/react-is/index.es.js +1 -1
- package/external/toposort/index.cjs.js +1 -1
- package/external/toposort/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/form/category-search/category-search.cjs.js +1 -0
- package/src/community/components/form/category-search/category-search.d.ts +9 -0
- package/src/community/components/form/category-search/category-search.es.js +297 -0
- package/src/community/components/form/category-search/category-search.module.scss.cjs.js +1 -0
- package/src/community/components/form/category-search/category-search.module.scss.es.js +21 -0
- package/src/community/components/form/category-search/category-search.types.d.ts +162 -0
- package/src/community/components/form/category-search/define-category-search-category.cjs.js +1 -0
- package/src/community/components/form/category-search/define-category-search-category.d.ts +7 -0
- package/src/community/components/form/category-search/define-category-search-category.es.js +25 -0
- package/src/community/components/form/category-search/index.d.ts +3 -0
- package/src/community/components/form/category-search/use-category-search.cjs.js +1 -0
- package/src/community/components/form/category-search/use-category-search.d.ts +17 -0
- package/src/community/components/form/category-search/use-category-search.es.js +64 -0
- package/src/community/index.d.ts +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useState as S, useRef as m, useEffect as o } from "react";
|
|
2
|
+
function b(u) {
|
|
3
|
+
const [f, l] = S(
|
|
4
|
+
() => new Map(u.map((t) => [t.id, { draft: t.initialValue(), status: "idle" }]))
|
|
5
|
+
), s = m(/* @__PURE__ */ new Map());
|
|
6
|
+
o(() => {
|
|
7
|
+
const t = s.current;
|
|
8
|
+
return () => {
|
|
9
|
+
t.forEach((n) => n.abort()), t.clear();
|
|
10
|
+
};
|
|
11
|
+
}, []), o(() => {
|
|
12
|
+
const t = new Set(u.map((n) => n.id));
|
|
13
|
+
if (t.size !== u.length) throw new Error("CategorySearch category IDs must be unique.");
|
|
14
|
+
s.current.forEach((n, e) => {
|
|
15
|
+
t.has(e) || (n.abort(), s.current.delete(e));
|
|
16
|
+
}), l((n) => {
|
|
17
|
+
const e = new Map(n);
|
|
18
|
+
let r = !1;
|
|
19
|
+
for (const a of u)
|
|
20
|
+
e.has(a.id) || (e.set(a.id, { draft: a.initialValue(), status: "idle" }), r = !0);
|
|
21
|
+
for (const a of n.keys())
|
|
22
|
+
t.has(a) || (e.delete(a), r = !0);
|
|
23
|
+
return r ? e : n;
|
|
24
|
+
});
|
|
25
|
+
}, [u]);
|
|
26
|
+
function c(t, n) {
|
|
27
|
+
l((e) => {
|
|
28
|
+
const r = e.get(t);
|
|
29
|
+
if (!r) return e;
|
|
30
|
+
const a = new Map(e);
|
|
31
|
+
return a.set(t, { ...r, ...n }), a;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function d(t, n) {
|
|
35
|
+
c(t, { draft: n });
|
|
36
|
+
}
|
|
37
|
+
function i(t) {
|
|
38
|
+
var n;
|
|
39
|
+
(n = s.current.get(t)) == null || n.abort(), s.current.delete(t), c(t, { status: "idle" });
|
|
40
|
+
}
|
|
41
|
+
function h(t) {
|
|
42
|
+
i(t.id), c(t.id, { draft: t.initialValue(), completedSearch: void 0, status: "idle" });
|
|
43
|
+
}
|
|
44
|
+
async function w(t, n) {
|
|
45
|
+
const e = t.id;
|
|
46
|
+
i(e);
|
|
47
|
+
const r = new AbortController();
|
|
48
|
+
s.current.set(e, r), c(e, { status: "loading" });
|
|
49
|
+
try {
|
|
50
|
+
const a = await t.onSearch(n, { signal: r.signal });
|
|
51
|
+
if (s.current.get(e) !== r) return;
|
|
52
|
+
c(e, { completedSearch: { input: n, result: a }, status: "idle" });
|
|
53
|
+
} catch {
|
|
54
|
+
if (s.current.get(e) !== r) return;
|
|
55
|
+
c(e, { status: "error" });
|
|
56
|
+
} finally {
|
|
57
|
+
s.current.get(e) === r && s.current.delete(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { states: f, changeDraft: d, search: w, clear: h, cancel: i };
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
b as useCategorySearch
|
|
64
|
+
};
|
package/src/community/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './components/dropdown/dropdown';
|
|
|
6
6
|
export * from './components/stepper';
|
|
7
7
|
export * from './components/card';
|
|
8
8
|
export * from './components/feedback/feedback';
|
|
9
|
+
export * from './components/form/category-search';
|
|
9
10
|
export * from './components/form/hidden-field/hidden-field';
|
|
10
11
|
export * from './components/form/choice-group';
|
|
11
12
|
export * from './components/form/check/check';
|