@arcadeai/design-system 1.5.1 → 1.7.0
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/dist/{arcade-DSu1Vp41.js → arcade-DzMbb7xi.js} +512 -586
- package/dist/components/index.js +302 -300
- package/dist/components/ui/atoms/alert-dialog.d.ts +14 -0
- package/dist/components/ui/atoms/alert-dialog.js +248 -0
- package/dist/components/ui/atoms/command.js +1 -1
- package/dist/components/ui/atoms/dialog.js +1 -1
- package/dist/components/ui/atoms/icons/codesandbox.d.ts +3 -0
- package/dist/components/ui/atoms/icons/codesandbox.js +26 -0
- package/dist/components/ui/atoms/icons/index.d.ts +1 -0
- package/dist/components/ui/atoms/icons/index.js +182 -180
- package/dist/components/ui/atoms/index.js +285 -283
- package/dist/components/ui/atoms/sheet.js +1 -1
- package/dist/components/ui/index.js +302 -300
- package/dist/components/ui/molecules/toolkit-picker-trigger.js +29 -32
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-filter.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-search.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-selection.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.d.ts +11 -3
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.js +141 -99
- package/dist/components/ui/organisms/toolkit-picker/index.d.ts +2 -0
- package/dist/components/ui/organisms/toolkit-picker/index.js +3 -2
- package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.d.ts +2 -0
- package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.js +247 -55
- package/dist/components/ui/organisms/toolkit-picker/toolkit-picker.test.js +2 -2
- package/dist/components/ui/utils/memo.test.js +1 -1
- package/dist/{index-BzU0xzeS.js → index-Dkey23PG.js} +3 -1
- package/dist/lib/arcade/arcade.js +3 -2
- package/dist/lib/arcade/arcade.test.js +2 -2
- package/dist/lib/utils.test.js +1 -1
- package/dist/main.js +313 -311
- package/dist/metadata/oauth-providers.js +9 -9
- package/dist/metadata/toolkits.js +383 -227
- package/dist/metadata/types.d.ts +2 -1
- package/dist/{react.esm-CFMQn0EI.js → react.esm-CAxz4dXo.js} +1 -1
- package/dist/{vi.bdSIJ99Y-CQ1FdEM8.js → vi.bdSIJ99Y-hyudrc3R.js} +3880 -3436
- package/dist/web-sgv-FK6q.js +84 -0
- package/package.json +2 -1
|
@@ -4,37 +4,37 @@ import { Badge as y } from "../atoms/badge.js";
|
|
|
4
4
|
import { Button as z } from "../atoms/button.js";
|
|
5
5
|
import { getToolkitIcon as j } from "../atoms/icons/utils.js";
|
|
6
6
|
import { Tooltip as C, TooltipTrigger as $, TooltipContent as L } from "../atoms/tooltip.js";
|
|
7
|
-
import { c as
|
|
7
|
+
import { c as p } from "../../../utils-Db4QWi-E.js";
|
|
8
8
|
import { useToolkitPicker as I } from "../organisms/toolkit-picker/hooks/use-toolkit-picker.js";
|
|
9
9
|
function D({
|
|
10
|
-
maxVisibleIcons:
|
|
11
|
-
className:
|
|
12
|
-
countType:
|
|
13
|
-
loading:
|
|
10
|
+
maxVisibleIcons: g = 2,
|
|
11
|
+
className: b,
|
|
12
|
+
countType: s = "toolkits",
|
|
13
|
+
loading: o = !1,
|
|
14
14
|
...n
|
|
15
15
|
}) {
|
|
16
16
|
const {
|
|
17
|
-
state: { committedToolkits: f, committedTools:
|
|
18
|
-
} = I(),
|
|
19
|
-
const
|
|
17
|
+
state: { committedToolkits: f, committedTools: N }
|
|
18
|
+
} = I(), i = Array.from(f.keys()), l = i.length, x = N.size, c = i.slice(0, g).map((a) => {
|
|
19
|
+
const r = f.get(a);
|
|
20
20
|
return j({
|
|
21
|
-
metadataIcon:
|
|
21
|
+
metadataIcon: r?.metadata?.icon,
|
|
22
22
|
toolkitName: a
|
|
23
23
|
});
|
|
24
|
-
}), k = Math.max(l - c.length, 0),
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
let u = `Select ${
|
|
28
|
-
return
|
|
24
|
+
}), k = Math.max(l - c.length, 0), T = s === "tools";
|
|
25
|
+
let d = "Toolkits", m = l;
|
|
26
|
+
T && (d = "Tools", m = x);
|
|
27
|
+
let u = `Select ${s === "tools" ? "Tools" : "Toolkits"}`;
|
|
28
|
+
return o ? u = "Loading toolkits..." : l > 0 && (u = `${m} ${d.toLowerCase()} selected`), /* @__PURE__ */ e(
|
|
29
29
|
z,
|
|
30
30
|
{
|
|
31
31
|
...n,
|
|
32
32
|
"aria-label": u,
|
|
33
|
-
className:
|
|
34
|
-
disabled:
|
|
33
|
+
className: p("gap-2 bg-transparent transition-colors", b),
|
|
34
|
+
disabled: o,
|
|
35
35
|
size: n.size ?? "sm",
|
|
36
36
|
variant: n.variant ?? "outline",
|
|
37
|
-
children:
|
|
37
|
+
children: o ? /* @__PURE__ */ t(h, { children: [
|
|
38
38
|
/* @__PURE__ */ e(v, { className: "h-4 w-4 animate-spin" }),
|
|
39
39
|
/* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
|
|
40
40
|
/* @__PURE__ */ e("div", { className: "h-4 w-16 animate-pulse rounded bg-neutral-200 dark:bg-neutral-700" }),
|
|
@@ -42,23 +42,20 @@ function D({
|
|
|
42
42
|
] })
|
|
43
43
|
] }) : /* @__PURE__ */ t(h, { children: [
|
|
44
44
|
l > 0 && /* @__PURE__ */ t(C, { children: [
|
|
45
|
-
/* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ t("span", { className: "mr-
|
|
46
|
-
c.map((a,
|
|
45
|
+
/* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ t("span", { className: "mr-2 flex items-center", children: [
|
|
46
|
+
c.map((a, r) => /* @__PURE__ */ e(
|
|
47
47
|
"div",
|
|
48
48
|
{
|
|
49
|
-
className:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
style: { zIndex: s + 1 },
|
|
54
|
-
children: /* @__PURE__ */ e("div", { className: "flex size-5 items-center justify-center rounded-full bg-neutral-200 p-2 ring-1 ring-black/15 dark:bg-neutral-800 dark:ring-white/15", children: /* @__PURE__ */ e(a, { className: "h-2.5 w-2.5" }) })
|
|
49
|
+
className: p("relative first:ml-0", r > 0 && "-ml-2"),
|
|
50
|
+
style: { zIndex: r + 1 },
|
|
51
|
+
children: /* @__PURE__ */ e("div", { className: "flex size-6 items-center justify-center rounded-xl bg-gradient-to-br from-white to-neutral-50 p-1.5 shadow-lg ring-1 ring-neutral-200/80 transition-all hover:scale-110 hover:shadow-xl dark:from-neutral-800 dark:to-neutral-900 dark:ring-neutral-700/80", children: /* @__PURE__ */ e(a, { className: "h-3 w-3 text-neutral-700 dark:text-neutral-300" }) })
|
|
55
52
|
},
|
|
56
|
-
`${a.name || "icon"}-${
|
|
53
|
+
`${a.name || "icon"}-${r}`
|
|
57
54
|
)),
|
|
58
55
|
k > 0 && /* @__PURE__ */ t(
|
|
59
56
|
"span",
|
|
60
57
|
{
|
|
61
|
-
className: "
|
|
58
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded-xl bg-gradient-to-br from-blue-50 to-blue-100 font-bold text-[11px] text-blue-800 shadow-lg ring-1 ring-blue-200/80 dark:from-blue-900/40 dark:to-blue-800/40 dark:text-blue-200 dark:ring-blue-700/80",
|
|
62
59
|
style: { zIndex: c.length + 10 },
|
|
63
60
|
children: [
|
|
64
61
|
"+",
|
|
@@ -72,14 +69,14 @@ function D({
|
|
|
72
69
|
/* @__PURE__ */ e("span", { className: "font-semibold text-neutral-800 dark:text-neutral-200", children: "Toolkits" }),
|
|
73
70
|
/* @__PURE__ */ t("span", { className: "text-neutral-700 dark:text-neutral-300", children: [
|
|
74
71
|
": ",
|
|
75
|
-
|
|
72
|
+
i.join(", ")
|
|
76
73
|
] })
|
|
77
74
|
] }),
|
|
78
75
|
/* @__PURE__ */ t("li", { children: [
|
|
79
76
|
/* @__PURE__ */ e("span", { className: "font-semibold text-neutral-800 dark:text-neutral-200", children: "Tools" }),
|
|
80
77
|
/* @__PURE__ */ t("span", { className: "text-neutral-700 dark:text-neutral-300", children: [
|
|
81
78
|
": ",
|
|
82
|
-
|
|
79
|
+
x,
|
|
83
80
|
" selected"
|
|
84
81
|
] })
|
|
85
82
|
] })
|
|
@@ -89,12 +86,12 @@ function D({
|
|
|
89
86
|
/* @__PURE__ */ e(w, { className: "h-4 w-4" }),
|
|
90
87
|
/* @__PURE__ */ t("span", { className: "truncate text-sm", children: [
|
|
91
88
|
"Select ",
|
|
92
|
-
|
|
89
|
+
s === "tools" ? "Tools" : "Toolkits"
|
|
93
90
|
] })
|
|
94
91
|
] }),
|
|
95
92
|
l > 0 && /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-2 truncate text-sm", children: [
|
|
96
|
-
|
|
97
|
-
/* @__PURE__ */ e(y, { className: "px-1.5 py-0 text-[11px]", variant: "default", children:
|
|
93
|
+
d,
|
|
94
|
+
/* @__PURE__ */ e(y, { className: "px-1.5 py-0 text-[11px]", variant: "default", children: m })
|
|
98
95
|
] })
|
|
99
96
|
] })
|
|
100
97
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { r as c, a as i } from "../../../../../react.esm-
|
|
2
|
+
import { r as c, a as i } from "../../../../../react.esm-CAxz4dXo.js";
|
|
3
3
|
import { mockToolkitCollection as a } from "../mocks/toolkit-collection.js";
|
|
4
4
|
import { useToolkitPicker as n, ToolkitPickerProvider as k } from "./use-toolkit-picker.js";
|
|
5
|
-
import { d as T, b as d, i as u, g as e, v as p } from "../../../../../vi.bdSIJ99Y-
|
|
5
|
+
import { d as T, b as d, i as u, g as e, v as p } from "../../../../../vi.bdSIJ99Y-hyudrc3R.js";
|
|
6
6
|
T("useToolkitPicker - Filter Tests", () => {
|
|
7
7
|
d(() => {
|
|
8
8
|
p.clearAllMocks();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { r as c, a as l } from "../../../../../react.esm-
|
|
2
|
+
import { r as c, a as l } from "../../../../../react.esm-CAxz4dXo.js";
|
|
3
3
|
import { mockToolkitCollection as a } from "../mocks/toolkit-collection.js";
|
|
4
4
|
import { useToolkitPicker as n, ToolkitPickerProvider as u } from "./use-toolkit-picker.js";
|
|
5
|
-
import { d as k, b as h, i as d, g as o, v as m } from "../../../../../vi.bdSIJ99Y-
|
|
5
|
+
import { d as k, b as h, i as d, g as o, v as m } from "../../../../../vi.bdSIJ99Y-hyudrc3R.js";
|
|
6
6
|
k("useToolkitPicker - Search Tests", () => {
|
|
7
7
|
h(() => {
|
|
8
8
|
m.clearAllMocks();
|
package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-selection.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { r as i, a as t } from "../../../../../react.esm-
|
|
2
|
+
import { r as i, a as t } from "../../../../../react.esm-CAxz4dXo.js";
|
|
3
3
|
import { simpleMockToolkitCollection as c } from "../mocks/toolkit-collection.js";
|
|
4
4
|
import { useToolkitPicker as a, ToolkitPickerProvider as n } from "./use-toolkit-picker.js";
|
|
5
|
-
import { d as u, b as k, i as d, g as o, v as m } from "../../../../../vi.bdSIJ99Y-
|
|
5
|
+
import { d as u, b as k, i as d, g as o, v as m } from "../../../../../vi.bdSIJ99Y-hyudrc3R.js";
|
|
6
6
|
u("useToolkitPicker - Selection Tests", () => {
|
|
7
7
|
k(() => {
|
|
8
8
|
m.clearAllMocks();
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ProcessedTool, ProcessedToolkit, ToolkitCollection } from '../../../../../lib/arcade/arcade';
|
|
3
3
|
import { SelectionMode } from '../index';
|
|
4
|
+
export type ToolkitPickerInitialProps = {
|
|
5
|
+
selectedToolkits?: string[];
|
|
6
|
+
selectedTools?: string[];
|
|
7
|
+
committedToolkits?: string[];
|
|
8
|
+
committedTools?: string[];
|
|
9
|
+
};
|
|
4
10
|
export type UseToolkitPickerProps = {
|
|
5
11
|
toolkitCollection?: ToolkitCollection;
|
|
6
12
|
selectionMode?: SelectionMode;
|
|
13
|
+
initialProps?: ToolkitPickerInitialProps;
|
|
7
14
|
};
|
|
8
15
|
export type ToolkitPickerTab = 'toolkits' | 'tools';
|
|
9
16
|
export type ToolkitSelectionMap = Map<string, ProcessedToolkit>;
|
|
10
17
|
export type ToolSelectionMap = Map<string, boolean>;
|
|
11
|
-
type UseToolkitPickerState =
|
|
18
|
+
type UseToolkitPickerState = {
|
|
19
|
+
toolkitCollection?: ToolkitCollection;
|
|
20
|
+
selectionMode: SelectionMode;
|
|
12
21
|
selectedToolkits: ToolkitSelectionMap;
|
|
13
22
|
selectedTools: ToolSelectionMap;
|
|
14
23
|
committedToolkits: ToolkitSelectionMap;
|
|
@@ -18,7 +27,6 @@ type UseToolkitPickerState = UseToolkitPickerProps & {
|
|
|
18
27
|
searchQuery: string;
|
|
19
28
|
toolkitFilter: string;
|
|
20
29
|
activeTab: ToolkitPickerTab;
|
|
21
|
-
selectionMode: SelectionMode;
|
|
22
30
|
};
|
|
23
31
|
type ToolkitPickerContextType = {
|
|
24
32
|
state: UseToolkitPickerState;
|
|
@@ -34,7 +42,7 @@ type ToolkitPickerContextType = {
|
|
|
34
42
|
clearFilter: () => void;
|
|
35
43
|
setActiveTab: (tab: ToolkitPickerTab) => void;
|
|
36
44
|
};
|
|
37
|
-
export declare function ToolkitPickerProvider({ children,
|
|
45
|
+
export declare function ToolkitPickerProvider({ children, toolkitCollection, selectionMode, initialProps, }: {
|
|
38
46
|
children: ReactNode;
|
|
39
47
|
} & UseToolkitPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
40
48
|
export declare function useToolkitPicker(): ToolkitPickerContextType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as S, useReducer as
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as S, useReducer as E, useEffect as C, useContext as w } from "react";
|
|
3
3
|
const r = (o, t) => t ? new Set(
|
|
4
4
|
o.filter((e) => e.searchableText?.toLowerCase().includes(t))
|
|
5
|
-
) : new Set(o),
|
|
5
|
+
) : new Set(o), d = (o, t) => {
|
|
6
6
|
if (!t)
|
|
7
7
|
return [];
|
|
8
8
|
const e = t.toolkitMap?.get(o);
|
|
@@ -10,9 +10,9 @@ const r = (o, t) => t ? new Set(
|
|
|
10
10
|
return [];
|
|
11
11
|
if (!t.tools?.length)
|
|
12
12
|
return [];
|
|
13
|
-
const l = new Set(e.tools.map((
|
|
14
|
-
return t.tools.filter((
|
|
15
|
-
},
|
|
13
|
+
const l = new Set(e.tools.map((i) => i.fully_qualified_name));
|
|
14
|
+
return t.tools.filter((i) => l.has(i.fully_qualified_name));
|
|
15
|
+
}, _ = (o, t, e) => e ? e.toolkitMap?.get(t)?.tools?.some((i) => o.has(i.fully_qualified_name)) ?? !1 : !1, h = (o, t, e) => !t.size && e.size ? "tools" : t.size && !e.size ? "toolkits" : o, y = (o, t) => {
|
|
16
16
|
if (!t)
|
|
17
17
|
return {
|
|
18
18
|
selectedToolkits: /* @__PURE__ */ new Map(),
|
|
@@ -20,22 +20,22 @@ const r = (o, t) => t ? new Set(
|
|
|
20
20
|
};
|
|
21
21
|
const e = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
22
22
|
if (o)
|
|
23
|
-
for (const
|
|
24
|
-
l.set(
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
28
|
-
|
|
23
|
+
for (const i of o) {
|
|
24
|
+
l.set(i, !0);
|
|
25
|
+
const n = t.toolToToolkitMap?.get(i);
|
|
26
|
+
if (n) {
|
|
27
|
+
const s = t.toolkitMap?.get(n);
|
|
28
|
+
s && e.set(n, s);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
else
|
|
32
|
-
for (const
|
|
33
|
-
e.set(
|
|
34
|
-
for (const
|
|
35
|
-
l.set(
|
|
32
|
+
for (const i of t.toolkits) {
|
|
33
|
+
e.set(i.name, i);
|
|
34
|
+
for (const n of i.tools)
|
|
35
|
+
l.set(n.fully_qualified_name, !0);
|
|
36
36
|
}
|
|
37
37
|
return { selectedToolkits: e, selectedTools: l };
|
|
38
|
-
},
|
|
38
|
+
}, p = (o, t, e) => {
|
|
39
39
|
if (!e)
|
|
40
40
|
return {
|
|
41
41
|
searchQuery: o,
|
|
@@ -43,87 +43,123 @@ const r = (o, t) => t ? new Set(
|
|
|
43
43
|
filteredToolkits: /* @__PURE__ */ new Set(),
|
|
44
44
|
filteredTools: /* @__PURE__ */ new Set()
|
|
45
45
|
};
|
|
46
|
-
const l = t ? new Set(
|
|
46
|
+
const l = t ? new Set(d(t, e)) : new Set(e.tools || []);
|
|
47
47
|
return {
|
|
48
48
|
searchQuery: o,
|
|
49
49
|
activeTab: "toolkits",
|
|
50
50
|
filteredToolkits: new Set(e.toolkits || []),
|
|
51
51
|
filteredTools: l
|
|
52
52
|
};
|
|
53
|
-
},
|
|
54
|
-
const e = o.toLowerCase().trim(), { toolkits: l = [], tools:
|
|
55
|
-
if (
|
|
53
|
+
}, L = (o, t) => {
|
|
54
|
+
const e = o.toLowerCase().trim(), { toolkits: l = [], tools: i = [] } = t.toolkitCollection || {}, n = !l.length, s = !i.length;
|
|
55
|
+
if (n && s)
|
|
56
56
|
return { searchQuery: o };
|
|
57
|
-
const c = r(l, e), u = t.toolkitFilter ?
|
|
57
|
+
const c = r(l, e), u = t.toolkitFilter ? d(t.toolkitFilter, t.toolkitCollection) : i, a = r(u, e);
|
|
58
58
|
return {
|
|
59
59
|
searchQuery: o,
|
|
60
60
|
filteredToolkits: c,
|
|
61
|
-
filteredTools:
|
|
62
|
-
activeTab:
|
|
61
|
+
filteredTools: a,
|
|
62
|
+
activeTab: h(t.activeTab, c, a)
|
|
63
63
|
};
|
|
64
|
-
},
|
|
65
|
-
const e = t.selectedTools.has(o), l = t.toolkitCollection?.toolToToolkitMap?.get(o),
|
|
64
|
+
}, M = (o, t) => {
|
|
65
|
+
const e = t.selectedTools.has(o), l = t.toolkitCollection?.toolToToolkitMap?.get(o), i = new Map(t.selectedToolkits), n = new Map(t.selectedTools);
|
|
66
66
|
if (e)
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
n.delete(o), l && (_(
|
|
68
|
+
n,
|
|
69
69
|
l,
|
|
70
70
|
t.toolkitCollection
|
|
71
|
-
) ||
|
|
72
|
-
else if (t.selectionMode === "single" && (
|
|
73
|
-
const
|
|
74
|
-
|
|
71
|
+
) || i.delete(l));
|
|
72
|
+
else if (t.selectionMode === "single" && (n.clear(), i.clear()), n.set(o, !0), l) {
|
|
73
|
+
const s = t.toolkitCollection?.toolkitMap?.get(l);
|
|
74
|
+
s && i.set(l, s);
|
|
75
75
|
}
|
|
76
|
-
return { selectedTools:
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
return { selectedTools: n, selectedToolkits: i };
|
|
77
|
+
}, k = (o, t, e) => {
|
|
78
|
+
const l = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
79
|
+
if (!e)
|
|
80
|
+
return { selectedToolkits: l, selectedTools: i };
|
|
81
|
+
if (o)
|
|
82
|
+
for (const n of o) {
|
|
83
|
+
const s = e.toolkitMap?.get(n);
|
|
84
|
+
s && l.set(n, s);
|
|
85
|
+
}
|
|
86
|
+
if (t)
|
|
87
|
+
for (const n of t)
|
|
88
|
+
i.set(n, !0);
|
|
89
|
+
return { selectedToolkits: l, selectedTools: i };
|
|
90
|
+
}, I = (o) => {
|
|
91
|
+
const { selectedToolkits: t, selectedTools: e } = k(
|
|
92
|
+
o.initialProps?.selectedToolkits,
|
|
93
|
+
o.initialProps?.selectedTools,
|
|
94
|
+
o.toolkitCollection
|
|
95
|
+
), { selectedToolkits: l, selectedTools: i } = k(
|
|
96
|
+
o.initialProps?.committedToolkits || o.initialProps?.selectedToolkits,
|
|
97
|
+
o.initialProps?.committedTools || o.initialProps?.selectedTools,
|
|
98
|
+
o.toolkitCollection
|
|
99
|
+
);
|
|
100
|
+
return {
|
|
101
|
+
toolkitCollection: o.toolkitCollection,
|
|
102
|
+
selectionMode: o.selectionMode || "multi",
|
|
103
|
+
selectedToolkits: t,
|
|
104
|
+
selectedTools: e,
|
|
105
|
+
committedToolkits: l,
|
|
106
|
+
committedTools: i,
|
|
107
|
+
searchQuery: "",
|
|
108
|
+
toolkitFilter: "",
|
|
109
|
+
activeTab: "toolkits",
|
|
110
|
+
filteredToolkits: new Set(o.toolkitCollection?.toolkits || []),
|
|
111
|
+
filteredTools: new Set(o.toolkitCollection?.tools || [])
|
|
112
|
+
};
|
|
113
|
+
}, O = (o, t) => {
|
|
90
114
|
switch (t.type) {
|
|
91
115
|
case "TOGGLE_TOOLKIT": {
|
|
92
|
-
const e = t.payload, { name: l, tools:
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
for (const c of
|
|
116
|
+
const e = t.payload, { name: l, tools: i } = e, n = o.selectedToolkits.has(l), s = new Map(o.selectedToolkits), T = new Map(o.selectedTools);
|
|
117
|
+
if (n) {
|
|
118
|
+
s.delete(l);
|
|
119
|
+
for (const c of i)
|
|
96
120
|
T.delete(c.fully_qualified_name);
|
|
97
121
|
} else {
|
|
98
|
-
|
|
99
|
-
for (const c of
|
|
122
|
+
s.set(l, e);
|
|
123
|
+
for (const c of i)
|
|
100
124
|
T.set(c.fully_qualified_name, !0);
|
|
101
125
|
}
|
|
102
126
|
return {
|
|
103
127
|
...o,
|
|
104
|
-
selectedToolkits:
|
|
128
|
+
selectedToolkits: s,
|
|
105
129
|
selectedTools: T
|
|
106
130
|
};
|
|
107
131
|
}
|
|
108
|
-
case "
|
|
109
|
-
const e = t.payload
|
|
132
|
+
case "SET_INITIAL_SELECTIONS": {
|
|
133
|
+
const e = t.payload, { selectedToolkits: l, selectedTools: i } = k(
|
|
134
|
+
e.selectedToolkits,
|
|
135
|
+
e.selectedTools,
|
|
136
|
+
o.toolkitCollection
|
|
137
|
+
), {
|
|
138
|
+
selectedToolkits: n,
|
|
139
|
+
selectedTools: s
|
|
140
|
+
} = k(
|
|
141
|
+
e.committedToolkits || e.selectedToolkits,
|
|
142
|
+
e.committedTools || e.selectedTools,
|
|
143
|
+
o.toolkitCollection
|
|
144
|
+
);
|
|
110
145
|
return {
|
|
111
146
|
...o,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
147
|
+
selectedToolkits: l,
|
|
148
|
+
selectedTools: i,
|
|
149
|
+
committedToolkits: n,
|
|
150
|
+
committedTools: s
|
|
115
151
|
};
|
|
116
152
|
}
|
|
117
153
|
case "TOGGLE_TOOL": {
|
|
118
|
-
const e = t.payload.fully_qualified_name, l =
|
|
154
|
+
const e = t.payload.fully_qualified_name, l = M(e, o);
|
|
119
155
|
return { ...o, ...l };
|
|
120
156
|
}
|
|
121
157
|
case "SELECT_ALL": {
|
|
122
|
-
const e = t.payload, l = e?.length === 0,
|
|
123
|
-
if (l ||
|
|
158
|
+
const e = t.payload, l = e?.length === 0, n = !e && !o.toolkitCollection?.toolkits?.length;
|
|
159
|
+
if (l || n)
|
|
124
160
|
return o;
|
|
125
|
-
const
|
|
126
|
-
return { ...o, ...
|
|
161
|
+
const s = y(e, o.toolkitCollection);
|
|
162
|
+
return { ...o, ...s };
|
|
127
163
|
}
|
|
128
164
|
case "CLEAR_SELECTIONS":
|
|
129
165
|
return {
|
|
@@ -148,19 +184,19 @@ const r = (o, t) => t ? new Set(
|
|
|
148
184
|
if (o.searchQuery === e)
|
|
149
185
|
return o;
|
|
150
186
|
if (!e.toLowerCase().trim()) {
|
|
151
|
-
const
|
|
187
|
+
const n = p(
|
|
152
188
|
e,
|
|
153
189
|
o.toolkitFilter,
|
|
154
190
|
o.toolkitCollection
|
|
155
191
|
);
|
|
156
|
-
return { ...o, ...
|
|
192
|
+
return { ...o, ...n };
|
|
157
193
|
}
|
|
158
|
-
const
|
|
159
|
-
return { ...o, ...
|
|
194
|
+
const i = L(e, o);
|
|
195
|
+
return { ...o, ...i };
|
|
160
196
|
}
|
|
161
197
|
case "CLEAR_SEARCH_QUERY": {
|
|
162
198
|
const e = o.toolkitFilter ? new Set(
|
|
163
|
-
|
|
199
|
+
d(o.toolkitFilter, o.toolkitCollection)
|
|
164
200
|
) : new Set(o.toolkitCollection?.tools || []);
|
|
165
201
|
return {
|
|
166
202
|
...o,
|
|
@@ -171,18 +207,18 @@ const r = (o, t) => t ? new Set(
|
|
|
171
207
|
};
|
|
172
208
|
}
|
|
173
209
|
case "SET_TOOLKIT_FILTER": {
|
|
174
|
-
const e = t.payload, l =
|
|
210
|
+
const e = t.payload, l = d(
|
|
175
211
|
e,
|
|
176
212
|
o.toolkitCollection
|
|
177
213
|
);
|
|
178
214
|
if (!l.length)
|
|
179
215
|
return { ...o, toolkitFilter: e };
|
|
180
|
-
const
|
|
216
|
+
const i = o.searchQuery.toLowerCase().trim();
|
|
181
217
|
return {
|
|
182
218
|
...o,
|
|
183
219
|
toolkitFilter: e,
|
|
184
220
|
activeTab: "tools",
|
|
185
|
-
filteredTools: r(l,
|
|
221
|
+
filteredTools: r(l, i)
|
|
186
222
|
};
|
|
187
223
|
}
|
|
188
224
|
case "CLEAR_FILTER": {
|
|
@@ -236,39 +272,45 @@ const r = (o, t) => t ? new Set(
|
|
|
236
272
|
default:
|
|
237
273
|
return o;
|
|
238
274
|
}
|
|
239
|
-
},
|
|
275
|
+
}, f = S(
|
|
240
276
|
null
|
|
241
277
|
);
|
|
242
|
-
function
|
|
278
|
+
function A({
|
|
243
279
|
children: o,
|
|
244
|
-
|
|
280
|
+
toolkitCollection: t,
|
|
281
|
+
selectionMode: e,
|
|
282
|
+
initialProps: l
|
|
245
283
|
}) {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
284
|
+
const i = {
|
|
285
|
+
toolkitCollection: t,
|
|
286
|
+
selectionMode: e,
|
|
287
|
+
initialProps: l
|
|
288
|
+
}, [n, s] = E(
|
|
289
|
+
O,
|
|
290
|
+
i,
|
|
291
|
+
I
|
|
250
292
|
);
|
|
251
|
-
|
|
252
|
-
t
|
|
253
|
-
}, [t
|
|
254
|
-
const
|
|
255
|
-
state:
|
|
256
|
-
toggleToolkit: (
|
|
257
|
-
toggleTool: (
|
|
258
|
-
selectAll: (
|
|
259
|
-
clearSelections: () =>
|
|
260
|
-
commitSelections: () =>
|
|
261
|
-
restoreCommittedState: () =>
|
|
262
|
-
setSearchQuery: (
|
|
263
|
-
clearSearchQuery: () =>
|
|
264
|
-
setToolkitFilter: (
|
|
265
|
-
clearFilter: () =>
|
|
266
|
-
setActiveTab: (
|
|
293
|
+
C(() => {
|
|
294
|
+
t && l && (l.selectedToolkits || l.selectedTools || l.committedToolkits || l.committedTools) && s({ type: "SET_INITIAL_SELECTIONS", payload: l });
|
|
295
|
+
}, [t, l]);
|
|
296
|
+
const T = {
|
|
297
|
+
state: n,
|
|
298
|
+
toggleToolkit: (c) => s({ type: "TOGGLE_TOOLKIT", payload: c }),
|
|
299
|
+
toggleTool: (c) => s({ type: "TOGGLE_TOOL", payload: c }),
|
|
300
|
+
selectAll: (c) => s({ type: "SELECT_ALL", payload: c }),
|
|
301
|
+
clearSelections: () => s({ type: "CLEAR_SELECTIONS" }),
|
|
302
|
+
commitSelections: () => s({ type: "COMMIT_SELECTIONS" }),
|
|
303
|
+
restoreCommittedState: () => s({ type: "RESTORE_COMMITTED_STATE" }),
|
|
304
|
+
setSearchQuery: (c) => s({ type: "SET_SEARCH_QUERY", payload: c }),
|
|
305
|
+
clearSearchQuery: () => s({ type: "CLEAR_SEARCH_QUERY" }),
|
|
306
|
+
setToolkitFilter: (c) => s({ type: "SET_TOOLKIT_FILTER", payload: c }),
|
|
307
|
+
clearFilter: () => s({ type: "CLEAR_FILTER" }),
|
|
308
|
+
setActiveTab: (c) => s({ type: "SET_ACTIVE_TAB", payload: c })
|
|
267
309
|
};
|
|
268
|
-
return /* @__PURE__ */ f
|
|
310
|
+
return /* @__PURE__ */ m(f.Provider, { value: T, children: o });
|
|
269
311
|
}
|
|
270
|
-
function
|
|
271
|
-
const o =
|
|
312
|
+
function F() {
|
|
313
|
+
const o = w(f);
|
|
272
314
|
if (!o)
|
|
273
315
|
throw new Error(
|
|
274
316
|
"useToolkitPicker must be used within a ToolkitPickerProvider. Make sure to wrap your component with <ToolkitPickerProvider>."
|
|
@@ -276,6 +318,6 @@ function g() {
|
|
|
276
318
|
return o;
|
|
277
319
|
}
|
|
278
320
|
export {
|
|
279
|
-
|
|
280
|
-
|
|
321
|
+
A as ToolkitPickerProvider,
|
|
322
|
+
F as useToolkitPicker
|
|
281
323
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ToolkitCollection } from '../../../../lib/arcade/arcade';
|
|
2
|
+
import { ToolkitPickerInitialProps } from './hooks/use-toolkit-picker';
|
|
2
3
|
import type * as React from 'react';
|
|
3
4
|
export type SelectionMode = 'multi' | 'single';
|
|
4
5
|
export type ToolkitPickerProps = {
|
|
@@ -10,5 +11,6 @@ export type ToolkitPickerProps = {
|
|
|
10
11
|
description?: string;
|
|
11
12
|
children: React.ReactElement;
|
|
12
13
|
selectionMode?: SelectionMode;
|
|
14
|
+
initialProps?: ToolkitPickerInitialProps;
|
|
13
15
|
};
|
|
14
16
|
export declare function ToolkitPicker(props: ToolkitPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { ToolkitPickerProvider as t } from "./hooks/use-toolkit-picker.js";
|
|
3
3
|
import { ToolkitPickerDialog as e } from "./toolkit-picker.js";
|
|
4
|
-
function
|
|
4
|
+
function c(o) {
|
|
5
5
|
return /* @__PURE__ */ i(
|
|
6
6
|
t,
|
|
7
7
|
{
|
|
8
|
+
initialProps: o.initialProps,
|
|
8
9
|
selectionMode: o.selectionMode,
|
|
9
10
|
toolkitCollection: o.toolkitCollection,
|
|
10
11
|
children: /* @__PURE__ */ i(e, { ...o })
|
|
@@ -12,5 +13,5 @@ function k(o) {
|
|
|
12
13
|
);
|
|
13
14
|
}
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
c as ToolkitPicker
|
|
16
17
|
};
|
|
@@ -4,4 +4,6 @@ export declare function createMockToolkitCollection(toolkits: Record<string, Too
|
|
|
4
4
|
export declare const simpleMockToolkits: Record<string, Toolkit>;
|
|
5
5
|
export declare const mockToolkitCollection: ToolkitCollection;
|
|
6
6
|
export declare const simpleMockToolkitCollection: ToolkitCollection;
|
|
7
|
+
export declare const demoMockToolkits: Record<string, Toolkit>;
|
|
8
|
+
export declare const demoMockToolkitCollection: ToolkitCollection;
|
|
7
9
|
export declare function generateLargeDataset(): Record<string, Toolkit>;
|