@apotech-os/ui-sdk 7.5.0 → 7.6.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/index.d.cts CHANGED
@@ -30,10 +30,32 @@ interface AppContextValue {
30
30
  * hide the control, never as permission.
31
31
  */
32
32
  platformRole?: 'VIEWER' | 'EDITOR' | 'ADMIN';
33
+ /**
34
+ * Where the shell mounted this app's pages: `/espace/<app>` when the app is
35
+ * opened directly, `/espace/<host>/<app>` when another app opens it inside
36
+ * its own navigation. Absent on older shells. Pages should not read it but
37
+ * build links with `useAppPageHref()`, which falls back on the direct form.
38
+ */
39
+ basePath?: string;
33
40
  }
34
41
  declare const AppContextProvider: React.Provider<AppContextValue | null>;
35
42
  /** Returns context info for the current app page (appSlug, pagePath, spaceId). */
36
43
  declare function useAppContext(): AppContextValue;
44
+ type AppPageQuery = URLSearchParams | Record<string, string | number | boolean | null | undefined>;
45
+ /**
46
+ * Returns a builder for links to another page of THIS app.
47
+ *
48
+ * Use it instead of writing `/espace/${appSlug}/…` by hand: when another app
49
+ * opens this one inside its own navigation, the page is mounted under that
50
+ * app (`/espace/<host>/<app>/…`), and a hand-written link would take the user
51
+ * out of it. `null`/`undefined` query values are dropped.
52
+ *
53
+ * ```tsx
54
+ * const pageHref = useAppPageHref();
55
+ * <Link href={pageHref('tickets', { ticket: id })}>Voir le ticket</Link>
56
+ * ```
57
+ */
58
+ declare function useAppPageHref(): (pagePath: string, query?: AppPageQuery) => string;
37
59
  interface AppApiClient {
38
60
  /**
39
61
  * Perform a GET request to a platform-data endpoint.
@@ -765,4 +787,4 @@ declare function toCsv(rows: string[][]): string;
765
787
  */
766
788
  declare function downloadCsv(rows: string[][], filename: string): void;
767
789
 
768
- export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, AreaChart, Badge, type BadgeProps, BarChart, Button, type ButtonProps, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CartesianChartProps, type ChartRow, type ChartSeries, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, DataTable, type DataTableBulkAction, type DataTableColumn, type DataTableColumnFormat, type DataTableCsvExport, type DataTableFacet, type DataTableFilter, type DataTableFilterOperator, type DataTableLoadMore, type DataTablePagination, type DataTableProps, type DataTableSort, type DataTableState, type DateRange, DateRangeCompare, type DateRangeCompareProps, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, FunnelChart, type FunnelChartProps, type FunnelStep, Input, KpiCard, type KpiCardProps, LineChart, Link, type LinkProps, Modal, type ModalProps, PERIOD_PRESETS, type PeriodCompareMode, type PeriodPreset, type PeriodPresetKey, type PeriodRange, type PeriodValue, Popover, type PopoverProps, Select, type SelectOption, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, StackedBarChart, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, type ToastInput, ToastProvider, Tooltip, type TooltipProps, type ValueFormatter, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppRun, useAppRuns, useAppSettings, useToast };
790
+ export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, type AppPageQuery, AreaChart, Badge, type BadgeProps, BarChart, Button, type ButtonProps, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CartesianChartProps, type ChartRow, type ChartSeries, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, DataTable, type DataTableBulkAction, type DataTableColumn, type DataTableColumnFormat, type DataTableCsvExport, type DataTableFacet, type DataTableFilter, type DataTableFilterOperator, type DataTableLoadMore, type DataTablePagination, type DataTableProps, type DataTableSort, type DataTableState, type DateRange, DateRangeCompare, type DateRangeCompareProps, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, FunnelChart, type FunnelChartProps, type FunnelStep, Input, KpiCard, type KpiCardProps, LineChart, Link, type LinkProps, Modal, type ModalProps, PERIOD_PRESETS, type PeriodCompareMode, type PeriodPreset, type PeriodPresetKey, type PeriodRange, type PeriodValue, Popover, type PopoverProps, Select, type SelectOption, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, StackedBarChart, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, type ToastInput, ToastProvider, Tooltip, type TooltipProps, type ValueFormatter, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppPageHref, useAppRun, useAppRuns, useAppSettings, useToast };
package/dist/index.d.ts CHANGED
@@ -30,10 +30,32 @@ interface AppContextValue {
30
30
  * hide the control, never as permission.
31
31
  */
32
32
  platformRole?: 'VIEWER' | 'EDITOR' | 'ADMIN';
33
+ /**
34
+ * Where the shell mounted this app's pages: `/espace/<app>` when the app is
35
+ * opened directly, `/espace/<host>/<app>` when another app opens it inside
36
+ * its own navigation. Absent on older shells. Pages should not read it but
37
+ * build links with `useAppPageHref()`, which falls back on the direct form.
38
+ */
39
+ basePath?: string;
33
40
  }
