// ─── Internal imports (used to assemble the curated `Legend` const) ───────── import { LegendProvider } from './provider/legend-provider' import { LegendGroup } from './components/legend-group/legend-group' import { LegendRow } from './components/legend-row/legend-row' import { LegendActions } from './components/legend-actions/legend-actions' import { LegendVisibilityToggle } from './components/legend-visibility-toggle/legend-visibility-toggle' import { LegendRowMenu } from './components/legend-row-menu/legend-row-menu' import { LegendZoomTo } from './components/legend-row-menu/legend-zoom-to' import { LegendShowOnlyLayer, LegendShowAllLayers, } from './components/legend-row-menu/legend-row-menu-items' import { LegendGroupMenu } from './components/legend-group-menu/legend-group-menu' import { LegendShowOnlyGroup, LegendShowAllGroups, LegendCollapseAllGroups, LegendZoomToGroup, } from './components/legend-group-menu/legend-group-menu-items' import { LegendPanelMenu } from './components/legend-panel-menu/legend-panel-menu' import { LegendVisibleLayers } from './components/legend-visible-layers/legend-visible-layers' import { LegendSortable } from './components/legend-sortable/legend-sortable' import { LegendOpacity } from './components/legend-opacity/legend-opacity' import { LegendConfigSelect } from './components/legend-config-select/legend-config-select' import { LegendItem } from './components/legend-item/legend-item' import { LegendItemUI } from './components/legend-item/legend-item-ui' import { LegendSwatch } from './components/legend-swatch/legend-swatch' import { LegendCategoryUI } from './components/legend-category/legend-category-ui' import { LegendRampUI } from './components/legend-ramp/legend-ramp-ui' import { LegendProportionUI } from './components/legend-proportion/legend-proportion-ui' import { LegendIconUI } from './components/legend-icon/legend-icon-ui' /** * Curated namespace export — the entry point to the legend module. * * Composable, widgets-v2 style: the lib ships wrapper shells + standalone * store-connected actions, and the **app mounts the legend** in its own * chrome (panel/drawer/sidebar). `Legend.Row`/`Legend.Group` partition their * children — `` renders in the sticky header (hover-fade), * everything else in the collapsible body. * * Collapse is the title row itself (whole header minus the actions), with an * informative chevron that touch devices don't show. The ⋮ menus are * extensible shells: compose the built-in items and append your own * `MenuItem`s. The built-in items are **self-contained** — their effect is * implemented inside the component through the store's primitive setters, so * they mount with zero wiring; only `ZoomTo`/`ZoomToGroup` take an `onZoomTo` * handler (zooming is the map's concern). Pass an async handler to keep the * menu open with in-item loading feedback until it settles. * * ```tsx * import { Legend } from '@carto/ps-react-ui/legend' * * * // Panel-wide actions (Show all groups / Collapse all) live once here, * // not repeated per group. * * * * * * * * // tri-state group eye * // ⋮ (rightmost) * * // this group's members * * * * * // Actions read L→R: eye · ⋮ options * * // layer eye * * * * * * * // bar between header and body * * * * * * ``` * * `Legend.ShowAllLayers` is composed at whichever site it targets: directly * in a `Legend.GroupMenu` for that group's members (as above), or in an * ungrouped row's `Legend.RowMenu` for the loose-layer bucket — it resolves * its own scope from context either way. * * @experimental This API is new and may change in a future release. */ export const Legend = { // Composition shell Provider: LegendProvider, Group: LegendGroup, Row: LegendRow, Actions: LegendActions, Sortable: LegendSortable, // Store-connected actions & controls (context-driven) VisibilityToggle: LegendVisibilityToggle, RowMenu: LegendRowMenu, ZoomTo: LegendZoomTo, ShowOnlyLayer: LegendShowOnlyLayer, ShowAllLayers: LegendShowAllLayers, GroupMenu: LegendGroupMenu, ShowOnlyGroup: LegendShowOnlyGroup, ShowAllGroups: LegendShowAllGroups, CollapseAllGroups: LegendCollapseAllGroups, ZoomToGroup: LegendZoomToGroup, PanelMenu: LegendPanelMenu, VisibleLayers: LegendVisibleLayers, Opacity: LegendOpacity, ConfigSelect: LegendConfigSelect, Item: LegendItem, // Pure UI ItemUI: LegendItemUI, Swatch: LegendSwatch, CategoryUI: LegendCategoryUI, RampUI: LegendRampUI, ProportionUI: LegendProportionUI, IconUI: LegendIconUI, } as const // ─── Labels ──────────────────────────────────────────────────────────────── // Exported separately so consumers can build customized label sets via spread. export { DEFAULT_LEGEND_LABELS } from './provider' // ─── Types ───────────────────────────────────────────────────────────────── export type { LegendProviderProps, LegendLabels } from './provider' export type { LegendGroupProps } from './components/legend-group/legend-group' export type { LegendRowProps } from './components/legend-row/legend-row' export type { LegendActionsProps } from './components/legend-actions/legend-actions' export type { LegendSortableProps } from './components/legend-sortable/legend-sortable' export type { LegendVisibilityToggleProps } from './components/legend-visibility-toggle/legend-visibility-toggle' export type { LegendRowMenuProps } from './components/legend-row-menu/legend-row-menu' export type { LegendZoomToProps } from './components/legend-row-menu/legend-zoom-to' export type { LegendGroupMenuProps } from './components/legend-group-menu/legend-group-menu' export type { LegendZoomToGroupProps } from './components/legend-group-menu/legend-group-menu-items' export type { LegendPanelMenuProps } from './components/legend-panel-menu/legend-panel-menu' export type { LegendRowContextValue } from './components/contexts' export type { LegendItemUIProps } from './components/legend-item/legend-item-ui' export type { LegendSwatchProps } from './components/legend-swatch/legend-swatch' export type { LegendCategoryUIProps } from './components/legend-category/legend-category-ui' export type { LegendRampUIProps } from './components/legend-ramp/legend-ramp-ui' export type { LegendProportionUIProps } from './components/legend-proportion/legend-proportion-ui' export type { LegendIconUIProps } from './components/legend-icon/legend-icon-ui' // Store entity & variable types (re-exported for convenience; full store API // lives at `@carto/ps-react-ui/legend/stores`). export type { LegendPosition, LegendVisibility, LegendOrientation, LegendSwatchShape, LegendFillPattern, LegendStrokeStyle, LegendVariable, LegendCategoryItem, LegendCategoryVariable, LegendRampStop, LegendRampVariable, LegendProportionVariable, LegendIconItem, LegendIconVariable, LegendConfigSection, LegendLayer, LegendGroup as LegendGroupModel, LegendLayerInput, LegendGroupInput, } from './stores'