@svgrid/enterprise 3.1.34 → 3.1.36

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 (250) hide show
  1. package/dist/ExpressionEditorHarness.svelte +1 -1
  2. package/dist/SvAdvancedFilter.svelte +1 -1
  3. package/dist/SvAlertRuleEditor.svelte +1 -1
  4. package/dist/SvAlertsManager.svelte +1 -1
  5. package/dist/SvAlertsPanel.svelte +1 -1
  6. package/dist/SvExpressionEditor.svelte +1 -1
  7. package/dist/SvGridBoard.svelte +1 -1
  8. package/dist/SvGridBulkEditDrawer.svelte +1 -1
  9. package/dist/SvGridEditPanel.svelte +1 -1
  10. package/dist/SvGridGallery.svelte +1 -1
  11. package/dist/SvGridMasterDetail.svelte +1 -1
  12. package/dist/SvGridScheduler.svelte +1 -1
  13. package/dist/SvGridSelectionBar.svelte +1 -1
  14. package/dist/SvPivotDesigner.svelte +1 -1
  15. package/dist/SvSchemaChart.svelte +1 -1
  16. package/dist/SvSchemaDashboard.svelte +1 -1
  17. package/dist/SvSheet.svelte +1 -1
  18. package/dist/SvSheetChartSetup.svelte +1 -1
  19. package/dist/SvSheetConditionalFormat.svelte +1 -1
  20. package/dist/SvSheetDataValidation.svelte +1 -1
  21. package/dist/SvSheetEditRanges.svelte +1 -1
  22. package/dist/SvSheetErrors.svelte +1 -1
  23. package/dist/SvSheetEvaluate.svelte +1 -1
  24. package/dist/SvSheetFindReplace.svelte +1 -1
  25. package/dist/SvSheetFormatCells.svelte +1 -1
  26. package/dist/SvSheetGoalSeek.svelte +1 -1
  27. package/dist/SvSheetInsertFunction.svelte +1 -1
  28. package/dist/SvSheetIteration.svelte +1 -1
  29. package/dist/SvSheetLink.svelte +1 -1
  30. package/dist/SvSheetManageRules.svelte +1 -1
  31. package/dist/SvSheetNameManager.svelte +1 -1
  32. package/dist/SvSheetPageSetup.svelte +1 -1
  33. package/dist/SvSheetPasteSpecial.svelte +1 -1
  34. package/dist/SvSheetPivot.svelte +1 -1
  35. package/dist/SvSheetProtectSheet.svelte +1 -1
  36. package/dist/SvSheetRemoveDuplicates.svelte +1 -1
  37. package/dist/SvSheetRibbon.svelte +1 -1
  38. package/dist/SvSheetSizeDialog.svelte +1 -1
  39. package/dist/SvSheetSort.svelte +1 -1
  40. package/dist/SvSheetSparklines.svelte +1 -1
  41. package/dist/SvSheetTable.svelte +1 -1
  42. package/dist/SvSheetTabs.svelte +1 -1
  43. package/dist/SvSheetTextToColumns.svelte +1 -1
  44. package/dist/SvSheetValidationAlert.svelte +1 -1
  45. package/dist/cdn/svgrid-enterprise.svelte-external.js +2 -2
  46. package/dist/designer/assets/{index-v61ZvIWw.js → index-CsdyIRos.js} +3 -3
  47. package/dist/designer/assets/{src-DkFgWld_.js → src-CSmsOfsG.js} +15 -15
  48. package/dist/designer/index.html +2 -2
  49. package/dist/fields/AiCell.svelte +41 -0
  50. package/dist/fields/AiCell.svelte.d.ts +5 -0
  51. package/dist/fields/AttachmentCell.svelte +1 -1
  52. package/dist/fields/AttachmentDialog.svelte +1 -1
  53. package/dist/fields/AttachmentEditor.svelte +1 -1
  54. package/dist/fields/AttachmentPreview.svelte +1 -1
  55. package/dist/fields/BaseAutomations.svelte +1 -1
  56. package/dist/fields/BaseChartView.svelte +1 -1
  57. package/dist/fields/BaseDashboardView.svelte +133 -0
  58. package/dist/fields/BaseDashboardView.svelte.d.ts +17 -0
  59. package/dist/fields/BaseImport.svelte +89 -0
  60. package/dist/fields/BaseImport.svelte.d.ts +15 -0
  61. package/dist/fields/BaseInboxView.svelte +112 -0
  62. package/dist/fields/BaseInboxView.svelte.d.ts +8 -0
  63. package/dist/fields/BaseListView.svelte +90 -0
  64. package/dist/fields/BaseListView.svelte.d.ts +8 -0
  65. package/dist/fields/BaseSearch.svelte +78 -0
  66. package/dist/fields/BaseSearch.svelte.d.ts +10 -0
  67. package/dist/fields/BaseTableView.svelte +28 -3
  68. package/dist/fields/BaseTableView.svelte.d.ts +5 -1
  69. package/dist/fields/BaseTabs.svelte +45 -8
  70. package/dist/fields/BaseTabs.svelte.d.ts +25 -1
  71. package/dist/fields/BaseTrash.svelte +63 -0
  72. package/dist/fields/BaseTrash.svelte.d.ts +15 -0
  73. package/dist/fields/CheckboxCell.svelte +1 -1
  74. package/dist/fields/ChecklistCell.svelte +22 -0
  75. package/dist/fields/ChecklistCell.svelte.d.ts +10 -0
  76. package/dist/fields/ChecklistEditor.svelte +81 -0
  77. package/dist/fields/ChecklistEditor.svelte.d.ts +12 -0
  78. package/dist/fields/ColorCell.svelte +13 -0
  79. package/dist/fields/ColorCell.svelte.d.ts +8 -0
  80. package/dist/fields/ColorEditor.svelte +60 -0
  81. package/dist/fields/ColorEditor.svelte.d.ts +11 -0
  82. package/dist/fields/DashboardRecords.svelte +35 -0
  83. package/dist/fields/DashboardRecords.svelte.d.ts +11 -0
  84. package/dist/fields/DashboardTileEditor.svelte +138 -0
  85. package/dist/fields/DashboardTileEditor.svelte.d.ts +15 -0
  86. package/dist/fields/DeleteFieldConfirm.svelte +1 -1
  87. package/dist/fields/DeleteRecordConfirm.svelte +1 -1
  88. package/dist/fields/FieldEditor.svelte +32 -3
  89. package/dist/fields/FieldInput.svelte +1 -1
  90. package/dist/fields/FieldsHeaderEnd.svelte +1 -1
  91. package/dist/fields/FootRowAdder.svelte +1 -1
  92. package/dist/fields/GroupHeader.svelte +3 -3
  93. package/dist/fields/LinkPickerEditor.svelte +1 -1
  94. package/dist/fields/LinkPreview.svelte +1 -1
  95. package/dist/fields/LinkedRecordView.svelte +1 -1
  96. package/dist/fields/LinkedRecordsCell.svelte +1 -1
  97. package/dist/fields/ListChips.svelte +21 -0
  98. package/dist/fields/ListChips.svelte.d.ts +9 -0
  99. package/dist/fields/LongTextEditor.svelte +1 -1
  100. package/dist/fields/MentionInput.svelte +59 -0
  101. package/dist/fields/MentionInput.svelte.d.ts +11 -0
  102. package/dist/fields/NumberEditor.svelte +1 -1
  103. package/dist/fields/OptionsEditor.svelte +1 -1
  104. package/dist/fields/PercentCell.svelte +1 -1
  105. package/dist/fields/PropertyInput.svelte +13 -10
  106. package/dist/fields/RatingCell.svelte +1 -1
  107. package/dist/fields/RatingEditor.svelte +1 -1
  108. package/dist/fields/RecordView.svelte +20 -25
  109. package/dist/fields/RowHeader.svelte +1 -1
  110. package/dist/fields/SelectCell.svelte +1 -1
  111. package/dist/fields/SelectEditor.svelte +1 -1
  112. package/dist/fields/SummaryCell.svelte +1 -1
  113. package/dist/fields/SvBase.svelte +48 -9
  114. package/dist/fields/SvBase.svelte.d.ts +33 -1
  115. package/dist/fields/SvBaseForm.svelte +2 -2
  116. package/dist/fields/SvBaseForm.svelte.d.ts +14 -0
  117. package/dist/fields/SvBaseViewBar.svelte +33 -12
  118. package/dist/fields/SvBaseViewBar.svelte.d.ts +2 -0
  119. package/dist/fields/TimeOfDayEditor.svelte +39 -0
  120. package/dist/fields/TimeOfDayEditor.svelte.d.ts +12 -0
  121. package/dist/fields/UserCell.svelte +1 -1
  122. package/dist/fields/activity.svelte.d.ts +29 -0
  123. package/dist/fields/activity.svelte.js +1 -1
  124. package/dist/fields/ai-field.svelte.d.ts +91 -0
  125. package/dist/fields/ai-field.svelte.js +1 -0
  126. package/dist/fields/ai-prompt.d.ts +64 -0
  127. package/dist/fields/ai-prompt.js +7 -0
  128. package/dist/fields/airtable.d.ts +90 -0
  129. package/dist/fields/airtable.js +1 -0
  130. package/dist/fields/bar-request.svelte.d.ts +1 -1
  131. package/dist/fields/base-history.d.ts +56 -0
  132. package/dist/fields/base-history.js +1 -0
  133. package/dist/fields/base-import.d.ts +54 -0
  134. package/dist/fields/base-import.js +2 -0
  135. package/dist/fields/base-search.d.ts +34 -0
  136. package/dist/fields/base-search.js +1 -0
  137. package/dist/fields/base-share.d.ts +45 -0
  138. package/dist/fields/base-share.js +1 -0
  139. package/dist/fields/base-sql.js +3 -3
  140. package/dist/fields/base-trash.d.ts +51 -0
  141. package/dist/fields/base-trash.js +1 -0
  142. package/dist/fields/builtin-types.js +1 -1
  143. package/dist/fields/chart-view.d.ts +12 -0
  144. package/dist/fields/chart-view.js +1 -1
  145. package/dist/fields/checklist.d.ts +36 -0
  146. package/dist/fields/checklist.js +4 -0
  147. package/dist/fields/color-value.d.ts +14 -0
  148. package/dist/fields/color-value.js +1 -0
  149. package/dist/fields/convert.js +1 -1
  150. package/dist/fields/copy-text.d.ts +1 -1
  151. package/dist/fields/copy-text.js +1 -1
  152. package/dist/fields/dashboard.d.ts +143 -0
  153. package/dist/fields/dashboard.js +1 -0
  154. package/dist/fields/field-access.svelte.d.ts +37 -0
  155. package/dist/fields/field-access.svelte.js +1 -0
  156. package/dist/fields/field-ops.js +1 -1
  157. package/dist/fields/filter-model.d.ts +4 -11
  158. package/dist/fields/filter-model.js +1 -1
  159. package/dist/fields/form-logic.d.ts +69 -0
  160. package/dist/fields/form-logic.js +1 -0
  161. package/dist/fields/formula.js +1 -1
  162. package/dist/fields/grid-access.d.ts +8 -0
  163. package/dist/fields/grid-access.js +1 -1
  164. package/dist/fields/index.d.ts +16 -0
  165. package/dist/fields/index.js +1 -1
  166. package/dist/fields/list-view.d.ts +40 -0
  167. package/dist/fields/list-view.js +1 -0
  168. package/dist/fields/mentions.d.ts +50 -0
  169. package/dist/fields/mentions.js +1 -0
  170. package/dist/fields/palette.d.ts +4 -2
  171. package/dist/fields/palette.js +1 -1
  172. package/dist/fields/record-menu.js +1 -1
  173. package/dist/fields/registry.svelte.d.ts +5 -0
  174. package/dist/fields/registry.svelte.js +1 -1
  175. package/dist/fields/time-of-day.d.ts +28 -0
  176. package/dist/fields/time-of-day.js +1 -0
  177. package/dist/fields/view-model.d.ts +24 -2
  178. package/dist/fields/view-model.js +1 -1
  179. package/dist/fields/viewbar/ChartPanel.svelte +1 -1
  180. package/dist/fields/viewbar/ColorPanel.svelte +1 -1
  181. package/dist/fields/viewbar/ConditionValue.svelte +4 -4
  182. package/dist/fields/viewbar/FilterPanel.svelte +1 -1
  183. package/dist/fields/viewbar/GanttPanel.svelte +1 -1
  184. package/dist/fields/viewbar/HideFieldsPanel.svelte +1 -1
  185. package/dist/fields/viewbar/ListPanel.svelte +36 -0
  186. package/dist/fields/viewbar/ListPanel.svelte.d.ts +11 -0
  187. package/dist/fields/viewbar/SortPanel.svelte +1 -1
  188. package/dist/fields/viewbar/ViewsMenu.svelte +27 -4
  189. package/dist/fields/viewbar/ViewsMenu.svelte.d.ts +6 -0
  190. package/dist/gantt/SvGridGantt.svelte +1 -1
  191. package/dist/node/studio.js +1 -1
  192. package/dist/review/RichCellMark.svelte +1 -1
  193. package/dist/review/SvReviewPanel.svelte +1 -1
  194. package/dist/server/SvGroupCell.svelte +1 -1
  195. package/dist/server/SvRowGroupPanel.svelte +1 -1
  196. package/dist/version.d.ts +2 -2
  197. package/dist/version.js +1 -1
  198. package/dist/wc/GridFind-DsTvdUXq.js +1 -0
  199. package/dist/wc/GridFooter-D-i8boBh.js +1 -0
  200. package/dist/wc/GridMenus-CYe9Fw2I.js +20 -0
  201. package/dist/wc/PinSplitter-LvyyrLhe.js +6 -0
  202. package/dist/wc/SvChartMenu-XKW_LOYw.js +1 -0
  203. package/dist/wc/SvDateRangeInput-CSOxqTB1.js +1 -0
  204. package/dist/wc/SvDateTimePicker-DvvFs2T9.js +4 -0
  205. package/dist/wc/SvField-BmQphyOs.js +20 -0
  206. package/dist/wc/SvForm-HD7y5vmk.js +46 -0
  207. package/dist/wc/SvGridCellEditor-776KAOe1.js +3 -0
  208. package/dist/wc/SvGridChart-DC7ZUhp8.js +171 -0
  209. package/dist/wc/SvGridChartBuilder-Dd3vWBvq.js +7 -0
  210. package/dist/wc/SvGridChartPanel-CwYjF46U.js +5 -0
  211. package/dist/wc/SvGridChartView-CSF38rBs.js +3 -0
  212. package/dist/wc/SvGridDropdown-4S1G7gsP.js +30 -0
  213. package/dist/wc/SvMenuList-D3ZLXjL_.js +1 -0
  214. package/dist/wc/SvModal-Dk0YwPWp.js +7 -0
  215. package/dist/wc/SvSwitchButton-DdZmc3ew.js +1 -0
  216. package/dist/wc/SvTabs-BI2cQHyw.js +2 -0
  217. package/dist/wc/base-react.d.ts +38 -0
  218. package/dist/wc/base-react.js +1 -0
  219. package/dist/wc/base-vue.d.ts +29 -0
  220. package/dist/wc/base-vue.js +1 -0
  221. package/dist/wc/board-RQp5fHPR.js +21 -0
  222. package/dist/wc/board-view.svelte-CpxuZcEg.js +1 -0
  223. package/dist/wc/card-marks.svelte-QwxIcKcZ.js +1 -0
  224. package/dist/wc/client-DNdLmGcu.js +3 -0
  225. package/dist/wc/createOverlay.svelte-CDw3RXgs.js +1 -0
  226. package/dist/wc/custom-filter-Dp8JxlQu.js +2 -0
  227. package/dist/wc/date-format-DtSmFyEB.js +18 -0
  228. package/dist/wc/editor-registry-CkKfcVLc.js +1 -0
  229. package/dist/wc/export-format-CGfE9_O5.js +5 -0
  230. package/dist/wc/gallery-CNOHNWEJ.js +4 -0
  231. package/dist/wc/gallery-view.svelte-27X-wCQH.js +1 -0
  232. package/dist/wc/grid-extension.svelte-hgqOteka.js +1 -0
  233. package/dist/wc/import-B9mIERCl.js +4 -0
  234. package/dist/wc/js-scroller.svelte-BP8Up6_q.js +1 -0
  235. package/dist/wc/license-CWVWqb-i.js +27 -0
  236. package/dist/wc/list-option-CI4nMshZ.js +1 -0
  237. package/dist/wc/react.d.ts +1 -0
  238. package/dist/wc/react.js +1 -1
  239. package/dist/wc/scheduler-CkVY4od-.js +147 -0
  240. package/dist/wc/scheduler-view.svelte-SzG7rU8b.js +1 -0
  241. package/dist/wc/sparkline-DWRBQubt.js +1 -0
  242. package/dist/wc/sv-base-element.d.ts +87 -0
  243. package/dist/wc/sv-base-element.js +273 -0
  244. package/dist/wc/sv-sheet-element.d.ts +2 -0
  245. package/dist/wc/sv-sheet-element.js +55 -55
  246. package/dist/wc/svelte-virtualizer.svelte-CSBwEZt9.js +1 -0
  247. package/dist/wc/types/sv-base-element.d.ts +87 -0
  248. package/dist/wc/vue.d.ts +1 -0
  249. package/dist/wc/vue.js +1 -1
  250. package/package.json +19 -4