34
41
  declare const AppContextProvider: React.Provider<AppContextValue | null>;
35
42
  /** Returns context info for the current app page (appSlug, pagePath, spaceId). */
36
43
  declare function useAppContext(): AppContextValue;
44
+ type AppPageQuery = URLSearchParams | Record<string, string | number | boolean | null | undefined>;
45
+ /**
46
+ * Returns a builder for links to another page of THIS app.
47
+ *
48
+ * Use it instead of writing `/espace/${appSlug}/…` by hand: when another app
49
+ * opens this one inside its own navigation, the page is mounted under that
50
+ * app (`/espace/<host>/<app>/…`), and a hand-written link would take the user
51
+ * out of it. `null`/`undefined` query values are dropped.
52
+ *
53
+ * ```tsx
54
+ * const pageHref = useAppPageHref();
55
+ * <Link href={pageHref('tickets', { ticket: id })}>Voir le ticket</Link>
56
+ * ```
57
+ */
58
+ declare function useAppPageHref(): (pagePath: string, query?: AppPageQuery) => string;
37
59
  interface AppApiClient {
38
60
  /**
39
61
  * Perform a GET request to a platform-data endpoint.
@@ -765,4 +787,4 @@ declare function toCsv(rows: string[][]): string;
765
787
  */
766
788
  declare function downloadCsv(rows: string[][], filename: string): void;
767
789
 
768
- export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, AreaChart, Badge, type BadgeProps, BarChart, Button, type ButtonProps, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CartesianChartProps, type ChartRow, type ChartSeries, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, DataTable, type DataTableBulkAction, type DataTableColumn, type DataTableColumnFormat, type DataTableCsvExport, type DataTableFacet, type DataTableFilter, type DataTableFilterOperator, type DataTableLoadMore, type DataTablePagination, type DataTableProps, type DataTableSort, type DataTableState, type DateRange, DateRangeCompare, type DateRangeCompareProps, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, FunnelChart, type FunnelChartProps, type FunnelStep, Input, KpiCard, type KpiCardProps, LineChart, Link, type LinkProps, Modal, type ModalProps, PERIOD_PRESETS, type PeriodCompareMode, type PeriodPreset, type PeriodPresetKey, type PeriodRange, type PeriodValue, Popover, type PopoverProps, Select, type SelectOption, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, StackedBarChart, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, type ToastInput, ToastProvider, Tooltip, type TooltipProps, type ValueFormatter, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppRun, useAppRuns, useAppSettings, useToast };
790
+ export { type AppApiClient, AppApiProvider, AppContextProvider, type AppContextValue, AppInvokeError, type AppPageQuery, AreaChart, Badge, type BadgeProps, BarChart, Button, type ButtonProps, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CartesianChartProps, type ChartRow, type ChartSeries, Checkbox, type CheckboxProps, CopyButton, type CopyButtonProps, DataTable, type DataTableBulkAction, type DataTableColumn, type DataTableColumnFormat, type DataTableCsvExport, type DataTableFacet, type DataTableFilter, type DataTableFilterOperator, type DataTableLoadMore, type DataTablePagination, type DataTableProps, type DataTableSort, type DataTableState, type DateRange, DateRangeCompare, type DateRangeCompareProps, DateRangePicker, type DateRangePickerProps, DropdownMenu, type DropdownMenuItem, type DropdownMenuProps, FunnelChart, type FunnelChartProps, type FunnelStep, Input, KpiCard, type KpiCardProps, LineChart, Link, type LinkProps, Modal, type ModalProps, PERIOD_PRESETS, type PeriodCompareMode, type PeriodPreset, type PeriodPresetKey, type PeriodRange, type PeriodValue, Popover, type PopoverProps, Select, type SelectOption, type SelectProps, SidePanel, type SidePanelProps, Spinner, type SpinnerProps, StackedBarChart, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, type TextareaProps, type ToastInput, ToastProvider, Tooltip, type TooltipProps, type ValueFormatter, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppPageHref, useAppRun, useAppRuns, useAppSettings, useToast };
package/dist/index.js CHANGED
@@ -29,6 +29,19 @@ function useAppContext() {
29
29
  if (!ctx) throw new Error("useAppContext must be used inside an app page mounted by the shell");
30
30
  return ctx;
31
31
  }
