@rise-x/apps-sdk 0.15.0 → 0.16.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/README.md CHANGED
@@ -771,7 +771,9 @@ Requirements in the app:
771
771
  The one component with a real library behind it. It renders a Leaflet basemap
772
772
  and nothing else — markers, routes and heat layers are yours to add. Leaflet is
773
773
  fetched in its own chunk on first mount, so apps that never show a map pay
774
- nothing for it.
774
+ nothing for it. The `light` and `dark` presets are OpenFreeMap vector styles
775
+ drawn by MapLibre GL, which arrives in a second chunk only when one of them is
776
+ shown.
775
777
 
776
778
  `onReady` hands back the map **and the Leaflet module it was built from**. Build
777
779
  layers off that `L`: the app then needs no `leaflet` dependency of its own, and
@@ -801,7 +803,26 @@ import { MapView, mapPin } from '@rise-x/apps-sdk/ui';
801
803
  ```
802
804
 
803
805
  `tiles` also takes a preset (`'light'`, `'dark'`, `'streets'`, `'satellite'`), a
804
- custom tile layer, or `null` for no basemap at all.
806
+ custom raster layer (`{ url, ...TileLayerOptions }`), a MapLibre style
807
+ (`{ style }`), or `null` for no basemap at all.
808
+
809
+ The built-in presets fetch from third-party hosts, so the host page's CSP must
810
+ allow them: `light` and `dark` need `connect-src https://tiles.openfreemap.org`
811
+ and `worker-src blob:` (MapLibre renders in a web worker); `streets` and
812
+ `satellite` load tile images, so `img-src` must allow
813
+ `https://tile.openstreetmap.org` and `https://server.arcgisonline.com`. The
814
+ host page's CSP controls this, so an app can't lift a block from its own
815
+ code. The Rise-X shell's allow-list carries the built-in preset hosts; for
816
+ any other host, ask Rise-X to add it. If no tile of a raster layer loads,
817
+ `MapView` warns once and removes the layer so Leaflet stops re-requesting
818
+ blocked tiles on every pan and zoom — use `tiles={null}` or a custom
819
+ `MapTileSpec` on a permitted origin instead. A vector style that fails to
820
+ load is handled the same way: `MapView` warns with the style's origin and
821
+ removes the layer. A vector style also needs WebGL2;
822
+ on a browser without it `MapView` warns and renders as `tiles={null}`, so pick
823
+ a raster preset where that is a possibility. `mapPin()` has no `aria-label` of
824
+ its own; set one via `marker.getElement()` after `addTo(map)` if the marker
825
+ needs an accessible name (see the JSDoc on `mapPin`).
805
826
 
806
827
  `center`/`zoom`/`bounds` set the **initial** view only — pan and zoom afterwards
807
828
  through the instance (`map.flyTo(...)`), so a re-render never yanks the map away
@@ -175,8 +175,8 @@
175
175
  ],
176
176
  "classes": {
177
177
  "flat": "inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0 text-muted-foreground",
178
- "up": "inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0 text-success-text",
179
- "down": "inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0 text-error-text"
178
+ "down": "inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0 text-error-text",
179
+ "up": "inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0 text-success-text"
180
180
  }
181
181
  },
