@jsb188/mday-web 1.1.10 → 1.1.11

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 (33) hide show
  1. package/package.json +34 -24
  2. package/src/libs/route-metadata.server.ts +67 -0
  3. package/src/modules/AgentDocs.tsx +800 -0
  4. package/src/modules/DocAccessSettings.tsx +963 -0
  5. package/src/modules/Grids.tsx +842 -0
  6. package/src/modules/RouteShell.tsx +76 -0
  7. package/src/utils/account-web.ts +64 -0
  8. package/src/utils/list-web.ts +17 -0
  9. package/src/utils/log-web.ts +162 -52
  10. package/src/utils/org-web.ts +35 -8
  11. package/src/utils/route-helpers.ts +902 -596
  12. package/src/utils/workflow-web.ts +96 -0
  13. package/tsconfig.json +11 -11
  14. package/src/modules/DataTable-ContextMenu.tsx +0 -169
  15. package/src/modules/DataTable-InboundContact.tsx +0 -523
  16. package/src/modules/DataTable.tsx +0 -5060
  17. package/src/modules/Sheet-ContextMenu.tsx +0 -161
  18. package/src/modules/Sheet.tsx +0 -28
  19. package/src/modules/cell-save-beacon.ts +0 -67
  20. package/src/modules/dataTable-interaction-state.ts +0 -276
  21. package/src/modules/dataTable-shortcuts.ts +0 -192
  22. package/src/modules/dataTable-viewport.ts +0 -89
  23. package/src/modules/grid-cell-render.ts +0 -72
  24. package/src/modules/grid-context-menu.ts +0 -112
  25. package/src/modules/grid-keyboard.ts +0 -267
  26. package/src/modules/grid-render-store.ts +0 -103
  27. package/src/modules/grid-runtime.ts +0 -178
  28. package/src/modules/grid-selection.ts +0 -336
  29. package/src/modules/grid-viewport.ts +0 -57
  30. package/src/modules/use-dataTable-states.ts +0 -529
  31. package/src/modules/use-debounced-cell-save-batch.ts +0 -160
  32. package/tests/DataTable.test.tsx +0 -4466
  33. package/tests/dataTable-interaction-state.test.ts +0 -127
@@ -0,0 +1,96 @@
1
+ import i18n from '@jsb188/app/i18n/index.ts';
2
+ import { getCronDescription } from '@jsb188/app/utils/cron.ts';
3
+ import { getFullDate } from '@jsb188/app/utils/datetime.ts';
4
+ import type { WorkflowGQL } from '@jsb188/mday/types/workflow.d.ts';
5
+ import {
6
+ getWorkflowShortLabel,
7
+ isRecurringReminder,
8
+ isWorkflowActive,
9
+ } from '@jsb188/mday/utils/workflow.ts';
10
+ import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
11
+
12
+ /*
13
+ * Return the icon name used to represent one workflow trigger.
14
+ */
15
+ export function getWorkflowIconName(workflow: WorkflowGQL) {
16
+ const firstLogType = workflow.logTypes?.[0];
17
+
18
+ return firstLogType
19
+ ? COMMON_ICON_NAMES[firstLogType] || COMMON_ICON_NAMES.general_workflow
20
+ : COMMON_ICON_NAMES.general_workflow;
21
+ }
22
+
23
+ /*
24
+ * Return the formatted next run date for one workflow, or a table-friendly empty value.
25
+ */
26
+ export function getWorkflowNextRunText(
27
+ workflow: WorkflowGQL,
28
+ timeZone: string | null,
29
+ ) {
30
+ return workflow.nextAt
31
+ ? getFullDate(workflow.nextAt, 'NUMERIC_TIME', timeZone)
32
+ : '-';
33
+ }
34
+
35
+ /*
36
+ * Return the schedule description for one reminder (cron text or one-time date).
37
+ */
38
+ export function getReminderScheduleText(
39
+ reminder: Pick<WorkflowGQL, 'triggerType' | 'schedule' | 'nextAt'>,
40
+ timeZone: string | null,
41
+ ) {
42
+ if (isRecurringReminder(reminder) && reminder.schedule) {
43
+ return getCronDescription(reminder.schedule, true);
44
+ }
45
+
46
+ return reminder.nextAt
47
+ ? getFullDate(reminder.nextAt, 'NUMERIC_TIME', timeZone)
48
+ : '-';
49
+ }
50
+
51
+ /*
52
+ * Return the short recipients summary for one reminder (names/addresses).
53
+ */
54
+ export function getReminderRecipientsSummaryText(
55
+ reminder: Pick<WorkflowGQL, 'recipients'>,
56
+ ) {
57
+ const labels = (reminder.recipients || [])
58
+ .map(
59
+ (recipient) => recipient.name || recipient.phone || recipient.email || '',
60
+ )
61
+ .filter(Boolean);
62
+
63
+ if (!labels.length) {
64
+ return '-';
65
+ }
66
+
67
+ if (labels.length <= 2) {
68
+ return labels.join(', ');
69
+ }
70
+
71
+ return `${labels.slice(0, 2).join(', ')} +${labels.length - 2}`;
72
+ }
73
+
74
+ /*
75
+ * Return the modal header description for one workflow's current scheduling state.
76
+ */
77
+ export function getWorkflowHeaderDescription(
78
+ workflow: WorkflowGQL,
79
+ timeZone: string | null,
80
+ ) {
81
+ if (!isWorkflowActive(workflow)) {
82
+ return i18n.t('workflow.not_active_msg');
83
+ }
84
+
85
+ if (workflow.nextAt) {
86
+ return `${i18n.t('form.next_run')}: ${getWorkflowNextRunText(workflow, timeZone)}`;
87
+ }
88
+
89
+ const logTypeShortLabel = workflow.logTypes?.length
90
+ ? getWorkflowShortLabel(workflow)
91
+ : null;
92
+
93
+ return i18n.t('workflow.active_msg', {
94
+ logType: logTypeShortLabel?.toLowerCase(),
95
+ });
96
+ }
package/tsconfig.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "allowImportingTsExtensions": true,
7
- "jsx": "react-jsx",
8
- "noEmit": true,
9
- "strict": true,
10
- "esModuleInterop": true
11
- },
12
- "include": ["src/**/*"]
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "jsx": "react-jsx",
8
+ "noEmit": true,
9
+ "strict": true,
10
+ "esModuleInterop": true
11
+ },
12
+ "include": ["src/**/*"]
13
13
  }
