@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.
Files changed (37) hide show
  1. package/dist/{arcade-DSu1Vp41.js → arcade-DzMbb7xi.js} +512 -586
  2. package/dist/components/index.js +302 -300
  3. package/dist/components/ui/atoms/alert-dialog.d.ts +14 -0
  4. package/dist/components/ui/atoms/alert-dialog.js +248 -0
  5. package/dist/components/ui/atoms/command.js +1 -1
  6. package/dist/components/ui/atoms/dialog.js +1 -1
  7. package/dist/components/ui/atoms/icons/codesandbox.d.ts +3 -0
  8. package/dist/components/ui/atoms/icons/codesandbox.js +26 -0
  9. package/dist/components/ui/atoms/icons/index.d.ts +1 -0
  10. package/dist/components/ui/atoms/icons/index.js +182 -180
  11. package/dist/components/ui/atoms/index.js +285 -283
  12. package/dist/components/ui/atoms/sheet.js +1 -1
  13. package/dist/components/ui/index.js +302 -300
  14. package/dist/components/ui/molecules/toolkit-picker-trigger.js +29 -32
  15. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-filter.test.js +2 -2
  16. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-search.test.js +2 -2
  17. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-selection.test.js +2 -2
  18. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.d.ts +11 -3
  19. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.js +141 -99
  20. package/dist/components/ui/organisms/toolkit-picker/index.d.ts +2 -0
  21. package/dist/components/ui/organisms/toolkit-picker/index.js +3 -2
  22. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.d.ts +2 -0
  23. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.js +247 -55
  24. package/dist/components/ui/organisms/toolkit-picker/toolkit-picker.test.js +2 -2
  25. package/dist/components/ui/utils/memo.test.js +1 -1
  26. package/dist/{index-BzU0xzeS.js → index-Dkey23PG.js} +3 -1
  27. package/dist/lib/arcade/arcade.js +3 -2
  28. package/dist/lib/arcade/arcade.test.js +2 -2
  29. package/dist/lib/utils.test.js +1 -1
  30. package/dist/main.js +313 -311
  31. package/dist/metadata/oauth-providers.js +9 -9
  32. package/dist/metadata/toolkits.js +383 -227
  33. package/dist/metadata/types.d.ts +2 -1
  34. package/dist/{react.esm-CFMQn0EI.js → react.esm-CAxz4dXo.js} +1 -1
  35. package/dist/{vi.bdSIJ99Y-CQ1FdEM8.js → vi.bdSIJ99Y-hyudrc3R.js} +3880 -3436
  36. package/dist/web-sgv-FK6q.js +84 -0
  37. 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 g } from "../../../utils-Db4QWi-E.js";
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: x = 2,
11
- className: N,
12
- countType: r = "toolkits",
13
- loading: i = !1,
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: T }
18
- } = I(), o = Array.from(f.keys()), l = o.length, p = T.size, c = o.slice(0, x).map((a) => {
19
- const s = f.get(a);
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: s?.metadata?.icon,
21
+ metadataIcon: r?.metadata?.icon,
22
22
  toolkitName: a
23
23
  });