@@ -1 +1 @@
1
- import{fillFieldColumn as B}from"./registry.svelte.js";import ne from"./RatingCell.svelte";import T from"./LinkCell.svelte";import se from"./AttachmentCell.svelte";import ce from"./CheckboxCell.svelte";import V from"./PercentCell.svelte";import A from"./UserCell.svelte";import ue from"./ButtonCell.svelte";import de from"./BarcodeCell.svelte";import me from"./LinkedRecordsCell.svelte";import pe from"./RichTextCell.svelte";import z from"./SelectCell.svelte";import{attachmentsText as fe,parseAttachments as be}from"./attachments.js";import{dateEditTokens as he,formatCurrency as _,formatDate as C,formatDuration as ye,formatNumber as F,formatPercent as H,numberFieldShape as j,numberFromText as ge,numberKind as ke,parseDuration as G,toNumber as b}from"./format.js";import{BRIGHT as N,CHECKBOX_ICONS as we,RATING_ICONS as ve}from"./palette.js";import{compileFormula as Me,isoDate as Se,selfReferenceError as Te}from"./formula.js";import{findFieldUser as Ae,getCurrentUser as W,getFieldUsers as K,getLinkedTable as k,linkedRows as w,listLinkedTables as Ce,resolveLinkIds as Fe}from"./sources.svelte.js";import{splitNames as $}from"./name-list.js";import{linkedFields as Ne}from"./linked-fields.js";const X=new WeakMap;let h=0;const Le=new Set(["formula","lookup","rollup","count"]);function Y(e,t){const l=o=>o?.[t];if(!e?.fields?.length)return l;let r=X.get(e.fields);if(r||X.set(e.fields,r=new Map),!r.has(t)){const o=Ne(e).find(n=>n.def.field===t);r.set(t,o?.def.fieldFn??null)}const i=r.get(t);return i?o=>{if(h>3)return l(o);h+=1;try{return i(o)}finally{h-=1}}:l}const a={text:"M4 6h16M4 12h10M4 18h7",longText:"M4 6h16M4 10h16M4 14h16M4 18h10",number:"M9 4 7 20M17 4l-2 16M4 9h16M3 15h16",currency:"M12 3v18M16 7.5C16 5.6 14.2 4.5 12 4.5S8 5.6 8 7.5s1.8 2.7 4 3.5 4 1.6 4 3.5-1.8 3-4 3-4-1.1-4-3",percent:"M19 5 5 19M7 7h.01M17 17h.01",date:"M4 6h16v14H4zM4 10h16M8 3v4M16 3v4",duration:"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zM12 8v4l3 2",checkbox:"M4 4h16v16H4zM8 12l3 3 5-6",singleSelect:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM8 11l4 4 4-4",multiSelect:"M3 7h11M3 12h11M3 17h11M17 6l2 2 3-3M17 16l2 2 3-3",rating:"M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3 6.5 20.2l1-6.2L3 9.6l6.2-.9z",url:"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",email:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2",attachment:"M20 11.5 12.3 19a5 5 0 0 1-7.1-7.1l7.8-7.8a3.3 3.3 0 0 1 4.7 4.7L9.9 16.6a1.7 1.7 0 0 1-2.4-2.4l7.1-7",user:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0",createdTime:"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zM12 8v4h4",modifiedTime:"M4 12a8 8 0 1 0 2.3-5.7M4 4v4h4M12 8v4l3 2",createdBy:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 11-7.5M19 15v6M16 18h6",modifiedBy:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 11-7.5M16 21l5-5-2-2-5 5v2z",autoNumber:"M5 7h3v10M11 9a2 2 0 1 1 4 0c0 2-4 3-4 6h4M18 7h2v10",barcode:"M4 5v14M7 5v14M10 5v14M13 5v14M15 5v14M18 5v14M20 5v14",button:"M4 7h16v10H4zM9 12h6",formula:"M7 20c2 0 2.5-2 3-5l2-10c.5-2 1.5-2 3-2M8 9h7",link:"M9 7H6a5 5 0 0 0 0 10h3M15 7h3a5 5 0 0 1 0 10h-3M8 12h8",lookup:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM20 20l-4-4M8 11h6",rollup:"M6 4h12L12 12l6 8H6",count:"M5 5h14v14H5zM9 9v6M12 9v6M15 9v6"},Ie={key:"separators",label:"Separators",kind:"choice",choices:[{value:"local",label:"Local"},{value:"comma-period",label:"1,000,000.00"},{value:"period-comma",label:"1.000.000,00"},{value:"space-comma",label:"1 000 000,00"},{value:"space-period",label:"1 000 000.00"}]},Pe={key:"showThousands",label:"Show thousands separator",kind:"checkbox"},Oe={key:"abbreviation",label:"Large number abbreviation",kind:"choice",choices:[{value:"none",label:"None"},{value:"thousand",label:"Thousand (K)"},{value:"million",label:"Million (M)"},{value:"billion",label:"Billion (B)"}]},De={key:"allowNegative",label:"Allow negative numbers",kind:"checkbox"},y={key:"default",label:"Default value",kind:"default",hint:"New rows start with this value."},L=(e,t)=>Array.from({length:t-e+1},(l,r)=>{const i=e+r;return{value:String(i),label:i===0?"1":`1.${"0".repeat(i)}`}}),v={key:"dateFormat",label:"Date format",kind:"choice",choices:[{value:"local",label:"Local"},{value:"friendly",label:"Friendly (October 14, 2026)"},{value:"us",label:"US (10/14/2026)"},{value:"european",label:"European (14/10/2026)"},{value:"iso",label:"ISO (2026-10-14)"}]},I=[{key:"time",label:"Include time",kind:"checkbox"},{key:"timeFormat",label:"Time format",kind:"segmented",choices:[{value:"12hour",label:"12 hour"},{value:"24hour",label:"24 hour"}],visible:e=>!!e.time},{key:"gmt",label:"Use the same time zone (GMT) for everyone",kind:"checkbox",visible:e=>!!e.time},{key:"showTimeZone",label:"Display time zone",kind:"checkbox",visible:e=>!!e.time}],Re=e=>e.columns.filter(t=>t.fieldType==="link").map(t=>({value:String(t.id??t.field),label:String(t.header??t.field)})),P={key:"linkField",label:"Link field",kind:"choice",choices:Re,hint:"A link-to-records field of this table."},Ee=e=>{const t=e.columns.find(i=>String(i.id??i.field)===e.props.linkField),l=k(t?.fieldProps?.table);return l?(l.fields??[{field:l.primaryField,header:l.primaryField}]).map(i=>({value:i.field,label:i.header})):[]},q={key:"field",label:"Field in the linked table",kind:"choice",choices:Ee,visible:e=>!!e.linkField},J=(e,t=0)=>{const l=Number(e.precision);return Number.isInteger(l)&&l>=0&&l<=8?l:t},Ue=e=>({precision:e.format==="integer"?0:J(e,e.format==="decimal"?1:0),separators:e.separators,showThousands:e.showThousands!==!1,abbreviation:e.abbreviation}),xe=(e,t)=>l=>{const r=typeof l.rawInput=="string"?l.rawInput:l.newValue;if(typeof r=="number"||r==null)return r;if(String(r).trim()==="")return null;const i=ge(String(r),e,t);return i??l.oldValue},Be=(e,t)=>t.allowNegative===!1&&!e.validate?{rejectInvalid:!0,validate:l=>Number(l.value)<0?"Negative numbers are not allowed":null}:{},Ve=(e,t)=>{const l={precision:j(e,t).places,separators:t.separators,showThousands:t.showThousands!==!1,abbreviation:e==="percent"?void 0:t.abbreviation};return r=>{const i=b(r.value);return i==null?"":e==="currency"?_(i,{...l,symbol:t.symbol,symbolPosition:t.symbolPosition}):e==="percent"?H(i,{...l,points:t.points}):F(i,l)}},O=(e,t,l)=>({...e,cellDataType:e.cellDataType??"number",editorType:e.editorType??"fieldNumber",align:e.align??(l==="percent"&&t.showBar?"left":"right"),...Be(e,t),valueParser:e.valueParser??xe(l,t),formatter:e.formatter??Ve(l,t)}),g=e=>Array.isArray(e.options)?e.options.map(t=>({value:t.value,label:t.label??String(t.value),...t.color?{color:t.color}:{}})):[],Q=(e,t)=>{const l=new Map;for(const i of g(e))l.set(String(i.value).toLowerCase(),i.value),l.set(String(i.label).toLowerCase(),i.value);const r=i=>l.get(i.toLowerCase())??i;return i=>{if(typeof i.rawInput!="string")return i.newValue;const o=i.rawInput.split(t?",":/\n/).map(n=>n.trim()).filter(Boolean);return t?[...new Set(o.map(r))]:o.length?r(o[0]):null}},Z=e=>{const t=new Map(g(e).map(l=>[String(l.value),l.label]));return l=>(Array.isArray(l.value)?l.value:l.value==null||l.value===""?[]:[l.value]).map(r=>t.get(String(r))??String(r)).join(", ")},ze=e=>{const t=new Map(g(e).map((l,r)=>[String(l.value),r]));return l=>l==null||l===""?null:t.get(String(l))??t.size},ee=e=>{const t={};for(const l of e){const r=String(l.field??l.id??"");r&&(t[r.toLowerCase()]=r,typeof l.header=="string"&&(t[l.header.trim().toLowerCase()]=r))}return t},d=e=>({editable:e.editable??!1}),D=e=>t=>C(t.value,e),R=e=>(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(t=>Ae(t)?.name??String(t)).join(", "),_e=e=>t=>{if(typeof t.rawInput!="string")return t.newValue;const l=K(),r=o=>{const n=o.toLowerCase();return l.find(m=>m.id.toLowerCase()===n||m.name.toLowerCase()===n||m.email?.toLowerCase()===n)?.id??o},i=e?$(t.rawInput):t.rawInput.split(/\n/).map(o=>o.trim()).filter(Boolean);return e?[...new Set(i.map(r))]:i.length?r(i[0]):null},He=e=>t=>{if(typeof t.rawInput!="string")return t.newValue;const l=k(e.table);if(!l)return t.newValue;const r=Fe(l,$(t.rawInput));return e.multiple===!1?r.slice(0,1):r};function te(e,t){if(e==null)return"";if(Array.isArray(e))return e.map(l=>te(l,t)).join(", ");if(e instanceof Date)return C(e,t);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"){if(t.result==="currency"||t.result==="percent"||t.result==="number"){const l=t.result,r={...Ue(t),precision:j(l,{precision:t.precision}).places};return l==="currency"?_(e,{...r,symbol:t.symbol}):l==="percent"?H(e,r):F(e,r)}return String(Math.round(e*1e10)/1e10)}if(t.result==="date"){const l=Se(String(e));if(l)return C(l,t)}return String(e)}const E={SUM:e=>e.reduce((t,l)=>t+(b(l)??0),0),AVERAGE:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?t.reduce((l,r)=>l+r,0)/t.length:null},MIN:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?Math.min(...t):null},MAX:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?Math.max(...t):null},COUNT:e=>e.filter(t=>typeof t=="number").length,COUNTA:e=>e.filter(t=>t!=null&&t!=="").length,COUNTALL:e=>e.length,ARRAYJOIN:e=>e.filter(t=>t!=null&&t!=="").map(String).join(", "),ARRAYUNIQUE:e=>[...new Set(e.filter(t=>t!=null&&t!=="").map(String))].join(", "),CONCATENATE:e=>e.map(t=>t==null?"":String(t)).join(""),AND:e=>e.every(Boolean),OR:e=>e.some(Boolean)},U=(e,t)=>{const l=t.columns.find(i=>String(i.id??i.field)===e.linkField);if(!l)return null;const r=l.fieldProps?.table;return{key:String(l.field??l.id),get table(){return k(r)}}},le=new WeakMap;function re(e,t){const l=e?.table?.fields;if(!l)return;let r=le.get(l);r||le.set(l,r=new Map);const i=String(t);if(r.has(i))return r.get(i);const o=l.find(m=>m.field===i),n=o?.fieldType?B({field:o.field,fieldType:o.fieldType,fieldProps:o.fieldProps}).formatter:void 0;return r.set(i,n),n}const M=()=>new Date().toISOString(),ie=[{key:"watch",label:"Changes to",kind:"segmented",choices:[{value:"all",label:"All fields"},{value:"specific",label:"Specific fields"}]},{key:"watchFields",label:"Fields",kind:"columns",visible:e=>e.watch==="specific"}];export const BUILTIN_FIELD_TYPES=[{id:"text",label:"Single line text",description:"A short line of text, like a name or a title.",icon:a.text,group:"basic",properties:[y],fill:e=>({...e,editorType:e.editorType??"text"})},{id:"longText",label:"Long text",description:"Several lines of text; Alt+Enter starts a new line.",icon:a.longText,group:"basic",width:260,properties:[{key:"richText",label:"Enable rich text formatting",kind:"checkbox",hint:"**bold**, *italic*, `code`, [links](https://...) and lists."}],fill:e=>({...e,editorType:e.editorType??"fieldLongText"}),cell:pe,hasCell:e=>!!e.richText},{id:"attachment",label:"Attachment",description:"Images and files: thumbnails in the cell, a dialog to add more.",icon:a.attachment,group:"basic",width:180,defaults:{maxFiles:20},properties:[{key:"accept",label:"Accepted types",kind:"text",placeholder:"image/*,.pdf (any when empty)"},{key:"maxFiles",label:"Most files per cell",kind:"number",min:1,max:100}],fill:(e,t)=>({...e,editorType:e.editorType??"attachment",formatter:e.formatter??(l=>fe(l.value)),valueParser:e.valueParser??(l=>be(l.newValue,t))}),cell:se},{id:"checkbox",label:"Checkbox",description:"Done or not done: one click to toggle.",icon:a.checkbox,group:"basic",width:90,defaults:{icon:"check",color:"#20c933"},properties:[{key:"icon",label:"Icon",kind:"icon",icons:we},{key:"color",label:"Color",kind:"color",palette:N},y],fill:e=>({...e,editorType:e.editorType??"checkbox",align:e.align??"center"}),cell:ce},{id:"singleSelect",label:"Single select",description:"One choice from a list of colored options.",icon:a.singleSelect,group:"basic",width:140,defaults:{options:[]},properties:[{key:"options",label:"Options",kind:"options"},y],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",editorOptions:e.editorOptions??g(t),formatter:e.formatter??Z(t),valueParser:e.valueParser??Q(t,!1),sortValue:e.sortValue??ze(t)}),cell:z},{id:"multiSelect",label:"Multiple select",description:"Any number of choices from a list of colored options.",icon:a.multiSelect,group:"basic",width:200,defaults:{options:[]},properties:[{key:"options",label:"Options",kind:"options"},y],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",editorMultiple:e.editorMultiple??!0,editorOptions:e.editorOptions??g(t),formatter:e.formatter??Z(t),valueParser:e.valueParser??Q(t,!0)}),cell:z},{id:"user",label:"User",description:"A person (or several) from the people the app lists.",icon:a.user,group:"basic",width:170,properties:[{key:"multiple",label:"Allow adding multiple users",kind:"checkbox"},y],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",valueParser:e.valueParser??_e(!!t.multiple),editorMultiple:e.editorMultiple??!!t.multiple,editorOptions:e.editorOptions??K().map(l=>({value:l.id,label:l.name})),formatter:e.formatter??(l=>R(l.value))}),cell:A},{id:"date",label:"Date",description:"A calendar date, with or without the time.",icon:a.date,group:"basic",width:150,defaults:{dateFormat:"local",timeFormat:"12hour"},properties:[v,...I,{key:"defaultToday",label:"Default to today",kind:"checkbox"}],fill:(e,t)=>({...e,cellDataType:e.cellDataType??(t.time?"date":"dateString"),editorType:e.editorType??(t.time?"datetime":"date"),editorFormatString:e.editorFormatString??he(t),formatter:e.formatter??D(t)}),newRowValue:({props:e})=>e.defaultToday?e.time?M():new Date().toISOString().slice(0,10):void 0},{id:"phone",label:"Phone number",description:"A phone number, shown as a tel link.",icon:a.phone,group:"basic",fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"email",label:"Email",description:"An email address, shown as a mailto link.",icon:a.email,group:"basic",width:200,fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"url",label:"URL",description:"A web address, shown as a link.",icon:a.url,group:"basic",width:200,fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"barcode",label:"Barcode",description:"A barcode's text, from a scanner or typed.",icon:a.barcode,group:"basic",width:160,fill:e=>({...e,editorType:e.editorType??"text",formatter:e.formatter??(t=>t.value&&typeof t.value=="object"?String(t.value.text??""):String(t.value??""))}),cell:de},{id:"button",label:"Button",description:"A button in every row that opens a link made from the row.",icon:a.button,group:"basic",width:120,defaults:{label:"Open",color:"#2d7ff9"},properties:[{key:"label",label:"Label",kind:"text",placeholder:"Open"},{key:"color",label:"Style",kind:"color",palette:N},{key:"url",label:"URL",kind:"text",placeholder:"https://example.com/orders/{Order id}",hint:"Use {Field name} for that field's value in the row. An app can set fieldProps.onClick instead."}],fill:(e,t,l)=>({...e,...d(e),sortable:e.sortable??!1,__fieldNames:ee(l.columns)}),cell:ue},{id:"number",label:"Number",description:"A number: whole, decimal, an amount of money or a percentage.",icon:a.number,group:"number",width:120,defaults:{format:"decimal",precision:1,separators:"local",showThousands:!0,abbreviation:"none",allowNegative:!0,symbol:"$",symbolPosition:"before",showBar:!1,points:!1,step:1},properties:[{key:"format",label:"Format",kind:"segmented",choices:[{value:"integer",label:"Integer"},{value:"decimal",label:"Decimal"},{value:"currency",label:"Currency"},{value:"percent",label:"Percent"}],alsoSets:e=>({precision:e==="decimal"?1:e==="currency"?2:0})},{key:"symbol",label:"Currency symbol",kind:"text",placeholder:"$, €, £, ¥, CHF, kr",visible:e=>e.format==="currency"},{key:"symbolPosition",label:"Symbol position",kind:"segmented",visible:e=>e.format==="currency",choices:[{value:"before",label:"Before ($1.00)"},{value:"after",label:"After (1.00 kr)"}]},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>e.format!=="integer"},{key:"step",label:"Spinner step",kind:"number",min:0,hint:"What the editor's arrows and Up / Down add or take away; Shift for ten times as much."},Ie,Pe,{...Oe,visible:e=>e.format!=="percent"},De,{key:"showBar",label:"Show as a progress bar",kind:"checkbox",visible:e=>e.format==="percent"},{key:"points",label:"Values are 0 to 100 (not 0 to 1)",kind:"checkbox",visible:e=>e.format==="percent"},y],fill:(e,t)=>O(e,t,ke("number",t)),cell:V,hasCell:e=>e.format==="percent"&&!!e.showBar},{id:"currency",label:"Currency",description:"An amount, with a currency symbol.",icon:a.currency,group:"number",width:120,defaults:{symbol:"$",symbolPosition:"before",precision:2,separators:"local",showThousands:!0,abbreviation:"none",allowNegative:!0},editAs:{type:"number",props:{format:"currency"}},fill:(e,t)=>O(e,t,"currency")},{id:"percent",label:"Percent",description:"A share, shown with a percent sign.",icon:a.percent,group:"number",width:110,defaults:{precision:0,separators:"local",showThousands:!0,allowNegative:!0,points:!1},editAs:{type:"number",props:{format:"percent"}},fill:(e,t)=>O(e,t,"percent"),cell:V,hasCell:e=>!!e.showBar},{id:"duration",label:"Duration",description:"A length of time, typed as 1:30 or 1h 30m.",icon:a.duration,group:"number",width:110,defaults:{durationFormat:"h:mm"},properties:[{key:"durationFormat",label:"Duration format",kind:"choice",choices:[{value:"h:mm",label:"h:mm"},{value:"h:mm:ss",label:"h:mm:ss"},{value:"h:mm:ss.S",label:"h:mm:ss.S"},{value:"h:mm:ss.SS",label:"h:mm:ss.SS"},{value:"h:mm:ss.SSS",label:"h:mm:ss.SSS"}]}],fill:(e,t)=>({...e,cellDataType:e.cellDataType??"number",editorType:e.editorType??"fieldNumber",formatter:e.formatter??(l=>{const r=b(l.value);return r==null?"":ye(r,t.durationFormat)}),valueParser:e.valueParser??(l=>typeof l.rawInput=="string"?l.rawInput.trim()?G(l.rawInput)??l.oldValue:null:typeof l.newValue=="number"?l.newValue:G(l.newValue))})},{id:"rating",label:"Rating",description:"One to ten stars, hearts, thumbs, flags or dots.",icon:a.rating,group:"number",width:130,defaults:{max:5,icon:"star",color:"#fcb400"},properties:[{key:"icon",label:"Icon",kind:"icon",icons:ve},{key:"color",label:"Color",kind:"color",palette:N},{key:"max",label:"Maximum",kind:"choice",choices:Array.from({length:10},(e,t)=>({value:String(t+1),label:String(t+1)}))}],fill:e=>({...e,cellDataType:e.cellDataType??"number",align:e.align??"left",editorType:e.editorType??"fieldRating"}),cell:ne},{id:"formula",label:"Formula",description:"A value computed from the row's other fields.",icon:a.formula,group:"computed",width:160,defaults:{formula:"",result:"auto"},properties:[{key:"formula",label:"Formula",kind:"formula"},{key:"result",label:"Format the result as",kind:"choice",choices:[{value:"auto",label:"As computed"},{value:"number",label:"Number"},{value:"currency",label:"Currency"},{value:"percent",label:"Percent"},{value:"date",label:"Date"}]},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>["number","currency","percent"].includes(e.result)},{key:"symbol",label:"Currency symbol",kind:"text",placeholder:"$",visible:e=>e.result==="currency"},{...v,visible:e=>e.result==="date"}],fill:(e,t,l)=>{const r=ee(l.columns),i=String(t.formula??""),o=String(e.field??e.id),n=new Set([o.toLowerCase(),typeof e.header=="string"?e.header.trim().toLowerCase():""].filter(Boolean)),m=s=>{const p=s.trim().toLowerCase(),f=r[p]??null;if(f===o||f==null&&n.has(p))throw Te(s);return f};let c=null;try{c=i.trim()?Me(i,m).fn:()=>null}catch{c=null}let u=null;const oe=()=>{if(u)return u;u=new Map;for(const s of l.columns){if(!Le.has(String(s.fieldType))||String(s.field??s.id)===o)continue;const p=B(s,l.columns);typeof p.fieldFn=="function"&&u.set(String(s.field??s.id),p.fieldFn)}return u},ae=s=>{const p=oe();return!p.size||!s?s:new Proxy(s,{get:(f,S)=>{const x=typeof S=="string"?p.get(S):void 0;if(!x||h>3)return f[S];h+=1;try{return x(f)}finally{h-=1}}})};return{...e,...d(e),fieldFn:s=>c?c(ae(s)):"#ERROR",align:e.align??(["number","currency","percent"].includes(t.result)?"right":void 0),formatter:e.formatter??(s=>te(s.value,t))}}},{id:"createdTime",label:"Created time",description:"When the row was added. Set automatically.",icon:a.createdTime,group:"computed",width:170,defaults:{dateFormat:"local",time:!0,timeFormat:"12hour"},properties:[v,...I],fill:(e,t)=>({...e,...d(e),formatter:e.formatter??D(t)}),newRowValue:()=>M(),onCreate:({rows:e})=>e.map(()=>M())},{id:"lastModifiedTime",label:"Last modified time",description:"When the row last changed. Set automatically.",icon:a.modifiedTime,group:"computed",width:170,defaults:{dateFormat:"local",time:!0,timeFormat:"12hour",watch:"all"},properties:[...ie,v,...I],fill:(e,t)=>({...e,...d(e),formatter:e.formatter??D(t)}),newRowValue:()=>M()},{id:"createdBy",label:"Created by",description:"Who added the row. Set automatically.",icon:a.createdBy,group:"computed",width:160,fill:e=>({...e,...d(e),formatter:e.formatter??(t=>R(t.value))}),newRowValue:()=>W()?.id??null,cell:A},{id:"lastModifiedBy",label:"Last modified by",description:"Who last changed the row. Set automatically.",icon:a.modifiedBy,group:"computed",width:160,defaults:{watch:"all"},properties:ie,fill:e=>({...e,...d(e),formatter:e.formatter??(t=>R(t.value))}),newRowValue:()=>W()?.id??null,cell:A},{id:"autoNumber",label:"Autonumber",description:"A number every row gets, counting up. Set automatically.",icon:a.autoNumber,group:"computed",width:100,fill:e=>({...e,...d(e),cellDataType:e.cellDataType??"number"}),newRowValue:({rows:e,field:t})=>e.reduce((l,r)=>Math.max(l,Number(r?.[t])||0),0)+1,onCreate:({rows:e})=>e.map((t,l)=>l+1)},{id:"link",label:"Link to records",description:"Rows of another table this row points at.",icon:a.link,group:"relation",width:200,defaults:{multiple:!0},properties:[{key:"table",label:"Table",kind:"choice",choices:()=>Ce().map(e=>({value:e.id,label:e.name})),hint:"The table gets a field that links back to this one."},{key:"multiple",label:"Allow linking to multiple records",kind:"checkbox"}],fill:(e,t)=>({...e,editorType:e.editorType??"fieldLink",formatter:e.formatter??(l=>{const r=k(t.table);return w(r,l.value).map(i=>String(i[r.primaryField]??"")).join(", ")}),valueParser:e.valueParser??He(t)}),cell:me},{id:"lookup",label:"Lookup",description:"A field of the linked rows, shown here.",icon:a.lookup,group:"relation",width:180,properties:[P,q],fill:(e,t,l)=>{const r=U(t,l),i=o=>{const n=re(r,t.field);return String(n?n({value:o})??"":o)};return{...e,...d(e),fieldFn:o=>{if(!r)return[];const n=Y(r.table,String(t.field));return w(r.table,o?.[r.key]).map(n)},formatter:e.formatter??(o=>Array.isArray(o.value)?o.value.filter(n=>n!=null&&n!=="").map(i).join(", "):o.value==null?"":i(o.value))}}},{id:"rollup",label:"Rollup",description:"A summary of a field over the linked rows (a sum, a count, a list).",icon:a.rollup,group:"relation",width:140,defaults:{aggregation:"SUM"},properties:[P,q,{key:"aggregation",label:"Aggregation",kind:"choice",choices:Object.keys(E).map(e=>({value:e,label:e}))},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>["SUM","AVERAGE","MIN","MAX"].includes(e.aggregation)}],fill:(e,t,l)=>{const r=U(t,l),i=E[String(t.aggregation)]??E.SUM,o=["SUM","AVERAGE","MIN","MAX","COUNT","COUNTA","COUNTALL"].includes(String(t.aggregation)),n=["SUM","AVERAGE","MIN","MAX"].includes(String(t.aggregation))&&t.precision==null,m=c=>{const u=n?re(r,t.field):void 0;return u?String(u({value:c})??""):F(c,{precision:J(t,0)})};return{...e,...d(e),...o?{cellDataType:e.cellDataType??"number"}:{},align:e.align??(o?"right":void 0),fieldFn:c=>{if(!r)return null;const u=Y(r.table,String(t.field));return i(w(r.table,c?.[r.key]).map(u))},formatter:e.formatter??(c=>typeof c.value=="number"?m(c.value):String(c.value??""))}}},{id:"count",label:"Count",description:"How many rows a link field points at.",icon:a.count,group:"relation",width:90,properties:[P],fill:(e,t,l)=>{const r=U(t,l);return{...e,...d(e),cellDataType:e.cellDataType??"number",fieldFn:i=>r?w(r.table,i?.[r.key]).length:0}}}];
1
+ import{fillFieldColumn as x}from"./registry.svelte.js";import ce from"./RatingCell.svelte";import T from"./LinkCell.svelte";import de from"./AttachmentCell.svelte";import me from"./CheckboxCell.svelte";import z from"./PercentCell.svelte";import A from"./UserCell.svelte";import fe from"./ButtonCell.svelte";import pe from"./BarcodeCell.svelte";import he from"./LinkedRecordsCell.svelte";import be from"./RichTextCell.svelte";import _ from"./SelectCell.svelte";import ye from"./ChecklistCell.svelte";import ge from"./ColorCell.svelte";import{attachmentsText as ke,parseAttachments as we}from"./attachments.js";import{dateEditTokens as ve,formatCurrency as H,formatDate as C,formatDuration as Me,formatNumber as F,formatPercent as j,numberFieldShape as G,numberFromText as Se,numberKind as Te,parseDuration as W,toNumber as b}from"./format.js";import{BRIGHT as P,CHECKBOX_ICONS as Ae,RATING_ICONS as Ce}from"./palette.js";import{compileFormula as Fe,isoDate as Pe,selfReferenceError as Ie}from"./formula.js";import{findFieldUser as Le,getCurrentUser as K,getFieldUsers as $,getLinkedTable as k,linkedRows as w,listLinkedTables as Oe,resolveLinkIds as Ne}from"./sources.svelte.js";import{splitNames as X}from"./name-list.js";import{linkedFields as De}from"./linked-fields.js";import{AI_FIELD_TYPE as Ve}from"./ai-field.svelte.js";import{CHECKLIST_GROUPS as Y,checklistGroup as Re,checklistSortValue as Ee,checklistText as Ue,parseChecklist as Be,toChecklist as xe}from"./checklist.js";import{colorSortValue as ze,parseColor as I}from"./color-value.js";import{formatTimeOfDay as _e,parseTimeOfDay as q,timeSeconds as He}from"./time-of-day.js";const J=new WeakMap;let y=0;const je=new Set(["formula","lookup","rollup","count"]);function Q(e,t){const l=i=>i?.[t];if(!e?.fields?.length)return l;let r=J.get(e.fields);if(r||J.set(e.fields,r=new Map),!r.has(t)){const i=De(e).find(n=>n.def.field===t);r.set(t,i?.def.fieldFn??null)}const o=r.get(t);return o?i=>{if(y>3)return l(i);y+=1;try{return o(i)}finally{y-=1}}:l}const a={text:"M4 6h16M4 12h10M4 18h7",longText:"M4 6h16M4 10h16M4 14h16M4 18h10",number:"M9 4 7 20M17 4l-2 16M4 9h16M3 15h16",currency:"M12 3v18M16 7.5C16 5.6 14.2 4.5 12 4.5S8 5.6 8 7.5s1.8 2.7 4 3.5 4 1.6 4 3.5-1.8 3-4 3-4-1.1-4-3",percent:"M19 5 5 19M7 7h.01M17 17h.01",date:"M4 6h16v14H4zM4 10h16M8 3v4M16 3v4",duration:"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zM12 8v4l3 2",checkbox:"M4 4h16v16H4zM8 12l3 3 5-6",singleSelect:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM8 11l4 4 4-4",multiSelect:"M3 7h11M3 12h11M3 17h11M17 6l2 2 3-3M17 16l2 2 3-3",rating:"M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3 6.5 20.2l1-6.2L3 9.6l6.2-.9z",url:"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",email:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2",attachment:"M20 11.5 12.3 19a5 5 0 0 1-7.1-7.1l7.8-7.8a3.3 3.3 0 0 1 4.7 4.7L9.9 16.6a1.7 1.7 0 0 1-2.4-2.4l7.1-7",user:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0",createdTime:"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zM12 8v4h4",modifiedTime:"M4 12a8 8 0 1 0 2.3-5.7M4 4v4h4M12 8v4l3 2",createdBy:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 11-7.5M19 15v6M16 18h6",modifiedBy:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 11-7.5M16 21l5-5-2-2-5 5v2z",autoNumber:"M5 7h3v10M11 9a2 2 0 1 1 4 0c0 2-4 3-4 6h4M18 7h2v10",barcode:"M4 5v14M7 5v14M10 5v14M13 5v14M15 5v14M18 5v14M20 5v14",button:"M4 7h16v10H4zM9 12h6",formula:"M7 20c2 0 2.5-2 3-5l2-10c.5-2 1.5-2 3-2M8 9h7",link:"M9 7H6a5 5 0 0 0 0 10h3M15 7h3a5 5 0 0 1 0 10h-3M8 12h8",lookup:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM20 20l-4-4M8 11h6",rollup:"M6 4h12L12 12l6 8H6",count:"M5 5h14v14H5zM9 9v6M12 9v6M15 9v6",checklist:"M3.5 6l1.5 1.5L7.5 5M3.5 12l1.5 1.5 2.5-2.5M3.5 18l1.5 1.5 2.5-2.5M11 6h9M11 12h9M11 18h9",color:"M12 3a9 9 0 1 0 0 18c1 0 1.6-.7 1.6-1.6 0-1-.8-1.4-.8-2.3 0-1 .8-1.7 1.8-1.7H17a4 4 0 0 0 4-4C21 6.6 17 3 12 3zM7.5 12h.01M9.5 7.5h.01M14.5 7.5h.01",timeOfDay:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 7v5l-3 2M12 3v2M21 12h-2M12 21v-2M3 12h2"},Ge={key:"separators",label:"Separators",kind:"choice",choices:[{value:"local",label:"Local"},{value:"comma-period",label:"1,000,000.00"},{value:"period-comma",label:"1.000.000,00"},{value:"space-comma",label:"1 000 000,00"},{value:"space-period",label:"1 000 000.00"}]},We={key:"showThousands",label:"Show thousands separator",kind:"checkbox"},Ke={key:"abbreviation",label:"Large number abbreviation",kind:"choice",choices:[{value:"none",label:"None"},{value:"thousand",label:"Thousand (K)"},{value:"million",label:"Million (M)"},{value:"billion",label:"Billion (B)"}]},$e={key:"allowNegative",label:"Allow negative numbers",kind:"checkbox"},p={key:"default",label:"Default value",kind:"default",hint:"New rows start with this value."},L=(e,t)=>Array.from({length:t-e+1},(l,r)=>{const o=e+r;return{value:String(o),label:o===0?"1":`1.${"0".repeat(o)}`}}),v={key:"dateFormat",label:"Date format",kind:"choice",choices:[{value:"local",label:"Local"},{value:"friendly",label:"Friendly (October 14, 2026)"},{value:"us",label:"US (10/14/2026)"},{value:"european",label:"European (14/10/2026)"},{value:"iso",label:"ISO (2026-10-14)"}]},O=[{key:"time",label:"Include time",kind:"checkbox"},{key:"timeFormat",label:"Time format",kind:"segmented",choices:[{value:"12hour",label:"12 hour"},{value:"24hour",label:"24 hour"}],visible:e=>!!e.time},{key:"gmt",label:"Use the same time zone (GMT) for everyone",kind:"checkbox",visible:e=>!!e.time},{key:"showTimeZone",label:"Display time zone",kind:"checkbox",visible:e=>!!e.time}],Xe=e=>e.columns.filter(t=>t.fieldType==="link").map(t=>({value:String(t.id??t.field),label:String(t.header??t.field)})),N={key:"linkField",label:"Link field",kind:"choice",choices:Xe,hint:"A link-to-records field of this table."},Ye=e=>{const t=e.columns.find(o=>String(o.id??o.field)===e.props.linkField),l=k(t?.fieldProps?.table);return l?(l.fields??[{field:l.primaryField,header:l.primaryField}]).map(o=>({value:o.field,label:o.header})):[]},Z={key:"field",label:"Field in the linked table",kind:"choice",choices:Ye,visible:e=>!!e.linkField},ee=(e,t=0)=>{const l=Number(e.precision);return Number.isInteger(l)&&l>=0&&l<=8?l:t},qe=e=>({precision:e.format==="integer"?0:ee(e,e.format==="decimal"?1:0),separators:e.separators,showThousands:e.showThousands!==!1,abbreviation:e.abbreviation}),Je=(e,t)=>l=>{const r=typeof l.rawInput=="string"?l.rawInput:l.newValue;if(typeof r=="number"||r==null)return r;if(String(r).trim()==="")return null;const o=Se(String(r),e,t);return o??l.oldValue},Qe=(e,t)=>t.allowNegative===!1&&!e.validate?{rejectInvalid:!0,validate:l=>Number(l.value)<0?"Negative numbers are not allowed":null}:{},Ze=(e,t)=>{const l={precision:G(e,t).places,separators:t.separators,showThousands:t.showThousands!==!1,abbreviation:e==="percent"?void 0:t.abbreviation};return r=>{const o=b(r.value);return o==null?"":e==="currency"?H(o,{...l,symbol:t.symbol,symbolPosition:t.symbolPosition}):e==="percent"?j(o,{...l,points:t.points}):F(o,l)}},D=(e,t,l)=>({...e,cellDataType:e.cellDataType??"number",editorType:e.editorType??"fieldNumber",align:e.align??(l==="percent"&&t.showBar?"left":"right"),...Qe(e,t),valueParser:e.valueParser??Je(l,t),formatter:e.formatter??Ze(l,t)}),g=e=>Array.isArray(e.options)?e.options.map(t=>({value:t.value,label:t.label??String(t.value),...t.color?{color:t.color}:{}})):[],te=(e,t)=>{const l=new Map;for(const o of g(e))l.set(String(o.value).toLowerCase(),o.value),l.set(String(o.label).toLowerCase(),o.value);const r=o=>l.get(o.toLowerCase())??o;return o=>{if(typeof o.rawInput!="string")return o.newValue;const i=o.rawInput.split(t?",":/\n/).map(n=>n.trim()).filter(Boolean);return t?[...new Set(i.map(r))]:i.length?r(i[0]):null}},le=e=>{const t=new Map(g(e).map(l=>[String(l.value),l.label]));return l=>(Array.isArray(l.value)?l.value:l.value==null||l.value===""?[]:[l.value]).map(r=>t.get(String(r))??String(r)).join(", ")},et=e=>{const t=new Map(g(e).map((l,r)=>[String(l.value),r]));return l=>l==null||l===""?null:t.get(String(l))??t.size},re=e=>{const t={};for(const l of e){const r=String(l.field??l.id??"");r&&(t[r.toLowerCase()]=r,typeof l.header=="string"&&(t[l.header.trim().toLowerCase()]=r))}return t},d=e=>({editable:e.editable??!1}),V=e=>t=>C(t.value,e),R=e=>(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(t=>Le(t)?.name??String(t)).join(", "),tt=e=>t=>{if(typeof t.rawInput!="string")return t.newValue;const l=$(),r=i=>{const n=i.toLowerCase();return l.find(m=>m.id.toLowerCase()===n||m.name.toLowerCase()===n||m.email?.toLowerCase()===n)?.id??i},o=e?X(t.rawInput):t.rawInput.split(/\n/).map(i=>i.trim()).filter(Boolean);return e?[...new Set(o.map(r))]:o.length?r(o[0]):null},lt=e=>t=>{if(typeof t.rawInput!="string")return t.newValue;const l=k(e.table);if(!l)return t.newValue;const r=Ne(l,X(t.rawInput));return e.multiple===!1?r.slice(0,1):r},rt=e=>typeof e.rawInput=="string"?e.rawInput.trim()?Be(e.rawInput):null:Array.isArray(e.newValue)?xe(e.newValue):e.newValue??null,ot=e=>{const t=typeof e.rawInput=="string"?e.rawInput:e.newValue;return t==null||String(t).trim()===""?null:I(t)??e.oldValue},it=e=>t=>{const l=typeof t.rawInput=="string"?t.rawInput:t.newValue;return l==null||typeof l=="string"&&l.trim()===""?null:q(l,{seconds:!!e.showSeconds})??t.oldValue};function oe(e,t){if(e==null)return"";if(Array.isArray(e))return e.map(l=>oe(l,t)).join(", ");if(e instanceof Date)return C(e,t);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"){if(t.result==="currency"||t.result==="percent"||t.result==="number"){const l=t.result,r={...qe(t),precision:G(l,{precision:t.precision}).places};return l==="currency"?H(e,{...r,symbol:t.symbol}):l==="percent"?j(e,r):F(e,r)}return String(Math.round(e*1e10)/1e10)}if(t.result==="date"){const l=Pe(String(e));if(l)return C(l,t)}return String(e)}const E={SUM:e=>e.reduce((t,l)=>t+(b(l)??0),0),AVERAGE:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?t.reduce((l,r)=>l+r,0)/t.length:null},MIN:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?Math.min(...t):null},MAX:e=>{const t=e.map(b).filter(l=>l!=null);return t.length?Math.max(...t):null},COUNT:e=>e.filter(t=>typeof t=="number").length,COUNTA:e=>e.filter(t=>t!=null&&t!=="").length,COUNTALL:e=>e.length,ARRAYJOIN:e=>e.filter(t=>t!=null&&t!=="").map(String).join(", "),ARRAYUNIQUE:e=>[...new Set(e.filter(t=>t!=null&&t!=="").map(String))].join(", "),CONCATENATE:e=>e.map(t=>t==null?"":String(t)).join(""),AND:e=>e.every(Boolean),OR:e=>e.some(Boolean)},U=(e,t)=>{const l=t.columns.find(o=>String(o.id??o.field)===e.linkField);if(!l)return null;const r=l.fieldProps?.table;return{key:String(l.field??l.id),get table(){return k(r)}}},ie=new WeakMap;function ae(e,t){const l=e?.table?.fields;if(!l)return;let r=ie.get(l);r||ie.set(l,r=new Map);const o=String(t);if(r.has(o))return r.get(o);const i=l.find(m=>m.field===o),n=i?.fieldType?x({field:i.field,fieldType:i.fieldType,fieldProps:i.fieldProps}).formatter:void 0;return r.set(o,n),n}const M=()=>new Date().toISOString(),at=(e,t)=>{const l=r=>r?Y.indexOf(r):Y.length;return l(e)-l(t)},ne=[{key:"watch",label:"Changes to",kind:"segmented",choices:[{value:"all",label:"All fields"},{value:"specific",label:"Specific fields"}]},{key:"watchFields",label:"Fields",kind:"columns",visible:e=>e.watch==="specific"}];export const BUILTIN_FIELD_TYPES=[{id:"text",label:"Single line text",description:"A short line of text, like a name or a title.",icon:a.text,group:"basic",properties:[p],fill:e=>({...e,editorType:e.editorType??"text"})},{id:"longText",label:"Long text",description:"Several lines of text; Alt+Enter starts a new line.",icon:a.longText,group:"basic",width:260,properties:[{key:"richText",label:"Enable rich text formatting",kind:"checkbox",hint:"**bold**, *italic*, `code`, [links](https://...) and lists."}],fill:e=>({...e,editorType:e.editorType??"fieldLongText"}),cell:be,hasCell:e=>!!e.richText},{id:"attachment",label:"Attachment",description:"Images and files: thumbnails in the cell, a dialog to add more.",icon:a.attachment,group:"basic",width:180,defaults:{maxFiles:20},properties:[{key:"accept",label:"Accepted types",kind:"text",placeholder:"image/*,.pdf (any when empty)"},{key:"maxFiles",label:"Most files per cell",kind:"number",min:1,max:100}],fill:(e,t)=>({...e,editorType:e.editorType??"attachment",formatter:e.formatter??(l=>ke(l.value)),valueParser:e.valueParser??(l=>we(l.newValue,t))}),cell:de},{id:"checkbox",label:"Checkbox",description:"Done or not done: one click to toggle.",icon:a.checkbox,group:"basic",width:90,defaults:{icon:"check",color:"#20c933"},properties:[{key:"icon",label:"Icon",kind:"icon",icons:Ae},{key:"color",label:"Color",kind:"color",palette:P},p],fill:e=>({...e,editorType:e.editorType??"checkbox",align:e.align??"center"}),cell:me},{id:"singleSelect",label:"Single select",description:"One choice from a list of colored options.",icon:a.singleSelect,group:"basic",width:140,defaults:{options:[]},properties:[{key:"options",label:"Options",kind:"options"},p],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",editorOptions:e.editorOptions??g(t),formatter:e.formatter??le(t),valueParser:e.valueParser??te(t,!1),sortValue:e.sortValue??et(t)}),cell:_},{id:"multiSelect",label:"Multiple select",description:"Any number of choices from a list of colored options.",icon:a.multiSelect,group:"basic",width:200,defaults:{options:[]},properties:[{key:"options",label:"Options",kind:"options"},p],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",editorMultiple:e.editorMultiple??!0,editorOptions:e.editorOptions??g(t),formatter:e.formatter??le(t),valueParser:e.valueParser??te(t,!0)}),cell:_},{id:"user",label:"User",description:"A person (or several) from the people the app lists.",icon:a.user,group:"basic",width:170,properties:[{key:"multiple",label:"Allow adding multiple users",kind:"checkbox"},p],fill:(e,t)=>({...e,editorType:e.editorType??"fieldSelect",valueParser:e.valueParser??tt(!!t.multiple),editorMultiple:e.editorMultiple??!!t.multiple,editorOptions:e.editorOptions??$().map(l=>({value:l.id,label:l.name})),formatter:e.formatter??(l=>R(l.value))}),cell:A},{id:"date",label:"Date",description:"A calendar date, with or without the time.",icon:a.date,group:"basic",width:150,defaults:{dateFormat:"local",timeFormat:"12hour"},properties:[v,...O,{key:"defaultToday",label:"Default to today",kind:"checkbox"}],fill:(e,t)=>({...e,cellDataType:e.cellDataType??(t.time?"date":"dateString"),editorType:e.editorType??(t.time?"datetime":"date"),editorFormatString:e.editorFormatString??ve(t),formatter:e.formatter??V(t)}),newRowValue:({props:e})=>e.defaultToday?e.time?M():new Date().toISOString().slice(0,10):void 0},{id:"phone",label:"Phone number",description:"A phone number, shown as a tel link.",icon:a.phone,group:"basic",fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"email",label:"Email",description:"An email address, shown as a mailto link.",icon:a.email,group:"basic",width:200,fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"url",label:"URL",description:"A web address, shown as a link.",icon:a.url,group:"basic",width:200,fill:e=>({...e,editorType:e.editorType??"text"}),cell:T},{id:"barcode",label:"Barcode",description:"A barcode's text, from a scanner or typed.",icon:a.barcode,group:"basic",width:160,fill:e=>({...e,editorType:e.editorType??"text",formatter:e.formatter??(t=>t.value&&typeof t.value=="object"?String(t.value.text??""):String(t.value??""))}),cell:pe},{id:"button",label:"Button",description:"A button in every row that opens a link made from the row.",icon:a.button,group:"basic",width:120,defaults:{label:"Open",color:"#2d7ff9"},properties:[{key:"label",label:"Label",kind:"text",placeholder:"Open"},{key:"color",label:"Style",kind:"color",palette:P},{key:"url",label:"URL",kind:"text",placeholder:"https://example.com/orders/{Order id}",hint:"Use {Field name} for that field's value in the row. An app can set fieldProps.onClick instead."}],fill:(e,t,l)=>({...e,...d(e),sortable:e.sortable??!1,__fieldNames:re(l.columns)}),cell:fe},{id:"checklist",label:"Checklist",description:"A list of to-dos; the cell shows how many are done.",icon:a.checklist,group:"basic",width:150,fill:e=>({...e,editorType:e.editorType??"fieldChecklist",formatter:e.formatter??(t=>Ue(t.value)),valueParser:e.valueParser??rt,sortValue:e.sortValue??Ee,groupValue:e.groupValue??Re,groupOrder:e.groupOrder??at}),cell:ye},{id:"color",label:"Color",description:"A color from the palette, or any hex code.",icon:a.color,group:"basic",width:130,properties:[p],fill:e=>({...e,editorType:e.editorType??"fieldColor",formatter:e.formatter??(t=>I(t.value)??String(t.value??"")),valueParser:e.valueParser??ot,sortValue:e.sortValue??ze}),newRowValue:({props:e})=>e.default==null||e.default===""?void 0:I(e.default),cell:ge},{id:"number",label:"Number",description:"A number: whole, decimal, an amount of money or a percentage.",icon:a.number,group:"number",width:120,defaults:{format:"decimal",precision:1,separators:"local",showThousands:!0,abbreviation:"none",allowNegative:!0,symbol:"$",symbolPosition:"before",showBar:!1,points:!1,step:1},properties:[{key:"format",label:"Format",kind:"segmented",choices:[{value:"integer",label:"Integer"},{value:"decimal",label:"Decimal"},{value:"currency",label:"Currency"},{value:"percent",label:"Percent"}],alsoSets:e=>({precision:e==="decimal"?1:e==="currency"?2:0})},{key:"symbol",label:"Currency symbol",kind:"text",placeholder:"$, €, £, ¥, CHF, kr",visible:e=>e.format==="currency"},{key:"symbolPosition",label:"Symbol position",kind:"segmented",visible:e=>e.format==="currency",choices:[{value:"before",label:"Before ($1.00)"},{value:"after",label:"After (1.00 kr)"}]},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>e.format!=="integer"},{key:"step",label:"Spinner step",kind:"number",min:0,hint:"What the editor's arrows and Up / Down add or take away; Shift for ten times as much."},Ge,We,{...Ke,visible:e=>e.format!=="percent"},$e,{key:"showBar",label:"Show as a progress bar",kind:"checkbox",visible:e=>e.format==="percent"},{key:"points",label:"Values are 0 to 100 (not 0 to 1)",kind:"checkbox",visible:e=>e.format==="percent"},p],fill:(e,t)=>D(e,t,Te("number",t)),cell:z,hasCell:e=>e.format==="percent"&&!!e.showBar},{id:"currency",label:"Currency",description:"An amount, with a currency symbol.",icon:a.currency,group:"number",width:120,defaults:{symbol:"$",symbolPosition:"before",precision:2,separators:"local",showThousands:!0,abbreviation:"none",allowNegative:!0},editAs:{type:"number",props:{format:"currency"}},fill:(e,t)=>D(e,t,"currency")},{id:"percent",label:"Percent",description:"A share, shown with a percent sign.",icon:a.percent,group:"number",width:110,defaults:{precision:0,separators:"local",showThousands:!0,allowNegative:!0,points:!1},editAs:{type:"number",props:{format:"percent"}},fill:(e,t)=>D(e,t,"percent"),cell:z,hasCell:e=>!!e.showBar},{id:"duration",label:"Duration",description:"A length of time, typed as 1:30 or 1h 30m.",icon:a.duration,group:"number",width:110,defaults:{durationFormat:"h:mm"},properties:[{key:"durationFormat",label:"Duration format",kind:"choice",choices:[{value:"h:mm",label:"h:mm"},{value:"h:mm:ss",label:"h:mm:ss"},{value:"h:mm:ss.S",label:"h:mm:ss.S"},{value:"h:mm:ss.SS",label:"h:mm:ss.SS"},{value:"h:mm:ss.SSS",label:"h:mm:ss.SSS"}]}],fill:(e,t)=>({...e,cellDataType:e.cellDataType??"number",editorType:e.editorType??"fieldNumber",formatter:e.formatter??(l=>{const r=b(l.value);return r==null?"":Me(r,t.durationFormat)}),valueParser:e.valueParser??(l=>typeof l.rawInput=="string"?l.rawInput.trim()?W(l.rawInput)??l.oldValue:null:typeof l.newValue=="number"?l.newValue:W(l.newValue))})},{id:"timeOfDay",label:"Time of day",description:"A time on the clock with no date, typed as 9:30 am, 14:05 or 2pm.",icon:a.timeOfDay,group:"number",width:120,defaults:{timeFormat:"12hour",showSeconds:!1},properties:[{key:"timeFormat",label:"Time format",kind:"segmented",choices:[{value:"12hour",label:"12 hour"},{value:"24hour",label:"24 hour"}]},{key:"showSeconds",label:"Show seconds",kind:"checkbox"},p],fill:(e,t)=>({...e,editorType:e.editorType??"fieldTime",formatter:e.formatter??(l=>_e(l.value,t)),valueParser:e.valueParser??it(t),sortValue:e.sortValue??He}),newRowValue:({props:e})=>e.default==null||e.default===""?void 0:q(e.default,{seconds:!!e.showSeconds})},{id:"rating",label:"Rating",description:"One to ten stars, hearts, thumbs, flags or dots.",icon:a.rating,group:"number",width:130,defaults:{max:5,icon:"star",color:"#fcb400"},properties:[{key:"icon",label:"Icon",kind:"icon",icons:Ce},{key:"color",label:"Color",kind:"color",palette:P},{key:"max",label:"Maximum",kind:"choice",choices:Array.from({length:10},(e,t)=>({value:String(t+1),label:String(t+1)}))}],fill:e=>({...e,cellDataType:e.cellDataType??"number",align:e.align??"left",editorType:e.editorType??"fieldRating"}),cell:ce},{id:"formula",label:"Formula",description:"A value computed from the row's other fields.",icon:a.formula,group:"computed",width:160,defaults:{formula:"",result:"auto"},properties:[{key:"formula",label:"Formula",kind:"formula"},{key:"result",label:"Format the result as",kind:"choice",choices:[{value:"auto",label:"As computed"},{value:"number",label:"Number"},{value:"currency",label:"Currency"},{value:"percent",label:"Percent"},{value:"date",label:"Date"}]},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>["number","currency","percent"].includes(e.result)},{key:"symbol",label:"Currency symbol",kind:"text",placeholder:"$",visible:e=>e.result==="currency"},{...v,visible:e=>e.result==="date"}],fill:(e,t,l)=>{const r=re(l.columns),o=String(t.formula??""),i=String(e.field??e.id),n=new Set([i.toLowerCase(),typeof e.header=="string"?e.header.trim().toLowerCase():""].filter(Boolean)),m=s=>{const f=s.trim().toLowerCase(),h=r[f]??null;if(h===i||h==null&&n.has(f))throw Ie(s);return h};let u=null;try{u=o.trim()?Fe(o,m).fn:()=>null}catch{u=null}let c=null;const se=()=>{if(c)return c;c=new Map;for(const s of l.columns){if(!je.has(String(s.fieldType))||String(s.field??s.id)===i)continue;const f=x(s,l.columns);typeof f.fieldFn=="function"&&c.set(String(s.field??s.id),f.fieldFn)}return c},ue=s=>{const f=se();return!f.size||!s?s:new Proxy(s,{get:(h,S)=>{const B=typeof S=="string"?f.get(S):void 0;if(!B||y>3)return h[S];y+=1;try{return B(h)}finally{y-=1}}})};return{...e,...d(e),fieldFn:s=>u?u(ue(s)):"#ERROR",align:e.align??(["number","currency","percent"].includes(t.result)?"right":void 0),formatter:e.formatter??(s=>oe(s.value,t))}}},{id:"createdTime",label:"Created time",description:"When the row was added. Set automatically.",icon:a.createdTime,group:"computed",width:170,defaults:{dateFormat:"local",time:!0,timeFormat:"12hour"},properties:[v,...O],fill:(e,t)=>({...e,...d(e),formatter:e.formatter??V(t)}),newRowValue:()=>M(),onCreate:({rows:e})=>e.map(()=>M())},{id:"lastModifiedTime",label:"Last modified time",description:"When the row last changed. Set automatically.",icon:a.modifiedTime,group:"computed",width:170,defaults:{dateFormat:"local",time:!0,timeFormat:"12hour",watch:"all"},properties:[...ne,v,...O],fill:(e,t)=>({...e,...d(e),formatter:e.formatter??V(t)}),newRowValue:()=>M()},{id:"createdBy",label:"Created by",description:"Who added the row. Set automatically.",icon:a.createdBy,group:"computed",width:160,fill:e=>({...e,...d(e),formatter:e.formatter??(t=>R(t.value))}),newRowValue:()=>K()?.id??null,cell:A},{id:"lastModifiedBy",label:"Last modified by",description:"Who last changed the row. Set automatically.",icon:a.modifiedBy,group:"computed",width:160,defaults:{watch:"all"},properties:ne,fill:e=>({...e,...d(e),formatter:e.formatter??(t=>R(t.value))}),newRowValue:()=>K()?.id??null,cell:A},{id:"autoNumber",label:"Autonumber",description:"A number every row gets, counting up. Set automatically.",icon:a.autoNumber,group:"computed",width:100,fill:e=>({...e,...d(e),cellDataType:e.cellDataType??"number"}),newRowValue:({rows:e,field:t})=>e.reduce((l,r)=>Math.max(l,Number(r?.[t])||0),0)+1,onCreate:({rows:e})=>e.map((t,l)=>l+1)},{id:"link",label:"Link to records",description:"Rows of another table this row points at.",icon:a.link,group:"relation",width:200,defaults:{multiple:!0},properties:[{key:"table",label:"Table",kind:"choice",choices:()=>Oe().map(e=>({value:e.id,label:e.name})),hint:"The table gets a field that links back to this one."},{key:"multiple",label:"Allow linking to multiple records",kind:"checkbox"}],fill:(e,t)=>({...e,editorType:e.editorType??"fieldLink",formatter:e.formatter??(l=>{const r=k(t.table);return w(r,l.value).map(o=>String(o[r.primaryField]??"")).join(", ")}),valueParser:e.valueParser??lt(t)}),cell:he},{id:"lookup",label:"Lookup",description:"A field of the linked rows, shown here.",icon:a.lookup,group:"relation",width:180,properties:[N,Z],fill:(e,t,l)=>{const r=U(t,l),o=i=>{const n=ae(r,t.field);return String(n?n({value:i})??"":i)};return{...e,...d(e),fieldFn:i=>{if(!r)return[];const n=Q(r.table,String(t.field));return w(r.table,i?.[r.key]).map(n)},formatter:e.formatter??(i=>Array.isArray(i.value)?i.value.filter(n=>n!=null&&n!=="").map(o).join(", "):i.value==null?"":o(i.value))}}},{id:"rollup",label:"Rollup",description:"A summary of a field over the linked rows (a sum, a count, a list).",icon:a.rollup,group:"relation",width:140,defaults:{aggregation:"SUM"},properties:[N,Z,{key:"aggregation",label:"Aggregation",kind:"choice",choices:Object.keys(E).map(e=>({value:e,label:e}))},{key:"precision",label:"Precision",kind:"choice",choices:L(0,8),visible:e=>["SUM","AVERAGE","MIN","MAX"].includes(e.aggregation)}],fill:(e,t,l)=>{const r=U(t,l),o=E[String(t.aggregation)]??E.SUM,i=["SUM","AVERAGE","MIN","MAX","COUNT","COUNTA","COUNTALL"].includes(String(t.aggregation)),n=["SUM","AVERAGE","MIN","MAX"].includes(String(t.aggregation))&&t.precision==null,m=u=>{const c=n?ae(r,t.field):void 0;return c?String(c({value:u})??""):F(u,{precision:ee(t,0)})};return{...e,...d(e),...i?{cellDataType:e.cellDataType??"number"}:{},align:e.align??(i?"right":void 0),fieldFn:u=>{if(!r)return null;const c=Q(r.table,String(t.field));return o(w(r.table,u?.[r.key]).map(c))},formatter:e.formatter??(u=>typeof u.value=="number"?m(u.value):String(u.value??""))}}},{id:"count",label:"Count",description:"How many rows a link field points at.",icon:a.count,group:"relation",width:90,properties:[N],fill:(e,t,l)=>{const r=U(t,l);return{...e,...d(e),cellDataType:e.cellDataType??"number",fieldFn:o=>r?w(r.table,o?.[r.key]).length:0}}},Ve];
@@ -30,6 +30,18 @@ export declare const chartYColumns: (ctrl: any) => FieldColumn[];
30
30
  export declare function defaultChart(ctrl: any): ChartSetting | null;
