@alepha/ui 0.32.0 → 0.33.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/dist/account/AccountConnections.js +1 -1
- package/dist/account/AccountConnections.js.map +1 -1
- package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
- package/dist/account/AccountDeleteDialog.js +17 -17
- package/dist/account/AccountDeleteDialog.js.map +1 -1
- package/dist/account/AccountKeys.js +2 -2
- package/dist/account/AccountKeys.js.map +1 -1
- package/dist/account/AccountMfaDialog.d.ts.map +1 -1
- package/dist/account/AccountMfaDialog.js +19 -25
- package/dist/account/AccountMfaDialog.js.map +1 -1
- package/dist/account/AccountPasswordDialog.d.ts.map +1 -1
- package/dist/account/AccountPasswordDialog.js +25 -24
- package/dist/account/AccountPasswordDialog.js.map +1 -1
- package/dist/account/AccountProfile.d.ts.map +1 -1
- package/dist/account/AccountProfile.js +17 -24
- package/dist/account/AccountProfile.js.map +1 -1
- package/dist/account/AccountSecurity.d.ts.map +1 -1
- package/dist/account/AccountSecurity.js +21 -19
- package/dist/account/AccountSecurity.js.map +1 -1
- package/dist/account/AccountSessions.js +1 -1
- package/dist/account/AccountSessions.js.map +1 -1
- package/dist/account/ApiKeyCreateDialog.d.ts.map +1 -1
- package/dist/account/ApiKeyCreateDialog.js +8 -12
- package/dist/account/ApiKeyCreateDialog.js.map +1 -1
- package/dist/admin/AdminFiles.js +1 -1
- package/dist/admin/AdminFiles.js.map +1 -1
- package/dist/admin/AdminJobs.js +1 -1
- package/dist/admin/AdminJobs.js.map +1 -1
- package/dist/admin/AdminKeys.js +1 -1
- package/dist/admin/AdminKeys.js.map +1 -1
- package/dist/admin/AdminParameters.d.ts.map +1 -1
- package/dist/admin/AdminParameters.js +7 -5
- package/dist/admin/AdminParameters.js.map +1 -1
- package/dist/admin/AdminParametersTreeFooterActions.d.ts +2 -2
- package/dist/admin/AdminParametersTreeFooterActions.d.ts.map +1 -1
- package/dist/admin/AdminParametersTreeFooterActions.js.map +1 -1
- package/dist/admin/AdminParametersTreePane.d.ts +2 -2
- package/dist/admin/AdminParametersTreePane.d.ts.map +1 -1
- package/dist/admin/AdminParametersTreePane.js.map +1 -1
- package/dist/admin/AdminRouter.d.ts +1 -3
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminRouter.js +2 -4
- package/dist/admin/AdminRouter.js.map +1 -1
- package/dist/admin/AdminSessions.js +1 -1
- package/dist/admin/AdminSessions.js.map +1 -1
- package/dist/admin/AdminUserAvatarControl.d.ts.map +1 -1
- package/dist/admin/AdminUserAvatarControl.js +9 -16
- package/dist/admin/AdminUserAvatarControl.js.map +1 -1
- package/dist/admin/AdminUserDetail.js +4 -4
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/admin/AdminUsers.d.ts.map +1 -1
- package/dist/admin/AdminUsers.js +10 -12
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/AdminUsersRolesPicker.d.ts +5 -1
- package/dist/admin/AdminUsersRolesPicker.d.ts.map +1 -1
- package/dist/admin/AdminUsersRolesPicker.js +2 -3
- package/dist/admin/AdminUsersRolesPicker.js.map +1 -1
- package/dist/admin/analytics/QueryPanel.js +1 -1
- package/dist/admin/analytics/QueryPanel.js.map +1 -1
- package/dist/admin/useConfirmedAction.d.ts +8 -2
- package/dist/admin/useConfirmedAction.d.ts.map +1 -1
- package/dist/admin/useConfirmedAction.js +15 -4
- package/dist/admin/useConfirmedAction.js.map +1 -1
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +4 -4
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthRegister.js.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/form/AutoForm.js +1 -1
- package/dist/form/AutoForm.js.map +1 -1
- package/dist/form/Control.js +1 -1
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlArray.js +5 -5
- package/dist/form/ControlArray.js.map +1 -1
- package/dist/form/ControlSelect.js +2 -2
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlUpload.d.ts +1 -1
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +0 -9
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/organizations/MyOrganizationInvitations.js +2 -2
- package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
- package/dist/organizations/OrganizationInviteDialog.js +1 -1
- package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
- package/dist/organizations/OrganizationMembers.js +1 -1
- package/dist/organizations/OrganizationMembers.js.map +1 -1
- package/dist/organizations/OrganizationPendingInvitations.js +1 -1
- package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
- package/dist/organizations/OrganizationRanks.js +3 -3
- package/dist/organizations/OrganizationRanks.js.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts +6 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.js +13 -13
- package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
- package/dist/organizations/useRevokeOrganizationInvitation.d.ts +7 -1
- package/dist/organizations/useRevokeOrganizationInvitation.d.ts.map +1 -1
- package/dist/organizations/useRevokeOrganizationInvitation.js +13 -2
- package/dist/organizations/useRevokeOrganizationInvitation.js.map +1 -1
- package/dist/shell/ButtonUser.d.ts +1 -2
- package/dist/shell/ButtonUser.d.ts.map +1 -1
- package/dist/shell/ButtonUser.js +14 -42
- package/dist/shell/ButtonUser.js.map +1 -1
- package/dist/shell/ButtonUserContent.d.ts +13 -0
- package/dist/shell/ButtonUserContent.d.ts.map +1 -0
- package/dist/shell/ButtonUserContent.js +52 -0
- package/dist/shell/ButtonUserContent.js.map +1 -0
- package/dist/shell/ButtonUserPlaceholder.d.ts +14 -0
- package/dist/shell/ButtonUserPlaceholder.d.ts.map +1 -0
- package/dist/shell/ButtonUserPlaceholder.js +17 -0
- package/dist/shell/ButtonUserPlaceholder.js.map +1 -0
- package/dist/styles.css +31 -0
- package/dist/table/DataTable.js +1 -1
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableFilterBar.js +2 -2
- package/dist/table/DataTableFilterBar.js.map +1 -1
- package/dist/table/dataTableBaseProps.d.ts +1 -1
- package/dist/table/dataTableTypes.d.ts +3 -3
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/useDataTableData.d.ts.map +1 -1
- package/dist/table/useDataTableData.js +3 -1
- package/dist/table/useDataTableData.js.map +1 -1
- package/dist/table/useDataTableRefresh.js +2 -2
- package/dist/table/useDataTableRefresh.js.map +1 -1
- package/dist/table/useDataTableSummary.d.ts.map +1 -1
- package/dist/table/useDataTableSummary.js +2 -1
- package/dist/table/useDataTableSummary.js.map +1 -1
- package/package.json +6 -6
- package/src/account/AccountConnections.tsx +1 -1
- package/src/account/AccountDeleteDialog.tsx +25 -31
- package/src/account/AccountKeys.tsx +2 -2
- package/src/account/AccountMfaDialog.tsx +33 -27
- package/src/account/AccountPasswordDialog.tsx +36 -39
- package/src/account/AccountProfile.tsx +29 -43
- package/src/account/AccountSecurity.tsx +57 -64
- package/src/account/AccountSessions.tsx +1 -1
- package/src/account/ApiKeyCreateDialog.tsx +12 -20
- package/src/account/__tests__/AccountRouter.spec.ts +2 -1
- package/src/admin/AdminFiles.tsx +1 -1
- package/src/admin/AdminJobs.tsx +1 -1
- package/src/admin/AdminKeys.tsx +1 -1
- package/src/admin/AdminParameters.tsx +7 -5
- package/src/admin/AdminParametersTreeFooterActions.tsx +2 -2
- package/src/admin/AdminParametersTreePane.tsx +2 -2
- package/src/admin/AdminRouter.tsx +2 -4
- package/src/admin/AdminSessions.tsx +1 -1
- package/src/admin/AdminUserAvatarControl.tsx +17 -22
- package/src/admin/AdminUserDetail.tsx +4 -4
- package/src/admin/AdminUsers.tsx +10 -12
- package/src/admin/AdminUsersRolesPicker.tsx +11 -4
- package/src/admin/__tests__/AdminRouter.spec.ts +3 -2
- package/src/admin/analytics/QueryPanel.tsx +1 -1
- package/src/admin/useConfirmedAction.tsx +24 -10
- package/src/auth/AuthLogin.tsx +10 -9
- package/src/auth/AuthRegister.tsx +2 -2
- package/src/form/AutoForm.tsx +1 -1
- package/src/form/Control.tsx +1 -1
- package/src/form/ControlArray.tsx +5 -5
- package/src/form/ControlSelect.tsx +2 -2
- package/src/form/ControlUpload.tsx +1 -1
- package/src/form/__tests__/ControlArrayChildChange.browser.spec.tsx +1 -1
- package/src/i18n/fr/uiFr.ts +0 -9
- package/src/organizations/MyOrganizationInvitations.tsx +2 -2
- package/src/organizations/OrganizationInviteDialog.tsx +1 -1
- package/src/organizations/OrganizationMembers.tsx +1 -1
- package/src/organizations/OrganizationPendingInvitations.tsx +1 -1
- package/src/organizations/OrganizationRanks.tsx +3 -3
- package/src/organizations/useInviteOrganizationMember.ts +22 -15
- package/src/organizations/useRevokeOrganizationInvitation.ts +23 -4
- package/src/shell/ButtonUser.tsx +14 -79
- package/src/shell/ButtonUserContent.tsx +92 -0
- package/src/shell/ButtonUserPlaceholder.tsx +25 -0
- package/src/shell/__tests__/ActionErrorToaster.browser.spec.tsx +1 -1
- package/src/shell/__tests__/ActionErrorToasterHandled.browser.spec.tsx +1 -2
- package/src/shell/__tests__/AppShell.pageCache.spec.tsx +67 -0
- package/src/styles.css +31 -0
- package/src/table/DataTable.tsx +1 -1
- package/src/table/DataTableFilterBar.tsx +2 -2
- package/src/table/__tests__/DataTableFilterDateRange.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableQuerySeed.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableShareFilters.browser.spec.tsx +1 -1
- package/src/table/dataTableBaseProps.ts +1 -1
- package/src/table/dataTableTypes.ts +3 -3
- package/src/table/useDataTableData.ts +2 -0
- package/src/table/useDataTableRefresh.ts +3 -3
- package/src/table/useDataTableSummary.ts +2 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ButtonUserProps } from "./ButtonUser.tsx";
|
|
3
|
+
/**
|
|
4
|
+
* The account button itself. See {@link ButtonUserProps}.
|
|
5
|
+
*/
|
|
6
|
+
export type ButtonUserContentProps = ButtonUserProps;
|
|
7
|
+
/**
|
|
8
|
+
* What `ButtonUser` renders once it may read the visitor: the sign-in icon
|
|
9
|
+
* when logged out, the avatar and its menu when logged in. Wrapped in
|
|
10
|
+
* `<Personal>` by `ButtonUser`, so a page showing it stays shareable.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ButtonUserContent: (props: ButtonUserContentProps) => React.JSX.Element;
|
|
13
|
+
//# sourceMappingURL=ButtonUserContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonUserContent.d.ts","sourceRoot":"","sources":["../../src/shell/ButtonUserContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,sBA+D9D,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "../core/DropdownMenu.js";
|
|
2
|
+
import { UserAvatar } from "../core/UserAvatar.js";
|
|
3
|
+
import { Button } from "../core/Button.js";
|
|
4
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../core/Tooltip.js";
|
|
5
|
+
import { ButtonUserDefaultMenu } from "./ButtonUserDefaultMenu.js";
|
|
6
|
+
import { LogIn, User } from "lucide-react";
|
|
7
|
+
import "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useAuth } from "alepha/react/auth";
|
|
10
|
+
//#region src/shell/ButtonUserContent.tsx
|
|
11
|
+
/**
|
|
12
|
+
* What `ButtonUser` renders once it may read the visitor: the sign-in icon
|
|
13
|
+
* when logged out, the avatar and its menu when logged in. Wrapped in
|
|
14
|
+
* `<Personal>` by `ButtonUser`, so a page showing it stays shareable.
|
|
15
|
+
*/
|
|
16
|
+
const ButtonUserContent = (props) => {
|
|
17
|
+
const auth = useAuth();
|
|
18
|
+
if (!auth.user) {
|
|
19
|
+
const signInLabel = props.signInLabel ?? "Sign in";
|
|
20
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
21
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
22
|
+
variant: props.variant ?? "minimal",
|
|
23
|
+
size: "icon",
|
|
24
|
+
"aria-label": signInLabel,
|
|
25
|
+
disabled: !props.onSignIn,
|
|
26
|
+
onClick: props.onSignIn
|
|
27
|
+
}),
|
|
28
|
+
children: /* @__PURE__ */ jsx(LogIn, { className: "size-4" })
|
|
29
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: signInLabel })] });
|
|
30
|
+
}
|
|
31
|
+
const menuLabel = props.menuLabel ?? "Account menu";
|
|
32
|
+
const face = props.avatar ?? (auth.user.picture ? /* @__PURE__ */ jsx(UserAvatar, {
|
|
33
|
+
fileId: auth.user.picture,
|
|
34
|
+
className: "size-7"
|
|
35
|
+
}) : /* @__PURE__ */ jsx(User, { className: "size-4" }));
|
|
36
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
37
|
+
render: /* @__PURE__ */ jsx(DropdownMenuTrigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
38
|
+
variant: props.variant ?? "minimal",
|
|
39
|
+
size: "icon",
|
|
40
|
+
"aria-label": menuLabel
|
|
41
|
+
}) }),
|
|
42
|
+
children: face
|
|
43
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: menuLabel })] }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
44
|
+
align: "end",
|
|
45
|
+
className: "w-56",
|
|
46
|
+
children: props.children ?? /* @__PURE__ */ jsx(ButtonUserDefaultMenu, { onAdminClick: props.onAdminClick })
|
|
47
|
+
})] });
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ButtonUserContent };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ButtonUserContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonUserContent.js","names":[],"sources":["../../src/shell/ButtonUserContent.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useAuth } from \"alepha/react/auth\";\nimport { LogIn, User } from \"lucide-react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from \"../core/DropdownMenu.tsx\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../core/Tooltip.tsx\";\nimport { UserAvatar } from \"../core/UserAvatar.tsx\";\nimport type { ButtonUserProps } from \"./ButtonUser.tsx\";\nimport { ButtonUserDefaultMenu } from \"./ButtonUserDefaultMenu.tsx\";\n\n/**\n * The account button itself. See {@link ButtonUserProps}.\n */\nexport type ButtonUserContentProps = ButtonUserProps;\n\n/**\n * What `ButtonUser` renders once it may read the visitor: the sign-in icon\n * when logged out, the avatar and its menu when logged in. Wrapped in\n * `<Personal>` by `ButtonUser`, so a page showing it stays shareable.\n */\nexport const ButtonUserContent = (props: ButtonUserContentProps) => {\n const auth = useAuth();\n\n if (!auth.user) {\n const signInLabel = props.signInLabel ?? \"Sign in\";\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n variant={props.variant ?? \"minimal\"}\n size=\"icon\"\n aria-label={signInLabel}\n disabled={!props.onSignIn}\n onClick={props.onSignIn}\n />\n }\n >\n <LogIn className=\"size-4\" />\n </TooltipTrigger>\n <TooltipContent>{signInLabel}</TooltipContent>\n </Tooltip>\n );\n }\n\n const menuLabel = props.menuLabel ?? \"Account menu\";\n const face =\n props.avatar ??\n (auth.user.picture ? (\n <UserAvatar fileId={auth.user.picture} className=\"size-7\" />\n ) : (\n <User className=\"size-4\" />\n ));\n return (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n variant={props.variant ?? \"minimal\"}\n size=\"icon\"\n aria-label={menuLabel}\n />\n }\n />\n }\n >\n {/* The tooltip and `aria-label` are untouched by the avatar: a\n face is not a label, and \"Account menu\" is still the accessible\n name of the button. */}\n {face}\n </TooltipTrigger>\n <TooltipContent>{menuLabel}</TooltipContent>\n </Tooltip>\n <DropdownMenuContent align=\"end\" className=\"w-56\">\n {props.children ?? (\n <ButtonUserDefaultMenu onAdminClick={props.onAdminClick} />\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAa,qBAAqB,UAAkC;CAClE,MAAM,OAAO,QAAQ;CAErB,IAAI,CAAC,KAAK,MAAM;EACd,MAAM,cAAc,MAAM,eAAe;EACzC,OACE,qBAAC,SAAD,EAAA,UAAA,CACE,oBAAC,gBAAD;GACE,QACE,oBAAC,QAAD;IACE,SAAS,MAAM,WAAW;IAC1B,MAAK;IACL,cAAY;IACZ,UAAU,CAAC,MAAM;IACjB,SAAS,MAAM;GAChB,CAAA;GAGH,UAAA,oBAAC,OAAD,EAAO,WAAU,SAAU,CAAA;EACb,CAAA,GAChB,oBAAC,gBAAD,EAAA,UAAiB,YAA4B,CAAA,CACtC,EAAA,CAAA;CAEb;CAEA,MAAM,YAAY,MAAM,aAAa;CACrC,MAAM,OACJ,MAAM,WACL,KAAK,KAAK,UACT,oBAAC,YAAD;EAAY,QAAQ,KAAK,KAAK;EAAS,WAAU;CAAU,CAAA,IAE3D,oBAAC,MAAD,EAAM,WAAU,SAAU,CAAA;CAE9B,OACE,qBAAC,cAAD,EAAA,UAAA,CACE,qBAAC,SAAD,EAAA,UAAA,CACE,oBAAC,gBAAD;EACE,QACE,oBAAC,qBAAD,EACE,QACE,oBAAC,QAAD;GACE,SAAS,MAAM,WAAW;GAC1B,MAAK;GACL,cAAY;EACb,CAAA,EAEJ,CAAA;EAMF,UAAA;CACa,CAAA,GAChB,oBAAC,gBAAD,EAAA,UAAiB,UAA0B,CAAA,CACpC,EAAA,CAAA,GACT,oBAAC,qBAAD;EAAqB,OAAM;EAAM,WAAU;EACxC,UAAA,MAAM,YACL,oBAAC,uBAAD,EAAuB,cAAc,MAAM,aAAe,CAAA;CAEzC,CAAA,CACT,EAAA,CAAA;AAElB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ButtonUserPlaceholderProps {
|
|
2
|
+
/**
|
|
3
|
+
* The variant of the button it stands for: an outlined button keeps its
|
|
4
|
+
* border, so the swap moves nothing.
|
|
5
|
+
*/
|
|
6
|
+
variant?: "minimal" | "outlined";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What a shared page shows where `ButtonUser` goes, before hydration: an
|
|
10
|
+
* empty slot the size of the icon button. Neither the sign-in icon nor an
|
|
11
|
+
* avatar, since the shared page cannot know which one its visitor gets.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ButtonUserPlaceholder: (props: ButtonUserPlaceholderProps) => import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=ButtonUserPlaceholder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonUserPlaceholder.d.ts","sourceRoot":"","sources":["../../src/shell/ButtonUserPlaceholder.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;CAClC;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAAW,0BAA0B,gCAStE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "../core/utils.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/shell/ButtonUserPlaceholder.tsx
|
|
4
|
+
/**
|
|
5
|
+
* What a shared page shows where `ButtonUser` goes, before hydration: an
|
|
6
|
+
* empty slot the size of the icon button. Neither the sign-in icon nor an
|
|
7
|
+
* avatar, since the shared page cannot know which one its visitor gets.
|
|
8
|
+
*/
|
|
9
|
+
const ButtonUserPlaceholder = (props) => /* @__PURE__ */ jsx("span", {
|
|
10
|
+
"aria-hidden": true,
|
|
11
|
+
"data-slot": "button-user-placeholder",
|
|
12
|
+
className: cn("inline-block size-9 shrink-0 rounded-md", props.variant === "outlined" && "border")
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ButtonUserPlaceholder };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=ButtonUserPlaceholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonUserPlaceholder.js","names":[],"sources":["../../src/shell/ButtonUserPlaceholder.tsx"],"sourcesContent":["import { cn } from \"../core/utils.ts\";\n\nexport interface ButtonUserPlaceholderProps {\n /**\n * The variant of the button it stands for: an outlined button keeps its\n * border, so the swap moves nothing.\n */\n variant?: \"minimal\" | \"outlined\";\n}\n\n/**\n * What a shared page shows where `ButtonUser` goes, before hydration: an\n * empty slot the size of the icon button. Neither the sign-in icon nor an\n * avatar, since the shared page cannot know which one its visitor gets.\n */\nexport const ButtonUserPlaceholder = (props: ButtonUserPlaceholderProps) => (\n <span\n aria-hidden\n data-slot=\"button-user-placeholder\"\n className={cn(\n \"inline-block size-9 shrink-0 rounded-md\",\n props.variant === \"outlined\" && \"border\",\n )}\n />\n);\n"],"mappings":";;;;;;;;AAeA,MAAa,yBAAyB,UACpC,oBAAC,QAAD;CACE,eAAA;CACA,aAAU;CACV,WAAW,GACT,2CACA,MAAM,YAAY,cAAc,QAClC;AACD,CAAA"}
|
package/dist/styles.css
CHANGED
|
@@ -893,3 +893,34 @@
|
|
|
893
893
|
) {
|
|
894
894
|
border-color: var(--border-hover);
|
|
895
895
|
}
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
* A collapsed sidebar before hydration (#E78).
|
|
899
|
+
*
|
|
900
|
+
* The server renders the shell expanded for every visitor, so the page cache
|
|
901
|
+
* can share it; the visitor's preference reaches React only on the first
|
|
902
|
+
* commit after hydration. The boot script has already set
|
|
903
|
+
* `data-sidebar="collapsed"` on `<html>` from the `alepha-ui` cookie, so an
|
|
904
|
+
* EXPANDED sidebar under that attribute is the pre-hydration frame: it is held
|
|
905
|
+
* at the icon width, labels clipped, until React renders it collapsed. A
|
|
906
|
+
* sidebar the visitor expands again updates the attribute with it, so the rule
|
|
907
|
+
* never fights React after hydration.
|
|
908
|
+
*/
|
|
909
|
+
html[data-sidebar="collapsed"]
|
|
910
|
+
[data-slot="sidebar"][data-state="expanded"]
|
|
911
|
+
[data-slot="sidebar-gap"],
|
|
912
|
+
html[data-sidebar="collapsed"]
|
|
913
|
+
[data-slot="sidebar"][data-state="expanded"]
|
|
914
|
+
[data-slot="sidebar-container"] {
|
|
915
|
+
width: var(--sidebar-width-icon);
|
|
916
|
+
overflow: hidden;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
html[data-sidebar="collapsed"]
|
|
920
|
+
[data-slot="sidebar"][data-state="expanded"]:is(
|
|
921
|
+
[data-variant="floating"],
|
|
922
|
+
[data-variant="inset"]
|
|
923
|
+
)
|
|
924
|
+
:is([data-slot="sidebar-gap"], [data-slot="sidebar-container"]) {
|
|
925
|
+
width: calc(var(--sidebar-width-icon) + 1rem + 2px);
|
|
926
|
+
}
|
package/dist/table/DataTable.js
CHANGED
|
@@ -181,7 +181,7 @@ const DataTable = (props) => {
|
|
|
181
181
|
* Filter VALUES are deliberately not reset here: `useForm` captures its
|
|
182
182
|
* `initialValues` once, so resetting them is form surgery rather than a
|
|
183
183
|
* state assignment. They are also not clobbered - the filter-persist effect
|
|
184
|
-
* writes only on `form:
|
|
184
|
+
* writes only on `form:changed` / `form:submit:success`, never on mount - so
|
|
185
185
|
* the stored filters of the project you left stay its own.
|
|
186
186
|
*/
|
|
187
187
|
const scopeRef = useRef(props.persistenceKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n });\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data,\n meta,\n rowFilters,\n loading,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n const { refresh, handleRefreshClick, resetFilters, canShare, shareFilters } =\n useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n const rowKeys = useMemo(\n () =>\n data.map((item, index) => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n }),\n [data, page, props.rowKey],\n );\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * The sort effect (`useDataTableData`) and the column writes\n * (`useDataTableColumns`) are keyed on `persistenceKey` too, so on the\n * render where it changes they would fire in the same flush and write the\n * OUTGOING scope's state under the INCOMING key - silently\n * overwriting the project you just opened with the one you just left. React\n * re-renders before committing this, so by the time those effects run the\n * state is already the new scope's and they write back what was just read.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:change` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n setSize(persistedSize(sizeKey, props.defaultSize));\n setSort(persistedSort(sortKey, props.defaultSort));\n setVisibleColumns(persistedColumns(columnsKey, props.columns));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n const bulkCtx: BulkActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n\n /**\n * How many filters currently narrow the list — a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n Boolean(props.filters) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu;\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n const cellPadding = DATA_TABLE_CELL_PADDING[props.cellPadding ?? \"normal\"];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n const showFooter =\n (props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1);\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n return (\n <ClientOnly>\n <div className={cn(\"flex flex-col gap-2\", props.className)}>\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary\n ? \"-mt-2 rounded-t-none border-t-0\"\n : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n \"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table className={cn(isEmptyState && \"h-full\")}>\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow above draws\n // the same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n onRowClick={props.onRowClick}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(\n squareRight?.bottom,\n flatBottom,\n props.chromeClassName,\n )}\n />\n )}\n </div>\n </ClientOnly>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ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AgB,mCAChC,aAAa,8BAA8B,aAAa,QACxD,UAGA,CAAC,eAAe,CAAC,eAAe,aAAa,KAU7C,sCACF;IAcA,UAAA,qBAAC,OAAD;KAAO,WAAW,GAAG,gBAAgB,QAAQ;KAA7C,UAAA,CAcE,oBAAC,aAAD;MACE,WAAW,GAMT,qHACA,MAAM,eACR;MAEA,UAAA,oBAAC,oBAAD;OACE,eAAe,YAAY;OACd;OACA;OACE;OACF;OACC;OACH;OACL;OACM;OACD;OACC;OACE;MACf,CAAA;KACU,CAAA,GACb,oBAAC,eAAD;MACE,eAAe,YAAY;MACrB;MACO;MACJ;MACA;MACI;MACA;MACE;MACG;MACP;MACA;MACH;MACR,YAAY,MAAM;MAClB,YAAY,MAAM;MAClB,YAAY,MAAM;MAClB,OAAO,MAAM;MACb,cAAc,MAAM;MACpB,YAAY,MAAM;MAClB,cAAc,MAAM;KACrB,CAAA,CACI;;GACJ,CAAA;GAKL,oBAAC,QAAD;IAAM,aAAU;IAAS,WAAU;IAChC,UAAA;GACG,CAAA;GAEL,cACC,oBAAC,iBAAD;IACE,WAAW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GACT,aAAa,QACb,YACA,MAAM,eACR;GACD,CAAA;EAEA;CACK,CAAA,EAAA,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n });\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data,\n meta,\n rowFilters,\n loading,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n const { refresh, handleRefreshClick, resetFilters, canShare, shareFilters } =\n useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n const rowKeys = useMemo(\n () =>\n data.map((item, index) => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n }),\n [data, page, props.rowKey],\n );\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * The sort effect (`useDataTableData`) and the column writes\n * (`useDataTableColumns`) are keyed on `persistenceKey` too, so on the\n * render where it changes they would fire in the same flush and write the\n * OUTGOING scope's state under the INCOMING key - silently\n * overwriting the project you just opened with the one you just left. React\n * re-renders before committing this, so by the time those effects run the\n * state is already the new scope's and they write back what was just read.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n setSize(persistedSize(sizeKey, props.defaultSize));\n setSort(persistedSort(sortKey, props.defaultSort));\n setVisibleColumns(persistedColumns(columnsKey, props.columns));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n const bulkCtx: BulkActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n\n /**\n * How many filters currently narrow the list — a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n Boolean(props.filters) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu;\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n const cellPadding = DATA_TABLE_CELL_PADDING[props.cellPadding ?? \"normal\"];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n const showFooter =\n (props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1);\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n return (\n <ClientOnly>\n <div className={cn(\"flex flex-col gap-2\", props.className)}>\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary\n ? \"-mt-2 rounded-t-none border-t-0\"\n : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n \"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table className={cn(isEmptyState && \"h-full\")}>\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow above draws\n // the same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n onRowClick={props.onRowClick}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(\n squareRight?.bottom,\n flatBottom,\n props.chromeClassName,\n )}\n />\n )}\n </div>\n </ClientOnly>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI,KAAA,IAAY,MAAM;CAKpD,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,WAAW,CAC1C;CACA,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;;;;;;;;;;;CAWvB,MAAM,WAAW,YAAY;CAE7B,MAAM,EAAE,MAAM,YAAY,qBAAqB,uBAAuB;EACpE,OAAO;EACP;EACA;CACF,CAAC;CAED,MAAM,mBAAmB,6BAA6B;EACpD,YAAY;EACZ;CACF,CAAC;CAED,MAAM,EACJ,MACA,SACA,UACA,MACA,SACA,MACA,MACA,YACA,SACA,YACA,eACA,cACA,iBACA,YACA,cACE,iBAAiB;EACnB,OAAO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aAAU;IAAS,WAAU;IAChC,UAAA;GACG,CAAA;GAEL,cACC,oBAAC,iBAAD;IACE,WAAW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GACT,aAAa,QACb,YACA,MAAM,eACR;GACD,CAAA;EAEA;CACK,CAAA,EAAA,CAAA;AAEhB"}
|
|
@@ -100,10 +100,10 @@ const DataTableFilterBar = (props) => {
|
|
|
100
100
|
const enumValuesOf = (field) => {
|
|
101
101
|
const schema = schemaOf(field);
|
|
102
102
|
if (!schema) return [];
|
|
103
|
-
if (z.schema.isEnum(schema)) return z.schema.
|
|
103
|
+
if (z.schema.isEnum(schema)) return z.schema.enumOptions(schema);
|
|
104
104
|
if (z.schema.isArray(schema)) {
|
|
105
105
|
const element = z.schema.unwrap(z.schema.element(schema));
|
|
106
|
-
if (z.schema.isEnum(element)) return z.schema.
|
|
106
|
+
if (z.schema.isEnum(element)) return z.schema.enumOptions(element);
|
|
107
107
|
}
|
|
108
108
|
return [];
|
|
109
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableFilterBar.js","names":[],"sources":["../../src/table/DataTableFilterBar.tsx"],"sourcesContent":["import { type ZObject, type ZType, z } from \"alepha\";\nimport type { FormModel } from \"alepha/react/form\";\nimport { useFormValues } from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Calendar, List, Search, Type } from \"lucide-react\";\nimport { useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { FilterSlot } from \"../core/FilterSlot.tsx\";\nimport { Control } from \"../form/Control.tsx\";\nimport type { SelectOption } from \"../form/ControlSelect.tsx\";\nimport type { DataTableFilterAddType } from \"./DataTableFilterAdd.tsx\";\nimport { DataTableFilterAdd } from \"./DataTableFilterAdd.tsx\";\nimport { DataTableFilterControl } from \"./DataTableFilterControl.tsx\";\nimport type { DataTableFilterOperatorOption } from \"./DataTableFilterOperator.tsx\";\nimport {\n DATA_TABLE_FILTER_OPERATORS,\n DataTableFilterOperator,\n} from \"./DataTableFilterOperator.tsx\";\nimport type {\n DataTableFilterFieldOptions,\n DataTableFilterMode,\n DataTableFilterPreset,\n} from \"./dataTableTypes.ts\";\n\nexport interface DataTableFilterBarProps {\n /**\n * The table's filter form. Every `key` below names one of its fields, and\n * so does every operator key.\n */\n form: FormModel<ZObject>;\n\n /**\n * Every filter, in declaration order: the order the bar draws them in and\n * the add menu lists them in.\n */\n fields: DataTableFilterBarField[];\n\n /**\n * Which filters are on the bar. The table's state, not the bar's, because\n * three things write it: this bar, Reset filters and persistence.\n *\n * A locked field is drawn whether or not it is in here.\n */\n shown: readonly string[];\n\n /**\n * The shown filters changed. `act` is true for the reader's own add or\n * remove, and false when a filter joined the bar because it holds a value:\n * that is not the reader choosing anything, and must not be stored.\n */\n onShownChange: (shown: string[], act: boolean) => void;\n\n /**\n * `\"dialog\"` draws every filter, each like a locked field, and no add menu:\n * the phone dialog is already the on-demand step, and a menu per filter\n * behind that button would be a second one.\n */\n variant?: \"bar\" | \"dialog\";\n}\n\n/**\n * The filter bar `DataTable` draws from `filters.fields`: the locked filters\n * (the search box), then the filters the reader put on the bar, then the menu\n * that adds one.\n *\n * **Which filters start on the bar is the field's `mode`.** An `optional`\n * field, the default, is off it until the reader adds it; a `default` field\n * is on it from the start and removable; a `locked` field is always there and\n * never removable. Showing every filter a table supports spends the width of\n * the bar on questions nobody has asked; four boxes reading \"Any status\",\n * \"Any team\", \"Any role\" say only that those columns exist.\n *\n * ⚠️ **A filter holding a value, or a non-default operator, is always on the\n * bar**, whatever its mode and however it got the value: restored from\n * persistence, read from a shared link, carried across a remount. Keyed on\n * the shown state alone, the bar came back empty while the table stayed\n * filtered, and \"Add filters\" handed back a filter that was already set. The\n * same holds for `hidden`: an empty hidden field is off the bar and out of the\n * menu, and a hidden field narrowing the list is still drawn, or the list\n * would be narrowed with nothing on screen saying why.\n *\n * **Operators** are optional per field, and each is a field of its own in the\n * filters schema, `<key>Op` unless `operatorKey` says otherwise. The backend\n * must declare the same key and values; a default operator sends no key at\n * all. See `DataTableFilterOperator` for why it is one switch rather than an\n * EQUAL toggle beside an OR/AND one.\n *\n * Internal to the table: a table given `fields` and no `filters.render`\n * mounts it, in the toolbar and in the phone dialog.\n *\n * Built and settled on the `apps/ui` showcase (`/blocks/data-table/basic`) in #Q2308.\n */\nexport const DataTableFilterBar = (props: DataTableFilterBarProps) => {\n const { tr } = useI18n();\n const values = useFormValues(props.form) as Record<string, unknown>;\n const dialog = props.variant === \"dialog\";\n const modeOf = (field: DataTableFilterBarField): DataTableFilterMode =>\n field.mode ?? (field.preset === \"search\" ? \"locked\" : \"optional\");\n const shown = props.shown;\n const root = useRef<HTMLDivElement>(null);\n // The filter to open once React has put it on screen. A REF, not state: the\n // effect below both reads and clears it, and clearing it with `setState`\n // inside an effect is a cascading render. Nothing renders from it.\n const pendingOpen = useRef<string | undefined>(undefined);\n // Which filters held a value at the last commit - see the operator effect.\n const heldValue = useRef<Record<string, boolean>>({});\n\n const inputs = props.form.input as unknown as Record<\n string,\n { set: (value: unknown) => void } | undefined\n >;\n\n const isSet = (key: string): boolean => {\n const value = values[key];\n return Array.isArray(value) ? value.length > 0 : Boolean(value);\n };\n\n const operatorKeyOf = (field: DataTableFilterBarField) =>\n field.operatorKey ?? `${field.key}Op`;\n\n // Narrowing the list, by a value or by an operator standing on its own.\n const holds = (field: DataTableFilterBarField): boolean =>\n isSet(field.key) || values[operatorKeyOf(field)] !== undefined;\n\n const isLocked = (field: DataTableFilterBarField) =>\n modeOf(field) === \"locked\";\n\n const operatorsOf = (\n field: DataTableFilterBarField,\n ): DataTableFilterOperatorOption[] | undefined => {\n if (!field.operators || typeof field.operators !== \"string\") {\n return field.operators as DataTableFilterOperatorOption[] | undefined;\n }\n // The values come from the one table the filter schema is built from; only\n // the words are this bar's. A value is labelled the same in every preset\n // it appears in, so one entry per value covers all three.\n const not = tr(\"dataTable.operator.prefixNot\", { default: \"not\" });\n const labels: Record<\n string,\n Omit<DataTableFilterOperatorOption, \"value\">\n > = {\n is: { label: tr(\"dataTable.operator.is\", { default: \"is\" }) },\n not: {\n label: tr(\"dataTable.operator.isNot\", { default: \"is not\" }),\n prefix: not,\n },\n any: { label: tr(\"dataTable.operator.anyOf\", { default: \"any of\" }) },\n all: {\n label: tr(\"dataTable.operator.allOf\", { default: \"all of\" }),\n prefix: tr(\"dataTable.operator.prefixAll\", { default: \"all\" }),\n },\n none: {\n label: tr(\"dataTable.operator.noneOf\", { default: \"none of\" }),\n prefix: not,\n },\n };\n return DATA_TABLE_FILTER_OPERATORS[field.operators].map((value) => ({\n value,\n label: labels[value]?.label ?? value,\n prefix: labels[value]?.prefix,\n }));\n };\n\n const operatorOf = (field: DataTableFilterBarField) => {\n const operators = operatorsOf(field);\n return (\n operators?.find(\n (operator) => operator.value === values[operatorKeyOf(field)],\n ) ?? operators?.[0]\n );\n };\n\n /**\n * The schema a field is read with, stripped of `.optional()`: its own, or\n * `z.string()` for the search preset.\n */\n const schemaOf = (field: DataTableFilterBarField): ZType | undefined =>\n field.schema\n ? z.schema.unwrap(field.schema)\n : field.preset === \"search\"\n ? z.string()\n : undefined;\n\n /**\n * The values an enum schema, or an array of one, allows. Empty for any\n * other schema.\n */\n const enumValuesOf = (field: DataTableFilterBarField): string[] => {\n const schema = schemaOf(field);\n if (!schema) return [];\n if (z.schema.isEnum(schema)) return z.schema.enumValues(schema);\n if (z.schema.isArray(schema)) {\n const element = z.schema.unwrap(z.schema.element(schema));\n if (z.schema.isEnum(element)) return z.schema.enumValues(element);\n }\n return [];\n };\n\n // Live data first, then the enum the schema declares. A bare string falls\n // back to the select's own label for it.\n const itemsOf = (\n field: DataTableFilterBarField,\n ): SelectOption[] | undefined => {\n if (typeof field.items === \"function\") return field.items(values);\n if (field.items) return field.items;\n const options = enumValuesOf(field);\n if (options.length === 0) return undefined;\n const optionLabel = field.optionLabel;\n return optionLabel\n ? options.map((value) => ({ value, label: optionLabel(value) }))\n : options;\n };\n\n // Classified in `Control`'s own order, so the menu names the control the\n // filter will actually draw.\n const kindOf = (field: DataTableFilterBarField): DataTableFilterAddType => {\n const schema = schemaOf(field);\n // Before the list test, as `Control` orders it: a range IS an array, and\n // tested as one it would be offered as a list and drawn as a calendar.\n if (schema && z.schema.isDateRange(schema)) return \"date\";\n if (\n field.items ||\n (schema && (z.schema.isEnum(schema) || z.schema.isArray(schema)))\n ) {\n return \"list\";\n }\n return \"text\";\n };\n\n const placeholderOf = (field: DataTableFilterBarField) =>\n field.placeholder ??\n field.control?.placeholder ??\n (field.preset === \"search\"\n ? tr(\"dataTable.search\", { default: \"Search\" })\n : undefined);\n\n const labelOf = (field: DataTableFilterBarField) =>\n field.label ?? placeholderOf(field) ?? field.key;\n\n // Every filter has an icon, as every `Control` does: the caller's, the\n // search glyph for the search preset, else its kind's (the same glyphs the\n // controls fall back to). Without the last step a filter the caller gave no\n // icon was the one bare row of the add menu (\"When\", beside \"Resource\" and\n // \"What\").\n const iconOf = (field: DataTableFilterBarField) => {\n if (field.icon) return field.icon;\n if (field.preset === \"search\") return Search;\n const kind = kindOf(field);\n if (kind === \"date\") return Calendar;\n if (kind === \"list\") return List;\n return Type;\n };\n\n // A filter goes back to its default operator as its value goes: an\n // operator standing with nothing to qualify still counts as a filter in the\n // table's reset button and badge, while narrowing nothing.\n const clearField = (field: DataTableFilterBarField) => {\n inputs[field.key]?.set(undefined);\n if (field.operators) inputs[operatorKeyOf(field)]?.set(undefined);\n };\n\n useEffect(() => {\n const key = pendingOpen.current;\n if (!key) return;\n pendingOpen.current = undefined;\n // ⚠️ Opening the new filter has to happen from OUT HERE, after the render\n // that mounts it: inside the menu's click handler the control does not\n // exist yet. Driven through the DOM because `Control` exposes no\n // imperative \"open\" - a combobox owns that state, and a date range's\n // popover owns its own. A text filter has no list, so it is focused\n // instead. Scoped to this bar, so two tables on one page cannot open each\n // other's filters.\n const slot = root.current?.querySelector(`[data-filter=\"${key}\"]`);\n const trigger = slot?.querySelector<HTMLElement>(\n '[data-slot=\"combobox-trigger\"], [data-slot=\"date-trigger\"]',\n );\n if (trigger) {\n trigger.click();\n return;\n }\n slot?.querySelector<HTMLInputElement>('[data-slot=\"input\"]')?.focus();\n }, [shown]);\n\n useEffect(() => {\n // The other way a value empties: unticked inside the list, or cleared by\n // a locked field's own cross, rather than cleared by the button. Only on\n // the transition from set to empty, so a reader who picks \"is not\" BEFORE\n // picking a value keeps it, and a persisted operator survives the mount\n // it is restored on.\n for (const field of props.fields) {\n const set = isSet(field.key);\n const operatorKey = operatorKeyOf(field);\n if (\n field.operators &&\n heldValue.current[field.key] &&\n !set &&\n values[operatorKey] !== undefined\n ) {\n inputs[operatorKey]?.set(undefined);\n }\n heldValue.current[field.key] = set;\n }\n }, [values]);\n\n // A field holding a value or an operator joins `shown` the moment it is\n // seen - see the docblock. Folded INTO `shown` rather than drawn as\n // `shown ∪ set`, because a filter visible only for holding a value would\n // unmount the instant the reader emptied it, list open and cursor on it.\n // Locked fields are drawn regardless and never join it, and the dialog\n // draws every field.\n const unshown = dialog\n ? []\n : props.fields\n .filter(\n (field) =>\n !isLocked(field) && holds(field) && !shown.includes(field.key),\n )\n .map((field) => field.key);\n\n // The table's state cannot be set from this component's render, so it is\n // set in a LAYOUT effect: React flushes that update synchronously, before\n // the browser paints, so no frame shows the bar without the filter. The\n // guard stops it looping - it only fires while something is missing, and\n // the update adds exactly that.\n useLayoutEffect(() => {\n if (unshown.length > 0) {\n props.onShownChange([...shown, ...unshown], false);\n }\n });\n\n const drawn = (field: DataTableFilterBarField): boolean => {\n if (field.hidden && !holds(field)) return false;\n if (dialog || isLocked(field)) return true;\n return shown.includes(field.key);\n };\n\n // Locked first, in declaration order, then the shown ones in the order they\n // joined the bar: an added filter goes to the END, beside the \"+\" that\n // brought it, not back to its declared slot. Added D, C, B, A reads\n // D C B A. The dialog keeps the declaration as it is: nothing there is\n // added or removed.\n const rank = (field: DataTableFilterBarField) => {\n const index = shown.indexOf(field.key);\n return index === -1 ? Number.MAX_SAFE_INTEGER : index;\n };\n const ordered = dialog\n ? props.fields\n : [\n ...props.fields.filter((field) => isLocked(field)),\n ...props.fields\n .filter((field) => !isLocked(field))\n .sort((a, b) => rank(a) - rank(b)),\n ];\n\n return (\n // `contents`, so the slots are items of the table's own wrapping row (and\n // of the phone dialog's grid) exactly as a caller's bare fragment is.\n <div ref={root} className=\"contents\">\n {ordered\n .filter((field) => drawn(field))\n .map((field) => {\n // In the dialog every filter is drawn like a locked one: no\n // clear-and-remove button, the control's own cross resets it.\n const removable = !dialog && !isLocked(field);\n const operators = operatorsOf(field);\n const operator = operatorOf(field);\n const label = labelOf(field);\n return (\n <FilterSlot key={field.key}>\n <div data-filter={field.key}>\n <DataTableFilterControl\n label={label}\n active={isSet(field.key)}\n // A cross empties a filter holding a value; a funnel-x\n // removes an empty one. `active` picks between the two.\n // A locked filter is given neither, so it keeps the cross\n // inside its own field.\n onClear={removable ? () => clearField(field) : undefined}\n onRemove={\n removable\n ? () => {\n clearField(field);\n props.onShownChange(\n shown.filter((key) => key !== field.key),\n true,\n );\n }\n : undefined\n }\n >\n <Control\n {...field.control}\n input={inputs[field.key] as never}\n label=\"\"\n icon={iconOf(field)}\n clearable\n placeholder={placeholderOf(field)}\n items={itemsOf(field) as never}\n // The filter's name, as the control's accessible name:\n // an empty select says only its placeholder, and a set\n // one only its value. A name the caller gave wins.\n inputProps={{\n \"aria-label\": label,\n // A text filter is as wide as its placeholder. The slot\n // grows from its content, and an input's content width\n // is its `size` in characters (20 by default), so a\n // long placeholder was cut at the slot's minimum.\n ...(kindOf(field) === \"text\"\n ? {\n size: Math.max(\n 20,\n placeholderOf(field)?.length ?? 0,\n ),\n }\n : {}),\n ...field.control?.inputProps,\n }}\n // The filter's name, and a non-default operator, muted in\n // front of the value: \"Status: not Active\". An empty\n // select draws no prefix; its placeholder names it. The\n // colon is a catalog entry because French spaces it.\n triggerPrefix={[\n tr(\"dataTable.filterName\", {\n default: `${label}:`,\n args: [label],\n }),\n operator?.prefix,\n ]\n .filter(Boolean)\n .join(\" \")}\n // Sized from its content, not the trigger: the trigger\n // grows as the reader picks, and a popup tied to it would\n // widen under the cursor.\n popupClassName=\"w-max min-w-48\"\n popupHeader={\n operators && (\n <DataTableFilterOperator\n options={operators}\n value={operator?.value}\n onChange={(value) =>\n inputs[operatorKeyOf(field)]?.set(value)\n }\n />\n )\n }\n />\n </DataTableFilterControl>\n </div>\n </FilterSlot>\n );\n })}\n\n {!dialog && (\n <DataTableFilterAdd\n labeled={!ordered.some((field) => drawn(field))}\n items={props.fields\n .filter(\n (field) =>\n !isLocked(field) && !field.hidden && !shown.includes(field.key),\n )\n .map((field) => ({\n key: field.key,\n label: labelOf(field),\n icon: iconOf(field),\n type: kindOf(field),\n }))}\n onAdd={(key) => {\n pendingOpen.current = key;\n props.onShownChange([...shown, key], true);\n }}\n />\n )}\n </div>\n );\n};\n\n/**\n * One filter of the bar: a field of `filters.fields` with its key, as the\n * table hands it over. `schema` is the one the table read at mount, and gives\n * the options of an enum and the kind the add menu names.\n */\nexport interface DataTableFilterBarField extends DataTableFilterFieldOptions {\n /**\n * The form field this filter writes.\n */\n key: string;\n schema?: ZType;\n preset?: DataTableFilterPreset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAa,sBAAsB,UAAmC;CACpE,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,SAAS,cAAc,MAAM,IAAI;CACvC,MAAM,SAAS,MAAM,YAAY;CACjC,MAAM,UAAU,UACd,MAAM,SAAS,MAAM,WAAW,WAAW,WAAW;CACxD,MAAM,QAAQ,MAAM;CACpB,MAAM,OAAO,OAAuB,IAAI;CAIxC,MAAM,cAAc,OAA2B,KAAA,CAAS;CAExD,MAAM,YAAY,OAAgC,CAAC,CAAC;CAEpD,MAAM,SAAS,MAAM,KAAK;CAK1B,MAAM,SAAS,QAAyB;EACtC,MAAM,QAAQ,OAAO;EACrB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,SAAS,IAAI,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B;MAKA,eAAe,CACb,GAAG,wBAAwB;OACzB,SAAS,GAAG,MAAM;OAClB,MAAM,CAAC,KAAK;MACd,CAAC,GACD,UAAU,MACZ,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;MAIX,gBAAe;MACf,aACE,aACE,oBAAC,yBAAD;OACE,SAAS;OACT,OAAO,UAAU;OACjB,WAAW,UACT,OAAO,cAAc,KAAK,EAAE,EAAE,IAAI,KAAK;MAE1C,CAAA;KAGN,CAAA;IACqB,CAAA;GACrB,CAAA,EACK,GAhFK,MAAM,GAgFX;EAEhB,CAAC,GAEF,CAAC,UACA,oBAAC,oBAAD;GACE,SAAS,CAAC,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;GAC9C,OAAO,MAAM,OACV,QACE,UACC,CAAC,SAAS,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,SAAS,MAAM,GAAG,CAClE,CAAC,CACA,KAAK,WAAW;IACf,KAAK,MAAM;IACX,OAAO,QAAQ,KAAK;IACpB,MAAM,OAAO,KAAK;IAClB,MAAM,OAAO,KAAK;GACpB,EAAE;GACJ,QAAQ,QAAQ;IACd,YAAY,UAAU;IACtB,MAAM,cAAc,CAAC,GAAG,OAAO,GAAG,GAAG,IAAI;GAC3C;EACD,CAAA,CAEA;;AAET"}
|
|
1
|
+
{"version":3,"file":"DataTableFilterBar.js","names":[],"sources":["../../src/table/DataTableFilterBar.tsx"],"sourcesContent":["import { type ZObject, type ZType, z } from \"alepha\";\nimport type { FormModel } from \"alepha/react/form\";\nimport { useFormValues } from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { Calendar, List, Search, Type } from \"lucide-react\";\nimport { useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { FilterSlot } from \"../core/FilterSlot.tsx\";\nimport { Control } from \"../form/Control.tsx\";\nimport type { SelectOption } from \"../form/ControlSelect.tsx\";\nimport type { DataTableFilterAddType } from \"./DataTableFilterAdd.tsx\";\nimport { DataTableFilterAdd } from \"./DataTableFilterAdd.tsx\";\nimport { DataTableFilterControl } from \"./DataTableFilterControl.tsx\";\nimport type { DataTableFilterOperatorOption } from \"./DataTableFilterOperator.tsx\";\nimport {\n DATA_TABLE_FILTER_OPERATORS,\n DataTableFilterOperator,\n} from \"./DataTableFilterOperator.tsx\";\nimport type {\n DataTableFilterFieldOptions,\n DataTableFilterMode,\n DataTableFilterPreset,\n} from \"./dataTableTypes.ts\";\n\nexport interface DataTableFilterBarProps {\n /**\n * The table's filter form. Every `key` below names one of its fields, and\n * so does every operator key.\n */\n form: FormModel<ZObject>;\n\n /**\n * Every filter, in declaration order: the order the bar draws them in and\n * the add menu lists them in.\n */\n fields: DataTableFilterBarField[];\n\n /**\n * Which filters are on the bar. The table's state, not the bar's, because\n * three things write it: this bar, Reset filters and persistence.\n *\n * A locked field is drawn whether or not it is in here.\n */\n shown: readonly string[];\n\n /**\n * The shown filters changed. `act` is true for the reader's own add or\n * remove, and false when a filter joined the bar because it holds a value:\n * that is not the reader choosing anything, and must not be stored.\n */\n onShownChange: (shown: string[], act: boolean) => void;\n\n /**\n * `\"dialog\"` draws every filter, each like a locked field, and no add menu:\n * the phone dialog is already the on-demand step, and a menu per filter\n * behind that button would be a second one.\n */\n variant?: \"bar\" | \"dialog\";\n}\n\n/**\n * The filter bar `DataTable` draws from `filters.fields`: the locked filters\n * (the search box), then the filters the reader put on the bar, then the menu\n * that adds one.\n *\n * **Which filters start on the bar is the field's `mode`.** An `optional`\n * field, the default, is off it until the reader adds it; a `default` field\n * is on it from the start and removable; a `locked` field is always there and\n * never removable. Showing every filter a table supports spends the width of\n * the bar on questions nobody has asked; four boxes reading \"Any status\",\n * \"Any team\", \"Any role\" say only that those columns exist.\n *\n * ⚠️ **A filter holding a value, or a non-default operator, is always on the\n * bar**, whatever its mode and however it got the value: restored from\n * persistence, read from a shared link, carried across a remount. Keyed on\n * the shown state alone, the bar came back empty while the table stayed\n * filtered, and \"Add filters\" handed back a filter that was already set. The\n * same holds for `hidden`: an empty hidden field is off the bar and out of the\n * menu, and a hidden field narrowing the list is still drawn, or the list\n * would be narrowed with nothing on screen saying why.\n *\n * **Operators** are optional per field, and each is a field of its own in the\n * filters schema, `<key>Op` unless `operatorKey` says otherwise. The backend\n * must declare the same key and values; a default operator sends no key at\n * all. See `DataTableFilterOperator` for why it is one switch rather than an\n * EQUAL toggle beside an OR/AND one.\n *\n * Internal to the table: a table given `fields` and no `filters.render`\n * mounts it, in the toolbar and in the phone dialog.\n *\n * Built and settled on the `apps/ui` showcase (`/blocks/data-table/basic`) in #Q2308.\n */\nexport const DataTableFilterBar = (props: DataTableFilterBarProps) => {\n const { tr } = useI18n();\n const values = useFormValues(props.form) as Record<string, unknown>;\n const dialog = props.variant === \"dialog\";\n const modeOf = (field: DataTableFilterBarField): DataTableFilterMode =>\n field.mode ?? (field.preset === \"search\" ? \"locked\" : \"optional\");\n const shown = props.shown;\n const root = useRef<HTMLDivElement>(null);\n // The filter to open once React has put it on screen. A REF, not state: the\n // effect below both reads and clears it, and clearing it with `setState`\n // inside an effect is a cascading render. Nothing renders from it.\n const pendingOpen = useRef<string | undefined>(undefined);\n // Which filters held a value at the last commit - see the operator effect.\n const heldValue = useRef<Record<string, boolean>>({});\n\n const inputs = props.form.input as unknown as Record<\n string,\n { set: (value: unknown) => void } | undefined\n >;\n\n const isSet = (key: string): boolean => {\n const value = values[key];\n return Array.isArray(value) ? value.length > 0 : Boolean(value);\n };\n\n const operatorKeyOf = (field: DataTableFilterBarField) =>\n field.operatorKey ?? `${field.key}Op`;\n\n // Narrowing the list, by a value or by an operator standing on its own.\n const holds = (field: DataTableFilterBarField): boolean =>\n isSet(field.key) || values[operatorKeyOf(field)] !== undefined;\n\n const isLocked = (field: DataTableFilterBarField) =>\n modeOf(field) === \"locked\";\n\n const operatorsOf = (\n field: DataTableFilterBarField,\n ): DataTableFilterOperatorOption[] | undefined => {\n if (!field.operators || typeof field.operators !== \"string\") {\n return field.operators as DataTableFilterOperatorOption[] | undefined;\n }\n // The values come from the one table the filter schema is built from; only\n // the words are this bar's. A value is labelled the same in every preset\n // it appears in, so one entry per value covers all three.\n const not = tr(\"dataTable.operator.prefixNot\", { default: \"not\" });\n const labels: Record<\n string,\n Omit<DataTableFilterOperatorOption, \"value\">\n > = {\n is: { label: tr(\"dataTable.operator.is\", { default: \"is\" }) },\n not: {\n label: tr(\"dataTable.operator.isNot\", { default: \"is not\" }),\n prefix: not,\n },\n any: { label: tr(\"dataTable.operator.anyOf\", { default: \"any of\" }) },\n all: {\n label: tr(\"dataTable.operator.allOf\", { default: \"all of\" }),\n prefix: tr(\"dataTable.operator.prefixAll\", { default: \"all\" }),\n },\n none: {\n label: tr(\"dataTable.operator.noneOf\", { default: \"none of\" }),\n prefix: not,\n },\n };\n return DATA_TABLE_FILTER_OPERATORS[field.operators].map((value) => ({\n value,\n label: labels[value]?.label ?? value,\n prefix: labels[value]?.prefix,\n }));\n };\n\n const operatorOf = (field: DataTableFilterBarField) => {\n const operators = operatorsOf(field);\n return (\n operators?.find(\n (operator) => operator.value === values[operatorKeyOf(field)],\n ) ?? operators?.[0]\n );\n };\n\n /**\n * The schema a field is read with, stripped of `.optional()`: its own, or\n * `z.string()` for the search preset.\n */\n const schemaOf = (field: DataTableFilterBarField): ZType | undefined =>\n field.schema\n ? z.schema.unwrap(field.schema)\n : field.preset === \"search\"\n ? z.string()\n : undefined;\n\n /**\n * The values an enum schema, or an array of one, allows. Empty for any\n * other schema.\n */\n const enumValuesOf = (field: DataTableFilterBarField): string[] => {\n const schema = schemaOf(field);\n if (!schema) return [];\n if (z.schema.isEnum(schema)) return z.schema.enumOptions(schema);\n if (z.schema.isArray(schema)) {\n const element = z.schema.unwrap(z.schema.element(schema));\n if (z.schema.isEnum(element)) return z.schema.enumOptions(element);\n }\n return [];\n };\n\n // Live data first, then the enum the schema declares. A bare string falls\n // back to the select's own label for it.\n const itemsOf = (\n field: DataTableFilterBarField,\n ): SelectOption[] | undefined => {\n if (typeof field.items === \"function\") return field.items(values);\n if (field.items) return field.items;\n const options = enumValuesOf(field);\n if (options.length === 0) return undefined;\n const optionLabel = field.optionLabel;\n return optionLabel\n ? options.map((value) => ({ value, label: optionLabel(value) }))\n : options;\n };\n\n // Classified in `Control`'s own order, so the menu names the control the\n // filter will actually draw.\n const kindOf = (field: DataTableFilterBarField): DataTableFilterAddType => {\n const schema = schemaOf(field);\n // Before the list test, as `Control` orders it: a range IS an array, and\n // tested as one it would be offered as a list and drawn as a calendar.\n if (schema && z.schema.isDateRange(schema)) return \"date\";\n if (\n field.items ||\n (schema && (z.schema.isEnum(schema) || z.schema.isArray(schema)))\n ) {\n return \"list\";\n }\n return \"text\";\n };\n\n const placeholderOf = (field: DataTableFilterBarField) =>\n field.placeholder ??\n field.control?.placeholder ??\n (field.preset === \"search\"\n ? tr(\"dataTable.search\", { default: \"Search\" })\n : undefined);\n\n const labelOf = (field: DataTableFilterBarField) =>\n field.label ?? placeholderOf(field) ?? field.key;\n\n // Every filter has an icon, as every `Control` does: the caller's, the\n // search glyph for the search preset, else its kind's (the same glyphs the\n // controls fall back to). Without the last step a filter the caller gave no\n // icon was the one bare row of the add menu (\"When\", beside \"Resource\" and\n // \"What\").\n const iconOf = (field: DataTableFilterBarField) => {\n if (field.icon) return field.icon;\n if (field.preset === \"search\") return Search;\n const kind = kindOf(field);\n if (kind === \"date\") return Calendar;\n if (kind === \"list\") return List;\n return Type;\n };\n\n // A filter goes back to its default operator as its value goes: an\n // operator standing with nothing to qualify still counts as a filter in the\n // table's reset button and badge, while narrowing nothing.\n const clearField = (field: DataTableFilterBarField) => {\n inputs[field.key]?.set(undefined);\n if (field.operators) inputs[operatorKeyOf(field)]?.set(undefined);\n };\n\n useEffect(() => {\n const key = pendingOpen.current;\n if (!key) return;\n pendingOpen.current = undefined;\n // ⚠️ Opening the new filter has to happen from OUT HERE, after the render\n // that mounts it: inside the menu's click handler the control does not\n // exist yet. Driven through the DOM because `Control` exposes no\n // imperative \"open\" - a combobox owns that state, and a date range's\n // popover owns its own. A text filter has no list, so it is focused\n // instead. Scoped to this bar, so two tables on one page cannot open each\n // other's filters.\n const slot = root.current?.querySelector(`[data-filter=\"${key}\"]`);\n const trigger = slot?.querySelector<HTMLElement>(\n '[data-slot=\"combobox-trigger\"], [data-slot=\"date-trigger\"]',\n );\n if (trigger) {\n trigger.click();\n return;\n }\n slot?.querySelector<HTMLInputElement>('[data-slot=\"input\"]')?.focus();\n }, [shown]);\n\n useEffect(() => {\n // The other way a value empties: unticked inside the list, or cleared by\n // a locked field's own cross, rather than cleared by the button. Only on\n // the transition from set to empty, so a reader who picks \"is not\" BEFORE\n // picking a value keeps it, and a persisted operator survives the mount\n // it is restored on.\n for (const field of props.fields) {\n const set = isSet(field.key);\n const operatorKey = operatorKeyOf(field);\n if (\n field.operators &&\n heldValue.current[field.key] &&\n !set &&\n values[operatorKey] !== undefined\n ) {\n inputs[operatorKey]?.set(undefined);\n }\n heldValue.current[field.key] = set;\n }\n }, [values]);\n\n // A field holding a value or an operator joins `shown` the moment it is\n // seen - see the docblock. Folded INTO `shown` rather than drawn as\n // `shown ∪ set`, because a filter visible only for holding a value would\n // unmount the instant the reader emptied it, list open and cursor on it.\n // Locked fields are drawn regardless and never join it, and the dialog\n // draws every field.\n const unshown = dialog\n ? []\n : props.fields\n .filter(\n (field) =>\n !isLocked(field) && holds(field) && !shown.includes(field.key),\n )\n .map((field) => field.key);\n\n // The table's state cannot be set from this component's render, so it is\n // set in a LAYOUT effect: React flushes that update synchronously, before\n // the browser paints, so no frame shows the bar without the filter. The\n // guard stops it looping - it only fires while something is missing, and\n // the update adds exactly that.\n useLayoutEffect(() => {\n if (unshown.length > 0) {\n props.onShownChange([...shown, ...unshown], false);\n }\n });\n\n const drawn = (field: DataTableFilterBarField): boolean => {\n if (field.hidden && !holds(field)) return false;\n if (dialog || isLocked(field)) return true;\n return shown.includes(field.key);\n };\n\n // Locked first, in declaration order, then the shown ones in the order they\n // joined the bar: an added filter goes to the END, beside the \"+\" that\n // brought it, not back to its declared slot. Added D, C, B, A reads\n // D C B A. The dialog keeps the declaration as it is: nothing there is\n // added or removed.\n const rank = (field: DataTableFilterBarField) => {\n const index = shown.indexOf(field.key);\n return index === -1 ? Number.MAX_SAFE_INTEGER : index;\n };\n const ordered = dialog\n ? props.fields\n : [\n ...props.fields.filter((field) => isLocked(field)),\n ...props.fields\n .filter((field) => !isLocked(field))\n .sort((a, b) => rank(a) - rank(b)),\n ];\n\n return (\n // `contents`, so the slots are items of the table's own wrapping row (and\n // of the phone dialog's grid) exactly as a caller's bare fragment is.\n <div ref={root} className=\"contents\">\n {ordered\n .filter((field) => drawn(field))\n .map((field) => {\n // In the dialog every filter is drawn like a locked one: no\n // clear-and-remove button, the control's own cross resets it.\n const removable = !dialog && !isLocked(field);\n const operators = operatorsOf(field);\n const operator = operatorOf(field);\n const label = labelOf(field);\n return (\n <FilterSlot key={field.key}>\n <div data-filter={field.key}>\n <DataTableFilterControl\n label={label}\n active={isSet(field.key)}\n // A cross empties a filter holding a value; a funnel-x\n // removes an empty one. `active` picks between the two.\n // A locked filter is given neither, so it keeps the cross\n // inside its own field.\n onClear={removable ? () => clearField(field) : undefined}\n onRemove={\n removable\n ? () => {\n clearField(field);\n props.onShownChange(\n shown.filter((key) => key !== field.key),\n true,\n );\n }\n : undefined\n }\n >\n <Control\n {...field.control}\n input={inputs[field.key] as never}\n label=\"\"\n icon={iconOf(field)}\n clearable\n placeholder={placeholderOf(field)}\n items={itemsOf(field) as never}\n // The filter's name, as the control's accessible name:\n // an empty select says only its placeholder, and a set\n // one only its value. A name the caller gave wins.\n inputProps={{\n \"aria-label\": label,\n // A text filter is as wide as its placeholder. The slot\n // grows from its content, and an input's content width\n // is its `size` in characters (20 by default), so a\n // long placeholder was cut at the slot's minimum.\n ...(kindOf(field) === \"text\"\n ? {\n size: Math.max(\n 20,\n placeholderOf(field)?.length ?? 0,\n ),\n }\n : {}),\n ...field.control?.inputProps,\n }}\n // The filter's name, and a non-default operator, muted in\n // front of the value: \"Status: not Active\". An empty\n // select draws no prefix; its placeholder names it. The\n // colon is a catalog entry because French spaces it.\n triggerPrefix={[\n tr(\"dataTable.filterName\", {\n default: `${label}:`,\n args: [label],\n }),\n operator?.prefix,\n ]\n .filter(Boolean)\n .join(\" \")}\n // Sized from its content, not the trigger: the trigger\n // grows as the reader picks, and a popup tied to it would\n // widen under the cursor.\n popupClassName=\"w-max min-w-48\"\n popupHeader={\n operators && (\n <DataTableFilterOperator\n options={operators}\n value={operator?.value}\n onChange={(value) =>\n inputs[operatorKeyOf(field)]?.set(value)\n }\n />\n )\n }\n />\n </DataTableFilterControl>\n </div>\n </FilterSlot>\n );\n })}\n\n {!dialog && (\n <DataTableFilterAdd\n labeled={!ordered.some((field) => drawn(field))}\n items={props.fields\n .filter(\n (field) =>\n !isLocked(field) && !field.hidden && !shown.includes(field.key),\n )\n .map((field) => ({\n key: field.key,\n label: labelOf(field),\n icon: iconOf(field),\n type: kindOf(field),\n }))}\n onAdd={(key) => {\n pendingOpen.current = key;\n props.onShownChange([...shown, key], true);\n }}\n />\n )}\n </div>\n );\n};\n\n/**\n * One filter of the bar: a field of `filters.fields` with its key, as the\n * table hands it over. `schema` is the one the table read at mount, and gives\n * the options of an enum and the kind the add menu names.\n */\nexport interface DataTableFilterBarField extends DataTableFilterFieldOptions {\n /**\n * The form field this filter writes.\n */\n key: string;\n schema?: ZType;\n preset?: DataTableFilterPreset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAa,sBAAsB,UAAmC;CACpE,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,SAAS,cAAc,MAAM,IAAI;CACvC,MAAM,SAAS,MAAM,YAAY;CACjC,MAAM,UAAU,UACd,MAAM,SAAS,MAAM,WAAW,WAAW,WAAW;CACxD,MAAM,QAAQ,MAAM;CACpB,MAAM,OAAO,OAAuB,IAAI;CAIxC,MAAM,cAAc,OAA2B,KAAA,CAA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QAAQ,KAAK;MAIpB,YAAY;OACV,cAAc;OAKd,GAAI,OAAO,KAAK,MAAM,SAClB,EACE,MAAM,KAAK,IACT,IACA,cAAc,KAAK,CAAC,EAAE,UAAU,CAClC,EACF,IACA,CAAC;OACL,GAAG,MAAM,SAAS;MACpB;MAKA,eAAe,CACb,GAAG,wBAAwB;OACzB,SAAS,GAAG,MAAM;OAClB,MAAM,CAAC,KAAK;MACd,CAAC,GACD,UAAU,MACZ,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;MAIX,gBAAe;MACf,aACE,aACE,oBAAC,yBAAD;OACE,SAAS;OACT,OAAO,UAAU;OACjB,WAAW,UACT,OAAO,cAAc,KAAK,EAAE,EAAE,IAAI,KAAK;MAE1C,CAAA;KAGN,CAAA;IACqB,CAAA;GACrB,CAAA,EACK,GAhFK,MAAM,GAgFX;EAEhB,CAAC,GAEF,CAAC,UACA,oBAAC,oBAAD;GACE,SAAS,CAAC,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;GAC9C,OAAO,MAAM,OACV,QACE,UACC,CAAC,SAAS,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,SAAS,MAAM,GAAG,CAClE,CAAC,CACA,KAAK,WAAW;IACf,KAAK,MAAM;IACX,OAAO,QAAQ,KAAK;IACpB,MAAM,OAAO,KAAK;IAClB,MAAM,OAAO,KAAK;GACpB,EAAE;GACJ,QAAQ,QAAQ;IACd,YAAY,UAAU;IACtB,MAAM,cAAc,CAAC,GAAG,OAAO,GAAG,GAAG,IAAI;GAC3C;EACD,CAAA,CAEA;;AAET"}
|
|
@@ -371,7 +371,7 @@ export interface DataTableBaseProps<T, F extends DataTableFilterFields = DataTab
|
|
|
371
371
|
onSortChange?: (sort: SortState | null) => void;
|
|
372
372
|
/**
|
|
373
373
|
* When true (default when `filters` is set), the table refetches on
|
|
374
|
-
* every `form:
|
|
374
|
+
* every `form:changed` event, debounced by 250ms. Set to `false` to
|
|
375
375
|
* require an explicit submit.
|
|
376
376
|
*/
|
|
377
377
|
autoApplyFilters?: boolean;
|
|
@@ -86,7 +86,7 @@ export interface RowActionContext {
|
|
|
86
86
|
export interface RowAction<T> {
|
|
87
87
|
label: string;
|
|
88
88
|
icon?: IconType;
|
|
89
|
-
onClick: (item: T, ctx: RowActionContext) =>
|
|
89
|
+
onClick: (item: T, ctx: RowActionContext) => unknown;
|
|
90
90
|
destructive?: boolean;
|
|
91
91
|
disabled?: (item: T) => boolean;
|
|
92
92
|
/**
|
|
@@ -138,7 +138,7 @@ export interface BulkActionContext {
|
|
|
138
138
|
export interface BulkAction<T> {
|
|
139
139
|
label: string;
|
|
140
140
|
icon?: IconType;
|
|
141
|
-
onClick: (selected: T[], ctx: BulkActionContext) =>
|
|
141
|
+
onClick: (selected: T[], ctx: BulkActionContext) => unknown;
|
|
142
142
|
destructive?: boolean;
|
|
143
143
|
/**
|
|
144
144
|
* Whether the action is offered for this selection. Absent means always.
|
|
@@ -562,7 +562,7 @@ export interface DataTableFilters<F extends DataTableFilterFields = DataTableNoF
|
|
|
562
562
|
* component's `key` to re-seed on a later arrival.
|
|
563
563
|
*
|
|
564
564
|
* **Transient, and by construction.** Persistence is written from
|
|
565
|
-
* `form:
|
|
565
|
+
* `form:changed` / `form:submit:success` only, never on mount , so a seed
|
|
566
566
|
* shows in the toolbar and narrows the fetch without overwriting the
|
|
567
567
|
* filter the reader chose for themselves last time. Touch any control and
|
|
568
568
|
* the resulting values (seed included) become the stored choice, which is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataTableTypes.d.ts","sourceRoot":"","sources":["../../src/table/dataTableTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,SAAS,EACT,KAAK,EACN,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE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AAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,CACjC,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,IACvD,CAAC,MAAM,EAAE;IACX,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;CACrB,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB,CAC/B,CAAC,SAAS,qBAAqB,GAAG,uBAAuB;IAEzD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACnC;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,uBAAuB,KAAK,SAAS,CAAC,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataTableData.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAa,KAAK,OAAO,EAAK,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"useDataTableData.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAa,KAAK,OAAO,EAAK,MAAM,QAAQ,CAAC;AAEjE,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,qBAAqB,CAAC,GACjD,eAAe,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC5C;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,WAAW,uBAAuB,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8M5C,MAAM,OAAO,SAAS,CAAC,CAAC,CAAC;qBAsB3C,MAAM,OACN,SAAS,CAAC,CAAC,CAAC,aACN,KAAK,GAAG,MAAM,GAAG,IAAI;CA0BnC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { persistedSort, writePersisted } from "./dataTablePersistence.js";
|
|
|
2
2
|
import { paginateLocal } from "./paginateLocal.js";
|
|
3
3
|
import { z } from "alepha";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { ActionErrorPolicy } from "alepha/react";
|
|
5
6
|
import { useForm } from "alepha/react/form";
|
|
6
7
|
//#region src/table/useDataTableData.ts
|
|
7
8
|
/**
|
|
@@ -86,7 +87,8 @@ const useDataTableData = (options) => {
|
|
|
86
87
|
alepha.events.emit("react:action:error", {
|
|
87
88
|
type: "custom",
|
|
88
89
|
id: "data-table:load",
|
|
89
|
-
error
|
|
90
|
+
error,
|
|
91
|
+
handled: ActionErrorPolicy.isHandled(error)
|
|
90
92
|
});
|
|
91
93
|
} finally {
|
|
92
94
|
if (isLatest()) setLoading(false);
|