182
182
  "node": {
@@ -14,9 +14,9 @@ export interface FacetedFilterOption extends DataTableFilterOption {
14
14
  * than printed as 0. */
15
15
  count?: number;
16
16
  }
17
- export interface FacetedFilterProps {
17
+ export interface FacetedFilterProps<TOption extends FacetedFilterOption = FacetedFilterOption> {
18
18
  title: string;
19
- options: FacetedFilterOption[];
19
+ options: TOption[];
20
20
  /** Applied values — a Set or an array, whichever the caller already holds. */
21
21
  selected: Iterable<string>;
22
22
  onSelect: (value: string, checked: boolean) => void;
@@ -26,6 +26,28 @@ export interface FacetedFilterProps {
26
26
  /** Drop options whose `count` is 0 — inert when counts aren't provided.
27
27
  * Applied values stay listed so they can be unticked. */
28
28
  hideEmpty?: boolean;
29
+ /** Replaces the CONTENTS of an option row — the tick, icon, label and count.
30
+ * The row button itself stays ours, so roving focus, `role="option"` and
31
+ * `aria-selected` keep working. Keep what you render NON-INTERACTIVE: the row
32
+ * IS a `<button>`, so a nested button, link or Checkbox is invalid HTML and
33
+ * fights the row's own tab stop and click handling.
34
+ *
35
+ * The row's accessible name is CONTENT, not an override — no `aria-label`
36
+ * is applied, so it stays whatever the default row already gave it (label,
37
+ * then count) and extends naturally when you render more. That cuts both
38
+ * ways: put the identifying text first, and mark anything purely decorative
39
+ * — an avatar's initials, an icon that only repeats what the label already
40
+ * says — `aria-hidden`, or it reads out ahead of the label. `option.label`
41
+ * stays load-bearing in two more places a renderer can now visually hide:
42
+ * it's what search matches against, and what the trigger's selected chips
43
+ * print. `TOption` lets an option carry whatever a custom renderer needs
44
+ * (an avatar, a second line) without a lookup back to the caller's own
45
+ * data — see `FacetedFilter`; `DataTable`'s `filters` still type this
46
+ * against the base `FacetedFilterOption`. Omitted, rows render
47
+ * `defaultFacetedOption` below. */
48
+ renderOption?: (option: TOption, state: {
49
+ checked: boolean;
50
+ }) => React.ReactNode;
29
51
  className?: string;
30
52
  }
31
53
  export interface DataTableFilter {
@@ -37,6 +59,11 @@ export interface DataTableFilter {
37
59
  searchable?: boolean;
38
60
  /** Drop options no visible row carries. */
39
61
  hideEmpty?: boolean;
62
+ /** Custom option row contents — see `FacetedFilterProps.renderOption`.
63
+ * Typed against the base `FacetedFilterOption`: the generic `TOption` that
64
+ * lets an option carry extra fields is only available through the unbound
65
+ * `FacetedFilter`, not through this descriptor. */
66
+ renderOption?: FacetedFilterProps['renderOption'];
40
67
  }
41
68
  export interface DataTableProps<TData, TValue> {
42
69
  columns: ColumnDef<TData, TValue>[];
@@ -57,21 +84,29 @@ export declare function DataTableColumnHeader<TData, TValue>({ column, title, cl
57
84
  title: string;
58
85
  className?: string;
59
86
  }): React.JSX.Element;
87
+ /** The stock option row: tick, optional icon, label, right-aligned count.
88
+ * Exported so a `renderOption` that wants to ADD to the stock row, rather
89
+ * than replace it, can render this and wrap it instead of hand-copying its
90
+ * `size-[15px]` / `rounded-[4px]` internals. */
91
+ export declare function defaultFacetedOption(option: FacetedFilterOption, { checked }: {
92
+ checked: boolean;
93
+ }): React.JSX.Element;
60
94
  /**
61
95
  * Multi-select filter trigger + menu, with no table attached — for toolbars
62
96
  * that filter something other than a DataTable. State is the caller's:
63
97
  * `selected` in, `onSelect`/`onClear` out. DataTableFacetedFilter is this
64
98
  * component wired to a TanStack column.
65
99
  */
66
- export declare function FacetedFilter({ title, options, selected: selectedValues, onSelect, onClear, searchable, hideEmpty, className, }: FacetedFilterProps): React.JSX.Element;
100
+ export declare function FacetedFilter<TOption extends FacetedFilterOption = FacetedFilterOption>({ title, options, selected: selectedValues, onSelect, onClear, searchable, hideEmpty, renderOption, className, }: FacetedFilterProps<TOption>): React.JSX.Element;
67
101
  /** FacetedFilter bound to a TanStack column: facet counts and the filter value
68
102
  * come from the table, so the toolbar only names the column. */
69
- export declare function DataTableFacetedFilter<TData>({ column, title, options, searchable, hideEmpty, }: {
103
+ export declare function DataTableFacetedFilter<TData>({ column, title, options, searchable, hideEmpty, renderOption, }: {
70
104
  column: Column<TData, unknown>;
71
105
  title: string;
72
106
  options: DataTableFilterOption[];
73
107
  searchable?: boolean;
74
108
  hideEmpty?: boolean;
109
+ renderOption?: FacetedFilterProps['renderOption'];
75
110
  }): React.JSX.Element;
76
111
  /**
77
112
  * Rise-X data table: search, faceted filters and column visibility are built
@@ -1,8 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import type { DivIconOptions, LatLngBoundsExpression, LatLngExpression, Map as LeafletMap, MapOptions, TileLayerOptions } from 'leaflet';
3
3
  type MapTilePreset = 'light' | 'dark' | 'streets' | 'satellite';
4
- type MapTileSpec = TileLayerOptions & {
4
+ type MapTileSpec = (TileLayerOptions & {
5
5
  url: string;
6
+ }) | {
7
+ style: string;
8
+ maxZoom?: number;
6
9
  };
7
10
  declare const MAP_TILES: Record<MapTilePreset, MapTileSpec>;
8
11
  type MapPinTone = 'default' | 'brand' | 'success' | 'warning' | 'error' | 'info';
@@ -7,7 +7,7 @@ declare function StatisticValue({ className, size, ...props }: React.ComponentPr
7
7
  }): React.JSX.Element;
8
8
  declare function StatisticCaption({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
9
9
  declare const trendVariants: (props?: ({
10
- direction?: "flat" | "up" | "down" | null | undefined;
10
+ direction?: "flat" | "down" | "up" | null | undefined;
11
11
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
12
  declare function Trend({ className, direction, ...props }: React.ComponentProps<'span'> & VariantProps<typeof trendVariants>): React.JSX.Element;
13
13
  declare const meterVariants: (props?: ({