@foris/avocado-not-front 7.0.0 → 8.0.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.
@@ -7,5 +7,5 @@ interface TableNotFrontExtendedProps extends TableNotFrontProps {
7
7
  userFlow: string;
8
8
  pageId: string;
9
9
  }
10
- declare const TableNotFront: ({ userFlow, pageId, responseKey, component, dataSource, rightActions, data: inlineData, pageSize, ...tableProps }: TableNotFrontExtendedProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const TableNotFront: ({ userFlow, pageId, responseKey, component, dataSource, rightActions, data: inlineData, pageSize, showRowsPerPage, pageSizeOptions, labelRowsPerPage, autoHeight, ...tableProps }: TableNotFrontExtendedProps) => import("react/jsx-runtime").JSX.Element;
11
11
  export default TableNotFront;
@@ -0,0 +1,17 @@
1
+ export declare const DEFAULT_TABLE_PAGE_SIZE = 10;
2
+ export declare const DEFAULT_TABLE_PAGE_SIZE_OPTIONS: number[];
3
+ /** Space reserved below the table for the offset pager (nav + rows-per-page row). */
4
+ export declare const PAGER_RESERVED_HEIGHT = 72;
5
+ /** Minimum scroll container height when the table sits low on the page. */
6
+ export declare const MIN_TABLE_HEIGHT = 120;
7
+ /**
8
+ * Resolves the initial rows-per-page value from JSON config and selectable options.
9
+ *
10
+ * Uses `pageSize` when it is listed in `pageSizeOptions`; otherwise falls back to
11
+ * the first option, or {@link DEFAULT_TABLE_PAGE_SIZE} when options are empty.
12
+ *
13
+ * @param pageSize - Optional page size from table JSON config.
14
+ * @param pageSizeOptions - Allowed values for the rows-per-page selector.
15
+ * @returns The page size used for the first fetch and pager display.
16
+ */
17
+ export declare const resolveInitialPageSize: (pageSize: number | undefined, pageSizeOptions: number[]) => number;
@@ -0,0 +1,12 @@
1
+ type ComputeAvailableHeightArgs = {
2
+ viewportHeight: number;
3
+ elementTop: number;
4
+ pagerReservedHeight?: number;
5
+ minTableHeight?: number;
6
+ };
7
+ /**
8
+ * Computes how much vertical space the table scroll container can use so the
9
+ * pager stays within the viewport.
10
+ */
11
+ export declare const computeAvailableHeight: ({ viewportHeight, elementTop, pagerReservedHeight, minTableHeight, }: ComputeAvailableHeightArgs) => number;
12
+ export {};
@@ -0,0 +1,20 @@
1
+ export type TableScrollLayout = {
2
+ maxHeight?: string | number;
3
+ stickyHeader: boolean;
4
+ };
5
+ type ResolveTableScrollLayoutArgs = {
6
+ maxHeight?: string | number;
7
+ stickyHeader?: boolean;
8
+ autoFitToViewport: boolean;
9
+ availableHeight?: number;
10
+ };
11
+ /**
12
+ * Resolves table scroll layout for EntityHub-style tables.
13
+ *
14
+ * David T.'s criterion: cap the table at the viewport space below it so the
15
+ * pager stays on screen. The suite scroll container grows with content up to
16
+ * that cap; overflow triggers internal scroll and the sticky header keeps
17
+ * column labels visible. Independent of rows-per-page (`autoFitToViewport`).
18
+ */
19
+ export declare const resolveTableScrollLayout: ({ maxHeight, stickyHeader, autoFitToViewport, availableHeight, }: ResolveTableScrollLayoutArgs) => TableScrollLayout;
20
+ export {};
@@ -0,0 +1,17 @@
1
+ type UseAvailableHeightArgs = {
2
+ enabled: boolean;
3
+ };
4
+ /**
5
+ * Measures the vertical space available for the table scroll container.
6
+ *
7
+ * EntityHub pages are JSON-driven and the table cannot assume a flex parent.
8
+ * David T.'s criterion: the table must not grow past the viewport — the pager
9
+ * stays visible and overflow scrolls inside the table. We measure from the
10
+ * container top to the viewport bottom, reserving {@link PAGER_RESERVED_HEIGHT}
11
+ * for the pager below. Recalculates on resize and layout changes, not scroll.
12
+ */
13
+ export declare const useAvailableHeight: ({ enabled }: UseAvailableHeightArgs) => {
14
+ tableContainerRef: import("react").Dispatch<import("react").SetStateAction<HTMLDivElement | null>>;
15
+ availableHeight: number | undefined;
16
+ };
17
+ export {};
@@ -399,8 +399,8 @@ export interface PillNotFrontProps extends NotFrontBaseProps, Omit<PillProps, 'c
399
399
  content: string;
400
400
  /**
401
401
  * Visual variant that applies predefined color schemes.
402
- * Automatically sets color, textColor, and iconColor based on the variant.
403
- * Default: 'neutral'
402
+ * Resolves color, textColor, and iconColor from the filled or outlined palette
403
+ * depending on `outlined`. Default: 'neutral'
404
404
  */
405
405
  variant?: 'success' | 'warning' | 'error' | 'info' | 'neutral';
406
406
  }
@@ -578,14 +578,32 @@ export interface TableNotFrontProps extends NotFrontBaseProps, Omit<TableProps,
578
578
  */