32
+ function useAppPageHref() {
33
+ const { appSlug, basePath } = useAppContext();
34
+ const base = basePath ?? `/espace/${appSlug}`;
35
+ return (pagePath, query) => {
36
+ const params = query instanceof URLSearchParams ? query : new URLSearchParams(
37
+ Object.entries(query ?? {}).flatMap(
38
+ ([key, value]) => value === null || value === void 0 ? [] : [[key, String(value)]]
39
+ )
40
+ );
41
+ const search = params.toString();
42
+ return `${base}/${pagePath}${search ? `?${search}` : ""}`;
43
+ };
44
+ }
32
45
  var AppInvokeError = class extends Error {
33
46
  constructor(status, message, code, invocationId) {
34
47
  super(message);
@@ -2626,6 +2639,6 @@ function Tooltip2({ label, children, side = "top", className }) {
2626
2639
  ] });
2627
2640
  }
2628
2641
 
2629
- export { AppApiProvider, AppContextProvider, AppInvokeError, AreaChart, Badge, BarChart, Button, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CopyButton, DataTable, DateRangeCompare, DateRangePicker, DropdownMenu, FunnelChart, Input, KpiCard, LineChart, Link, Modal, PERIOD_PRESETS, Popover, Select, SidePanel, Spinner, StackedBarChart, Switch, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip2 as Tooltip, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppRun, useAppRuns, useAppSettings, useToast };
2642
+ export { AppApiProvider, AppContextProvider, AppInvokeError, AreaChart, Badge, BarChart, Button, COMPARE_LABELS, COMPARE_SHORT_LABELS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CopyButton, DataTable, DateRangeCompare, DateRangePicker, DropdownMenu, FunnelChart, Input, KpiCard, LineChart, Link, Modal, PERIOD_PRESETS, Popover, Select, SidePanel, Spinner, StackedBarChart, Switch, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip2 as Tooltip, badgeVariants, buttonVariants, cn, comparisonRange, copyToClipboard, downloadBlob, downloadCsv, formatCellValue, formatPeriod, formatRange, makePeriod, periodFromPreset, relativeDelta, toCsv, useAppApi, useAppContext, useAppPageHref, useAppRun, useAppRuns, useAppSettings, useToast };
2630
2643
  //# sourceMappingURL=index.js.map
2631
2644
  //# sourceMappingURL=index.js.map