24
- }), k = Math.max(l - c.length, 0), b = r === "tools";
25
- let m = "Toolkits", d = l;
26
- b && (m = "Tools", d = p);
27
- let u = `Select ${r === "tools" ? "Tools" : "Toolkits"}`;
28
- return i ? u = "Loading toolkits..." : l > 0 && (u = `${d} ${m.toLowerCase()} selected`), /* @__PURE__ */ e(
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: g("gap-2 bg-transparent transition-colors", N),
34
- disabled: i,
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: i ? /* @__PURE__ */ t(h, { 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-1.5 flex items-center", children: [
46
- c.map((a, s) => /* @__PURE__ */ e(
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: g(
50
- "relative first:ml-0",
51
- s > 0 && "-ml-1.5"
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"}-${s}`
53
+ `${a.name || "icon"}-${r}`
57
54
  )),
58
55
  k > 0 && /* @__PURE__ */ t(
59
56
  "span",
60
57
  {
61
- className: "-ml-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-neutral-200 font-medium text-[10px] text-neutral-700 ring-1 ring-black/15 dark:bg-neutral-800 dark:text-neutral-200 dark:ring-white/15",
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
- o.join(", ")
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
- p,
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
- r === "tools" ? "Tools" : "Toolkits"
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
- m,
97
- /* @__PURE__ */ e(y, { className: "px-1.5 py-0 text-[11px]", variant: "default", children: d })
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-CFMQn0EI.js";
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-CQ1FdEM8.js";
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-CFMQn0EI.js";
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-CQ1FdEM8.js";
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();
@@ -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-CFMQn0EI.js";
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-CQ1FdEM8.js";
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 = UseToolkitPickerProps & {
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, ...props }: {
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 f } from "react/jsx-runtime";
2
- import { createContext as S, useReducer as w, useEffect as m, useContext as E } from "react";
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), a = (o, t) => {
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((s) => s.fully_qualified_name));
14
- return t.tools.filter((s) => l.has(s.fully_qualified_name));
15
- }, C = (o, t, e) => e ? e.toolkitMap?.get(t)?.tools?.some((s) => o.has(s.fully_qualified_name)) ?? !1 : !1, p = (o, t, e) => !t.size && e.size ? "tools" : t.size && !e.size ? "toolkits" : o, _ = (o, t) => {
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 s of o) {
24
- l.set(s, !0);
25
- const i = t.toolToToolkitMap?.get(s);
26
- if (i) {
27
- const n = t.toolkitMap?.get(i);
28
- n && e.set(i, n);
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 s of t.toolkits) {
33
- e.set(s.name, s);
34
- for (const i of s.tools)
35
- l.set(i.fully_qualified_name, !0);
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
- }, h = (o, t, e) => {
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(a(t, e)) : new Set(e.tools || []);
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
- }, y = (o, t) => {
54
- const e = o.toLowerCase().trim(), { toolkits: l = [], tools: s = [] } = t.toolkitCollection || {}, i = !l.length, n = !s.length;
55
- if (i && n)
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 ? a(t.toolkitFilter, t.toolkitCollection) : s, k = r(u, e);
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: k,
62
- activeTab: p(t.activeTab, c, k)
61
+ filteredTools: a,
62
+ activeTab: h(t.activeTab, c, a)
63
63
  };
64
- }, L = (o, t) => {
65
- const e = t.selectedTools.has(o), l = t.toolkitCollection?.toolToToolkitMap?.get(o), s = new Map(t.selectedToolkits), i = new Map(t.selectedTools);
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
- i.delete(o), l && (C(
68
- i,
67
+ n.delete(o), l && (_(
68
+ n,
69
69
  l,
70
70
  t.toolkitCollection
71
- ) || s.delete(l));
72
- else if (t.selectionMode === "single" && (i.clear(), s.clear()), i.set(o, !0), l) {
73
- const n = t.toolkitCollection?.toolkitMap?.get(l);
74
- n && s.set(l, n);
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: i, selectedToolkits: s };
77
- }, M = (o) => ({
78
- ...o,
79
- selectedToolkits: /* @__PURE__ */ new Map(),
80
- selectedTools: /* @__PURE__ */ new Map(),
81
- committedToolkits: /* @__PURE__ */ new Map(),
82
- committedTools: /* @__PURE__ */ new Map(),
83
- searchQuery: "",
84
- toolkitFilter: "",
85
- activeTab: "toolkits",
86
- selectionMode: o.selectionMode || "multi",
87
- filteredToolkits: new Set(o.toolkitCollection?.toolkits || []),
88
- filteredTools: new Set(o.toolkitCollection?.tools || [])
89
- }), I = (o, t) => {
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: s } = e, i = o.selectedToolkits.has(l), n = new Map(o.selectedToolkits), T = new Map(o.selectedTools);
93
- if (i) {
94
- n.delete(l);
95
- for (const c of s)
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
- n.set(l, e);
99
- for (const c of s)
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: n,
128
+ selectedToolkits: s,
105
129
  selectedTools: T
106
130
  };
107
131
  }
108
- case "SET_INITIAL_DATA": {
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
- toolkitCollection: e,
113
- filteredToolkits: new Set(e.toolkits || []),
114
- filteredTools: new Set(e.tools || [])
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 = L(e, o);
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, i = !e && !o.toolkitCollection?.toolkits?.length;
123
- if (l || i)
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 n = _(e, o.toolkitCollection);
126
- return { ...o, ...n };
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 i = h(
187
+ const n = p(
152
188
  e,
153
189
  o.toolkitFilter,
154
190
  o.toolkitCollection
155
191
  );
156
- return { ...o, ...i };
192
+ return { ...o, ...n };
157
193
  }
158
- const s = y(e, o);
159
- return { ...o, ...s };
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
- a(o.toolkitFilter, o.toolkitCollection)
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 = a(
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 s = o.searchQuery.toLowerCase().trim();
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, s)
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
- }, d = S(
275
+ }, f = S(
240
276
  null
241
277
  );
242
- function R({
278
+ function A({
243
279
  children: o,
244
- ...t
280
+ toolkitCollection: t,
281
+ selectionMode: e,
282
+ initialProps: l
245
283
  }) {
246
- const [e, l] = w(
247
- I,
248
- t,
249
- M
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
- m(() => {
252
- t.toolkitCollection && l({ type: "SET_INITIAL_DATA", payload: t.toolkitCollection });
253
- }, [t.toolkitCollection]);
254
- const s = {
255
- state: e,
256
- toggleToolkit: (i) => l({ type: "TOGGLE_TOOLKIT", payload: i }),
257
- toggleTool: (i) => l({ type: "TOGGLE_TOOL", payload: i }),
258
- selectAll: (i) => l({ type: "SELECT_ALL", payload: i }),
259
- clearSelections: () => l({ type: "CLEAR_SELECTIONS" }),
260
- commitSelections: () => l({ type: "COMMIT_SELECTIONS" }),
261
- restoreCommittedState: () => l({ type: "RESTORE_COMMITTED_STATE" }),
262
- setSearchQuery: (i) => l({ type: "SET_SEARCH_QUERY", payload: i }),
263
- clearSearchQuery: () => l({ type: "CLEAR_SEARCH_QUERY" }),
264
- setToolkitFilter: (i) => l({ type: "SET_TOOLKIT_FILTER", payload: i }),
265
- clearFilter: () => l({ type: "CLEAR_FILTER" }),
266
- setActiveTab: (i) => l({ type: "SET_ACTIVE_TAB", payload: i })
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(d.Provider, { value: s, children: o });
310
+ return /* @__PURE__ */ m(f.Provider, { value: T, children: o });
269
311
  }
270
- function g() {
271
- const o = E(d);
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
- R as ToolkitPickerProvider,
280
- g as useToolkitPicker
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 k(o) {
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
- k as ToolkitPicker
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>;