579
579
  data?: TableProps['data'];
580
580
  /**
581
- * Enables client-side pagination over static `data`. When provided and the
582
- * number of rows exceeds `pageSize`, the table renders one page at a time
583
- * with a pager. When omitted, all static rows are shown at once.
584
- *
585
- * Only applies to static `data`. It is ignored when `dataSource` is present
586
- * (in that case pagination is server-driven via the response).
581
+ * Initial page size. For static `data`, enables client-side pagination when
582
+ * the number of rows exceeds this value. For `dataSource`, sent on the first
583
+ * request and kept in sync when the user changes rows per page.
587
584
  */
588
585
  pageSize?: number;
586
+ /**
587
+ * Shows the rows-per-page selector in the pager. Only applies to offset
588
+ * pagination (not cursor). Default: false.
589
+ */
590
+ showRowsPerPage?: boolean;
591
+ /**
592
+ * Caps the table scroll area to the viewport space below it so the pager
593
+ * stays on screen. Overflow uses internal scroll with a sticky header.
594
+ * Default: true (disabled for cursor pagination). Override with explicit
595
+ * `maxHeight` / `stickyHeader`.
596
+ */
597
+ autoHeight?: boolean;
598
+ /**
599
+ * Options for the rows-per-page selector. The backend may override the
600
+ * default list. Default when omitted: `[10, 20, 50, 100]`.
601
+ */
602
+ pageSizeOptions?: number[];
603
+ /**
604
+ * Label for the rows-per-page selector. Default: "Filas por página:".
605
+ */
606
+ labelRowsPerPage?: string;
589
607
  /**
590
608
  * Data source to load data for table. Required when not providing static data.
591
609
  */
@@ -24,10 +24,15 @@ interface BaseDataSource {
24
24
  headers?: Record<string, string>;
25
25
  params?: any;
26
26
  }
27
+ export type NotFrontPaginationKeys = {
28
+ page?: string;
29
+ text?: string;
30
+ size?: string;
31
+ };
27
32
  export interface NotFrontDataSourceRest extends BaseDataSource {
28
33
  type: 'rest';
29
34
  data?: any;
30
- paginationKeys?: Record<string, string>;
35
+ paginationKeys?: NotFrontPaginationKeys;
31
36
  }
32
37
  export interface NotFrontDataSourceGraphQL extends BaseDataSource {
33
38
  type: 'graphql';
@@ -13,9 +13,10 @@ export declare const normalizeHttpMethod: (method: string | undefined) => NotFro
13
13
  * @param dataSource - The REST data source configuration.
14
14
  * @param page - The current pagination page number.
15
15
  * @param search - Optional search term to include as a query parameter.
16
+ * @param pageSize - Optional page size to include as a query parameter.
16
17
  * @returns {string} The complete URL with all query parameters combined.
17
18
  */
18
- export declare const buildQueryParams: (dataSource: NotFrontDataSourceRest, page: number, search?: string) => string;
19
+ export declare const buildQueryParams: (dataSource: NotFrontDataSourceRest, page: number, search?: string, pageSize?: number) => string;
19
20
  /**
20
21
  * Utility to build a normalized NotFrontDataSource object for REST or GraphQL requests.
21
22
  *
@@ -28,8 +29,9 @@ export declare const buildQueryParams: (dataSource: NotFrontDataSourceRest, page
28
29
  * @param page - The page number for pagination (default: 1)
29
30
  * @param search - Optional search string (used for filtering, e.g., in selects)
30
31
  * @param cursorPayload - Optional cursor object built from the previous response; merged into the REST request `data` after the flow's original `data`.
32
+ * @param pageSize - Optional page size sent with pagination requests.
31
33
  * @returns A NotFrontDataSource object ready for fetchDataSource
32
34
  * @throws If the dataSource type is not supported
33
35
  */
34
- export declare const buildRequestDataSource: (dataSource: NotFrontDataSource, page: number, search?: string, cursorPayload?: Record<string, unknown> | null) => NotFrontDataSource;
36
+ export declare const buildRequestDataSource: (dataSource: NotFrontDataSource, page: number, search?: string, cursorPayload?: Record<string, unknown> | null, pageSize?: number) => NotFrontDataSource;
35
37
  export {};
@@ -15,6 +15,15 @@ export declare const PILL_VARIANT_COLORS: Record<TablePillVariant, TablePillColo
15
15
  * border. Each variant gets a solid border token and a readable text token.
16
16
  */
17
17
  export declare const PILL_OUTLINED_VARIANT_COLORS: Record<TablePillVariant, TablePillColors>;
18
+ /**
19
+ * The tokens a pill of this variant needs, filled or outlined.
20
+ *
21
+ * `Pill` paints `color` as the border when `outlined` is set, so the two looks
22
+ * cannot share a table: the filled tokens would draw a border the user cannot
23
+ * see. Every caller that renders a pill from a variant has to go through here,
24
+ * or the outlined look silently degrades to an invisible outline.
25
+ */
26
+ export declare const resolvePillColors: (variant: TablePillVariant, outlined?: boolean) => TablePillColors;
18
27
  export declare const TABLE_PILL_OUTLINED_TOKEN = "outlined";
19
28
  export declare const isTablePillVariant: (value: unknown) => value is "success" | "warning" | "error" | "info" | "neutral";
20
29
  export type ParsedTablePill = {