@jsb188/mday-web 1.1.10 → 1.1.12

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.
Files changed (38) hide show
  1. package/package.json +36 -24
  2. package/src/libs/route-metadata.server.ts +67 -0
  3. package/src/modules/Grids.filters.ts +36 -0
  4. package/src/modules/Grids.tsx +610 -0
  5. package/src/modules/RouteShell.tsx +76 -0
  6. package/src/schemas/organization.ts +128 -0
  7. package/src/utils/email.ts +117 -0
  8. package/src/utils/list-web.ts +17 -0
  9. package/src/utils/log-web.helpers.ts +99 -0
  10. package/src/utils/log-web.icons.ts +184 -0
  11. package/src/utils/log-web.ts +74 -364
  12. package/src/utils/operation-pages.ts +154 -0
  13. package/src/utils/org-web.ts +35 -8
  14. package/src/utils/route-helpers.ts +837 -596
  15. package/src/utils/workflow-web.ts +72 -0
  16. package/tests/log-web.test.ts +134 -0
  17. package/tests/route-helpers.test.ts +17 -0
  18. package/tsconfig.json +11 -11
  19. package/src/modules/DataTable-ContextMenu.tsx +0 -169
  20. package/src/modules/DataTable-InboundContact.tsx +0 -523
  21. package/src/modules/DataTable.tsx +0 -5060
  22. package/src/modules/Sheet-ContextMenu.tsx +0 -161
  23. package/src/modules/Sheet.tsx +0 -28
  24. package/src/modules/cell-save-beacon.ts +0 -67
  25. package/src/modules/dataTable-interaction-state.ts +0 -276
  26. package/src/modules/dataTable-shortcuts.ts +0 -192
  27. package/src/modules/dataTable-viewport.ts +0 -89
  28. package/src/modules/grid-cell-render.ts +0 -72
  29. package/src/modules/grid-context-menu.ts +0 -112
  30. package/src/modules/grid-keyboard.ts +0 -267
  31. package/src/modules/grid-render-store.ts +0 -103
  32. package/src/modules/grid-runtime.ts +0 -178
  33. package/src/modules/grid-selection.ts +0 -336
  34. package/src/modules/grid-viewport.ts +0 -57
  35. package/src/modules/use-dataTable-states.ts +0 -529
  36. package/src/modules/use-debounced-cell-save-batch.ts +0 -160
  37. package/tests/DataTable.test.tsx +0 -4466
  38. package/tests/dataTable-interaction-state.test.ts +0 -127
package/package.json CHANGED
@@ -1,26 +1,38 @@
1
1
  {
2
- "name": "@jsb188/mday-web",
3
- "version": "1.1.10",
4
- "description": "Web components and utilities for Marketday app.",
5
- "license": "ISC",
6
- "author": "jsb188",
7
- "type": "module",
8
- "exports": {
9
- "./DataTable": "./src/modules/DataTable.tsx",
10
- "./Sheet": "./src/modules/Sheet.tsx",
11
- "./utils/route": "./src/utils/route-helpers.ts",
12
- "./utils/log-web": "./src/utils/log-web.ts",
13
- "./utils/org-web": "./src/utils/org-web.ts"
14
- },
15
- "dependencies": {},
16
- "peerDependencies": {
17
- "@jsb188/app": "1.1.10",
18
- "@jsb188/graphql": "1.1.10",
19
- "@jsb188/mday": "1.1.10",
20
- "@jsb188/react": "1.1.10",
21
- "@jsb188/react-web": "1.1.10"
22
- },
23
- "scripts": {
24
- "test": "vitest run --config ./vitest.config.ts"
25
- }
2
+ "name": "@jsb188/mday-web",
3
+ "version": "1.1.12",
4
+ "description": "Web components and utilities for Marketday app.",
5
+ "license": "ISC",
6
+ "author": "jsb188",
7
+ "type": "module",
8
+ "exports": {
9
+ "./libs/public-form-beacon": "./src/libs/public-form-beacon.ts",
10
+ "./libs/route-metadata.server": "./src/libs/route-metadata.server.ts",
11
+ "./utils/email": "./src/utils/email.ts",
12
+ "./utils/route": "./src/utils/route-helpers.ts",
13
+ "./utils/log-web": "./src/utils/log-web.ts",
14
+ "./utils/list-web": "./src/utils/list-web.ts",
15
+ "./utils/org-web": "./src/utils/org-web.ts",
16
+ "./utils/operation-pages": "./src/utils/operation-pages.ts",
17
+ "./utils/public-form": "./src/utils/public-form.ts",
18
+ "./utils/workflow-web": "./src/utils/workflow-web.ts",
19
+ "./modules/Grids": "./src/modules/Grids.tsx",
20
+ "./modules/RouteShell": "./src/modules/RouteShell.tsx",
21
+ "./schemas/organization": "./src/schemas/organization.ts"
22
+ },
23
+ "dependencies": {
24
+ "zod": "^3.25.76"
25
+ },
26
+ "peerDependencies": {
27
+ "@jsb188/app": "1.1.12",
28
+ "@jsb188/graphql": "1.1.12",
29
+ "@jsb188/mday": "1.1.12",
30
+ "@jsb188/react": "1.1.12",
31
+ "@jsb188/react-web": "1.1.12",
32
+ "@jsb188/auth-web": "1.1.12",
33
+ "@jsb188/form": "1.1.12"
34
+ },
35
+ "scripts": {
36
+ "test": "vitest run --config ./vitest.config.ts --passWithNoTests"
37
+ }
26
38
  }
