@ateam-ai-mobile/ui 0.1.1 → 0.1.2

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Message, JobProgress, UIAction, TenantMembership } from '@ateam-ai-mobile/core';
2
+ import { Message, JobProgress, UIAction, AdasSession, TenantMembership } from '@ateam-ai-mobile/core';
3
3
  import * as react from 'react';
4
4
  import react__default from 'react';
5
5
  import { PluginSurfaceMeta, PlatformPluginManifest } from '@ateam-ai-mobile/plugin-runtime';
@@ -152,12 +152,15 @@ interface Props$1 {
152
152
  declare function WidgetWebView({ visible, title, bundleUrl, onClose }: Props$1): react_jsx_runtime.JSX.Element;
153
153
 
154
154
  interface TenantPickerProps {
155
- /** Called with the picked tenant. Host mints a JWT for it and re-inits. */
156
- onSelect: (tenant: TenantMembership) => void;
155
+ /** Called after a successful SDK-driven switch (host navigates/refreshes). */
156
+ onSwitched?: (session: AdasSession) => void;
157
+ /** Intercept the tap instead of switching — for fully custom host flows.
158
+ * When provided, the SDK does NOT call switchTenant(). */
159
+ onSelect?: (tenant: TenantMembership) => void;
157
160
  /** Highlight the active tenant. Defaults to the SDK config's tenant. */
158
161
  currentTenantId?: string;
159
162
  }
160
- declare function TenantPicker({ onSelect, currentTenantId }: TenantPickerProps): react_jsx_runtime.JSX.Element;
163
+ declare function TenantPicker({ onSwitched, onSelect, currentTenantId }: TenantPickerProps): react_jsx_runtime.JSX.Element;
161
164
 
162
165
  declare function Lightbox(): react_jsx_runtime.JSX.Element | null;
163
166
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Message, JobProgress, UIAction, TenantMembership } from '@ateam-ai-mobile/core';
2
+ import { Message, JobProgress, UIAction, AdasSession, TenantMembership } from '@ateam-ai-mobile/core';
3
3
  import * as react from 'react';
4
4
  import react__default from 'react';
5
5
  import { PluginSurfaceMeta, PlatformPluginManifest } from '@ateam-ai-mobile/plugin-runtime';
@@ -152,12 +152,15 @@ interface Props$1 {
152
152
  declare function WidgetWebView({ visible, title, bundleUrl, onClose }: Props$1): react_jsx_runtime.JSX.Element;
153
153
 
154
154
  interface TenantPickerProps {
155
- /** Called with the picked tenant. Host mints a JWT for it and re-inits. */
156
- onSelect: (tenant: TenantMembership) => void;
155
+ /** Called after a successful SDK-driven switch (host navigates/refreshes). */
156
+ onSwitched?: (session: AdasSession) => void;
157
+ /** Intercept the tap instead of switching — for fully custom host flows.
158
+ * When provided, the SDK does NOT call switchTenant(). */
159
+ onSelect?: (tenant: TenantMembership) => void;
157
160
  /** Highlight the active tenant. Defaults to the SDK config's tenant. */
158
161
  currentTenantId?: string;
159
162
  }
160
- declare function TenantPicker({ onSelect, currentTenantId }: TenantPickerProps): react_jsx_runtime.JSX.Element;
163
+ declare function TenantPicker({ onSwitched, onSelect, currentTenantId }: TenantPickerProps): react_jsx_runtime.JSX.Element;
161
164
 
162
165
  declare function Lightbox(): react_jsx_runtime.JSX.Element | null;
163
166
 
package/dist/index.js CHANGED
@@ -1918,9 +1918,10 @@ var import_react_native13 = require("react-native");
1918
1918
  var import_core15 = require("@ateam-ai-mobile/core");
1919
1919
  var import_jsx_runtime14 = require("react/jsx-runtime");
1920
1920
  var fontFam5 = import_react_native13.Platform.OS === "ios" ? "SF Pro Rounded" : void 0;
1921
- function TenantPicker({ onSelect, currentTenantId }) {
1921
+ function TenantPicker({ onSwitched, onSelect, currentTenantId }) {
1922
1922
  const [tenants, setTenants] = (0, import_react11.useState)(null);
1923
1923
  const [error, setError] = (0, import_react11.useState)(null);
1924
+ const [switching, setSwitching] = (0, import_react11.useState)(null);
1924
1925
  const active = currentTenantId ?? (0, import_core15.getTenant)();
1925
1926
  (0, import_react11.useEffect)(() => {
1926
1927
  let cancelled = false;
@@ -1933,6 +1934,23 @@ function TenantPicker({ onSelect, currentTenantId }) {
1933
1934
  cancelled = true;
1934
1935
  };
1935
1936
  }, []);
1937
+ const handlePress = async (t) => {
1938
+ if (t.id === active || switching) return;
1939
+ if (onSelect) {
1940
+ onSelect(t);
1941
+ return;
1942
+ }
1943
+ setError(null);
1944
+ setSwitching(t.id);
1945
+ try {
1946
+ const session = await (0, import_core15.switchTenant)(t.id);
1947
+ onSwitched?.(session);
1948
+ } catch (e) {
1949
+ setError(e?.message || "Could not switch team");
1950
+ } finally {
1951
+ setSwitching(null);
1952
+ }
1953
+ };
1936
1954
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.error, children: error });
1937
1955
  if (!tenants) {
1938
1956
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.View, { style: styles12.loading, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.ActivityIndicator, { color: import_core15.ada.orange }) });
@@ -1940,12 +1958,14 @@ function TenantPicker({ onSelect, currentTenantId }) {
1940
1958
  if (tenants.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.empty, children: "No teams found for this account." });
1941
1959
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.View, { style: styles12.list, children: tenants.map((t) => {
1942
1960
  const isActive = t.id === active;
1961
+ const isSwitching = switching === t.id;
1943
1962
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1944
1963
  import_react_native13.Pressable,
1945
1964
  {
1946
1965
  accessibilityRole: "button",
1947
1966
  accessibilityLabel: `Team ${t.name}${isActive ? ", current" : ""}`,
1948
- onPress: () => onSelect(t),
1967
+ disabled: !!switching,
1968
+ onPress: () => handlePress(t),
1949
1969
  style: [styles12.row, isActive && styles12.rowActive],
1950
1970
  children: [
1951
1971
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.View, { style: styles12.dot }),
@@ -1953,7 +1973,7 @@ function TenantPicker({ onSelect, currentTenantId }) {
1953
1973
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.name, children: t.name }),
1954
1974
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.slug, children: t.id })
1955
1975
  ] }),
1956
- isActive && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.check, children: "\u2713" })
1976
+ isSwitching ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.ActivityIndicator, { color: import_core15.ada.orange }) : isActive ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.Text, { style: styles12.check, children: "\u2713" }) : null
1957
1977
  ]
1958
1978
  },
1959
1979
  t.id