@aglyn/plugins-crm 1.0.0-beta.232 → 1.0.0-beta.234

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 (55) hide show
  1. package/package.json +14 -14
  2. package/src/lib/components/companies-section.js +43 -8
  3. package/src/lib/components/companies-section.js.map +1 -1
  4. package/src/lib/components/company-edit-drawer.js +3 -1
  5. package/src/lib/components/company-edit-drawer.js.map +1 -1
  6. package/src/lib/components/contact-detail-page.js +6 -1
  7. package/src/lib/components/contact-detail-page.js.map +1 -1
  8. package/src/lib/components/contacts-section.js +37 -8
  9. package/src/lib/components/contacts-section.js.map +1 -1
  10. package/src/lib/components/crm-email-check.d.ts +14 -0
  11. package/src/lib/components/crm-email-check.js +38 -1
  12. package/src/lib/components/crm-email-check.js.map +1 -1
  13. package/src/lib/components/crm-next-activity-column.d.ts +5 -4
  14. package/src/lib/components/crm-next-activity-column.js +5 -4
  15. package/src/lib/components/crm-next-activity-column.js.map +1 -1
  16. package/src/lib/components/deal-edit-drawer.js +3 -1
  17. package/src/lib/components/deal-edit-drawer.js.map +1 -1
  18. package/src/lib/components/deals-section.js +50 -6
  19. package/src/lib/components/deals-section.js.map +1 -1
  20. package/src/lib/components/lead-properties-card.js +9 -3
  21. package/src/lib/components/lead-properties-card.js.map +1 -1
  22. package/src/lib/components/leads-section.js +61 -11
  23. package/src/lib/components/leads-section.js.map +1 -1
  24. package/src/lib/components/tasks-section.js +61 -9
  25. package/src/lib/components/tasks-section.js.map +1 -1
  26. package/src/lib/constants/company-filters.js +40 -2
  27. package/src/lib/constants/company-filters.js.map +1 -1
  28. package/src/lib/constants/contact-filters.d.ts +10 -1
  29. package/src/lib/constants/contact-filters.js +62 -2
  30. package/src/lib/constants/contact-filters.js.map +1 -1
  31. package/src/lib/constants/deal-filters.js +78 -0
  32. package/src/lib/constants/deal-filters.js.map +1 -1
  33. package/src/lib/hooks/use-crm-column-sort.d.ts +67 -0
  34. package/src/lib/hooks/use-crm-column-sort.js +156 -0
  35. package/src/lib/hooks/use-crm-column-sort.js.map +1 -0
  36. package/src/lib/hooks/use-crm-tasks.d.ts +6 -1
  37. package/src/lib/hooks/use-crm-tasks.js +10 -8
  38. package/src/lib/hooks/use-crm-tasks.js.map +1 -1
  39. package/src/lib/model/crm-list-query.d.ts +6 -0
  40. package/src/lib/model/crm-list-query.js +13 -0
  41. package/src/lib/model/crm-list-query.js.map +1 -1
  42. package/src/lib/model/lead-filters.d.ts +19 -2
  43. package/src/lib/model/lead-filters.js +112 -2
  44. package/src/lib/model/lead-filters.js.map +1 -1
  45. package/src/lib/model/native-vocabulary.d.ts +41 -0
  46. package/src/lib/model/native-vocabulary.js +59 -0
  47. package/src/lib/model/native-vocabulary.js.map +1 -0
  48. package/src/lib/model/task-views.d.ts +15 -2
  49. package/src/lib/model/task-views.js +50 -4
  50. package/src/lib/model/task-views.js.map +1 -1
  51. package/src/lib/server/email-check.d.ts +4 -1
  52. package/src/lib/server/email-check.js +18 -6
  53. package/src/lib/server/email-check.js.map +1 -1
  54. package/src/lib/transfer/tasks.js +2 -1
  55. package/src/lib/transfer/tasks.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-crm",
3
- "version": "1.0.0-beta.232",
3
+ "version": "1.0.0-beta.234",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,19 +25,19 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.232",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.232",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.232",
31
- "@aglyn/shared-ui-jsx": "1.0.0-beta.232",
32
- "@aglyn/shared-ui-next": "1.0.0-beta.232",
33
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.232",
34
- "@aglyn/shared-util-email": "1.0.0-beta.232",
35
- "@aglyn/shared-util-http": "1.0.0-beta.232",
36
- "@aglyn/shared-util-timestamp": "1.0.0-beta.232",
37
- "@aglyn/shared-util-tools": "1.0.0-beta.232",
38
- "@aglyn/tenant-data-admin": "1.0.0-beta.232",
39
- "@aglyn/tenant-feature-instance": "1.0.0-beta.232",
40
- "@aglyn/tenant-runtime": "1.0.0-beta.232",
28
+ "@aglyn/aglyn": "1.0.0-beta.234",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.234",
30
+ "@aglyn/shared-data-mdi": "1.0.0-beta.234",
31
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.234",
32
+ "@aglyn/shared-ui-next": "1.0.0-beta.234",
33
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.234",
34
+ "@aglyn/shared-util-email": "1.0.0-beta.234",
35
+ "@aglyn/shared-util-http": "1.0.0-beta.234",
36
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.234",
37
+ "@aglyn/shared-util-tools": "1.0.0-beta.234",
38
+ "@aglyn/tenant-data-admin": "1.0.0-beta.234",
39
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.234",
40
+ "@aglyn/tenant-runtime": "1.0.0-beta.234",
41
41
  "@dnd-kit/core": "^6.3.1",
42
42
  "@dnd-kit/utilities": "^3.2.2",
43
43
  "@swc/helpers": "0.5.23",
@@ -16,7 +16,7 @@
16
16
  */ 'use client';
17
17
  import { _ as _extends } from "@swc/helpers/_/_extends";
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
- import { CRM_COLLECTIONS, crmPicklistKey, pluginDocsHelp, crmMemberPickerLabel } from "@aglyn/aglyn";
19
+ import { CRM_COLLECTIONS, crmPicklistKey, crmPicklistRank, pluginDocsHelp, crmMemberPickerLabel } from "@aglyn/aglyn";
20
20
  import { mdiPlus } from "@aglyn/shared-data-mdi";
21
21
  import { CardDisplay, MdiIcon } from "@aglyn/shared-ui-jsx";
22
22
  import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
@@ -38,7 +38,8 @@ import { Button, Chip, Stack, Typography } from "@mui/material";
38
38
  import { getGridSingleSelectOperators } from "@mui/x-data-grid";
39
39
  import { useRouter } from "next/navigation";
40
40
  import { useCallback, useEffect, useMemo, useState } from "react";
41
- import { COMPANY_LIST_DECLARATION, COMPANY_LIST_FILTER_FIELDS, COMPANY_PICKLIST_FILTERS, COMPANY_PREFIX_SEARCH } from "../constants/company-filters.js";
41
+ import { COMPANY_LIST_DECLARATION, COMPANY_LIST_FILTER_FIELDS, COMPANY_LIST_SORTS, COMPANY_PICKLIST_FILTERS, COMPANY_PREFIX_SEARCH } from "../constants/company-filters.js";
42
+ import { crmViewQuerySort, useCrmColumnSort } from "../hooks/use-crm-column-sort.js";
42
43
  import { useCompanyPicklists } from "../hooks/use-company-picklists.js";
43
44
  import { formatMoney } from "../model/deal-board-model.js";
44
45
  import { useContactFieldDefinitions } from "../hooks/use-contact-field-definitions.js";
@@ -156,6 +157,10 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
156
157
  const viewFilters = views.state.filters;
157
158
  const [searchWords, setSearchWords] = useState([]);
158
159
  const foldsScope = useCrmFoldsScope(orgId, visibleTo);
160
+ // The header order the view asks (AGL-3680), read before the query it orders.
161
+ const companySort = useMemo(()=>crmViewQuerySort(COMPANY_LIST_SORTS, views.state.sort, COMPANY_LIST_SORTS[0]), [
162
+ views.state.sort
163
+ ]);
159
164
  const { rows: companies, status, hasMore, page, setPage, pageSize, setPageSize, plan } = useCrmListQuery({
160
165
  scope,
161
166
  collection: CRM_COLLECTIONS.companies,
@@ -164,7 +169,8 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
164
169
  declaration: COMPANY_LIST_DECLARATION,
165
170
  clauses: viewFilters,
166
171
  search: searchWords,
167
- prefixSearch: COMPANY_PREFIX_SEARCH
172
+ prefixSearch: COMPANY_PREFIX_SEARCH,
173
+ sort: companySort.sort
168
174
  });
