@bfrs/agentic-components 0.6.3 → 0.6.5
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/BFRS_AGENTIC_COMPONENTS.md +0 -1
- package/dist/components/data-display/DataTable/DataTable.types.d.ts +18 -1
- package/dist/components/data-display/DataTable/TableColumnVisibility.d.ts +1 -1
- package/dist/components/data-display/DataTable/TableEmptyState.d.ts +2 -2
- package/dist/components/data-display/DataTable/TableViewSelector.d.ts +44 -0
- package/dist/components/data-display/DataTable/index.d.ts +2 -0
- package/dist/components/data-display/DataTable/saveViewApi.d.ts +22 -10
- package/dist/components/data-display/DataTable/viewStore.d.ts +55 -0
- package/dist/components/filters/DateRangePicker/DateRangePicker.utils.d.ts +8 -0
- package/dist/components/ui/forms/MultiSelect/MultiSelect.d.ts +0 -1
- package/dist/custom-elements.d.ts +10 -0
- package/dist/custom-elements.js +10158 -9222
- package/dist/custom-elements.js.map +1 -1
- package/dist/index.js +6500 -5638
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -691,7 +691,6 @@ Angular custom element:
|
|
|
691
691
|
| `disabled` | `boolean` | `false` |
|
|
692
692
|
| `error` | `boolean` | `false` |
|
|
693
693
|
| `clearable` | `boolean` | `true` |
|
|
694
|
-
| `maxVisibleValues` | `number` | `2` |
|
|
695
694
|
| `commitMode` | `"change" \| "apply"` | `"change"` |
|
|
696
695
|
| `applyLabel` | `string` | `"Apply"` |
|
|
697
696
|
| `cancelLabel` | `string` | `"Cancel"` |
|
|
@@ -141,6 +141,17 @@ export type TableStateProps = {
|
|
|
141
141
|
colSpan?: number;
|
|
142
142
|
className?: string;
|
|
143
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Empty ("no data") view props. Unlike the shared `TableStateProps` (used by the
|
|
146
|
+
* loading/error rows), both `title` and `description` are **required** — the
|
|
147
|
+
* no-data view is always a two-line message. DataTable defaults both, so table
|
|
148
|
+
* consumers never have to pass them; consumers rendering TableEmptyState directly
|
|
149
|
+
* must supply both lines.
|
|
150
|
+
*/
|
|
151
|
+
export type TableEmptyStateProps = Omit<TableStateProps, "title" | "description"> & {
|
|
152
|
+
title: ReactNode;
|
|
153
|
+
description: ReactNode;
|
|
154
|
+
};
|
|
144
155
|
export type TableSkeletonProps = {
|
|
145
156
|
rows?: number;
|
|
146
157
|
columns?: number;
|
|
@@ -158,7 +169,7 @@ export type TableBulkActionsProps = {
|
|
|
158
169
|
label?: ReactNode;
|
|
159
170
|
className?: string;
|
|
160
171
|
};
|
|
161
|
-
export type ViewType =
|
|
172
|
+
export type ViewType = string;
|
|
162
173
|
export type ViewColumn = {
|
|
163
174
|
key: string;
|
|
164
175
|
order: number;
|
|
@@ -202,6 +213,12 @@ export type TableColumnVisibilityProps = {
|
|
|
202
213
|
label?: ReactNode;
|
|
203
214
|
resetLabel?: ReactNode;
|
|
204
215
|
onReset?: () => void;
|
|
216
|
+
/**
|
|
217
|
+
* Clears any active table filters. Called by the "Reset" footer action
|
|
218
|
+
* alongside `onReset`, so resetting the view reverts columns *and* filters.
|
|
219
|
+
* Supplying only this (without `onReset`) still renders the Reset button.
|
|
220
|
+
*/
|
|
221
|
+
onClearFilters?: () => void;
|
|
205
222
|
/** Label for the "Show all" footer button. Defaults to "Show all". */
|
|
206
223
|
showAllLabel?: ReactNode;
|
|
207
224
|
/** Override the "Show all" action. Defaults to making every column visible. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TableColumnVisibilityProps } from './DataTable.types';
|
|
2
|
-
export declare function TableColumnVisibility({ columns, visibleColumnIds, onVisibleColumnIdsChange, label, resetLabel, onReset, showAllLabel, onShowAll, className }: TableColumnVisibilityProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function TableColumnVisibility({ columns, visibleColumnIds, onVisibleColumnIdsChange, label, resetLabel, onReset, onClearFilters, showAllLabel, onShowAll, className }: TableColumnVisibilityProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function TableEmptyState({ title, description, action, colSpan, className }:
|
|
1
|
+
import { TableEmptyStateProps } from './DataTable.types';
|
|
2
|
+
export declare function TableEmptyState({ title, description, action, colSpan, className }: TableEmptyStateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SavedView } from './DataTable.types';
|
|
3
|
+
import { ViewStore } from './viewStore';
|
|
4
|
+
export type TableViewSelectorProps = {
|
|
5
|
+
/** Free-form screen key used for localStorage scoping, e.g. "orders_new". */
|
|
6
|
+
screenName: string;
|
|
7
|
+
/** Optional store adapter. Defaults to localStorage via createLocalViewStore(screenName). */
|
|
8
|
+
store?: ViewStore;
|
|
9
|
+
/** Controlled selected view id. Selection is separate from the persisted primary view. */
|
|
10
|
+
value?: string | null;
|
|
11
|
+
/** Initial selected view id for uncontrolled mode. Falls back to the store's primary view. */
|
|
12
|
+
defaultValue?: string | null;
|
|
13
|
+
/** Select and emit the screen's primary view when no selected value is present. Defaults to true. */
|
|
14
|
+
selectPrimaryByDefault?: boolean;
|
|
15
|
+
onValueChange?: (viewId: string | null, view: SavedView | null) => void;
|
|
16
|
+
onViewSelect?: (view: SavedView) => void;
|
|
17
|
+
onPrimaryViewChange?: (view: SavedView) => void;
|
|
18
|
+
onRenameView?: (view: SavedView) => void;
|
|
19
|
+
onDeleteView?: (viewId: string) => void;
|
|
20
|
+
onResetSavedFilters?: () => void;
|
|
21
|
+
onError?: (error: unknown) => void;
|
|
22
|
+
triggerLabel?: ReactNode;
|
|
23
|
+
placeholder?: ReactNode;
|
|
24
|
+
viewsLabel?: ReactNode;
|
|
25
|
+
emptyLabel?: ReactNode;
|
|
26
|
+
loadingLabel?: ReactNode;
|
|
27
|
+
resetLabel?: ReactNode;
|
|
28
|
+
setPrimaryLabel?: ReactNode;
|
|
29
|
+
renameLabel?: ReactNode;
|
|
30
|
+
deleteLabel?: ReactNode;
|
|
31
|
+
renameTitle?: ReactNode;
|
|
32
|
+
renameDescription?: ReactNode;
|
|
33
|
+
renameInputLabel?: ReactNode;
|
|
34
|
+
renameCancelLabel?: ReactNode;
|
|
35
|
+
renameSaveLabel?: ReactNode;
|
|
36
|
+
/** Trigger size. Matches select-family sizing: sm = 28px, md = 36px. */
|
|
37
|
+
size?: "sm" | "md";
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
className?: string;
|
|
40
|
+
triggerClassName?: string;
|
|
41
|
+
contentClassName?: string;
|
|
42
|
+
actionMenuClassName?: string;
|
|
43
|
+
};
|
|
44
|
+
export declare function TableViewSelector({ screenName, store, value, defaultValue, selectPrimaryByDefault, onValueChange, onViewSelect, onPrimaryViewChange, onRenameView, onDeleteView, onResetSavedFilters, onError, triggerLabel, placeholder, viewsLabel, emptyLabel, loadingLabel, resetLabel, setPrimaryLabel, renameLabel, deleteLabel, renameTitle, renameDescription, renameInputLabel, renameCancelLabel, renameSaveLabel, size, disabled, className, triggerClassName, contentClassName, actionMenuClassName }: TableViewSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { SaveViewPayload, SaveViewResult } from './DataTable.types';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export type SaveViewHeaderSource = Record<string, string | null | undefined> | (() => Record<string, string | null | undefined>);
|
|
3
|
+
export type SaveViewTokenSource = string | null | undefined | (() => string | null | undefined);
|
|
4
|
+
export type SaveViewApiConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Base URL of the API service. Both host roots and `/api/v1` roots are
|
|
7
|
+
* supported, e.g. `https://platform.shiprocket.in` or
|
|
8
|
+
* `https://platform.shiprocket.in/api/v1/`.
|
|
9
|
+
*/
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Endpoint path. Defaults to `api/v1/saveview` and de-dupes `/api/v1`. */
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
/** Auth token or lazy token reader. Defaults to common Shiprocket localStorage keys. */
|
|
14
|
+
token?: SaveViewTokenSource;
|
|
15
|
+
/** Extra headers or lazy header reader. */
|
|
16
|
+
headers?: SaveViewHeaderSource;
|
|
17
|
+
credentials?: RequestCredentials;
|
|
18
|
+
fetcher?: typeof globalThis.fetch;
|
|
19
|
+
};
|
|
20
|
+
export type SaveViewOptions = SaveViewApiConfig & {
|
|
6
21
|
payload: SaveViewPayload;
|
|
7
22
|
};
|
|
8
23
|
/**
|
|
@@ -11,16 +26,13 @@ export type SaveViewOptions = {
|
|
|
11
26
|
* Saves a user view. Returns the saved view and whether it was a duplicate.
|
|
12
27
|
* Throws on HTTP error (auth, validation, network).
|
|
13
28
|
*/
|
|
14
|
-
export declare function saveView({ baseUrl, token, payload }: SaveViewOptions): Promise<SaveViewResult>;
|
|
29
|
+
export declare function saveView({ baseUrl, endpoint, token, headers, credentials, fetcher, payload, }: SaveViewOptions): Promise<SaveViewResult>;
|
|
15
30
|
/**
|
|
16
31
|
* Creates a pre-configured save function bound to a base URL and token.
|
|
17
32
|
* The returned function matches the `TableSaveView.onSave` signature directly.
|
|
18
33
|
*
|
|
19
34
|
* @example
|
|
20
|
-
* const save = createSaveView({ baseUrl: import.meta.env.
|
|
35
|
+
* const save = createSaveView({ baseUrl: import.meta.env.VITE_AGENTIC_BASE_URL });
|
|
21
36
|
* <TableSaveView onSave={save} onSaved={...} />
|
|
22
37
|
*/
|
|
23
|
-
export declare function createSaveView(
|
|
24
|
-
baseUrl: string;
|
|
25
|
-
token: string;
|
|
26
|
-
}): (payload: SaveViewPayload) => Promise<SaveViewResult>;
|
|
38
|
+
export declare function createSaveView(config?: SaveViewApiConfig): (payload: SaveViewPayload) => Promise<SaveViewResult>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { SavedView, SaveViewPayload, SaveViewResult } from './DataTable.types';
|
|
2
|
+
import { SaveViewApiConfig } from './saveViewApi';
|
|
3
|
+
/**
|
|
4
|
+
* A persistence backend for a single screen's saved views.
|
|
5
|
+
*
|
|
6
|
+
* Every method is async so an HTTP-backed adapter (e.g. `createApiViewStore`)
|
|
7
|
+
* can be swapped in later without touching a single call site — the localStorage
|
|
8
|
+
* adapter simply resolves synchronously. `TableViewSelector` depends only on this
|
|
9
|
+
* interface, never on `localStorage` directly.
|
|
10
|
+
*/
|
|
11
|
+
export interface ViewStore {
|
|
12
|
+
/** All saved views for the screen, in stored order. */
|
|
13
|
+
list(): Promise<SavedView[]>;
|
|
14
|
+
/** A single view by id, or `null` if it isn't stored. */
|
|
15
|
+
get(viewId: string): Promise<SavedView | null>;
|
|
16
|
+
/** The primary view (`is_default: true`) for the screen, or `null`. */
|
|
17
|
+
getActive(): Promise<SavedView | null>;
|
|
18
|
+
/** Upsert by name — mirrors `saveView`'s `{ view, alreadyExists }` shape. */
|
|
19
|
+
save(payload: SaveViewPayload): Promise<SaveViewResult>;
|
|
20
|
+
/** Change a view's name in place. Rejects if the id isn't found. */
|
|
21
|
+
rename(viewId: string, name: string): Promise<SavedView>;
|
|
22
|
+
/** Delete a view. Promotes a new primary if the deleted one was primary. */
|
|
23
|
+
remove(viewId: string): Promise<void>;
|
|
24
|
+
/** Mark a view primary (`is_default: true`), clearing it on all others. */
|
|
25
|
+
setPrimary(viewId: string): Promise<SavedView>;
|
|
26
|
+
/** Remove every saved view for the screen ("Reset saved filters"). */
|
|
27
|
+
reset(): Promise<void>;
|
|
28
|
+
/** Subscribe to same-tab and cross-tab changes; returns an unsubscribe fn. */
|
|
29
|
+
subscribe(listener: () => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
export type RemoteSaveView = (payload: SaveViewPayload) => Promise<SaveViewResult | void>;
|
|
32
|
+
export type LocalViewStoreOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* Optional remote save adapter. When supplied, `save()` calls this first and
|
|
35
|
+
* only mirrors the view into localStorage after the remote save succeeds.
|
|
36
|
+
*/
|
|
37
|
+
remoteSave?: RemoteSaveView;
|
|
38
|
+
/** Convenience API config that uses the library `saveView()` implementation. */
|
|
39
|
+
saveApi?: SaveViewApiConfig;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Creates a localStorage-backed {@link ViewStore} scoped to `screenName`.
|
|
43
|
+
* Views for a screen live under `bfrs.savedViews.<screenName>`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createLocalViewStore(screenName: string, options?: LocalViewStoreOptions): ViewStore;
|
|
46
|
+
/**
|
|
47
|
+
* A pre-bound save function for a screen's local store, matching the
|
|
48
|
+
* `TableSaveView.onSave` signature — the localStorage counterpart of
|
|
49
|
+
* `createSaveView`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const onSave = createLocalSaveView("orders_new");
|
|
53
|
+
* <TableSaveView viewType="orders_new" onSave={onSave} />
|
|
54
|
+
*/
|
|
55
|
+
export declare function createLocalSaveView(screenName: string, options?: LocalViewStoreOptions): (payload: SaveViewPayload) => Promise<SaveViewResult>;
|
|
@@ -28,6 +28,14 @@ export declare function hasCompleteRange(value: DateRangeValue): value is DateRa
|
|
|
28
28
|
from: Date;
|
|
29
29
|
to: Date;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes an incoming value so `from`/`to` are always real `Date` objects (or
|
|
33
|
+
* `undefined`). Consumers commonly hydrate the value/defaultValue from
|
|
34
|
+
* JSON/API/storage where dates arrive as ISO strings or timestamps; without this
|
|
35
|
+
* the picker crashes on `getFullYear` and never recognizes the range as filled
|
|
36
|
+
* (so the trigger's filled border never lights up).
|
|
37
|
+
*/
|
|
38
|
+
export declare function coerceDateRangeValue(value: DateRangeValue): DateRangeValue;
|
|
31
39
|
export declare function getInitialCalendar(value: DateRangeValue, months: 1 | 2): {
|
|
32
40
|
year: number;
|
|
33
41
|
month: number;
|
|
@@ -24,7 +24,6 @@ export type MultiSelectProps = {
|
|
|
24
24
|
error?: boolean;
|
|
25
25
|
clearable?: boolean;
|
|
26
26
|
size?: "sm" | "md";
|
|
27
|
-
maxVisibleValues?: number;
|
|
28
27
|
/** Option popover width relative to the trigger. Defaults to `"auto"` (the
|
|
29
28
|
* popover grows to fit its content and can be wider than the trigger). */
|
|
30
29
|
menuWidth?: SelectMenuWidth;
|
|
@@ -584,6 +584,8 @@ export declare class BfrsTableToolbarElement extends ReactCustomElement {
|
|
|
584
584
|
declare abstract class BfrsTableStateElement extends ReactCustomElement {
|
|
585
585
|
protected abstract stateComponent(): typeof TableEmptyState | typeof TableErrorState;
|
|
586
586
|
protected abstract defaultTitle(): string;
|
|
587
|
+
/** Default second line. Empty for the error row; the empty state overrides it. */
|
|
588
|
+
protected defaultDescription(): string;
|
|
587
589
|
static get observedAttributes(): string[];
|
|
588
590
|
protected defaultDisplay(): string;
|
|
589
591
|
protected renderElement(): unknown;
|
|
@@ -592,6 +594,7 @@ export declare class BfrsTableEmptyStateElement extends BfrsTableStateElement {
|
|
|
592
594
|
static readonly tagName = "table-empty-state";
|
|
593
595
|
protected stateComponent(): typeof TableEmptyState;
|
|
594
596
|
protected defaultTitle(): string;
|
|
597
|
+
protected defaultDescription(): string;
|
|
595
598
|
}
|
|
596
599
|
export declare class BfrsTableErrorStateElement extends BfrsTableStateElement {
|
|
597
600
|
static readonly tagName = "table-error-state";
|
|
@@ -626,6 +629,12 @@ export declare class BfrsTableSaveViewElement extends OpenCustomElement {
|
|
|
626
629
|
protected defaultDisplay(): string;
|
|
627
630
|
protected renderElement(): unknown;
|
|
628
631
|
}
|
|
632
|
+
export declare class BfrsTableViewSelectorElement extends ReactCustomElement {
|
|
633
|
+
static readonly tagName = "table-view-selector";
|
|
634
|
+
static get observedAttributes(): string[];
|
|
635
|
+
protected defaultDisplay(): string;
|
|
636
|
+
protected renderElement(): unknown;
|
|
637
|
+
}
|
|
629
638
|
export declare class BfrsDataTableElement extends ReactCustomElement {
|
|
630
639
|
static readonly tagName = "data-table";
|
|
631
640
|
static get observedAttributes(): string[];
|
|
@@ -973,6 +982,7 @@ declare global {
|
|
|
973
982
|
"bfrs-table-bulk-actions": BfrsTableBulkActionsElement;
|
|
974
983
|
"bfrs-table-column-visibility": BfrsTableColumnVisibilityElement;
|
|
975
984
|
"bfrs-table-save-view": BfrsTableSaveViewElement;
|
|
985
|
+
"bfrs-table-view-selector": BfrsTableViewSelectorElement;
|
|
976
986
|
"bfrs-tabs": BfrsTabsElement;
|
|
977
987
|
"bfrs-tabs-list": BfrsTabsListElement;
|
|
978
988
|
"bfrs-tabs-trigger": BfrsTabsTriggerElement;
|