@@ -1,169 +0,0 @@
1
- import i18n from '@jsb188/app/i18n/index.ts';
2
- import type { POListIfaceItem } from '@jsb188/react/types/PopOver.d';
3
- import { type OpenModalPopUpFn } from '@jsb188/react/states';
4
- import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
5
- import { copyTextToClipboard } from '@jsb188/react-web/utils/dom';
6
- import { useEffect } from 'react';
7
- import { getGridContextMenuPopOverId, useGridContextMenu } from './grid-context-menu.ts';
8
-
9
- export const SHEET_CONTEXT_MENU_ID = 'dataTable-context-menu';
10
- export const SHEET_DELETE_ROW_POPUP_PRESET = 'DELETE_SHEET_ROW';
11
-
12
- export const SHEET_CONTEXT_MENU_ACTIONS = {
13
- copyCellValue: 'COPY_CELL_VALUE',
14
- deleteRow: 'DELETE_ROW',
15
- editCell: 'EDIT_CELL',
16
- openCell: 'OPEN_CELL',
17
- } as const;
18
-
19
- export type DataTableArrowNavigationDirection = 'left' | 'right' | 'up' | 'down';
20
- export type DataTableContextMenuAction = typeof SHEET_CONTEXT_MENU_ACTIONS[keyof typeof SHEET_CONTEXT_MENU_ACTIONS];
21
-
22
- export type DataTableContextMenuTarget<Lookup = unknown> = {
23
- canDeleteRow: boolean;
24
- canEdit: boolean;
25
- canOpen: boolean;
26
- cellKey: string;
27
- displayValue: string;
28
- lookup: Lookup;
29
- organizationId: string;
30
- rowId: string;
31
- rowNumber?: number | null;
32
- dataTableId: string;
33
- viewId?: string | null;
34
- };
35
-
36
- type UseDataTableContextMenuParams<Lookup> = {
37
- openModalPopUp: OpenModalPopUpFn;
38
- onEditCell: (target: DataTableContextMenuTarget<Lookup>) => void;
39
- onOpenCell: (target: DataTableContextMenuTarget<Lookup>) => void;
40
- };
41
-
42
- /*
43
- * Copy one dataTable context-menu target's display value to the clipboard.
44
- */
45
-
46
- function copyDataTableContextMenuCellValue(target: DataTableContextMenuTarget) {
47
- void copyTextToClipboard(target.displayValue || '');
48
- }
49
-
50
- /*
51
- * Build the PopOver list options for one dataTable context-menu target.
52
- */
53
-
54
- function getDataTableContextMenuOptions(target: DataTableContextMenuTarget): POListIfaceItem[] {
55
- const options: POListIfaceItem[] = [{
56
- __type: 'LIST_ITEM',
57
- disabled: !target.canEdit,
58
- iconName: COMMON_ICON_NAMES.edit_note,
59
- text: i18n.t('dataTable.context_menu_edit_cell'),
60
- value: SHEET_CONTEXT_MENU_ACTIONS.editCell,
61
- }, {
62
- __type: 'LIST_ITEM',
63
- disabled: !target.canOpen,
64
- iconName: 'external-link',
65
- text: i18n.t('dataTable.context_menu_open_cell'),
66
- value: SHEET_CONTEXT_MENU_ACTIONS.openCell,
67
- }, {
68
- __type: 'LIST_ITEM',
69
- iconName: COMMON_ICON_NAMES.copy,
70
- text: i18n.t('dataTable.context_menu_copy_cell_value'),
71
- value: SHEET_CONTEXT_MENU_ACTIONS.copyCellValue,
72
- }];
73
-
74
- if (target.canDeleteRow) {
75
- options.push({
76
- __type: 'BREAK',
77
- }, {
78
- __type: 'LIST_ITEM',
79
- className: 'cl_err',
80
- iconName: COMMON_ICON_NAMES.delete,
81
- text: i18n.t('dataTable.delete_row'),
82
- value: SHEET_CONTEXT_MENU_ACTIONS.deleteRow,
83
- });
84
- }
85
-
86
- return options;
87
- }
88
-
89
- /*
90
- * Open the delete-row confirmation popup for a menu target.
91
- */
92
-
93
- function openDataTableDeleteRowPopUp<Lookup>(
94
- openModalPopUp: OpenModalPopUpFn,
95
- target: DataTableContextMenuTarget<Lookup>,
96
- ) {
97
- openModalPopUp({
98
- name: SHEET_DELETE_ROW_POPUP_PRESET,
99
- preset: SHEET_DELETE_ROW_POPUP_PRESET,
100
- props: {
101
- allowDelete: target.canDeleteRow,
102
- organizationId: target.organizationId,
103
- rowNumber: target.rowNumber,
104
- dataTableId: target.dataTableId,
105
- dataTableRowId: target.rowId,
106
- viewId: target.viewId || null,
107
- },
108
- });
109
- }
110
-
111
- /*
112
- * Own the DataTable context-menu PopOver actions.
113
- */
114
-
115
- export function useDataTableContextMenu<Lookup>(p: UseDataTableContextMenuParams<Lookup>) {
116
- const {
117
- onEditCell,
118
- onOpenCell,
119
- openModalPopUp,
120
- } = p;
121
- const {
122
- activeTargetRef,
123
- closeContextMenu: closeDataTableContextMenu,
124
- closePopOver,
125
- openContextMenu: openDataTableContextMenu,
126
- popOver,
127
- } = useGridContextMenu<DataTableContextMenuTarget<Lookup>>({
128
- contextMenuId: SHEET_CONTEXT_MENU_ID,
129
- getOptions: getDataTableContextMenuOptions,
130
- });
131
-
132
- useEffect(() => {
133
- const { action, id, value } = popOver?.globalState || {};
134
- const target = activeTargetRef.current;
135
-
136
- if (!target || id !== getGridContextMenuPopOverId(SHEET_CONTEXT_MENU_ID, target) || action !== 'ITEM') {
137
- return;
138
- }
139
-
140
- switch (value as DataTableContextMenuAction) {
141
- case SHEET_CONTEXT_MENU_ACTIONS.copyCellValue:
142
- copyDataTableContextMenuCellValue(target);
143
- closePopOver();
144
- break;
145
- case SHEET_CONTEXT_MENU_ACTIONS.deleteRow:
146
- openDataTableDeleteRowPopUp(openModalPopUp, target);
147
- closePopOver();
148
- break;
149
- case SHEET_CONTEXT_MENU_ACTIONS.editCell:
150
- if (target.canEdit) {
151
- onEditCell(target);
152
- }
153
- closePopOver();
154
- break;
155
- case SHEET_CONTEXT_MENU_ACTIONS.openCell:
156
- if (target.canOpen) {
157
- onOpenCell(target);
158
- }
159
- closePopOver();
160
- break;
161
- default:
162
- }
163
- }, [closePopOver, onEditCell, onOpenCell, openModalPopUp, popOver?.globalState]);
164
-
165
- return {
166
- closeDataTableContextMenu,
167
- openDataTableContextMenu,
168
- };
169
- }