169
175
  const nowMs = useMemo(()=>Date.now(), []);
170
176
  const [createOpen, setCreateOpen] = useState(false);
@@ -495,6 +501,32 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
495
501
  * stored `equals` back as the single-select `is` the panel offers — so a
496
502
  * view opened from its address reads as filtered, not as a mystery.
497
503
  */ const grid = useCrmViewGrid(views, filterColumns, COMPANY_HIDDEN_COLUMNS);
504
+ /*
505
+ * EVERY HEADER SORTS (AGL-3680). The grid used to sort the view's order
506
+ * over the one page on screen while the footer paged the query, which read
507
+ * as the whole list's order. Company, Updated and Next activity sort the
508
+ * QUERY now (`COMPANY_LIST_SORTS`); the rest sort the page and say so —
509
+ * Type, Industry and Rating in the order the org keeps their values.
510
+ */ const pageSorts = useMemo(()=>Object.fromEntries(COMPANY_PICKLIST_FILTERS.map((entry)=>[
511
+ entry.column,
512
+ (row)=>{
513
+ const label = row[entry.column];
514
+ const list = picklists.lists[entry.picklistId];
515
+ return list && label ? crmPicklistRank(list, label) : null;
516
+ }
517
+ ])), [
518
+ picklists.lists
519
+ ]);
520
+ const columnSort = useCrmColumnSort({
521
+ views,
522
+ sorts: COMPANY_LIST_SORTS,
523
+ defaultSort: COMPANY_LIST_SORTS[0],
524
+ asked: companySort,
525
+ orderBy: plan.orderBy,
526
+ rows: companies,
527
+ columns: grid.columns,
528
+ pageSorts
529
+ });
498
530
  /** Whether anything narrows the list, so an empty one is "no match", not "none yet". */ const narrowed = viewFilters.length > 0 || searchWords.some((word)=>word.trim());
499
531
  const newCompanyButton = /*#__PURE__*/ _jsx(Button, {
500
532
  size: "small",
@@ -563,7 +595,10 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
563
595
  }),
564
596
  /*#__PURE__*/ _jsx(ListQueryNotices, {
565
597
  refused: refused,
566
- notices: plan.notices
598
+ notices: [
599
+ ...plan.notices,
600
+ ...columnSort.notices
601
+ ]
567
602
  }),
