@mohasinac/appkit 4.30.5 → 4.30.6
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.
|
@@ -99,7 +99,17 @@ export function AdminUsersView({ children, ...props }) {
|
|
|
99
99
|
const config = {
|
|
100
100
|
portal: "admin",
|
|
101
101
|
title: "Users",
|
|
102
|
-
|
|
102
|
+
// Exact match, and the copy has to say so. `/api/admin/users` branches on
|
|
103
|
+
// whether the term contains "@": an email resolves through
|
|
104
|
+
// `emailIndex == piiBlindIndex(q)` and a name through `displayName == q`.
|
|
105
|
+
// BOTH are equality. Email cannot be partial-matched at all — it is
|
|
106
|
+
// encrypted, and ciphertext has no usable prefix (D1) — and "seller
|
|
107
|
+
// handles" were never matched by anything.
|
|
108
|
+
search: {
|
|
109
|
+
placeholder: "Full name or email (exact match)",
|
|
110
|
+
mode: "exact",
|
|
111
|
+
fields: ["displayName", "email"],
|
|
112
|
+
},
|
|
103
113
|
emptyLabel: "No users found",
|
|
104
114
|
filterKeys: ["status", "role"],
|
|
105
115
|
defaultSort: sortBy("createdAt", "DESC"),
|
|
@@ -78,7 +78,36 @@ export interface ListingViewConfig<TResponse, TRow extends {
|
|
|
78
78
|
portal: "admin" | "seller" | "user";
|
|
79
79
|
title: string;
|
|
80
80
|
subtitle?: string;
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Search box copy. OPTIONAL — declaring it is what makes the box exist.
|
|
83
|
+
*
|
|
84
|
+
* It was REQUIRED, and `DataListingView` passed `onSearchChange`
|
|
85
|
+
* unconditionally, so a developer could not build a listing view without
|
|
86
|
+
* rendering a search box. `ListingToolbar` has always gated the box on
|
|
87
|
+
* `onSearchChange` being supplied; nothing ever declined to supply it.
|
|
88
|
+
*
|
|
89
|
+
* That is the structural cause of the dead boxes: ~39 views render a search
|
|
90
|
+
* input whose endpoint never reads `q`. The box accepts typing, the request
|
|
91
|
+
* carries the term, and the results do not change — no error anywhere.
|
|
92
|
+
*
|
|
93
|
+
* Omit it when the endpoint cannot search. Do not pass a placeholder
|
|
94
|
+
* describing a capability the endpoint lacks.
|
|
95
|
+
*/
|
|
96
|
+
searchPlaceholder?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Explicit search capability. Prefer this over a bare `searchPlaceholder`
|
|
99
|
+
* when the match semantics matter to the user — PII-backed fields are
|
|
100
|
+
* exact-match by construction (encryption and partial-match search are
|
|
101
|
+
* mutually exclusive), and a placeholder promising "search by email" over a
|
|
102
|
+
* blind index is a promise the backend cannot keep.
|
|
103
|
+
*/
|
|
104
|
+
search?: {
|
|
105
|
+
placeholder: string;
|
|
106
|
+
/** `exact` for a field resolved through an HMAC blind index. */
|
|
107
|
+
mode?: "partial" | "exact";
|
|
108
|
+
/** Fields the endpoint actually matches on. */
|
|
109
|
+
fields?: readonly string[];
|
|
110
|
+
};
|
|
82
111
|
emptyLabel?: string;
|
|
83
112
|
sortOptions: ListingSortOption[];
|
|
84
113
|
columns?: AdminTableColumn<TRow>[];
|
|
@@ -78,7 +78,13 @@ export function DataListingView({ config, }) {
|
|
|
78
78
|
window.location.href = href;
|
|
79
79
|
}
|
|
80
80
|
: undefined;
|
|
81
|
-
|
|
81
|
+
// A box exists only when the config asks for one.
|
|
82
|
+
const searchEnabled = Boolean(config.search ?? config.searchPlaceholder);
|
|
83
|
+
return (_jsxs(Div, { className: config.className ?? "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: config.search?.placeholder ?? config.searchPlaceholder,
|
|
84
|
+
// Passing this is what renders the box — ListingToolbar gates on it.
|
|
85
|
+
// Undefined when the config declares no search, so a view whose
|
|
86
|
+
// endpoint cannot search no longer shows an input that does nothing.
|
|
87
|
+
onSearchChange: searchEnabled ? setSearchInput : undefined, onSearchCommit: searchEnabled ? commitSearch : undefined, sortValue: table.get("sort") || config.defaultSort, sortOptions: config.sortOptions, onSortChange: (v) => table.set("sort", v), showTableView: !config.hideTableView, toggles: config.toggles, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState, extra: config.primaryAction || config.toolbarExtra ? (_jsxs(Row, { align: "center", gap: "sm", children: [config.toolbarExtra, config.primaryAction && (_jsxs(Button, { gap: "sm", size: "sm", onClick: () => config.primaryAction.onClick({
|
|
82
88
|
openCreatePanel: panel.openCreatePanel,
|
|
83
89
|
}), children: [config.primaryAction.icon ?? _jsx(Plus, { className: "h-4 w-4" }), config.primaryAction.label] }))] })) : undefined }), config.renderAboveContent?.(), bulkActionItems && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActionItems })), totalPages > 1 && (_jsx(StickyToolbar, { offset: "header+pagination", tone: "translucent", border: true, padding: "toolbar", children: _jsx(Row, { justify: "center", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p), pageSize: pageSize, onPageSizeChange: setPageSize, paginationConfig: { showPageSizeSelector: true, pageSizeOptions: [10, 25, 50, 100] } }) }) })), _jsxs(Div, { paddingX: "x-sm-md", padding: "y-md", children: [errorMessage && (_jsx(Div, { textSize: "sm", className: "mb-4 border border-error/20", color: "error", surface: "danger-surface", padding: "inline", rounded: "xl", children: errorMessage })), view === "table" && !config.hideTableView && !isMobile ? (_jsx(DataTable, { columns: config.columns, rows: rows, resourceIcon: resourceIcon, isLoading: isLoading, emptyLabel: config.emptyLabel ?? `No ${config.title.toLowerCase()} found`, selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next
|
|
84
90
|
? selection.setSelectedIds(rows.map((r) => r.id))
|