@@ -0,0 +1,67 @@
1
+ import { graphqlServerRequest } from '@jsb188/graphql/client';
2
+ import { AuthSession } from '@jsb188/react-web/utils/remix';
3
+
4
+ /*
5
+ * Fetch one GraphQL metadata field with the supplied viewer token.
6
+ */
7
+ async function fetchRouteMetadataWithToken<T>(
8
+ query: any,
9
+ variables: Record<string, unknown>,
10
+ resultKey: string,
11
+ authToken: string | null,
12
+ ): Promise<T | null> {
13
+ try {
14
+ const result = await graphqlServerRequest(query, variables, {
15
+ authToken,
16
+ cacheAccountId: '*',
17
+ });
18
+
19
+ return (result?.[resultKey] as T | null | undefined) || null;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+
25
+ /*
26
+ * Fetch one metadata field with optional authentication for a public route.
27
+ */
28
+ export async function fetchRouteMetadata<T>(
29
+ request: Request,
30
+ query: any,
31
+ variables: Record<string, unknown>,
32
+ resultKey: string,
33
+ ): Promise<T | null> {
34
+ const session = await AuthSession.getSession(request.headers.get('Cookie'));
35
+ const authToken = session.get('auth_token') || null;
36
+
37
+ return await fetchRouteMetadataWithToken<T>(
38
+ query,
39
+ variables,
40
+ resultKey,
41
+ authToken,
42
+ );
43
+ }
44
+
45
+ /*
46
+ * Fetch one authenticated metadata field without letting metadata failures
47
+ * replace the route's primary page response.
48
+ */
49
+ export async function fetchAuthenticatedRouteMetadata<T>(
50
+ request: Request,
51
+ query: any,
52
+ variables: Record<string, unknown>,
53
+ resultKey: string,
54
+ ): Promise<T | null> {
55
+ const session = await AuthSession.getSession(request.headers.get('Cookie'));
56
+ const authToken = session.get('auth_token') || null;
57
+ if (!authToken) {
58
+ return null;
59
+ }
60
+
61
+ return await fetchRouteMetadataWithToken<T>(
62
+ query,
63
+ variables,
64
+ resultKey,
65
+ authToken,
66
+ );
67
+ }
@@ -0,0 +1,36 @@
1
+ import i18n from '@jsb188/app/i18n/index.ts';
2
+ import { definePageFilterSchema } from '@jsb188/react/libs/page-filters';
3
+ import { usePageFilters } from '@jsb188/react/libs/use-page-filters';
4
+ import {
5
+ makePageToolbarFilters,
6
+ type PageToolbarFilter,
7
+ } from '@jsb188/react-web/modules/ToolbarFilters';
8
+ import type { GridItemSortEnum } from '@jsb188/mday/types/sheet.d.ts';
9
+
10
+ export const GRIDS_FILTER_SCHEMA = definePageFilterSchema({
11
+ filter: {},
12
+ sort: {
13
+ values: ['UPDATED_AT_DESC', 'TITLE_ASC'],
14
+ default: 'UPDATED_AT_DESC',
15
+ },
16
+ });
17
+ export const GRIDS_SORT_TOOLBAR: PageToolbarFilter = {
18
+ control: 'sort',
19
+ label: i18n.t('c.sort_by'),
20
+ labels: {
21
+ UPDATED_AT_DESC: i18n.t('app.grids_sort_updated_date'),
22
+ TITLE_ASC: i18n.t('app.grids_sort_title'),
23
+ },
24
+ };
25
+
26
+ /*
27
+ * Share committed URL sort state between the grids toolbar and both grid queries.
28
+ */
29
+ export function useGridsToolbarState() {
30
+ const state = usePageFilters(GRIDS_FILTER_SCHEMA);
31
+ return {
32
+ ...state,
33
+ sortQueryValue: state.sort as GridItemSortEnum,
34
+ toolbarOptions: makePageToolbarFilters(state, [GRIDS_SORT_TOOLBAR]),
35
+ };
36
+ }