568
603
  /*#__PURE__*/ _jsx(CompaniesBulkBar, {
569
604
  hostId: hostId,
@@ -579,7 +614,8 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
579
614
  rowHeight: TABLE_ROW_HEIGHT,
580
615
  columns: grid.columns,
581
616
  slots: CRM_LIST_SLOTS,
582
- rows: companies,
617
+ rows: columnSort.rows,
618
+ columnSort: columnSort,
583
619
  selectable: {
584
620
  selected: selectedIds,
585
621
  onChange: setSelectedIds
@@ -598,11 +634,10 @@ const COMPANY_GRID_FILTER_HEADERS = _extends({
598
634
  filterModel: gridFilter.filterModel,
599
635
  onFilterModelChange: gridFilter.onFilterModelChange,
600
636
  quickFilter: true,
601
- // Columns and sort are the view's, controlled (AGL-2617).
637
+ // Columns are the view's, controlled (AGL-2617); so is the
638
+ // header order, which `columnSort` keeps in it (AGL-3680).
602
639
  columnVisibilityModel: grid.columnVisibilityModel,
603
640
  onColumnVisibilityModelChange: grid.onColumnVisibilityModelChange,
604
- sortModel: grid.sortModel,
605
- onSortModelChange: grid.onSortModelChange,
606
641
  // Paged by the footer below, so the grid must not also slice.
607
642
  hideFooter: true
608
643
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/companies-section.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n type AglynOrgBilling,\n CRM_COLLECTIONS,\n type CrmCompany,\n crmPicklistKey,\n pluginDocsHelp,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { mdiPlus } from '@aglyn/shared-data-mdi'\nimport { CardDisplay, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { listFilterColumn } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport { useCrmSavedView } from '../hooks/use-crm-saved-view'\nimport { useCrmViewGrid } from '../hooks/use-crm-view-grid'\nimport { CRM_LIST_SLOTS, CrmColumnOrderProvider } from './crm-column-menu'\nimport {\n CRM_NEXT_ACTIVITY_FILTER_FIELD,\n CRM_NEXT_ACTIVITY_FILTER_HEADER,\n nextActivityColumn,\n} from './crm-next-activity-column'\nimport { useCrmFoldsScope, useCrmListQuery } from '../hooks/use-crm-list-query'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { listFilterGridColumns } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport CrmViewsControl from './crm-views-control'\nimport { CrmListActions, CrmListToolbar } from './crm-list-toolbar'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { Button, Chip, Stack, Typography } from '@mui/material'\nimport {\n getGridSingleSelectOperators,\n type GridColDef,\n} from '@mui/x-data-grid'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n COMPANY_LIST_DECLARATION,\n COMPANY_LIST_FILTER_FIELDS,\n COMPANY_PICKLIST_FILTERS,\n COMPANY_PREFIX_SEARCH,\n} from '../constants/company-filters'\nimport { useCompanyPicklists } from '../hooks/use-company-picklists'\nimport { formatMoney } from '../model/deal-board-model'\nimport { useContactFieldDefinitions } from '../hooks/use-contact-field-definitions'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { useOrgMemberOptions } from '../hooks/use-org-member-options'\nimport { CRM_COMPANIES_RESOURCE } from '../transfer/fields'\nimport { crmRoutes } from '../model/crm-routes'\nimport CompaniesBulkBar from './companies-bulk-bar'\nimport CompanyEditDrawer from './company-edit-drawer'\nimport { CrmExportButton, CrmImportButton } from './crm-transfer-buttons'\nimport { customFieldColumns } from './contact-custom-columns'\n\nexport interface CompaniesSectionProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n org?: Partial<AglynOrgBilling>\n /** The CRM hub URL, which every company route hangs beneath. */\n basePath: string\n}\n\ntype CompanyRow = Partial<CrmCompany> & { $id: string; updatedAt?: any }\n\n/** What the companies grid's panel offers — every field the query asks. */\nconst COMPANY_GRID_FILTER_FIELDS = COMPANY_LIST_FILTER_FIELDS\nconst COMPANY_GRID_FILTER_HEADERS: Readonly<Record<string, string>> = {\n name: 'Company',\n ownerUid: 'Owner',\n [CRM_NEXT_ACTIVITY_FILTER_FIELD.column]: CRM_NEXT_ACTIVITY_FILTER_HEADER,\n ...Object.fromEntries(COMPANY_PICKLIST_FILTERS.map((entry) => [entry.column, entry.header])),\n}\n\n/** The grid's select columns — the owner and each picklist — as the filter hook names them. */\nconst COMPANY_SELECT_FIELDS = ['ownerUid', ...COMPANY_PICKLIST_FILTERS.map((entry) => entry.column)]\n\n/**\n * Salesforce's Account columns (AGL-3514), optional: a reader turns one on\n * from the column menu, and a view that shows it stores it by name.\n */\nconst COMPANY_HIDDEN_COLUMNS: Readonly<Record<string, boolean>> = {\n type: false,\n industry: false,\n rating: false,\n accountSource: false,\n numberOfEmployees: false,\n annualRevenueCents: false,\n}\n\n/** A text cell that reads as a dash when empty. */\nfunction textCell(value: unknown) {\n const text = value === null || value === undefined ? '' : String(value)\n return text ? (\n <Typography variant=\"body2\" noWrap>\n {text}\n </Typography>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n )\n}\n\n/**\n * `/crm/companies` — the organizations behind the people (AGL-2597).\n *\n * A section of its own rather than a column on the contact list, because a\n * company is known by several contacts and carries records of its own: a\n * domain the email suggestion keys on, an address, an owner, and the deals\n * and tasks filed against it. The row opens `/crm/companies/{id}`, where all\n * of that lives; this list is the cheaper surface and reads nothing a row\n * does not show.\n *\n * ## What the listener carries\n *\n * Paged and ordered by the server — `updatedAt desc`, so a company somebody\n * just touched is on page one — and SCOPED by the same `visibleTo\n * array-contains-any` predicate the contact list runs. That predicate is what\n * the rules evaluate: a filtered query is provable per document, and an\n * unfiltered one is refused rather than quietly returning the whole org's\n * accounts to a site that may see one client's.\n *\n * ## What a filter may be\n *\n * Every clause and the search word are on the one query (AGL-3321): the\n * search reads the name's and the domain's word prefixes, the name is also\n * an exact match and a prefix, the owner a choice from the roster, and \"No\n * next activity\" a `null` — each reaching the whole collection, which is\n * the property a filter must have: a company on page four is found, not\n * reported missing. `COMPANY_LIST_DECLARATION` states what the query asks.\n *\n * ## Creating is a drawer\n *\n * \"New company\" opens the same eight-field drawer the company's page edits\n * with, and the new record's page opens when it is saved. A form above a\n * list has nowhere to grow, and this one has an address in it.\n *\n * ## Selection, the bar and the file (AGL-2621)\n *\n * The rows are selectable, and a selection raises `CompaniesBulkBar` over\n * the table. Import and Export open the console's import wizard and\n * export dialog on `crm.companies` (AGL-3527): the export over the\n * selection, the list's own query, or every company.\n */\nexport function CompaniesSection(props: CompaniesSectionProps) {\n const { hostId, org, basePath } = props\n const routes = crmRoutes(basePath)\n const router = useRouter()\n const { scope, orgId, visibleTo } = useCrmScope({ hostId, org })\n /*\n * The team, read once for this surface: the Owner column names a person\n * from a uid, and the create drawer picks from the same roster. One fetch\n * serves both, which is why the drawer takes it as a prop.\n */\n const members = useOrgMemberOptions(orgId)\n // The org's company fields, for the optional columns below (AGL-2661).\n const companyFields = useContactFieldDefinitions(orgId, 'company')\n // The lists behind Type, Industry and Rating, for their filters (AGL-3514).\n const picklists = useCompanyPicklists(orgId)\n\n /*\n * The clauses are the saved VIEW'S (AGL-2617), beside its columns and\n * sort; the grid's panel and the chips edit them, and the query answers\n * every one and the search word together (AGL-3321).\n */\n const views = useCrmSavedView({ section: 'companies', hostId, org, basePath })\n const viewFilters = views.state.filters\n const [searchWords, setSearchWords] = useState<string[]>([])\n const foldsScope = useCrmFoldsScope(orgId, visibleTo)\n const {\n rows: companies,\n status,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n plan,\n } = useCrmListQuery<CompanyRow>({\n scope,\n collection: CRM_COLLECTIONS.companies,\n visibleTo,\n foldsScope,\n declaration: COMPANY_LIST_DECLARATION,\n clauses: viewFilters,\n search: searchWords,\n prefixSearch: COMPANY_PREFIX_SEARCH,\n })\n const nowMs = useMemo(() => Date.now(), [])\n\n const [createOpen, setCreateOpen] = useState(false)\n const [selectedIds, setSelectedIds] = useState<string[]>([])\n // A filter, a search or a page is a different set of rows.\n useEffect(() => setSelectedIds([]), [plan, page])\n // The list's filter, when one narrows it, for the export to read the same\n // records the list does (AGL-3527).\n const exportFilter = useMemo(\n () => (plan.served.length || plan.searched ? { label: 'what the list shows', plan } : null),\n [plan],\n )\n const openCompany = useCallback(\n (id: string) => router.push(routes.company(id)),\n [router, routes],\n )\n\n const columns: GridColDef[] = useMemo(\n () => [\n {\n field: 'name',\n headerName: 'Company',\n flex: 1.6,\n minWidth: 240,\n ...listFilterColumn(COMPANY_LIST_FILTER_FIELDS, 'name'),\n valueGetter: (_value, row: CompanyRow) => String(row.name ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Stack\n sx={{ justifyContent: 'center', height: '100%', lineHeight: 1.25 }}\n >\n <Typography variant=\"body2\" sx={{ lineHeight: 1.25 }}>\n {row.name}\n </Typography>\n {row.industry ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ lineHeight: 1.25 }}\n noWrap\n >\n {row.industry}\n </Typography>\n ) : null}\n </Stack>\n ),\n },\n {\n field: 'domain',\n headerName: 'Domain',\n flex: 1,\n minWidth: 160,\n // Stored normalized, so it could be filtered exactly — but a domain\n // lookup is what the company suggestion on a contact does, and a\n // filter here would need an index of its own for one more way to\n // find a row the name filter already finds.\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => String(row.domain ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) =>\n row.domain ? (\n <Typography variant=\"body2\">{row.domain}</Typography>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n ),\n },\n {\n field: 'contactsCount',\n headerName: 'Contacts',\n width: 110,\n align: 'right',\n headerAlign: 'right',\n /*\n * The denormalized count every link moves (AGL-2613) — a stored\n * number, so a page of companies costs no read per row. Absent on a\n * company nobody has linked since the counter existed, which reads\n * as zero; the company's own page takes the live aggregate.\n */\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => Number(row.contactsCount ?? 0),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography\n variant=\"body2\"\n color={row.contactsCount ? 'text.primary' : 'text.secondary'}\n >\n {Number(row.contactsCount ?? 0).toLocaleString()}\n </Typography>\n ),\n },\n {\n field: 'tags',\n headerName: 'Tags',\n flex: 1,\n minWidth: 140,\n // Written by the drawer and the bulk bar (AGL-2621); read here, not\n // filtered — a tag filter would need an `array-contains` index of\n // its own beside the scope predicate.\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => (row.tags ?? []).join(', '),\n renderCell: ({ row }: { row: CompanyRow }) =>\n row.tags?.length ? (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center', overflow: 'hidden' }}>\n {row.tags.slice(0, 3).map((tag) => (\n <Chip key={tag} size=\"small\" variant=\"outlined\" label={tag} />\n ))}\n {row.tags.length > 3 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`+${row.tags.length - 3}`}\n </Typography>\n ) : null}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n ),\n },\n {\n field: 'ownerUid',\n headerName: 'Owner',\n flex: 1,\n minWidth: 160,\n sortable: false,\n /*\n * A CHOICE from the roster, not a text box for a uid. The grid's\n * single-select `is` operator is what the panel offers; the handler\n * below maps it onto the declared field's `equals`, which the\n * translator turns into the equality the index serves.\n */\n type: 'singleSelect',\n valueOptions: members.options.map((option) => ({\n value: option.uid,\n label: crmMemberPickerLabel(option),\n })),\n filterable: members.options.length > 0,\n filterOperators: getGridSingleSelectOperators().filter(\n (operator) => operator.value === 'is',\n ),\n valueGetter: (_value, row: CompanyRow) => String(row.ownerUid ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography\n variant=\"body2\"\n color={row.ownerUid ? 'text.primary' : 'text.secondary'}\n >\n {row.ownerUid\n ? members.ready\n ? members.labelFor(row.ownerUid)\n : '…'\n : '—'}\n </Typography>\n ),\n },\n {\n field: 'updatedAt',\n headerName: 'Updated',\n flex: 0.8,\n minWidth: 140,\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n row.updatedAt?.seconds ? new Date(row.updatedAt.seconds * 1000) : null,\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {row.updatedAt?.seconds\n ? new Date(row.updatedAt.seconds * 1000).toLocaleDateString()\n : '—'}\n </Typography>\n ),\n },\n // When the earliest open task against the company is due (AGL-2661).\n nextActivityColumn(nowMs),\n // Salesforce's Account fields (AGL-3514), each optional. Type, Industry\n // and Rating filter by the key stored beside the label; the rest read.\n ...COMPANY_PICKLIST_FILTERS.map(\n (entry): GridColDef => ({\n field: entry.column,\n headerName: entry.header,\n flex: 0.8,\n minWidth: 130,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n crmPicklistKey(row[entry.column as 'type' | 'industry' | 'rating']) ?? '',\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(row[entry.column as 'type' | 'industry' | 'rating']),\n }),\n ),\n {\n field: 'accountSource',\n headerName: 'Account source',\n flex: 0.8,\n minWidth: 140,\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => String(row.accountSource ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => textCell(row.accountSource),\n },\n {\n field: 'numberOfEmployees',\n headerName: 'Employees',\n width: 120,\n align: 'right',\n headerAlign: 'right',\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n typeof row.numberOfEmployees === 'number' ? row.numberOfEmployees : null,\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(\n typeof row.numberOfEmployees === 'number' ? row.numberOfEmployees.toLocaleString() : '',\n ),\n },\n {\n field: 'annualRevenueCents',\n headerName: 'Annual revenue',\n width: 150,\n align: 'right',\n headerAlign: 'right',\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n typeof row.annualRevenueCents === 'number' ? row.annualRevenueCents : null,\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(\n typeof row.annualRevenueCents === 'number'\n ? formatMoney(row.annualRevenueCents, row.currency)\n : '',\n ),\n },\n // The org's company fields as optional columns (AGL-2661), read off\n // the row's own `custom` map the way the contacts list reads its own.\n ...customFieldColumns(companyFields.active),\n ],\n [members, companyFields.active, nowMs],\n )\n\n /*\n * The grid's own Filters panel and quick search edit the view's clauses\n * (AGL-3313); the query answers them all (AGL-3321).\n */\n const ownerOptions = useMemo(\n () =>\n members.options.map((option) => ({\n value: option.uid,\n label: crmMemberPickerLabel(option),\n })),\n [members.options],\n )\n /*\n * Each picklist's choices (AGL-3514): every value the org keeps, valued\n * by the key the query compares and captioned by the label, inactive\n * ones marked. A stored clause naming a key no longer listed stays a\n * choice, so the panel can show it and clear it.\n */\n const filterOptions = useMemo(() => {\n const options: Record<string, Array<{ value: string; label: string }>> = {\n ownerUid: ownerOptions,\n }\n for (const entry of COMPANY_PICKLIST_FILTERS) {\n const list = picklists.lists[entry.picklistId]\n const known = (list?.values ?? []).flatMap((value) => {\n const key = crmPicklistKey(value.label)\n return key ? [{ value: key, label: value.active ? value.label : `${value.label} (inactive)` }] : []\n })\n const stale = viewFilters\n .filter((clause) => clause.field === entry.column)\n .flatMap((clause) => clause.value.split(','))\n .map((value) => value.trim())\n .filter((value) => value && !known.some((option) => option.value === value))\n .map((value) => ({ value, label: value }))\n options[entry.column] = [...known, ...stale]\n }\n return options\n }, [ownerOptions, picklists.lists, viewFilters])\n const filterColumns = useMemo(\n () =>\n listFilterGridColumns(columns, COMPANY_GRID_FILTER_FIELDS, filterOptions, COMPANY_GRID_FILTER_HEADERS),\n [columns, filterOptions],\n )\n const gridFilter = useListGridFilter({\n clauses: viewFilters,\n onChange: views.setFilters,\n selectFields: COMPANY_SELECT_FIELDS,\n search: { words: searchWords, onChange: setSearchWords },\n })\n // What the query could not hold, named by the clause the reader set.\n const refused = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: COMPANY_GRID_FILTER_FIELDS,\n headers: COMPANY_GRID_FILTER_HEADERS,\n options: filterOptions,\n }),\n [plan.refused, filterOptions],\n )\n /*\n * The grid's models are the view's (AGL-2617). The filter model shows the\n * view's clause in the panel as a typed one would appear — the owner's\n * stored `equals` back as the single-select `is` the panel offers — so a\n * view opened from its address reads as filtered, not as a mystery.\n */\n const grid = useCrmViewGrid(views, filterColumns, COMPANY_HIDDEN_COLUMNS)\n\n /** Whether anything narrows the list, so an empty one is \"no match\", not \"none yet\". */\n const narrowed = viewFilters.length > 0 || searchWords.some((word) => word.trim())\n\n const newCompanyButton = (\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!scope}\n startIcon={<MdiIcon path={mdiPlus.path} size={0.8} />}\n onClick={() => setCreateOpen(true)}\n >\n {'New company'}\n </Button>\n )\n\n return (\n <CardDisplay\n header={'Companies'}\n help={pluginDocsHelp('companies', { anchor: '#the-companies-list' })}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n HeaderProps={{\n // The record actions, top right and never clipped (AGL-3311).\n action: (\n <CrmListActions>\n <CrmImportButton resource={CRM_COMPANIES_RESOURCE} noun=\"companies\" hostId={hostId} mappingZone=\"companies\" />\n <CrmExportButton resource={CRM_COMPANIES_RESOURCE} hostId={hostId} filter={exportFilter} />\n {newCompanyButton}\n </CrmListActions>\n ),\n }}\n >\n <Stack spacing={1.5}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'The organizations your contacts belong to. Open one to see its ' +\n 'people, its deals and its open tasks, or to link a contact ' +\n 'to it.'}\n </Typography>\n {/* The saved view, and the clauses narrowing it as chips (AGL-3313). */}\n <CrmListToolbar label=\"Company filters\">\n <CrmViewsControl controller={views} allLabel=\"All companies\" />\n <ListFilterChips\n fields={COMPANY_GRID_FILTER_FIELDS}\n headers={COMPANY_GRID_FILTER_HEADERS}\n clauses={viewFilters}\n onChange={views.setFilters}\n options={filterOptions}\n marksServed={false}\n />\n </CrmListToolbar>\n <ListQueryNotices refused={refused} notices={plan.notices} />\n <CompaniesBulkBar\n hostId={hostId}\n scope={scope}\n rows={companies}\n selected={selectedIds}\n onSelectedChange={setSelectedIds}\n members={members}\n />\n <CrmColumnOrderProvider value={grid.columnOrder}>\n <ListTable\n rowHeight={TABLE_ROW_HEIGHT}\n columns={grid.columns}\n slots={CRM_LIST_SLOTS}\n rows={companies}\n selectable={{ selected: selectedIds, onChange: setSelectedIds }}\n noRowsLabel={narrowed ? 'No companies match these filters' : 'No companies yet'}\n noRowsDescription={\n narrowed\n ? undefined\n : 'A company groups the contacts who work at one business, with its domain, owner and address. Create the first one, or link a contact to a company from their page.'\n }\n noRowsAction={narrowed ? undefined : newCompanyButton}\n onOpen={(id) => openCompany(String(id))}\n // An empty table while the read is in flight reads as \"you have\n // none\" rather than \"these are on their way\".\n loading={!scope || status === 'loading'}\n /*\n * The grid must NOT also filter. The query answers it, so a client\n * pass could only drop rows the query already matched (AGL-3321).\n */\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n // Columns and sort are the view's, controlled (AGL-2617).\n columnVisibilityModel={grid.columnVisibilityModel}\n onColumnVisibilityModelChange={grid.onColumnVisibilityModelChange}\n sortModel={grid.sortModel}\n onSortModelChange={grid.onSortModelChange}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n />\n </CrmColumnOrderProvider>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={companies.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n </Stack>\n {/*\n Mounted only while it is open, so the list pays for none of the\n drawer's state — and a fresh mount is what seeds an empty form.\n */}\n {createOpen ? (\n <CompanyEditDrawer\n open\n onClose={() => setCreateOpen(false)}\n hostId={hostId}\n org={org}\n members={members}\n onSaved={openCompany}\n />\n ) : null}\n </CardDisplay>\n )\n}\nCompaniesSection.displayName = 'CompaniesSection'\n\nexport default CompaniesSection\n"],"names":["CRM_COLLECTIONS","crmPicklistKey","pluginDocsHelp","crmMemberPickerLabel","mdiPlus","CardDisplay","MdiIcon","ListPagination","ListTable","listFilterColumn","ListQueryNotices","listQueryRefusals","useCrmSavedView","useCrmViewGrid","CRM_LIST_SLOTS","CrmColumnOrderProvider","CRM_NEXT_ACTIVITY_FILTER_FIELD","CRM_NEXT_ACTIVITY_FILTER_HEADER","nextActivityColumn","useCrmFoldsScope","useCrmListQuery","ListFilterChips","listFilterGridColumns","useListGridFilter","CrmViewsControl","CrmListActions","CrmListToolbar","TABLE_ROW_HEIGHT","Button","Chip","Stack","Typography","getGridSingleSelectOperators","useRouter","useCallback","useEffect","useMemo","useState","COMPANY_LIST_DECLARATION","COMPANY_LIST_FILTER_FIELDS","COMPANY_PICKLIST_FILTERS","COMPANY_PREFIX_SEARCH","useCompanyPicklists","formatMoney","useContactFieldDefinitions","useCrmScope","useOrgMemberOptions","CRM_COMPANIES_RESOURCE","crmRoutes","CompaniesBulkBar","CompanyEditDrawer","CrmExportButton","CrmImportButton","customFieldColumns","COMPANY_GRID_FILTER_FIELDS","COMPANY_GRID_FILTER_HEADERS","name","ownerUid","column","Object","fromEntries","map","entry","header","COMPANY_SELECT_FIELDS","COMPANY_HIDDEN_COLUMNS","type","industry","rating","accountSource","numberOfEmployees","annualRevenueCents","textCell","value","text","undefined","String","variant","noWrap","color","CompaniesSection","props","hostId","org","basePath","routes","router","scope","orgId","visibleTo","members","companyFields","picklists","views","section","viewFilters","state","filters","searchWords","setSearchWords","foldsScope","rows","companies","status","hasMore","page","setPage","pageSize","setPageSize","plan","collection","declaration","clauses","search","prefixSearch","nowMs","Date","now","createOpen","setCreateOpen","selectedIds","setSelectedIds","exportFilter","served","length","searched","label","openCompany","id","push","company","columns","field","headerName","flex","minWidth","valueGetter","_value","row","renderCell","sx","justifyContent","height","lineHeight","filterable","sortable","domain","width","align","headerAlign","Number","contactsCount","toLocaleString","tags","join","direction","spacing","alignItems","overflow","slice","tag","size","valueOptions","options","option","uid","filterOperators","filter","operator","ready","labelFor","updatedAt","seconds","toLocaleDateString","currency","active","ownerOptions","filterOptions","list","lists","picklistId","known","values","flatMap","key","stale","clause","split","trim","some","filterColumns","gridFilter","onChange","setFilters","selectFields","words","refused","fields","headers","grid","narrowed","word","newCompanyButton","disabled","startIcon","path","onClick","help","anchor","contentGutterX","contentGutterY","contentBordered","HeaderProps","action","resource","noun","mappingZone","controller","allLabel","marksServed","notices","selected","onSelectedChange","columnOrder","rowHeight","slots","selectable","noRowsLabel","noRowsDescription","noRowsAction","onOpen","loading","filterMode","filterModel","onFilterModelChange","quickFilter","columnVisibilityModel","onColumnVisibilityModelChange","sortModel","onSortModelChange","hideFooter","rowCount","onPageChange","onPageSizeChange","open","onClose","onSaved","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAEEA,eAAe,EAEfC,cAAc,EACdC,cAAc,EACdC,oBAAoB,QACf,eAAc;AACrB,SAASC,OAAO,QAAQ,yBAAwB;AAChD,SAASC,WAAW,EAAEC,OAAO,QAAQ,uBAAsB;AAC3D,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE,SAASC,eAAe,QAAQ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wBACPc,MAAMC;wBACNuH,UAAUrG;wBACVsG,kBAAkBrG;wBAClB/B,SAASA;;kCAEX,KAAC3E;wBAAuB0D,OAAO8H,KAAKwB,WAAW;kCAC7C,cAAA,KAACvN;4BACCwN,WAAWrM;4BACXwG,SAASoE,KAAKpE,OAAO;4BACrB8F,OAAOnN;4BACPuF,MAAMC;4BACN4H,YAAY;gCAAEL,UAAUrG;gCAAawE,UAAUvE;4BAAe;4BAC9D0G,aAAa3B,WAAW,qCAAqC;4BAC7D4B,mBACE5B,WACI7H,YACA;4BAEN0J,cAAc7B,WAAW7H,YAAY+H;4BACrC4B,QAAQ,CAACtG,KAAOD,YAAYnD,OAAOoD;4BACnC,gEAAgE;4BAChE,8CAA8C;4BAC9CuG,SAAS,CAAChJ,SAASgB,WAAW;4BAC9B;;;aAGC,GACDiI,YAAW;4BACXC,aAAa1C,WAAW0C,WAAW;4BACnCC,qBAAqB3C,WAAW2C,mBAAmB;4BACnDC,WAAW;4BACX,0DAA0D;4BAC1DC,uBAAuBrC,KAAKqC,qBAAqB;4BACjDC,+BAA+BtC,KAAKsC,6BAA6B;4BACjEC,WAAWvC,KAAKuC,SAAS;4BACzBC,mBAAmBxC,KAAKwC,iBAAiB;4BACzC,8DAA8D;4BAC9DC,UAAU;;;kCAGd,KAACzO;wBACCkG,MAAMA;wBACNE,UAAUA;wBACVsI,UAAU3I,UAAUsB,MAAM;wBAC1BpB,SAASA;wBACT0I,cAAcxI;wBACdyI,kBAAkBvI;;;;YAOrBU,2BACC,KAACpE;gBACCkM,IAAI;gBACJC,SAAS,IAAM9H,cAAc;gBAC7BrC,QAAQA;gBACRC,KAAKA;gBACLO,SAASA;gBACT4J,SAASvH;iBAET;;;AAGV;AACA/C,iBAAiBuK,WAAW,GAAG;AAE/B,eAAevK,iBAAgB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/companies-section.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n type AglynOrgBilling,\n CRM_COLLECTIONS,\n type CrmCompany,\n crmPicklistKey,\n crmPicklistRank,\n pluginDocsHelp,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { mdiPlus } from '@aglyn/shared-data-mdi'\nimport { CardDisplay, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { listFilterColumn } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport { useCrmSavedView } from '../hooks/use-crm-saved-view'\nimport { useCrmViewGrid } from '../hooks/use-crm-view-grid'\nimport { CRM_LIST_SLOTS, CrmColumnOrderProvider } from './crm-column-menu'\nimport {\n CRM_NEXT_ACTIVITY_FILTER_FIELD,\n CRM_NEXT_ACTIVITY_FILTER_HEADER,\n nextActivityColumn,\n} from './crm-next-activity-column'\nimport { useCrmFoldsScope, useCrmListQuery } from '../hooks/use-crm-list-query'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { listFilterGridColumns } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport CrmViewsControl from './crm-views-control'\nimport { CrmListActions, CrmListToolbar } from './crm-list-toolbar'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { Button, Chip, Stack, Typography } from '@mui/material'\nimport {\n getGridSingleSelectOperators,\n type GridColDef,\n} from '@mui/x-data-grid'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n COMPANY_LIST_DECLARATION,\n COMPANY_LIST_FILTER_FIELDS,\n COMPANY_LIST_SORTS,\n COMPANY_PICKLIST_FILTERS,\n COMPANY_PREFIX_SEARCH,\n} from '../constants/company-filters'\nimport { crmViewQuerySort, useCrmColumnSort } from '../hooks/use-crm-column-sort'\nimport { useCompanyPicklists } from '../hooks/use-company-picklists'\nimport { formatMoney } from '../model/deal-board-model'\nimport { useContactFieldDefinitions } from '../hooks/use-contact-field-definitions'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { useOrgMemberOptions } from '../hooks/use-org-member-options'\nimport { CRM_COMPANIES_RESOURCE } from '../transfer/fields'\nimport { crmRoutes } from '../model/crm-routes'\nimport CompaniesBulkBar from './companies-bulk-bar'\nimport CompanyEditDrawer from './company-edit-drawer'\nimport { CrmExportButton, CrmImportButton } from './crm-transfer-buttons'\nimport { customFieldColumns } from './contact-custom-columns'\n\nexport interface CompaniesSectionProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n org?: Partial<AglynOrgBilling>\n /** The CRM hub URL, which every company route hangs beneath. */\n basePath: string\n}\n\ntype CompanyRow = Partial<CrmCompany> & { $id: string; updatedAt?: any }\n\n/** What the companies grid's panel offers — every field the query asks. */\nconst COMPANY_GRID_FILTER_FIELDS = COMPANY_LIST_FILTER_FIELDS\nconst COMPANY_GRID_FILTER_HEADERS: Readonly<Record<string, string>> = {\n name: 'Company',\n ownerUid: 'Owner',\n [CRM_NEXT_ACTIVITY_FILTER_FIELD.column]: CRM_NEXT_ACTIVITY_FILTER_HEADER,\n ...Object.fromEntries(COMPANY_PICKLIST_FILTERS.map((entry) => [entry.column, entry.header])),\n}\n\n/** The grid's select columns — the owner and each picklist — as the filter hook names them. */\nconst COMPANY_SELECT_FIELDS = ['ownerUid', ...COMPANY_PICKLIST_FILTERS.map((entry) => entry.column)]\n\n/**\n * Salesforce's Account columns (AGL-3514), optional: a reader turns one on\n * from the column menu, and a view that shows it stores it by name.\n */\nconst COMPANY_HIDDEN_COLUMNS: Readonly<Record<string, boolean>> = {\n type: false,\n industry: false,\n rating: false,\n accountSource: false,\n numberOfEmployees: false,\n annualRevenueCents: false,\n}\n\n/** A text cell that reads as a dash when empty. */\nfunction textCell(value: unknown) {\n const text = value === null || value === undefined ? '' : String(value)\n return text ? (\n <Typography variant=\"body2\" noWrap>\n {text}\n </Typography>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n )\n}\n\n/**\n * `/crm/companies` — the organizations behind the people (AGL-2597).\n *\n * A section of its own rather than a column on the contact list, because a\n * company is known by several contacts and carries records of its own: a\n * domain the email suggestion keys on, an address, an owner, and the deals\n * and tasks filed against it. The row opens `/crm/companies/{id}`, where all\n * of that lives; this list is the cheaper surface and reads nothing a row\n * does not show.\n *\n * ## What the listener carries\n *\n * Paged and ordered by the server — `updatedAt desc`, so a company somebody\n * just touched is on page one — and SCOPED by the same `visibleTo\n * array-contains-any` predicate the contact list runs. That predicate is what\n * the rules evaluate: a filtered query is provable per document, and an\n * unfiltered one is refused rather than quietly returning the whole org's\n * accounts to a site that may see one client's.\n *\n * ## What a filter may be\n *\n * Every clause and the search word are on the one query (AGL-3321): the\n * search reads the name's and the domain's word prefixes, the name is also\n * an exact match and a prefix, the owner a choice from the roster, and \"No\n * next activity\" a `null` — each reaching the whole collection, which is\n * the property a filter must have: a company on page four is found, not\n * reported missing. `COMPANY_LIST_DECLARATION` states what the query asks.\n *\n * ## Creating is a drawer\n *\n * \"New company\" opens the same eight-field drawer the company's page edits\n * with, and the new record's page opens when it is saved. A form above a\n * list has nowhere to grow, and this one has an address in it.\n *\n * ## Selection, the bar and the file (AGL-2621)\n *\n * The rows are selectable, and a selection raises `CompaniesBulkBar` over\n * the table. Import and Export open the console's import wizard and\n * export dialog on `crm.companies` (AGL-3527): the export over the\n * selection, the list's own query, or every company.\n */\nexport function CompaniesSection(props: CompaniesSectionProps) {\n const { hostId, org, basePath } = props\n const routes = crmRoutes(basePath)\n const router = useRouter()\n const { scope, orgId, visibleTo } = useCrmScope({ hostId, org })\n /*\n * The team, read once for this surface: the Owner column names a person\n * from a uid, and the create drawer picks from the same roster. One fetch\n * serves both, which is why the drawer takes it as a prop.\n */\n const members = useOrgMemberOptions(orgId)\n // The org's company fields, for the optional columns below (AGL-2661).\n const companyFields = useContactFieldDefinitions(orgId, 'company')\n // The lists behind Type, Industry and Rating, for their filters (AGL-3514).\n const picklists = useCompanyPicklists(orgId)\n\n /*\n * The clauses are the saved VIEW'S (AGL-2617), beside its columns and\n * sort; the grid's panel and the chips edit them, and the query answers\n * every one and the search word together (AGL-3321).\n */\n const views = useCrmSavedView({ section: 'companies', hostId, org, basePath })\n const viewFilters = views.state.filters\n const [searchWords, setSearchWords] = useState<string[]>([])\n const foldsScope = useCrmFoldsScope(orgId, visibleTo)\n // The header order the view asks (AGL-3680), read before the query it orders.\n const companySort = useMemo(\n () => crmViewQuerySort(COMPANY_LIST_SORTS, views.state.sort, COMPANY_LIST_SORTS[0]),\n [views.state.sort],\n )\n const {\n rows: companies,\n status,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n plan,\n } = useCrmListQuery<CompanyRow>({\n scope,\n collection: CRM_COLLECTIONS.companies,\n visibleTo,\n foldsScope,\n declaration: COMPANY_LIST_DECLARATION,\n clauses: viewFilters,\n search: searchWords,\n prefixSearch: COMPANY_PREFIX_SEARCH,\n sort: companySort.sort,\n })\n const nowMs = useMemo(() => Date.now(), [])\n\n const [createOpen, setCreateOpen] = useState(false)\n const [selectedIds, setSelectedIds] = useState<string[]>([])\n // A filter, a search or a page is a different set of rows.\n useEffect(() => setSelectedIds([]), [plan, page])\n // The list's filter, when one narrows it, for the export to read the same\n // records the list does (AGL-3527).\n const exportFilter = useMemo(\n () => (plan.served.length || plan.searched ? { label: 'what the list shows', plan } : null),\n [plan],\n )\n const openCompany = useCallback(\n (id: string) => router.push(routes.company(id)),\n [router, routes],\n )\n\n const columns: GridColDef[] = useMemo(\n () => [\n {\n field: 'name',\n headerName: 'Company',\n flex: 1.6,\n minWidth: 240,\n ...listFilterColumn(COMPANY_LIST_FILTER_FIELDS, 'name'),\n valueGetter: (_value, row: CompanyRow) => String(row.name ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Stack\n sx={{ justifyContent: 'center', height: '100%', lineHeight: 1.25 }}\n >\n <Typography variant=\"body2\" sx={{ lineHeight: 1.25 }}>\n {row.name}\n </Typography>\n {row.industry ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ lineHeight: 1.25 }}\n noWrap\n >\n {row.industry}\n </Typography>\n ) : null}\n </Stack>\n ),\n },\n {\n field: 'domain',\n headerName: 'Domain',\n flex: 1,\n minWidth: 160,\n // Stored normalized, so it could be filtered exactly — but a domain\n // lookup is what the company suggestion on a contact does, and a\n // filter here would need an index of its own for one more way to\n // find a row the name filter already finds.\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => String(row.domain ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) =>\n row.domain ? (\n <Typography variant=\"body2\">{row.domain}</Typography>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n ),\n },\n {\n field: 'contactsCount',\n headerName: 'Contacts',\n width: 110,\n align: 'right',\n headerAlign: 'right',\n /*\n * The denormalized count every link moves (AGL-2613) — a stored\n * number, so a page of companies costs no read per row. Absent on a\n * company nobody has linked since the counter existed, which reads\n * as zero; the company's own page takes the live aggregate.\n */\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => Number(row.contactsCount ?? 0),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography\n variant=\"body2\"\n color={row.contactsCount ? 'text.primary' : 'text.secondary'}\n >\n {Number(row.contactsCount ?? 0).toLocaleString()}\n </Typography>\n ),\n },\n {\n field: 'tags',\n headerName: 'Tags',\n flex: 1,\n minWidth: 140,\n // Written by the drawer and the bulk bar (AGL-2621); read here, not\n // filtered — a tag filter would need an `array-contains` index of\n // its own beside the scope predicate.\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => (row.tags ?? []).join(', '),\n renderCell: ({ row }: { row: CompanyRow }) =>\n row.tags?.length ? (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center', overflow: 'hidden' }}>\n {row.tags.slice(0, 3).map((tag) => (\n <Chip key={tag} size=\"small\" variant=\"outlined\" label={tag} />\n ))}\n {row.tags.length > 3 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`+${row.tags.length - 3}`}\n </Typography>\n ) : null}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'—'}\n </Typography>\n ),\n },\n {\n field: 'ownerUid',\n headerName: 'Owner',\n flex: 1,\n minWidth: 160,\n sortable: false,\n /*\n * A CHOICE from the roster, not a text box for a uid. The grid's\n * single-select `is` operator is what the panel offers; the handler\n * below maps it onto the declared field's `equals`, which the\n * translator turns into the equality the index serves.\n */\n type: 'singleSelect',\n valueOptions: members.options.map((option) => ({\n value: option.uid,\n label: crmMemberPickerLabel(option),\n })),\n filterable: members.options.length > 0,\n filterOperators: getGridSingleSelectOperators().filter(\n (operator) => operator.value === 'is',\n ),\n valueGetter: (_value, row: CompanyRow) => String(row.ownerUid ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography\n variant=\"body2\"\n color={row.ownerUid ? 'text.primary' : 'text.secondary'}\n >\n {row.ownerUid\n ? members.ready\n ? members.labelFor(row.ownerUid)\n : '…'\n : '—'}\n </Typography>\n ),\n },\n {\n field: 'updatedAt',\n headerName: 'Updated',\n flex: 0.8,\n minWidth: 140,\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n row.updatedAt?.seconds ? new Date(row.updatedAt.seconds * 1000) : null,\n renderCell: ({ row }: { row: CompanyRow }) => (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {row.updatedAt?.seconds\n ? new Date(row.updatedAt.seconds * 1000).toLocaleDateString()\n : '—'}\n </Typography>\n ),\n },\n // When the earliest open task against the company is due (AGL-2661).\n nextActivityColumn(nowMs),\n // Salesforce's Account fields (AGL-3514), each optional. Type, Industry\n // and Rating filter by the key stored beside the label; the rest read.\n ...COMPANY_PICKLIST_FILTERS.map(\n (entry): GridColDef => ({\n field: entry.column,\n headerName: entry.header,\n flex: 0.8,\n minWidth: 130,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n crmPicklistKey(row[entry.column as 'type' | 'industry' | 'rating']) ?? '',\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(row[entry.column as 'type' | 'industry' | 'rating']),\n }),\n ),\n {\n field: 'accountSource',\n headerName: 'Account source',\n flex: 0.8,\n minWidth: 140,\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) => String(row.accountSource ?? ''),\n renderCell: ({ row }: { row: CompanyRow }) => textCell(row.accountSource),\n },\n {\n field: 'numberOfEmployees',\n headerName: 'Employees',\n width: 120,\n align: 'right',\n headerAlign: 'right',\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n typeof row.numberOfEmployees === 'number' ? row.numberOfEmployees : null,\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(\n typeof row.numberOfEmployees === 'number' ? row.numberOfEmployees.toLocaleString() : '',\n ),\n },\n {\n field: 'annualRevenueCents',\n headerName: 'Annual revenue',\n width: 150,\n align: 'right',\n headerAlign: 'right',\n filterable: false,\n sortable: false,\n valueGetter: (_value, row: CompanyRow) =>\n typeof row.annualRevenueCents === 'number' ? row.annualRevenueCents : null,\n renderCell: ({ row }: { row: CompanyRow }) =>\n textCell(\n typeof row.annualRevenueCents === 'number'\n ? formatMoney(row.annualRevenueCents, row.currency)\n : '',\n ),\n },\n // The org's company fields as optional columns (AGL-2661), read off\n // the row's own `custom` map the way the contacts list reads its own.\n ...customFieldColumns(companyFields.active),\n ],\n [members, companyFields.active, nowMs],\n )\n\n /*\n * The grid's own Filters panel and quick search edit the view's clauses\n * (AGL-3313); the query answers them all (AGL-3321).\n */\n const ownerOptions = useMemo(\n () =>\n members.options.map((option) => ({\n value: option.uid,\n label: crmMemberPickerLabel(option),\n })),\n [members.options],\n )\n /*\n * Each picklist's choices (AGL-3514): every value the org keeps, valued\n * by the key the query compares and captioned by the label, inactive\n * ones marked. A stored clause naming a key no longer listed stays a\n * choice, so the panel can show it and clear it.\n */\n const filterOptions = useMemo(() => {\n const options: Record<string, Array<{ value: string; label: string }>> = {\n ownerUid: ownerOptions,\n }\n for (const entry of COMPANY_PICKLIST_FILTERS) {\n const list = picklists.lists[entry.picklistId]\n const known = (list?.values ?? []).flatMap((value) => {\n const key = crmPicklistKey(value.label)\n return key ? [{ value: key, label: value.active ? value.label : `${value.label} (inactive)` }] : []\n })\n const stale = viewFilters\n .filter((clause) => clause.field === entry.column)\n .flatMap((clause) => clause.value.split(','))\n .map((value) => value.trim())\n .filter((value) => value && !known.some((option) => option.value === value))\n .map((value) => ({ value, label: value }))\n options[entry.column] = [...known, ...stale]\n }\n return options\n }, [ownerOptions, picklists.lists, viewFilters])\n const filterColumns = useMemo(\n () =>\n listFilterGridColumns(columns, COMPANY_GRID_FILTER_FIELDS, filterOptions, COMPANY_GRID_FILTER_HEADERS),\n [columns, filterOptions],\n )\n const gridFilter = useListGridFilter({\n clauses: viewFilters,\n onChange: views.setFilters,\n selectFields: COMPANY_SELECT_FIELDS,\n search: { words: searchWords, onChange: setSearchWords },\n })\n // What the query could not hold, named by the clause the reader set.\n const refused = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: COMPANY_GRID_FILTER_FIELDS,\n headers: COMPANY_GRID_FILTER_HEADERS,\n options: filterOptions,\n }),\n [plan.refused, filterOptions],\n )\n /*\n * The grid's models are the view's (AGL-2617). The filter model shows the\n * view's clause in the panel as a typed one would appear — the owner's\n * stored `equals` back as the single-select `is` the panel offers — so a\n * view opened from its address reads as filtered, not as a mystery.\n */\n const grid = useCrmViewGrid(views, filterColumns, COMPANY_HIDDEN_COLUMNS)\n /*\n * EVERY HEADER SORTS (AGL-3680). The grid used to sort the view's order\n * over the one page on screen while the footer paged the query, which read\n * as the whole list's order. Company, Updated and Next activity sort the\n * QUERY now (`COMPANY_LIST_SORTS`); the rest sort the page and say so —\n * Type, Industry and Rating in the order the org keeps their values.\n */\n const pageSorts = useMemo(\n () =>\n Object.fromEntries(\n COMPANY_PICKLIST_FILTERS.map((entry) => [\n entry.column,\n (row: CompanyRow) => {\n const label = row[entry.column as 'type' | 'industry' | 'rating']\n const list = picklists.lists[entry.picklistId]\n return list && label ? crmPicklistRank(list, label) : null\n },\n ]),\n ),\n [picklists.lists],\n )\n const columnSort = useCrmColumnSort<CompanyRow>({\n views,\n sorts: COMPANY_LIST_SORTS,\n defaultSort: COMPANY_LIST_SORTS[0],\n asked: companySort,\n orderBy: plan.orderBy,\n rows: companies,\n columns: grid.columns,\n pageSorts,\n })\n\n /** Whether anything narrows the list, so an empty one is \"no match\", not \"none yet\". */\n const narrowed = viewFilters.length > 0 || searchWords.some((word) => word.trim())\n\n const newCompanyButton = (\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!scope}\n startIcon={<MdiIcon path={mdiPlus.path} size={0.8} />}\n onClick={() => setCreateOpen(true)}\n >\n {'New company'}\n </Button>\n )\n\n return (\n <CardDisplay\n header={'Companies'}\n help={pluginDocsHelp('companies', { anchor: '#the-companies-list' })}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n HeaderProps={{\n // The record actions, top right and never clipped (AGL-3311).\n action: (\n <CrmListActions>\n <CrmImportButton resource={CRM_COMPANIES_RESOURCE} noun=\"companies\" hostId={hostId} mappingZone=\"companies\" />\n <CrmExportButton resource={CRM_COMPANIES_RESOURCE} hostId={hostId} filter={exportFilter} />\n {newCompanyButton}\n </CrmListActions>\n ),\n }}\n >\n <Stack spacing={1.5}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'The organizations your contacts belong to. Open one to see its ' +\n 'people, its deals and its open tasks, or to link a contact ' +\n 'to it.'}\n </Typography>\n {/* The saved view, and the clauses narrowing it as chips (AGL-3313). */}\n <CrmListToolbar label=\"Company filters\">\n <CrmViewsControl controller={views} allLabel=\"All companies\" />\n <ListFilterChips\n fields={COMPANY_GRID_FILTER_FIELDS}\n headers={COMPANY_GRID_FILTER_HEADERS}\n clauses={viewFilters}\n onChange={views.setFilters}\n options={filterOptions}\n marksServed={false}\n />\n </CrmListToolbar>\n <ListQueryNotices refused={refused} notices={[...plan.notices, ...columnSort.notices]} />\n <CompaniesBulkBar\n hostId={hostId}\n scope={scope}\n rows={companies}\n selected={selectedIds}\n onSelectedChange={setSelectedIds}\n members={members}\n />\n <CrmColumnOrderProvider value={grid.columnOrder}>\n <ListTable\n rowHeight={TABLE_ROW_HEIGHT}\n columns={grid.columns}\n slots={CRM_LIST_SLOTS}\n rows={columnSort.rows}\n columnSort={columnSort}\n selectable={{ selected: selectedIds, onChange: setSelectedIds }}\n noRowsLabel={narrowed ? 'No companies match these filters' : 'No companies yet'}\n noRowsDescription={\n narrowed\n ? undefined\n : 'A company groups the contacts who work at one business, with its domain, owner and address. Create the first one, or link a contact to a company from their page.'\n }\n noRowsAction={narrowed ? undefined : newCompanyButton}\n onOpen={(id) => openCompany(String(id))}\n // An empty table while the read is in flight reads as \"you have\n // none\" rather than \"these are on their way\".\n loading={!scope || status === 'loading'}\n /*\n * The grid must NOT also filter. The query answers it, so a client\n * pass could only drop rows the query already matched (AGL-3321).\n */\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n // Columns are the view's, controlled (AGL-2617); so is the\n // header order, which `columnSort` keeps in it (AGL-3680).\n columnVisibilityModel={grid.columnVisibilityModel}\n onColumnVisibilityModelChange={grid.onColumnVisibilityModelChange}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n />\n </CrmColumnOrderProvider>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={companies.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n </Stack>\n {/*\n Mounted only while it is open, so the list pays for none of the\n drawer's state — and a fresh mount is what seeds an empty form.\n */}\n {createOpen ? (\n <CompanyEditDrawer\n open\n onClose={() => setCreateOpen(false)}\n hostId={hostId}\n org={org}\n members={members}\n onSaved={openCompany}\n />\n ) : null}\n </CardDisplay>\n )\n}\nCompaniesSection.displayName = 'CompaniesSection'\n\nexport default CompaniesSection\n"],"names":["CRM_COLLECTIONS","crmPicklistKey","crmPicklistRank","pluginDocsHelp","crmMemberPickerLabel","mdiPlus","CardDisplay","MdiIcon","ListPagination","ListTable","listFilterColumn","ListQueryNotices","listQueryRefusals","useCrmSavedView","useCrmViewGrid","CRM_LIST_SLOTS","CrmColumnOrderProvider","CRM_NEXT_ACTIVITY_FILTER_FIELD","CRM_NEXT_ACTIVITY_FILTER_HEADER","nextActivityColumn","useCrmFoldsScope","useCrmListQuery","ListFilterChips","listFilterGridColumns","useListGridFilter","CrmViewsControl","CrmListActions","CrmListToolbar","TABLE_ROW_HEIGHT","Button","Chip","Stack","Typography","getGridSingleSelectOperators","useRouter","useCallback","useEffect","useMemo","useState","COMPANY_LIST_DECLARATION","COMPANY_LIST_FILTER_FIELDS","COMPANY_LIST_SORTS","COMPANY_PICKLIST_FILTERS","COMPANY_PREFIX_SEARCH","crmViewQuerySort","useCrmColumnSort","useCompanyPicklists","formatMoney","useContactFieldDefinitions","useCrmScope","useOrgMemberOptions","CRM_COMPANIES_RESOURCE","crmRoutes","CompaniesBulkBar","CompanyEditDrawer","CrmExportButton","CrmImportButton","customFieldColumns","COMPANY_GRID_FILTER_FIELDS","COMPANY_GRID_FILTER_HEADERS","name","ownerUid","column","Object","fromEntries","map","entry","header","COMPANY_SELECT_FIELDS","COMPANY_HIDDEN_COLUMNS","type","industry","rating","accountSource","numberOfEmployees","annualRevenueCents","textCell","value","text","undefined","String","variant","noWrap","color","CompaniesSection","props","hostId","org","basePath","routes","router","scope","orgId","visibleTo","members","companyFields","picklists","views","section","viewFilters","state","filters","searchWords","setSearchWords","foldsScope","companySort","sort","rows","companies","status","hasMore","page","setPage","pageSize","setPageSize","plan","collection","declaration","clauses","search","prefixSearch","nowMs","Date","now","createOpen","setCreateOpen","selectedIds","setSelectedIds","exportFilter","served","length","searched","label","openCompany","id","push","company","columns","field","headerName","flex","minWidth","valueGetter","_value","row","renderCell","sx","justifyContent","height","lineHeight","filterable","sortable","domain","width","align","headerAlign","Number","contactsCount","toLocaleString","tags","join","direction","spacing","alignItems","overflow","slice","tag","size","valueOptions","options","option","uid","filterOperators","filter","operator","ready","labelFor","updatedAt","seconds","toLocaleDateString","currency","active","ownerOptions","filterOptions","list","lists","picklistId","known","values","flatMap","key","stale","clause","split","trim","some","filterColumns","gridFilter","onChange","setFilters","selectFields","words","refused","fields","headers","grid","pageSorts","columnSort","sorts","defaultSort","asked","orderBy","narrowed","word","newCompanyButton","disabled","startIcon","path","onClick","help","anchor","contentGutterX","contentGutterY","contentBordered","HeaderProps","action","resource","noun","mappingZone","controller","allLabel","marksServed","notices","selected","onSelectedChange","columnOrder","rowHeight","slots","selectable","noRowsLabel","noRowsDescription","noRowsAction","onOpen","loading","filterMode","filterModel","onFilterModelChange","quickFilter","columnVisibilityModel","onColumnVisibilityModelChange","hideFooter","rowCount","onPageChange","onPageSizeChange","open","onClose","onSaved","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAEEA,eAAe,EAEfC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,oBAAoB,QACf,eAAc;AACrB,SAASC,OAAO,QAAQ,yBAAwB;AAChD,SAASC,WAAW,EAAEC,OAAO,QAAQ,uBAAsB;AAC3D,SAAS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;4BACP4F,MAAMoG,WAAWpG,IAAI;4BACrBoG,YAAYA;4BACZ+B,YAAY;gCAAEL,UAAU3G;gCAAawE,UAAUvE;4BAAe;4BAC9DgH,aAAa3B,WAAW,qCAAqC;4BAC7D4B,mBACE5B,WACIrI,YACA;4BAENkK,cAAc7B,WAAWrI,YAAYuI;4BACrC4B,QAAQ,CAAC5G,KAAOD,YAAYrD,OAAOsD;4BACnC,gEAAgE;4BAChE,8CAA8C;4BAC9C6G,SAAS,CAACxJ,SAASkB,WAAW;4BAC9B;;;aAGC,GACDuI,YAAW;4BACXC,aAAahD,WAAWgD,WAAW;4BACnCC,qBAAqBjD,WAAWiD,mBAAmB;4BACnDC,WAAW;4BACX,2DAA2D;4BAC3D,2DAA2D;4BAC3DC,uBAAuB3C,KAAK2C,qBAAqB;4BACjDC,+BAA+B5C,KAAK4C,6BAA6B;4BACjE,8DAA8D;4BAC9DC,UAAU;;;kCAGd,KAAClP;wBACCuG,MAAMA;wBACNE,UAAUA;wBACV0I,UAAU/I,UAAUsB,MAAM;wBAC1BpB,SAASA;wBACT8I,cAAc5I;wBACd6I,kBAAkB3I;;;;YAOrBU,2BACC,KAACtE;gBACCwM,IAAI;gBACJC,SAAS,IAAMlI,cAAc;gBAC7BvC,QAAQA;gBACRC,KAAKA;gBACLO,SAASA;gBACTkK,SAAS3H;iBAET;;;AAGV;AACAjD,iBAAiB6K,WAAW,GAAG;AAE/B,eAAe7K,iBAAgB"}
@@ -38,13 +38,15 @@ import { companyDraftFields, companyDraftFrom, EMPTY_COMPANY_DRAFT } from "../mo
38
38
  import { crmCustomDraftDocument, crmCustomDraftMissingRequired, crmCustomDraftValue, crmCustomDraftWrites } from "../model/crm-custom-draft.js";
39
39
  import { CrmCustomFieldControl } from "./crm-custom-field-control.js";
40
40
  import { CrmSitePicker } from "./crm-site-picker.js";
41
- import { CRM_CLIENT_SEARCH_FIELDS, crmClientListFields } from "../model/crm-list-query.js";
41
+ import { CRM_CLIENT_SEARCH_FIELDS, CRM_CLIENT_SORT_FIELDS, crmClientListFields } from "../model/crm-list-query.js";
42
42
  /**
43
43
  * The list fields a client edit of a company rewrites: the search tokens,
44
44
  * and the key beside each picklist field the Companies list filters by
45
45
  * (AGL-3514).
46
46
  */ const COMPANY_CLIENT_LIST_FIELDS = [
47
47
  ...CRM_CLIENT_SEARCH_FIELDS,
48
+ // Any header sort key the edit's inputs move (AGL-3680).
49
+ ...CRM_CLIENT_SORT_FIELDS,
48
50
  ...CRM_COMPANY_PICKLIST_FIELDS.flatMap((entry)=>'keyField' in entry ? [
49
51
  entry.keyField
50
52
  ] : [])