31
31
  /** The chart for `rows` (the records the view shows), or null when its fields are gone. */
32
32
  export declare function chartSpec(ctrl: any, setting: ChartSetting, rows: ReadonlyArray<Row>): ChartSpec | null;
33
+ /**
34
+ * The value axis gutter fits the widest tick as the field writes it
35
+ * ("$1,000,000"); the chart's own default fits its short "1M" style. A pie
36
+ * and a horizontal bar have no such axis.
37
+ */
38
+ export declare function withValueGutter(spec: ChartSpec, formatValue: ((value: number) => string) | undefined): ChartSpec;
33
39
  /** How a value shows on the axis and in tooltips: as the summed field shows it ($48,000), a count as a whole number. */
34
40
  export declare function chartFormatter(ctrl: any, setting: ChartSetting): ((value: number) => string) | undefined;
41
+ /**
42
+ * The rows in one of the chart's buckets: the ones grouped under `category`,
43
+ * the label the chart shows ("Won", "Nov 2026", "Empty"). A row in several
44
+ * buckets (a multiple select, a link) is in each of them.
45
+ */
46
+ export declare function chartBucketRows<R extends Row>(ctrl: any, setting: ChartSetting, rows: ReadonlyArray<R>, category: string): R[];
35
47
  export {};
@@ -1 +1 @@
1
- import{fieldColumns as y}from"./grid-access.js";import{fieldPropsOf as g,originalColumn as b}from"./registry.svelte.js";import{findFieldUser as v,getLinkedTable as D,linkedRows as w}from"./sources.svelte.js";export const CHART_KINDS=[{kind:"bar",label:"Bar"},{kind:"barH",label:"Horizontal bar"},{kind:"line",label:"Line"},{kind:"pie",label:"Pie"},{kind:"donut",label:"Donut"}];const C=new Set(["singleSelect","multiSelect","user","date","checkbox","link","text","rating","createdTime","createdBy","formula","lookup"]),$=new Set(["number","currency","percent","rating","duration","count","rollup"]),E=new Set(["number","currency","percent"]);export const chartXColumns=n=>y(n).filter(r=>C.has(r.fieldType??"")||r.def.cellDataType==="date"||r.def.cellDataType==="dateString"),chartYColumns=n=>y(n).filter(r=>$.has(r.fieldType??"")||r.fieldType==="formula"&&E.has(String(g(b(r.def)).result))||!r.fieldType&&r.def.cellDataType==="number");export function defaultChart(n){const r=chartXColumns(n),o=r.find(l=>l.fieldType==="singleSelect")??r[0];return o?{kind:"bar",x:o.id}:null}const u="Empty",F=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N(n,r){const o=n.def.fieldFn;return o?o(r):r?.[n.field]}function O(n,r){const o=N(n,r),l=Array.isArray(o)?o:o==null||o===""?[]:[o];if(n.fieldType==="checkbox")return[o===!0?"Checked":"Unchecked"];if(!l.length)return[u];if(n.fieldType==="user"||n.fieldType==="createdBy")return l.map(t=>v(t)?.name??String(t));if(n.fieldType==="link"){const t=D(g(b(n.def)).table),i=t?w(t,o).map(e=>String(e[t.primaryField]??"")):[];return i.length?i:[u]}if(n.fieldType==="lookup"){const t=n.def.formatter,i=l.map(e=>String(t?t({value:e})??"":e)).filter(e=>e!=="");return i.length?[...new Set(i)]:[u]}if(n.fieldType==="formula"){const t=g(b(n.def)).result==="date"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString",i=l.map(e=>e instanceof Date?Number.isNaN(e.getTime())?u:`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`:typeof e=="number"?String(Math.round(e*1e10)/1e10):t&&typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,7):String(e));return[...new Set(i)]}if(n.fieldType==="date"||n.fieldType==="createdTime"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString"){const t=String(l[0]),i=/^(\d{4})-(\d{2})/.exec(t);return[i?`${i[1]}-${i[2]}`:t]}return l.map(t=>String(t))}function H(n,r){const o={},l=r.includes(u)?[u]:[],t=r.filter(e=>e!==u);if(n.fieldType==="singleSelect"||n.fieldType==="multiSelect"){const e=g(b(n.def)).options??[],d=new Map(e.map((s,c)=>[String(s.value),c]));for(const s of e)s.color&&(o[String(s.value)]=s.color);return t.sort((s,c)=>(d.get(s)??1e9)-(d.get(c)??1e9)),{keys:[...t,...l],label:s=>s,colors:o}}return t.length>0&&t.every(e=>/^\d{4}-\d{2}$/.test(e))?(t.sort(),{keys:[...t,...l],label:e=>e===u?e:`${F[Number(e.slice(5))-1]} ${e.slice(0,4)}`,colors:o}):(t.length&&t.every(e=>e!==""&&!Number.isNaN(Number(e)))&&t.sort((e,d)=>Number(e)-Number(d)),{keys:[...t,...l],label:e=>e,colors:o})}export function chartSpec(n,r,o){const l=y(n),t=l.find(a=>a.id===r.x);if(!t)return null;const i=r.y?l.find(a=>a.id===r.y):void 0,e=new Map;for(const a of o){if(a==null)continue;const f=i?Number(N(i,a)):1;for(const k of O(t,a)){const S=e.get(k)??{total:0,n:0};(!i||Number.isFinite(f))&&(S.total+=Number.isFinite(f)?f:0,S.n+=1),e.set(k,S)}}const{keys:d,label:s,colors:c}=H(t,[...e.keys()]),T=!!i&&r.aggregation==="avg",M=d.map(a=>{const f=e.get(a);return T?f.n?f.total/f.n:0:f.total}),h=d.map(s),m={};d.forEach((a,f)=>{c[a]&&(m[h[f]]=c[a])});const p=r.kind;return{type:p==="barH"?"bar":p==="donut"?"pie":p,categories:h,series:[{label:i?`${T?"Average":"Sum"} of ${i.header}`:"Records",values:M,...Object.keys(m).length&&(p==="bar"||p==="barH")?{colors:d.map(a=>c[a]??null)}:{}}],...Object.keys(m).length?{categoryColors:m}:{},...p==="barH"?{orientation:"horizontal"}:{},...p==="donut"?{innerRadius:.58}:{}}}export function chartFormatter(n,r){const o=r.y?y(n).find(t=>t.id===r.y):void 0;if(!o)return t=>String(Math.round(t));const l=o.def.formatter;return l?t=>String(l({value:t})??t):void 0}
1
+ import{fieldColumns as m}from"./grid-access.js";import{fieldPropsOf as g,originalColumn as b}from"./registry.svelte.js";import{findFieldUser as x,getLinkedTable as D,linkedRows as C}from"./sources.svelte.js";export const CHART_KINDS=[{kind:"bar",label:"Bar"},{kind:"barH",label:"Horizontal bar"},{kind:"line",label:"Line"},{kind:"pie",label:"Pie"},{kind:"donut",label:"Donut"}];const $=new Set(["singleSelect","multiSelect","user","date","checkbox","link","text","rating","createdTime","createdBy","formula","lookup"]),E=new Set(["number","currency","percent","rating","duration","count","rollup"]),F=new Set(["number","currency","percent"]);export const chartXColumns=n=>m(n).filter(r=>$.has(r.fieldType??"")||r.def.cellDataType==="date"||r.def.cellDataType==="dateString"),chartYColumns=n=>m(n).filter(r=>E.has(r.fieldType??"")||r.fieldType==="formula"&&F.has(String(g(b(r.def)).result))||!r.fieldType&&r.def.cellDataType==="number");export function defaultChart(n){const r=chartXColumns(n),o=r.find(l=>l.fieldType==="singleSelect")??r[0];return o?{kind:"bar",x:o.id}:null}const d="Empty",O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(n,r){const o=n.def.fieldFn;return o?o(r):r?.[n.field]}function N(n,r){const o=M(n,r),l=Array.isArray(o)?o:o==null||o===""?[]:[o];if(n.fieldType==="checkbox")return[o===!0?"Checked":"Unchecked"];if(!l.length)return[d];if(n.fieldType==="user"||n.fieldType==="createdBy")return l.map(e=>x(e)?.name??String(e));if(n.fieldType==="link"){const e=D(g(b(n.def)).table),i=e?C(e,o).map(t=>String(t[e.primaryField]??"")):[];return i.length?i:[d]}if(n.fieldType==="lookup"){const e=n.def.formatter,i=l.map(t=>String(e?e({value:t})??"":t)).filter(t=>t!=="");return i.length?[...new Set(i)]:[d]}if(n.fieldType==="formula"){const e=g(b(n.def)).result==="date"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString",i=l.map(t=>t instanceof Date?Number.isNaN(t.getTime())?d:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`:typeof t=="number"?String(Math.round(t*1e10)/1e10):e&&typeof t=="string"&&/^\d{4}-\d{2}-\d{2}/.test(t)?t.slice(0,7):String(t));return[...new Set(i)]}if(n.fieldType==="date"||n.fieldType==="createdTime"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString"){const e=String(l[0]),i=/^(\d{4})-(\d{2})/.exec(e);return[i?`${i[1]}-${i[2]}`:e]}return l.map(e=>String(e))}function v(n,r){const o={},l=r.includes(d)?[d]:[],e=r.filter(t=>t!==d);if(n.fieldType==="singleSelect"||n.fieldType==="multiSelect"){const t=g(b(n.def)).options??[],a=new Map(t.map((f,c)=>[String(f.value),c]));for(const f of t)f.color&&(o[String(f.value)]=f.color);return e.sort((f,c)=>(a.get(f)??1e9)-(a.get(c)??1e9)),{keys:[...e,...l],label:f=>f,colors:o}}return e.length>0&&e.every(t=>/^\d{4}-\d{2}$/.test(t))?(e.sort(),{keys:[...e,...l],label:t=>t===d?t:`${O[Number(t.slice(5))-1]} ${t.slice(0,4)}`,colors:o}):(e.length&&e.every(t=>t!==""&&!Number.isNaN(Number(t)))&&e.sort((t,a)=>Number(t)-Number(a)),{keys:[...e,...l],label:t=>t,colors:o})}export function chartSpec(n,r,o){const l=m(n),e=l.find(s=>s.id===r.x);if(!e)return null;const i=r.y?l.find(s=>s.id===r.y):void 0,t=new Map;for(const s of o){if(s==null)continue;const u=i?Number(M(i,s)):1;for(const k of N(e,s)){const S=t.get(k)??{total:0,n:0};(!i||Number.isFinite(u))&&(S.total+=Number.isFinite(u)?u:0,S.n+=1),t.set(k,S)}}const{keys:a,label:f,colors:c}=v(e,[...t.keys()]),h=!!i&&r.aggregation==="avg",w=a.map(s=>{const u=t.get(s);return h?u.n?u.total/u.n:0:u.total}),T=a.map(f),y={};a.forEach((s,u)=>{c[s]&&(y[T[u]]=c[s])});const p=r.kind;return{type:p==="barH"?"bar":p==="donut"?"pie":p,categories:T,series:[{label:i?`${h?"Average":"Sum"} of ${i.header}`:"Records",values:w,...Object.keys(y).length&&(p==="bar"||p==="barH")?{colors:a.map(s=>c[s]??null)}:{}}],...Object.keys(y).length?{categoryColors:y}:{},...p==="barH"?{orientation:"horizontal"}:{},...p==="donut"?{innerRadius:.58}:{}}}export function withValueGutter(n,r){if(!r||n.type==="pie"||n.orientation==="horizontal")return n;const o=Math.max(0,...n.series.flatMap(i=>i.values)),l=o>0?10**Math.ceil(Math.log10(o)):1,e=Math.max(48,Math.round(r(l).length*6.4+14));return{...n,yAxis:{width:e}}}export function chartFormatter(n,r){const o=r.y?m(n).find(e=>e.id===r.y):void 0;if(!o)return e=>String(Math.round(e));const l=o.def.formatter;return l?e=>String(l({value:e})??e):void 0}export function chartBucketRows(n,r,o,l){const e=m(n).find(a=>a.id===r.x);if(!e)return[];const i=o.filter(a=>a!=null).map(a=>({row:a,keys:N(e,a)})),{label:t}=v(e,[...new Set(i.flatMap(a=>a.keys))]);return i.filter(a=>a.keys.some(f=>t(f)===l)).map(a=>a.row)}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The checklist field's value: to-do items in order, each with its own id so
3
+ * a rename or a reorder keeps it the same item. The text a copy, an export
4
+ * and a type change write is one item per line, "[x] Done thing" or
5
+ * "[ ] Open thing", and that text reads back into items.
6
+ */
7
+ export type ChecklistItem = {
8
+ id: string;
9
+ text: string;
10
+ done: boolean;
11
+ };
12
+ export declare const newChecklistItemId: () => string;
13
+ /**
14
+ * A stored value as items: an array of items (or of plain strings, each an
15
+ * open item), or text as `parseChecklist` reads it. Anything else is no items.
16
+ */
17
+ export declare function toChecklist(v: unknown): ChecklistItem[];
18
+ /**
19
+ * Text as items: one per line, "[x]" for a done item, "[ ]" or no mark for an
20
+ * open one. A single line with several marks ("[x] Draft [ ] Review", what a
21
+ * copy of one cell writes) holds several items.
22
+ */
23
+ export declare function parseChecklist(text: string): ChecklistItem[];
24
+ /** Items as text: "[x] text" per item, a line each (`sep`: what goes between them). */
25
+ export declare function checklistText(v: unknown, sep?: string): string;
26
+ /** How many items are done, of how many. */
27
+ export declare function checklistProgress(v: unknown): {
28
+ done: number;
29
+ total: number;
30
+ };
31
+ /** What a checklist sorts by: the share done, 0 to 1; no items sorts with the blanks. */
32
+ export declare function checklistSortValue(v: unknown): number | null;
33
+ /** The groups a checklist falls in, in their order; no items is the blank group. */
34
+ export declare const CHECKLIST_GROUPS: readonly ["Not started", "In progress", "Done"];
35
+ /** What a checklist groups by: "Not started", "In progress", "Done", or '' with no items. */
36
+ export declare function checklistGroup(v: unknown): string;
@@ -0,0 +1,4 @@
1
+ let c=0;export const newChecklistItemId=()=>`ci-${Date.now().toString(36)}-${(c++).toString(36)}`;const l=/^\s*(?:[-*]\s+)?\[( |x|X)?\]\s*/;export function toChecklist(o){if(typeof o=="string")return parseChecklist(o);if(!Array.isArray(o))return[];const e=[];for(const t of o)if(typeof t=="string")t.trim()&&e.push({id:newChecklistItemId(),text:t.trim(),done:!1});else if(t&&typeof t=="object"){const n=t,r=String(n.text??n.name??"").trim();if(!r)continue;e.push({id:typeof n.id=="string"&&n.id?n.id:newChecklistItemId(),text:r,done:n.done===!0||n.checked===!0})}return e}export function parseChecklist(o){const e=[];for(const t of o.replace(/\r\n?/g,`
2
+ `).split(`
3
+ `)){const n=[];for(const r of t.split(/\s+(?=\[(?: |x|X)?\]\s)/))n.length&&/^\s*[-*]$/.test(n[n.length-1])?n[n.length-1]+=` ${r}`:n.push(r);for(const r of n){const s=l.exec(r),i=(s?r.slice(s[0].length):r).trim();i&&e.push({id:newChecklistItemId(),text:i,done:!!s&&(s[1]==="x"||s[1]==="X")})}}return e}export function checklistText(o,e=`
4
+ `){return toChecklist(o).map(t=>`[${t.done?"x":" "}] ${t.text}`).join(e)}export function checklistProgress(o){const e=toChecklist(o);return{done:e.filter(t=>t.done).length,total:e.length}}export function checklistSortValue(o){const{done:e,total:t}=checklistProgress(o);return t?e/t:null}export const CHECKLIST_GROUPS=["Not started","In progress","Done"];export function checklistGroup(o){const{done:e,total:t}=checklistProgress(o);return t?e===t?CHECKLIST_GROUPS[2]:e?CHECKLIST_GROUPS[1]:CHECKLIST_GROUPS[0]:""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The color field's value: a hex color, stored lower case as '#rrggbb'.
3
+ * Typed or pasted text is read as '#rgb', '#rrggbb' (the '#' may be left
4
+ * out when the code has a digit in it), 'rgb(45, 127, 249)', or one of the
5
+ * CSS color names below. Other text (a name not listed, 'hsl()', a color
6
+ * with alpha) is not a color here: a paste of it keeps the cell as it was.
7
+ */
8
+ /** Text (or a stored value) as '#rrggbb', or null when it is not a color this field reads. */
9
+ export declare function parseColor(v: unknown): string | null;
10
+ /**
11
+ * What a color sorts and groups by: around the color wheel from red, then
12
+ * the grays from dark to light after every hue.
13
+ */
14
+ export declare function colorSortValue(v: unknown): number | null;
@@ -0,0 +1 @@
1
+ const u={black:"#000000",white:"#ffffff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",red:"#ff0000",maroon:"#800000",orange:"#ffa500",yellow:"#ffff00",olive:"#808000",lime:"#00ff00",green:"#008000",teal:"#008080",cyan:"#00ffff",aqua:"#00ffff",blue:"#0000ff",navy:"#000080",purple:"#800080",magenta:"#ff00ff",fuchsia:"#ff00ff",pink:"#ffc0cb",brown:"#a52a2a",gold:"#ffd700",indigo:"#4b0082",violet:"#ee82ee"};export function parseColor(n){if(typeof n!="string")return null;const t=n.trim().toLowerCase();if(!t)return null;if(u[t])return u[t];let f=/^#?([0-9a-f]{6})$/.exec(t);if(f&&(t.startsWith("#")||/\d/.test(f[1])))return`#${f[1]}`;if(f=/^#([0-9a-f]{3})$/.exec(t),f)return`#${[...f[1]].map(e=>e+e).join("")}`;if(f=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/.exec(t),f){const e=[f[1],f[2],f[3]].map(Number);if(e.every(r=>r<=255))return`#${e.map(r=>r.toString(16).padStart(2,"0")).join("")}`}return null}export function colorSortValue(n){const t=parseColor(n);if(!t)return null;const[f,e,r]=[1,3,5].map(c=>parseInt(t.slice(c,c+2),16)/255),a=Math.max(f,e,r),l=Math.min(f,e,r),s=(a+l)/2,o=a-l;if(o<.08)return 1e3+s;let i=a===f?(e-r)/o%6:a===e?(r-f)/o+2:(f-e)/o+4;return i=(i*60+360)%360,i+s/2}
@@ -1 +1 @@
1
- import{attachmentsFromText as y,attachmentsText as d,toAttachments as h}from"./attachments.js";import{parseDuration as b}from"./format.js";import{fillFieldColumn as g,getFieldType as S}from"./registry.svelte.js";import{splitNames as A}from"./name-list.js";import{getLinkedTable as l,resolveLinkId as x,resolveLinkIds as N}from"./sources.svelte.js";const T=new Set(["text","longText","url","email","phone","barcode"]),f=new Set(["formula","lookup","rollup","count","createdTime","lastModifiedTime","createdBy","lastModifiedBy","autoNumber","button"]),k=new Set(["number","currency","percent","rating"]);export const keepsStoredValues=t=>f.has(t),isEmptyValue=t=>t==null||t===""||Array.isArray(t)&&t.length===0||typeof t=="number"&&Number.isNaN(t);export function asText(t,r){return t==null?"":r==="attachment"?d(t):Array.isArray(t)?t.map(e=>asText(e)).filter(Boolean).join(", "):t instanceof Date?u(t):String(t)}const u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;export function convertValue(t,r,e,n){if(f.has(e))return t;if(isEmptyValue(t))return e==="checkbox"?!1:e==="multiSelect"||e==="attachment"?[]:null;if(r===e)return t;if(T.has(e))return asText(t,r);if(e==="duration")return typeof t=="number"?t:b(asText(t,r));if(e==="user")return Array.isArray(t)?t.map(s=>asText(s)):asText(t,r)||null;if(e==="link"){const s=l(n?.table),o=s?N(s,m(t,r)):[];return n?.multiple===!1?o.slice(0,1):o}if(k.has(e)){if(typeof t=="boolean")return t?1:0;if(typeof t=="number")return e==="rating"?Math.max(0,Math.min(10,Math.round(t))):t;if(Array.isArray(t))return t.length===1?convertValue(t[0],void 0,e):null;const s=asText(t,r).replace(/[^0-9.eE+-]/g,""),o=/\d/.test(s)?Number(s):NaN;return Number.isFinite(o)?e==="rating"?Math.max(0,Math.min(10,Math.round(o))):o:null}if(e==="checkbox")return typeof t=="boolean"?t:typeof t=="number"?t!==0:/^(true|yes|y|1|x|on|done|checked)$/i.test(asText(t,r).trim());if(e==="date"){if(t instanceof Date)return Number.isNaN(t.getTime())?null:u(t);const s=new Date(asText(t,r));return Number.isNaN(s.getTime())?null:s.toISOString().slice(0,10)}if(e==="singleSelect")return(Array.isArray(t)?asText(t[0]):asText(t,r)).trim()||null;if(e==="multiSelect"){const s=Array.isArray(t)?t.map(o=>asText(o)):asText(t,r).split(",");return[...new Set(s.map(o=>o.trim()).filter(Boolean))]}if(e==="attachment")return r==="attachment"?h(t):y(asText(t,r));const i=M(e,n),a=asText(t,r);if(!i)return t!==null&&typeof t=="object"?a||null:t;const c=i(a);return c===void 0?null:c}const p=new WeakMap;function M(t,r){const e=S(t);if(!e)return null;let n=p.get(e);n||p.set(e,n=new Map);const i=JSON.stringify(r??{});if(!n.has(i)){const a=g({field:"__convert",fieldType:t,fieldProps:r??{}}).valueParser;n.set(i,typeof a=="function"?c=>{try{return a({newValue:c,oldValue:null,rawInput:c})}catch{return null}}:null)}return n.get(i)}function m(t,r){return Array.isArray(t)?t.map(e=>asText(e).trim()).filter(Boolean):A(asText(t,r))}function w(t,r,e,n){if(e==="singleSelect")return Array.isArray(t)&&new Set(t.map(i=>asText(i).trim()).filter(Boolean)).size>1;if(e==="link"){const i=l(n?.table);if(!i)return!1;const a=m(t,r).map(c=>x(i,c));return a.some(c=>c==null)||n?.multiple===!1&&new Set(a).size>1}return!1}export function countCleared(t,r,e,n){if(f.has(e)||r===e)return 0;let i=0;for(const a of t)isEmptyValue(a)||(isEmptyValue(convertValue(a,r,e,n))||w(a,r,e,n))&&(i+=1);return i}export function optionsFromValues(t){const r=new Set;for(const e of t)for(const n of Array.isArray(e)?e:[e]){const i=n==null?"":String(n).trim();i&&r.add(i)}return[...r].slice(0,200).map(e=>({value:e}))}
1
+ import{attachmentsFromText as d,attachmentsText as h,toAttachments as S}from"./attachments.js";import{parseDuration as b}from"./format.js";import{fillFieldColumn as g,getFieldType as A}from"./registry.svelte.js";import{splitNames as k}from"./name-list.js";import{checklistText as x,toChecklist as l}from"./checklist.js";import{parseColor as T}from"./color-value.js";import{parseTimeOfDay as N,timeFromSeconds as w}from"./time-of-day.js";import{getLinkedTable as u,resolveLinkId as M,resolveLinkIds as D}from"./sources.svelte.js";const E=new Set(["text","longText","url","email","phone","barcode"]),f=new Set(["formula","lookup","rollup","count","createdTime","lastModifiedTime","createdBy","lastModifiedBy","autoNumber","button"]),F=new Set(["number","currency","percent","rating"]);export const keepsStoredValues=t=>f.has(t),isEmptyValue=t=>t==null||t===""||Array.isArray(t)&&t.length===0||typeof t=="number"&&Number.isNaN(t);export function asText(t,e){return t==null?"":e==="attachment"?h(t):e==="checklist"?x(t):Array.isArray(t)?t.map(r=>asText(r)).filter(Boolean).join(", "):t instanceof Date?m(t):String(t)}const m=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;export function convertValue(t,e,r,n){if(f.has(r))return t;if(isEmptyValue(t))return r==="checkbox"?!1:r==="multiSelect"||r==="attachment"?[]:null;if(e===r)return t;if(E.has(r))return asText(t,e);if(r==="duration")return typeof t=="number"?t:b(asText(t,e));if(r==="user")return Array.isArray(t)?t.map(s=>asText(s)):asText(t,e)||null;if(r==="link"){const s=u(n?.table),o=s?D(s,y(t,e)):[];return n?.multiple===!1?o.slice(0,1):o}if(F.has(r)){if(typeof t=="boolean")return t?1:0;if(typeof t=="number")return r==="rating"?Math.max(0,Math.min(10,Math.round(t))):t;if(Array.isArray(t))return t.length===1?convertValue(t[0],void 0,r):null;const s=asText(t,e).replace(/[^0-9.eE+-]/g,""),o=/\d/.test(s)?Number(s):NaN;return Number.isFinite(o)?r==="rating"?Math.max(0,Math.min(10,Math.round(o))):o:null}if(r==="checkbox")return typeof t=="boolean"?t:typeof t=="number"?t!==0:/^(true|yes|y|1|x|on|done|checked)$/i.test(asText(t,e).trim());if(r==="date"){if(t instanceof Date)return Number.isNaN(t.getTime())?null:m(t);const s=new Date(asText(t,e));return Number.isNaN(s.getTime())?null:s.toISOString().slice(0,10)}if(r==="singleSelect")return(Array.isArray(t)?asText(t[0]):asText(t,e)).trim()||null;if(r==="multiSelect"){const s=Array.isArray(t)?t.map(o=>asText(o)):asText(t,e).split(",");return[...new Set(s.map(o=>o.trim()).filter(Boolean))]}if(r==="attachment")return e==="attachment"?S(t):d(asText(t,e));if(r==="checklist"){const s=Array.isArray(t)&&e!=="checklist"?l(t.map(o=>asText(o))):l(asText(t,e));return s.length?s:null}if(r==="color")return T(asText(t,e));if(r==="timeOfDay")return e==="duration"&&typeof t=="number"?w(t):N(t instanceof Date?t:asText(t,e),{seconds:!!n?.showSeconds});const i=B(r,n),c=asText(t,e);if(!i)return t!==null&&typeof t=="object"?c||null:t;const a=i(c);return a===void 0?null:a}const p=new WeakMap;function B(t,e){const r=A(t);if(!r)return null;let n=p.get(r);n||p.set(r,n=new Map);const i=JSON.stringify(e??{});if(!n.has(i)){const c=g({field:"__convert",fieldType:t,fieldProps:e??{}}).valueParser;n.set(i,typeof c=="function"?a=>{try{return c({newValue:a,oldValue:null,rawInput:a})}catch{return null}}:null)}return n.get(i)}function y(t,e){return Array.isArray(t)?t.map(r=>asText(r).trim()).filter(Boolean):k(asText(t,e))}function V(t,e,r,n){if(r==="singleSelect")return Array.isArray(t)&&new Set(t.map(i=>asText(i).trim()).filter(Boolean)).size>1;if(r==="link"){const i=u(n?.table);if(!i)return!1;const c=y(t,e).map(a=>M(i,a));return c.some(a=>a==null)||n?.multiple===!1&&new Set(c).size>1}return!1}export function countCleared(t,e,r,n){if(f.has(r)||e===r)return 0;let i=0;for(const c of t)isEmptyValue(c)||(isEmptyValue(convertValue(c,e,r,n))||V(c,e,r,n))&&(i+=1);return i}export function optionsFromValues(t){const e=new Set;for(const r of t)for(const n of Array.isArray(r)?r:[r]){const i=n==null?"":String(n).trim();i&&e.add(i)}return[...e].slice(0,200).map(r=>({value:r}))}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What a copy (Ctrl+C) writes for a field of a base: names for people and
3
3
  * links (their paste reads names back), the URLs of attachments (a paste of
4
- * URLs attaches them), a barcode's text. Every other value is copied as
4
+ * URLs attaches them), a barcode's text, a checklist's "[x] item" marks. Every other value is copied as
5
5
  * stored, so numbers and dates paste back exactly. Names of linked records
6
6
  * and of several people are quoted when they hold a comma ("Acme, Inc."),
7
7
  * so the paste splits them back the same way.
@@ -1 +1 @@
1
- import{toAttachments as l}from"./attachments.js";import{joinNames as i}from"./name-list.js";import{findFieldUser as a,getLinkedTable as u,linkedRows as f}from"./sources.svelte.js";const m=new Set(["user","createdBy","lastModifiedBy","link","lookup","barcode"]);function c(e){if(typeof location>"u")return e;try{return new URL(e,location.href).href}catch{return e}}export function fieldCopyText(e){const r=e.column?.columnDef,n=r?.fieldType;if(n==="attachment")return l(e.value).map(t=>t.url).filter(Boolean).map(c).join(" ");if(n==="link"){const t=u(r?.fieldProps?.table);if(t)return i(f(t,e.value).map(o=>String(o[t.primaryField]??"")))}if(n==="user"&&r?.fieldProps?.multiple){const t=Array.isArray(e.value)?e.value:e.value==null||e.value===""?[]:[e.value];return i(t.map(o=>a(o)?.name??String(o)))}return!m.has(n)||typeof r?.formatter!="function"?e.value:r.formatter({value:e.value,row:e.row,column:e.column})}
1
+ import{toAttachments as l}from"./attachments.js";import{checklistText as a}from"./checklist.js";import{joinNames as i}from"./name-list.js";import{findFieldUser as u,getLinkedTable as f,linkedRows as c}from"./sources.svelte.js";const m=new Set(["user","createdBy","lastModifiedBy","link","lookup","barcode"]);function s(e){if(typeof location>"u")return e;try{return new URL(e,location.href).href}catch{return e}}export function fieldCopyText(e){const r=e.column?.columnDef,o=r?.fieldType;if(o==="attachment")return l(e.value).map(t=>t.url).filter(Boolean).map(s).join(" ");if(o==="checklist")return a(e.value," ");if(o==="link"){const t=f(r?.fieldProps?.table);if(t)return i(c(t,e.value).map(n=>String(n[t.primaryField]??"")))}if(o==="user"&&r?.fieldProps?.multiple){const t=Array.isArray(e.value)?e.value:e.value==null||e.value===""?[]:[e.value];return i(t.map(n=>u(n)?.name??String(n)))}return!m.has(o)||typeof r?.formatter!="function"?e.value:r.formatter({value:e.value,row:e.row,column:e.column})}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Dashboards: a view of tiles that sum up the base. A tile reads one table
3
+ * (any table of the base, not only the one the view is on), keeps the
4
+ * records its filter matches, and shows one number, a chart, the first few
5
+ * records by a sort, or how many of the records match. The tiles are kept on
6
+ * the view (`FieldView.dashboard`); this module turns them into what each
7
+ * tile draws, from plain tables, with no grid.
8
+ */
9
+ import type { ChartSpec } from '@svgrid/grid';
10
+ import { type ChartSetting } from './chart-view.js';
11
+ import { type FieldFilter } from './filter-model.js';
12
+ import { type FieldColumn } from './grid-access.js';
13
+ import { type BaseTable } from './base-tables.js';
14
+ type Row = Record<string, unknown>;
15
+ export type DashboardTileKind = 'number' | 'chart' | 'list' | 'progress';
16
+ /** Columns x rows of the dashboard's grid a tile takes. */
17
+ export type DashboardTileSize = '1x1' | '2x1' | '2x2';
18
+ export type NumberAggregation = 'count' | 'sum' | 'avg' | 'min' | 'max';
19
+ /** One tile of a dashboard view. */
20
+ export type DashboardTile = {
21
+ id: string;
22
+ kind: DashboardTileKind;
23
+ /** Shown over the tile. Default: what it shows ("Sum of Value"). */
24
+ title?: string;
25
+ /** The table it reads (a table id of the base). Default: the view's own table. */
26
+ table?: string;
27
+ /** Default: 1x1 for a number or progress, 2x2 for a chart or list. */
28
+ size?: DashboardTileSize;
29
+ /** Only the records it matches count. A progress tile shows how many of all the records match. */
30
+ filter?: FieldFilter;
31
+ /** Number: how the records become one number (default 'count'). */
32
+ aggregation?: NumberAggregation;
33
+ /** Number: the field added up, averaged or compared (not for a count). */
34
+ field?: string;
35
+ /** Number: a line under the number to compare it with ("Target $500,000"). */
36
+ caption?: string;
37
+ /** Chart: what it groups the records by and counts or adds up, as a chart view does. */
38
+ chart?: ChartSetting;
39
+ /** List: the field the records are sorted by, and whether high to low. */
40
+ sortBy?: string;
41
+ sortDesc?: boolean;
42
+ /** List: how many records it shows (default 5). */
43
+ limit?: number;
44
+ /** List: the field shown beside each record's name (default: the sort field). */
45
+ detail?: string;
46
+ };
47
+ export declare const TILE_KINDS: ReadonlyArray<{
48
+ kind: DashboardTileKind;
49
+ label: string;
50
+ }>;
51
+ export declare const TILE_SIZES: ReadonlyArray<{
52
+ size: DashboardTileSize;
53
+ label: string;
54
+ }>;
55
+ export declare const AGGREGATIONS: ReadonlyArray<{
56
+ aggregation: NumberAggregation;
57
+ label: string;
58
+ }>;
59
+ export declare const tileSize: (tile: DashboardTile) => DashboardTileSize;
60
+ export declare const newTileId: () => string;
61
+ /**
62
+ * A table as the grid helpers read one (`fieldColumns`, the chart view, the
63
+ * filter panel): its fields filled in by their types, all shown.
64
+ */
65
+ export declare function tableCtrl(t: BaseTable): any;
66
+ /** Fields a tile can add up or compare: the ones a chart can add up. */
67
+ export declare const numberColumns: (t: BaseTable) => FieldColumn[];
68
+ /** Fields a list can sort by and show. */
69
+ export declare const tileFieldColumns: (t: BaseTable) => FieldColumn[];
70
+ /** The records of `t` a filter keeps (every record without one). */
71
+ export declare function tileRows(t: BaseTable, filter: FieldFilter | undefined): Row[];
72
+ /** The table a tile reads: its own, else the view's (`home`). */
73
+ export declare const tileTable: (tile: DashboardTile, tables: ReadonlyArray<BaseTable>, home: string) => BaseTable | undefined;
74
+ export type TileResult = {
75
+ kind: 'missing';
76
+ message: string;
77
+ } | {
78
+ kind: 'number';
79
+ value: number | null;
80
+ text: string;
81
+ records: number;
82
+ } | {
83
+ kind: 'chart';
84
+ spec: ChartSpec | null;
85
+ formatValue?: (value: number) => string;
86
+ records: number;
87
+ } | {
88
+ kind: 'list';
89
+ items: Array<{
90
+ id: string;
91
+ title: string;
92
+ detail: string;
93
+ }>;
94
+ records: number;
95
+ } | {
96
+ kind: 'progress';
97
+ part: number;
98
+ whole: number;
99
+ percent: number;
100
+ };
101
+ /** What a tile draws, read from the base's tables; `home` is the table the view is on. */
102
+ export declare function tileResult(tile: DashboardTile, tables: ReadonlyArray<BaseTable>, home: string): TileResult;
103
+ /** What a tile opens: the records it counts, with a few of their fields to show. */
104
+ export type TileRecords = {
105
+ table: BaseTable;
106
+ /** Each record: its id, its name, and the fields' text in `fields` order. */
107
+ items: Array<{
108
+ id: string;
109
+ title: string;
110
+ cells: string[];
111
+ }>;
112
+ /** The headers of the fields beside each name. */
113
+ fields: string[];
114
+ /** For a chart's bucket: the field and the bucket ("Stage", "Won"). */
115
+ bucket?: {
116
+ field: string;
117
+ label: string;
118
+ };
119
+ };
120
+ /**
121
+ * The records a tile counts: a number's and a progress tile's matching
122
+ * records, or for a chart the ones in the bucket `category` too. Beside each
123
+ * name, the field the tile adds up or sorts by, then the table's next
124
+ * fields, up to `extra`.
125
+ */
126
+ export declare function tileRecords(tile: DashboardTile, tables: ReadonlyArray<BaseTable>, home: string, category?: string, extra?: number): TileRecords | null;
127
+ /** A tile's title: its own, else what it shows ("Sum of Value", "Deals by Stage"). */
128
+ export declare function tileTitle(tile: DashboardTile, tables: ReadonlyArray<BaseTable>, home: string): string;
129
+ /** A first tile of a kind for table `t`: a count, a chart by its first select, the first records by its primary field. */
130
+ export declare function newTile(kind: DashboardTileKind, t: BaseTable | undefined, home: string): DashboardTile;
131
+ /** A new dashboard's tiles, over the grid's own table: its record count, and a chart by its first select. */
132
+ export declare function starterTiles(ctrl: any): DashboardTile[];
133
+ /** Fields a chart tile on `t` can group by and add up. */
134
+ export declare const tileChartColumns: (t: BaseTable) => {
135
+ x: FieldColumn[];
136
+ y: FieldColumn[];
137
+ };
138
+ /** The tiles with `tile` in place of the one with its id, or added at the end. */
139
+ export declare function putTile(tiles: ReadonlyArray<DashboardTile>, tile: DashboardTile): DashboardTile[];
140
+ export declare const removeTile: (tiles: ReadonlyArray<DashboardTile>, id: string) => DashboardTile[];
141
+ /** The tiles with the one at `from` moved to `to` (both clamped to the list). */
142
+ export declare function moveTile(tiles: ReadonlyArray<DashboardTile>, from: number, to: number): DashboardTile[];
143
+ export {};
@@ -0,0 +1 @@
1
+ import{chartBucketRows as C,chartFormatter as v,chartSpec as $,chartXColumns as w,chartYColumns as x,defaultChart as k,withValueGutter as F}from"./chart-view.js";import{compileFieldFilter as L,describeFieldFilter as N}from"./filter-model.js";import{fieldColumns as I}from"./grid-access.js";import{primaryOf as m,rowIdOf as y}from"./base-tables.js";import{tableFields as d}from"./automations.svelte.js";import{fieldText as g,fieldValue as b,linkNames as M}from"./base-alerts.js";export const TILE_KINDS=[{kind:"number",label:"Number"},{kind:"chart",label:"Chart"},{kind:"list",label:"List"},{kind:"progress",label:"Progress"}],TILE_SIZES=[{size:"1x1",label:"Small"},{size:"2x1",label:"Wide"},{size:"2x2",label:"Large"}],AGGREGATIONS=[{aggregation:"count",label:"Number of records"},{aggregation:"sum",label:"Sum"},{aggregation:"avg",label:"Average"},{aggregation:"min",label:"Smallest"},{aggregation:"max",label:"Largest"}],tileSize=e=>e.size??(e.kind==="chart"||e.kind==="list"?"2x2":"1x1");let A=0;export const newTileId=()=>`tile-${Date.now().toString(36)}-${A+=1}`;const T=new WeakMap;export function tableCtrl(e){const t=T.get(e.columns);if(t)return t;const n={internalColumns:[...d(e).values()].map(i=>i.def),allColumns:[...d(e).keys()].map(i=>({id:i})),hiddenColumns:{}};return T.set(e.columns,n),n}export const numberColumns=e=>x(tableCtrl(e)),tileFieldColumns=e=>I(tableCtrl(e)).filter(t=>t.fieldType!=="button"&&t.fieldType!=="attachment");export function tileRows(e,t){const o=e.data.filter(r=>r!=null);if(!t)return o;const n=d(e),i=L(t,(r,a)=>{const s=n.get(a);return s?b(s,r):r[a]},M);return i?o.filter(i):o}export const tileTable=(e,t,o)=>t.find(n=>n.id===(e.table||o));const B=e=>{if(e==null||e===""||typeof e=="boolean")return null;const t=Number(e);return Number.isFinite(t)?t:null};function O(e,t){const o=e?.def.formatter;if(e&&o)try{return String(o({value:t,row:{},column:{id:e.id,columnDef:e.def}})??t)}catch{}return(Math.round(t*100)/100).toLocaleString()}function R(e,t,o){const n=e.aggregation??"count";if(n==="count")return{kind:"number",value:o.length,text:o.length.toLocaleString(),records:o.length};const i=d(t).get(e.field??"");if(!i)return{kind:"missing",message:"Choose a field to add up."};const r=o.map(s=>B(b(i,s))).filter(s=>s!=null);let a;return n==="sum"?a=r.reduce((s,l)=>s+l,0):r.length?n==="avg"?a=r.reduce((s,l)=>s+l,0)/r.length:a=n==="min"?Math.min(...r):Math.max(...r):a=null,{kind:"number",value:a,text:a==null?"No values":O(i,a),records:o.length}}function z(e,t,o){const n=e.def.groupOrder??((s,l)=>String(s).localeCompare(String(l),void 0,{numeric:!0})),i=s=>s==null||s===""||Array.isArray(s)&&!s.length,r=t.map(s=>({r:s,v:b(e,s)})),a=r.filter(s=>!i(s.v));return a.sort((s,l)=>(o?-1:1)*n(s.v,l.v)),[...a,...r.filter(s=>i(s.v))].map(s=>s.r)}function E(e,t,o){const n=d(t),i=n.get(m(t))??[...n.values()].find(u=>u.field===m(t))??[...n.values()][0],r=e.sortBy?n.get(e.sortBy):void 0,a=e.detail?n.get(e.detail):r;return{kind:"list",items:(r?z(r,o,!!e.sortDesc):o).slice(0,Math.max(1,e.limit??5)).map(u=>({id:y(t,u),title:(i?g(i,u):"")||"Unnamed record",detail:a&&a!==i?g(a,u):""})),records:o.length}}export function tileResult(e,t,o){const n=tileTable(e,t,o);if(!n)return{kind:"missing",message:"The table this tile reads is gone. Edit the tile to pick another."};if(e.kind==="progress"){const l=n.data.filter(h=>h!=null).length,u=e.filter?tileRows(n,e.filter).length:l;return{kind:"progress",part:u,whole:l,percent:l?u/l:0}}const i=tileRows(n,e.filter);if(e.kind==="number")return R(e,n,i);if(e.kind==="list")return E(e,n,i);const r=tableCtrl(n),a=e.chart?$(r,e.chart,i):null;if(!a)return{kind:"missing",message:"Choose a field to group the records by."};const s=v(r,e.chart);return{kind:"chart",spec:F(a,s),formatValue:s,records:i.length}}export function tileRecords(e,t,o,n,i=3){const r=tileTable(e,t,o);if(!r)return null;let a=tileRows(r,e.filter),s;e.kind==="chart"&&e.chart&&n!=null&&(a=C(tableCtrl(r),e.chart,a,n),s={field:d(r).get(e.chart.x)?.header??e.chart.x,label:n});const l=tileFieldColumns(r),u=l.find(c=>c.field===m(r))??l[0],h=[e.field,e.chart?.y,e.sortBy,e.detail].map(c=>l.find(p=>p.id===c)).filter(c=>!!c),S=new Set([u?.id,s?e.chart?.x:void 0]),f=[];for(const c of[...h,...l])f.length<i&&!S.has(c.id)&&!f.includes(c)&&f.push(c);return{table:r,items:a.map(c=>({id:y(r,c),title:(u?g(u,c):"")||"Unnamed record",cells:f.map(p=>g(p,c))})),fields:f.map(c=>c.header),...s?{bucket:s}:{}}}export function tileTitle(e,t,o){if(e.title?.trim())return e.title.trim();const n=tileTable(e,t,o);if(!n)return"Tile";const i=r=>r?d(n).get(r)?.header:void 0;if(e.kind==="number"){const r=e.aggregation??"count",a=i(e.field);return r==="count"||!a?n.name:r==="sum"?`Total ${a}`:r==="avg"?`Average ${a}`:r==="min"?`Smallest ${a}`:`Largest ${a}`}if(e.kind==="chart"){const r=i(e.chart?.x),a=i(e.chart?.y);return r?`${a??n.name} by ${r}`:n.name}if(e.kind==="list"){const r=i(e.sortBy);return r?`${n.name} by ${r}`:n.name}return e.filter?N(e.filter,r=>i(r)??r):n.name}export function newTile(e,t,o){const n={id:newTileId(),kind:e,...t&&t.id!==o?{table:t.id}:{}};if(!t)return n;if(e==="number")return{...n,aggregation:"count"};if(e==="chart"){const i=k(tableCtrl(t));return i?{...n,chart:i}:n}if(e==="list"){const i=tileFieldColumns(t).find(r=>r.field===m(t))??tileFieldColumns(t)[0];return{...n,...i?{sortBy:i.id}:{},limit:5}}return n}export function starterTiles(e){const t=k(e);return[{id:newTileId(),kind:"number",aggregation:"count"},...t?[{id:newTileId(),kind:"chart",chart:t}]:[]]}export const tileChartColumns=e=>({x:w(tableCtrl(e)),y:x(tableCtrl(e))});export function putTile(e,t){return e.some(o=>o.id===t.id)?e.map(o=>o.id===t.id?t:o):[...e,t]}export const removeTile=(e,t)=>e.filter(o=>o.id!==t);export function moveTile(e,t,o){const n=[...e];if(t<0||t>=n.length)return n;const[i]=n.splice(t,1);return n.splice(Math.max(0,Math.min(n.length,o)),0,i),n}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Protected fields: who may change a field's values. `fieldProps.editors`
3
+ * lists the user ids that may; everyone else sees the field read-only in the
4
+ * grid, the record view, a board's lanes and a calendar's dates. Without the
5
+ * list, anyone who can edit the base can edit the field. `setCanEditField`
6
+ * replaces the check with the app's own (roles, a server's answer).
7
+ *
8
+ * The browser enforces this, for the person in front of it. A base whose
9
+ * records live in a database still needs the server to refuse the writes.
10
+ */
11
+ import { type FieldUser } from './sources.svelte.js';
12
+ /** The field as the check sees it. */
13
+ export type FieldAccessField = {
14
+ id: string;
15
+ name: string;
16
+ fieldType: string;
17
+ fieldProps: Record<string, unknown>;
18
+ };
19
+ /** Whether `user` may change the values of `field`. */
20
+ export type CanEditField = (field: FieldAccessField, user: FieldUser | null) => boolean;
21
+ /** The people a field's values are limited to, or null when it is not protected. */
22
+ export declare function fieldEditors(fieldProps: Record<string, unknown> | undefined): string[] | null;
23
+ /** The built-in check: a field with `editors` takes edits from those people only. */
24
+ export declare const defaultCanEditField: CanEditField;
25
+ /** Use the app's own check for every field of every base on the page; null goes back to `editors`. */
26
+ export declare function setCanEditField(fn: CanEditField | null): void;
27
+ /** Take `fn` off again, if it is still the check (a base unmounting leaves another's alone). */
28
+ export declare function releaseCanEditField(fn: CanEditField): void;
29
+ /** Whether an app check is set (a field without `editors` may still be read-only then). */
30
+ export declare const hasCanEditField: () => boolean;
31
+ /** Whether the signed-in person may say who edits a field (the field editor's "Who can edit"). */
32
+ export declare function setFieldProtection(allowed: boolean): void;
33
+ export declare const canProtectFields: () => boolean;
34
+ /** Whether the signed-in person may change the values of the field `def` (its `fieldProps` in `props`). */
35
+ export declare function canEditField(def: Record<string, any>, props?: Record<string, unknown>): boolean;
36
+ /** "Only Ana Ruiz and Ben Okafor can edit this field." for a protected field; null otherwise. */
37
+ export declare function protectionText(def: Record<string, any>, props?: Record<string, unknown>): string | null;
@@ -0,0 +1 @@
1
+ import{findFieldUser,getCurrentUser}from"./sources.svelte.js";let check=$state.raw(null);let protecting=$state(true);export function fieldEditors(fieldProps){const list=fieldProps?.editors;return Array.isArray(list)?list.map(String):null}export const defaultCanEditField=(field,user)=>{const editors=fieldEditors(field.fieldProps);return!editors||!!user&&editors.includes(user.id)};export function setCanEditField(fn){check=fn}export function releaseCanEditField(fn){if(check===fn)check=null}export const hasCanEditField=()=>check!==null;export function setFieldProtection(allowed){protecting=allowed}export const canProtectFields=()=>protecting;export function canEditField(def,props=def.fieldProps??{}){const field={id:String(def.id??def.field??""),name:String(def.header??def.id??def.field??""),fieldType:String(def.fieldType??""),fieldProps:props};try{return(check??defaultCanEditField)(field,getCurrentUser())!==false}catch{return false}}export function protectionText(def,props=def.fieldProps??{}){const editors=fieldEditors(props);if(editors){const names=editors.map(id=>findFieldUser(id)?.name??id);if(!names.length)return"Nobody can edit this field.";const list=names.length===1?names[0]:`${names.slice(0,-1).join(", ")} and ${names.at(-1)}`;return`Only ${list} can edit this field.`}return check&&!canEditField(def,props)?"You cannot edit this field.":null}
@@ -1 +1 @@
1
- import{convertValue as A,countCleared as v,keepsStoredValues as D,optionsFromValues as b}from"./convert.js";import{renameFormulaRefs as L}from"./formula.js";import{fieldPropsOf as C,fillFieldColumn as T,getFieldType as y,originalColumn as f}from"./registry.svelte.js";import{getLinkedTable as R,linkedRows as I}from"./sources.svelte.js";const M=["editorType","cellDataType","format","align","editorOptions","editorMultiple","formatter","valueParser"];export const defId=e=>String(e.id??e.field??"");export function plainDef(e){return{...f(e)}}export const plainColumns=e=>e.internalColumns.map(t=>plainDef(t));export function uniqueId(e,t){const i=new Set(t),n=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"field";let o=n;for(let l=2;i.has(o);l++)o=`${n}_${l}`;return o}export function nameTaken(e,t,i){const n=t.trim().toLowerCase();return e.internalColumns.some(o=>defId(o)!==i&&String(o.header??"").trim().toLowerCase()===n)}function g(e){const t={};for(const[i,n]of Object.entries(e))n!==void 0&&n!==""&&!(Array.isArray(n)&&n.length===0&&i!=="options")&&(t[i]=n);return t}function p(e){return e.map(t=>f(t).fieldType?T(f(t),e):t)}function x(e,t){typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{const i=e.scrollContainer,n=i?.querySelector(`[data-svgrid-header-col="${t}"]`);if(!i||!n)return;const o=i.getBoundingClientRect(),l=n.getBoundingClientRect(),r=o.left+i.clientWidth;l.right>r?i.scrollLeft+=Math.min(l.right-r,l.left-o.left):l.left<o.left&&(i.scrollLeft-=o.left-l.left)})}function S(e,t,i){const n=e.slice();return n.splice(i==="end"?n.length:Math.max(0,Math.min(i,n.length)),0,t),n}export function addField(e,t,i="end"){const n=uniqueId(t.name,e.internalColumns.map(defId)),o=y(t.fieldType),l={id:n,field:n,header:t.name.trim(),width:o?.width??150,fieldType:t.fieldType,fieldProps:g(t.fieldProps),...t.description?.trim()?{description:t.description.trim()}:{}};let r;const s=o?.onCreate?.({props:C(l),field:n,rows:e.internalData});return s&&(r=e.internalData.map((a,u)=>a==null?a:{...a,[n]:s[u]}),e.internalData=r),e.internalColumns=p(S(e.internalColumns,l,i)),e.props.onColumnAdd?.({column:l,columns:plainColumns(e),...r?{data:r}:{}}),x(e,n),l}let h=0;export function newRecordId(){return h=(h+1)%1296,`rec${Date.now().toString(36).slice(-5)}${Math.random().toString(36).slice(2,4)}${h.toString(36).padStart(2,"0")}`}export function newRowValues(e,t={}){const i={};for(const n of e.internalColumns){const o=f(n);if(!o.fieldType||!n.field)continue;const l=String(n.field),r=C(o),s=y(o.fieldType)?.newRowValue?.({props:r,field:l,rows:e.internalData}),a=s!==void 0?s:r.default;a!==void 0&&(i[l]=Array.isArray(a)?a.slice():a)}return!("id"in t)&&(e.internalData??[]).some(n=>n&&typeof n=="object"&&"id"in n)&&(i.id=newRecordId()),{...i,...t}}const $=new Set(["autoNumber","createdTime","createdBy","lastModifiedTime","lastModifiedBy"]),k=e=>$.has(String(e))||y(e)?.copy===!1;export function recordCopyValues(e,t){const i={};for(const n of e.internalColumns){const o=f(n);if(!n.field||n.fieldFn||o.fieldFn||k(o.fieldType))continue;const l=t[String(n.field)];l!==void 0&&(i[String(n.field)]=Array.isArray(l)?l.slice():l)}return i}function w(e,t,i){const n=String(t.field),o=e.internalData.map(s=>s?.[n]);if(D(i))return o;const l=f(t),r=(l.fieldType?T(l,e.internalColumns):t).fieldFn;if(typeof r=="function")return e.internalData.map(s=>{if(s==null)return;const a=r(s);return a==="#ERROR"?null:a});if(l.fieldType==="link"&&i!=="link"){const s=R(C(l).table);if(s)return o.map(a=>I(s,a).map(u=>u[s.primaryField]).filter(u=>u!=null&&u!==""))}return o}export function previewChange(e,t,i){const n=e.internalColumns.find(o=>defId(o)===t);return!n||n.fieldType===i.fieldType||!n.field?0:v(w(e,n,i.fieldType),n.fieldType,i.fieldType,g(i.fieldProps))}function V(e,t,i,n){const o=i.trim().toLowerCase();return!o||o===n.trim().toLowerCase()?e:e.map(l=>{const r=f(l);if(r.fieldType!=="formula"||String(r.field??r.id)===t)return l;const s=String(r.fieldProps?.formula??""),a=L(s,u=>u.trim().toLowerCase()===o?n:null);return a===s?l:{...r,fieldProps:{...r.fieldProps,formula:a}}})}export function updateField(e,t,i){const n=e.internalColumns.findIndex(d=>defId(d)===t);if(n<0)return null;const o=plainDef(e.internalColumns[n]),l=o.fieldType!==i.fieldType,r=g(i.fieldProps);let s;if(l&&o.field){const d=String(o.field),F=w(e,e.internalColumns[n],i.fieldType);s=e.internalData.map((m,P)=>m==null?m:{...m,[d]:A(F[P],o.fieldType,i.fieldType,r)}),(i.fieldType==="singleSelect"||i.fieldType==="multiSelect")&&!r.options?.length&&(r.options=b(s.map(m=>m?.[d])))}const a={...o};if(l)for(const d of M)delete a[d];const u={...a,header:i.name.trim(),fieldType:i.fieldType,fieldProps:r};i.description?.trim()?u.description=i.description.trim():delete u.description;let c=e.internalColumns.slice();return c[n]=u,typeof o.header=="string"&&o.field&&(c=V(c,String(o.field),o.header,String(u.header))),e.internalColumns=p(c),s&&(e.internalData=s),e.props.onColumnChange?.({column:u,previous:o,columns:plainColumns(e),...s?{data:s}:{}}),u}export function addSelectOptions(e,t,i){const n=e.internalColumns.findIndex(u=>defId(u)===t);if(n<0||!i.length)return null;const o=plainDef(e.internalColumns[n]),l=Array.isArray(o.fieldProps?.options)?o.fieldProps.options.slice():[],r=new Set(l.map(u=>String(u.value)));for(const u of i)r.has(u.value)||(r.add(u.value),l.push({...u}));const s={...o,fieldProps:{...o.fieldProps,options:l}},a=e.internalColumns.slice();return a[n]=s,e.internalColumns=p(a),e.props.onColumnChange?.({column:s,previous:o,columns:plainColumns(e)}),s}export function setFieldSummary(e,t,i){const n=e.internalColumns.findIndex(a=>defId(a)===t);if(n<0)return null;const o=plainDef(e.internalColumns[n]),l={...o.fieldProps};i==="none"?delete l.summary:l.summary=i;const r={...o,fieldProps:l},s=e.internalColumns.slice();return s[n]=r,e.internalColumns=p(s),e.props.onColumnChange?.({column:r,previous:o,columns:plainColumns(e)}),r}export function duplicateField(e,t){const i=e.internalColumns.findIndex(a=>defId(a)===t);if(i<0)return null;const n=plainDef(e.internalColumns[i]),o=`${String(n.header??t)} copy`,l=uniqueId(o,e.internalColumns.map(defId)),r={...n,id:l,field:l,header:o};let s;if(n.field){const a=String(n.field);s=e.internalData.map(u=>u==null?u:{...u,[l]:O(u[a])}),e.internalData=s}return e.internalColumns=p(S(e.internalColumns,r,i+1)),e.props.onColumnAdd?.({column:r,columns:plainColumns(e),...s?{data:s}:{}}),x(e,l),r}export function removeField(e,t){e.internalColumns=p(e.internalColumns.filter(i=>defId(i)!==t)),e.props.onColumnRemove?.({columnId:t,columns:plainColumns(e)})}export function hideField(e,t){e.buildApi?.()?.setColumnVisible?.(t,!1)}export function indexBeside(e,t,i){const n=e.internalColumns.findIndex(o=>defId(o)===t);return n<0?e.internalColumns.length:i==="left"?n:n+1}function O(e){if(e==null||typeof e!="object")return e;try{return structuredClone(e)}catch{return Array.isArray(e)?e.slice():{...e}}}
1
+ import{convertValue as A,countCleared as v,keepsStoredValues as D,optionsFromValues as b}from"./convert.js";import{renameFormulaRefs as L}from"./formula.js";import{renamePromptRefs as R}from"./ai-prompt.js";import{fieldPropsOf as C,fillFieldColumn as T,getFieldType as y,originalColumn as p}from"./registry.svelte.js";import{getLinkedTable as I,linkedRows as M}from"./sources.svelte.js";const $=["editorType","cellDataType","format","align","editorOptions","editorMultiple","formatter","valueParser"];export const defId=e=>String(e.id??e.field??"");export function plainDef(e){return{...p(e)}}export const plainColumns=e=>e.internalColumns.map(t=>plainDef(t));export function uniqueId(e,t){const i=new Set(t),n=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"field";let o=n;for(let r=2;i.has(o);r++)o=`${n}_${r}`;return o}export function nameTaken(e,t,i){const n=t.trim().toLowerCase();return e.internalColumns.some(o=>defId(o)!==i&&String(o.header??"").trim().toLowerCase()===n)}function g(e){const t={};for(const[i,n]of Object.entries(e))n!==void 0&&n!==""&&!(Array.isArray(n)&&n.length===0&&i!=="options"&&i!=="editors")&&(t[i]=n);return t}function m(e){return e.map(t=>p(t).fieldType?T(p(t),e):t)}function x(e,t){typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{const i=e.scrollContainer,n=i?.querySelector(`[data-svgrid-header-col="${t}"]`);if(!i||!n)return;const o=i.getBoundingClientRect(),r=n.getBoundingClientRect(),l=o.left+i.clientWidth;r.right>l?i.scrollLeft+=Math.min(r.right-l,r.left-o.left):r.left<o.left&&(i.scrollLeft-=o.left-r.left)})}function S(e,t,i){const n=e.slice();return n.splice(i==="end"?n.length:Math.max(0,Math.min(i,n.length)),0,t),n}export function addField(e,t,i="end"){const n=uniqueId(t.name,e.internalColumns.map(defId)),o=y(t.fieldType),r={id:n,field:n,header:t.name.trim(),width:o?.width??150,fieldType:t.fieldType,fieldProps:g(t.fieldProps),...t.description?.trim()?{description:t.description.trim()}:{}};let l;const s=o?.onCreate?.({props:C(r),field:n,rows:e.internalData});return s&&(l=e.internalData.map((u,a)=>u==null?u:{...u,[n]:s[a]}),e.internalData=l),e.internalColumns=m(S(e.internalColumns,r,i)),e.props.onColumnAdd?.({column:r,columns:plainColumns(e),...l?{data:l}:{}}),x(e,n),r}let h=0;export function newRecordId(){return h=(h+1)%1296,`rec${Date.now().toString(36).slice(-5)}${Math.random().toString(36).slice(2,4)}${h.toString(36).padStart(2,"0")}`}export function newRowValues(e,t={}){const i={};for(const n of e.internalColumns){const o=p(n);if(!o.fieldType||!n.field)continue;const r=String(n.field),l=C(o),s=y(o.fieldType)?.newRowValue?.({props:l,field:r,rows:e.internalData}),u=s!==void 0?s:l.default;u!==void 0&&(i[r]=Array.isArray(u)?u.slice():u)}return!("id"in t)&&(e.internalData??[]).some(n=>n&&typeof n=="object"&&"id"in n)&&(i.id=newRecordId()),{...i,...t}}const k=new Set(["autoNumber","createdTime","createdBy","lastModifiedTime","lastModifiedBy"]),V=e=>k.has(String(e))||y(e)?.copy===!1;export function recordCopyValues(e,t){const i={};for(const n of e.internalColumns){const o=p(n);if(!n.field||n.fieldFn||o.fieldFn||V(o.fieldType))continue;const r=t[String(n.field)];r!==void 0&&(i[String(n.field)]=Array.isArray(r)?r.slice():r)}return i}function w(e,t,i){const n=String(t.field),o=e.internalData.map(s=>s?.[n]);if(D(i))return o;const r=p(t),l=(r.fieldType?T(r,e.internalColumns):t).fieldFn;if(typeof l=="function")return e.internalData.map(s=>{if(s==null)return;const u=l(s);return u==="#ERROR"?null:u});if(r.fieldType==="link"&&i!=="link"){const s=I(C(r).table);if(s)return o.map(u=>M(s,u).map(a=>a[s.primaryField]).filter(a=>a!=null&&a!==""))}return o}export function previewChange(e,t,i){const n=e.internalColumns.find(o=>defId(o)===t);return!n||n.fieldType===i.fieldType||!n.field?0:v(w(e,n,i.fieldType),n.fieldType,i.fieldType,g(i.fieldProps))}function O(e,t,i,n){const o=i.trim().toLowerCase();return!o||o===n.trim().toLowerCase()?e:e.map(r=>{const l=p(r);if(String(l.field??l.id)===t)return r;if(l.fieldType==="ai"){const a=String(l.fieldProps?.prompt??""),d=R(a,f=>f.trim().toLowerCase()===o?n:null);return d===a?r:{...l,fieldProps:{...l.fieldProps,prompt:d}}}if(l.fieldType!=="formula")return r;const s=String(l.fieldProps?.formula??""),u=L(s,a=>a.trim().toLowerCase()===o?n:null);return u===s?r:{...l,fieldProps:{...l.fieldProps,formula:u}}})}export function updateField(e,t,i){const n=e.internalColumns.findIndex(f=>defId(f)===t);if(n<0)return null;const o=plainDef(e.internalColumns[n]),r=o.fieldType!==i.fieldType,l=g(i.fieldProps);let s;if(r&&o.field){const f=String(o.field),P=w(e,e.internalColumns[n],i.fieldType);s=e.internalData.map((c,F)=>c==null?c:{...c,[f]:A(P[F],o.fieldType,i.fieldType,l)}),(i.fieldType==="singleSelect"||i.fieldType==="multiSelect")&&!l.options?.length&&(l.options=b(s.map(c=>c?.[f])))}const u={...o};if(r)for(const f of $)delete u[f];const a={...u,header:i.name.trim(),fieldType:i.fieldType,fieldProps:l};i.description?.trim()?a.description=i.description.trim():delete a.description;let d=e.internalColumns.slice();return d[n]=a,typeof o.header=="string"&&o.field&&(d=O(d,String(o.field),o.header,String(a.header))),e.internalColumns=m(d),s&&(e.internalData=s),e.props.onColumnChange?.({column:a,previous:o,columns:plainColumns(e),...s?{data:s}:{}}),a}export function addSelectOptions(e,t,i){const n=e.internalColumns.findIndex(a=>defId(a)===t);if(n<0||!i.length)return null;const o=plainDef(e.internalColumns[n]),r=Array.isArray(o.fieldProps?.options)?o.fieldProps.options.slice():[],l=new Set(r.map(a=>String(a.value)));for(const a of i)l.has(a.value)||(l.add(a.value),r.push({...a}));const s={...o,fieldProps:{...o.fieldProps,options:r}},u=e.internalColumns.slice();return u[n]=s,e.internalColumns=m(u),e.props.onColumnChange?.({column:s,previous:o,columns:plainColumns(e)}),s}export function setFieldSummary(e,t,i){const n=e.internalColumns.findIndex(u=>defId(u)===t);if(n<0)return null;const o=plainDef(e.internalColumns[n]),r={...o.fieldProps};i==="none"?delete r.summary:r.summary=i;const l={...o,fieldProps:r},s=e.internalColumns.slice();return s[n]=l,e.internalColumns=m(s),e.props.onColumnChange?.({column:l,previous:o,columns:plainColumns(e)}),l}export function duplicateField(e,t){const i=e.internalColumns.findIndex(u=>defId(u)===t);if(i<0)return null;const n=plainDef(e.internalColumns[i]),o=`${String(n.header??t)} copy`,r=uniqueId(o,e.internalColumns.map(defId)),l={...n,id:r,field:r,header:o};let s;if(n.field){const u=String(n.field);s=e.internalData.map(a=>a==null?a:{...a,[r]:q(a[u])}),e.internalData=s}return e.internalColumns=m(S(e.internalColumns,l,i+1)),e.props.onColumnAdd?.({column:l,columns:plainColumns(e),...s?{data:s}:{}}),x(e,r),l}export function removeField(e,t){e.internalColumns=m(e.internalColumns.filter(i=>defId(i)!==t)),e.props.onColumnRemove?.({columnId:t,columns:plainColumns(e)})}export function hideField(e,t){e.buildApi?.()?.setColumnVisible?.(t,!1)}export function indexBeside(e,t,i){const n=e.internalColumns.findIndex(o=>defId(o)===t);return n<0?e.internalColumns.length:i==="left"?n:n+1}function q(e){if(e==null||typeof e!="object")return e;try{return structuredClone(e)}catch{return Array.isArray(e)?e.slice():{...e}}}
@@ -1,12 +1,3 @@
1
- /**
2
- * The view bar's filter: conditions on fields, each with the operators that
3
- * fit its type ("has any of" for a multiple select, "is within the past
4
- * week" for a date), joined by "and" or "or", one level of groups deep.
5
- *
6
- * It is the grid's advanced filter (`api.setAdvancedFilter`) with its own
7
- * expression kind, `fieldFilter`, so it is saved and restored with the rest
8
- * of the grid's state.
9
- */
10
1
  /**
11
2
  * A person condition's value meaning whoever is signed in (`setCurrentUser`)
12
3
  * when the filter runs, so one "My tasks" view works for everyone. With
@@ -15,8 +6,8 @@
15
6
  export declare const ME = "@me";
16
7
  export declare function resolveMeWith(fn: () => string | undefined): void;
17
8
  /** What a condition compares, from the field's type. */
18
- export type FilterKind = 'text' | 'number' | 'select' | 'multi' | 'checkbox' | 'date' | 'files' | 'link';
19
- export type FilterOp = 'contains' | 'notContains' | 'is' | 'isNot' | 'isEmpty' | 'isNotEmpty' | 'eq' | 'neq' | 'lt' | 'gt' | 'lte' | 'gte' | 'isAnyOf' | 'isNoneOf' | 'hasAnyOf' | 'hasAllOf' | 'hasNoneOf' | 'isExactly' | 'isBefore' | 'isAfter' | 'isOnOrBefore' | 'isOnOrAfter' | 'isWithin';
9
+ export type FilterKind = 'text' | 'number' | 'select' | 'multi' | 'checkbox' | 'date' | 'files' | 'link' | 'checklist' | 'time';
10
+ export type FilterOp = 'contains' | 'notContains' | 'is' | 'isNot' | 'isEmpty' | 'isNotEmpty' | 'eq' | 'neq' | 'lt' | 'gt' | 'lte' | 'gte' | 'isAnyOf' | 'isNoneOf' | 'hasAnyOf' | 'hasAllOf' | 'hasNoneOf' | 'isExactly' | 'isBefore' | 'isAfter' | 'isOnOrBefore' | 'isOnOrAfter' | 'isWithin' | 'allDone' | 'notAllDone';
20
11
  /** A day a date condition names, relative to today or exact. */
21
12
  export type DateTarget = {
22
13
  mode: 'today' | 'tomorrow' | 'yesterday' | 'oneWeekAgo' | 'oneWeekFromNow' | 'oneMonthAgo' | 'oneMonthFromNow';
@@ -60,6 +51,8 @@ export declare function operatorsFor(kind: FilterKind): ReadonlyArray<{
60
51
  op: FilterOp;
61
52
  label: string;
62
53
  }>;
54
+ /** Operators that take no value: "is empty", "is complete". */
55
+ export declare const NO_VALUE: ReadonlySet<FilterOp>;
63
56
  /** The value a new condition starts with for an operator. */
64
57
  export declare function defaultValue(kind: FilterKind, op: FilterOp): unknown;
65
58
  /** A new condition on a column, with its first operator. */