@svgrid/enterprise 3.1.34 → 3.1.35

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 (171) hide show
  1. package/dist/SvGridBoard.svelte +1 -1
  2. package/dist/cdn/svgrid-enterprise.svelte-external.js +2 -2
  3. package/dist/designer/assets/{index-v61ZvIWw.js → index-Eyxa9vgS.js} +3 -3
  4. package/dist/designer/assets/{src-DkFgWld_.js → src-CSmsOfsG.js} +15 -15
  5. package/dist/designer/index.html +2 -2
  6. package/dist/fields/AiCell.svelte +41 -0
  7. package/dist/fields/AiCell.svelte.d.ts +5 -0
  8. package/dist/fields/BaseChartView.svelte +1 -1
  9. package/dist/fields/BaseDashboardView.svelte +133 -0
  10. package/dist/fields/BaseDashboardView.svelte.d.ts +17 -0
  11. package/dist/fields/BaseImport.svelte +89 -0
  12. package/dist/fields/BaseImport.svelte.d.ts +15 -0
  13. package/dist/fields/BaseInboxView.svelte +112 -0
  14. package/dist/fields/BaseInboxView.svelte.d.ts +8 -0
  15. package/dist/fields/BaseListView.svelte +90 -0
  16. package/dist/fields/BaseListView.svelte.d.ts +8 -0
  17. package/dist/fields/BaseSearch.svelte +78 -0
  18. package/dist/fields/BaseSearch.svelte.d.ts +10 -0
  19. package/dist/fields/BaseTableView.svelte +28 -3
  20. package/dist/fields/BaseTableView.svelte.d.ts +5 -1
  21. package/dist/fields/BaseTabs.svelte +45 -8
  22. package/dist/fields/BaseTabs.svelte.d.ts +25 -1
  23. package/dist/fields/BaseTrash.svelte +63 -0
  24. package/dist/fields/BaseTrash.svelte.d.ts +15 -0
  25. package/dist/fields/ChecklistCell.svelte +22 -0
  26. package/dist/fields/ChecklistCell.svelte.d.ts +10 -0
  27. package/dist/fields/ChecklistEditor.svelte +81 -0
  28. package/dist/fields/ChecklistEditor.svelte.d.ts +12 -0
  29. package/dist/fields/ColorCell.svelte +13 -0
  30. package/dist/fields/ColorCell.svelte.d.ts +8 -0
  31. package/dist/fields/ColorEditor.svelte +60 -0
  32. package/dist/fields/ColorEditor.svelte.d.ts +11 -0
  33. package/dist/fields/DashboardRecords.svelte +35 -0
  34. package/dist/fields/DashboardRecords.svelte.d.ts +11 -0
  35. package/dist/fields/DashboardTileEditor.svelte +138 -0
  36. package/dist/fields/DashboardTileEditor.svelte.d.ts +15 -0
  37. package/dist/fields/FieldEditor.svelte +32 -3
  38. package/dist/fields/FieldInput.svelte +1 -1
  39. package/dist/fields/GroupHeader.svelte +3 -3
  40. package/dist/fields/ListChips.svelte +21 -0
  41. package/dist/fields/ListChips.svelte.d.ts +9 -0
  42. package/dist/fields/MentionInput.svelte +59 -0
  43. package/dist/fields/MentionInput.svelte.d.ts +11 -0
  44. package/dist/fields/PropertyInput.svelte +13 -10
  45. package/dist/fields/RecordView.svelte +20 -25
  46. package/dist/fields/SvBase.svelte +48 -9
  47. package/dist/fields/SvBase.svelte.d.ts +33 -1
  48. package/dist/fields/SvBaseForm.svelte +2 -2
  49. package/dist/fields/SvBaseForm.svelte.d.ts +14 -0
  50. package/dist/fields/SvBaseViewBar.svelte +33 -12
  51. package/dist/fields/SvBaseViewBar.svelte.d.ts +2 -0
  52. package/dist/fields/TimeOfDayEditor.svelte +39 -0
  53. package/dist/fields/TimeOfDayEditor.svelte.d.ts +12 -0
  54. package/dist/fields/activity.svelte.d.ts +29 -0
  55. package/dist/fields/activity.svelte.js +1 -1
  56. package/dist/fields/ai-field.svelte.d.ts +91 -0
  57. package/dist/fields/ai-field.svelte.js +1 -0
  58. package/dist/fields/ai-prompt.d.ts +64 -0
  59. package/dist/fields/ai-prompt.js +7 -0
  60. package/dist/fields/airtable.d.ts +90 -0
  61. package/dist/fields/airtable.js +1 -0
  62. package/dist/fields/bar-request.svelte.d.ts +1 -1
  63. package/dist/fields/base-history.d.ts +56 -0
  64. package/dist/fields/base-history.js +1 -0
  65. package/dist/fields/base-import.d.ts +54 -0
  66. package/dist/fields/base-import.js +2 -0
  67. package/dist/fields/base-search.d.ts +34 -0
  68. package/dist/fields/base-search.js +1 -0
  69. package/dist/fields/base-share.d.ts +45 -0
  70. package/dist/fields/base-share.js +1 -0
  71. package/dist/fields/base-sql.js +3 -3
  72. package/dist/fields/base-trash.d.ts +51 -0
  73. package/dist/fields/base-trash.js +1 -0
  74. package/dist/fields/builtin-types.js +1 -1
  75. package/dist/fields/chart-view.d.ts +12 -0
  76. package/dist/fields/chart-view.js +1 -1
  77. package/dist/fields/checklist.d.ts +36 -0
  78. package/dist/fields/checklist.js +4 -0
  79. package/dist/fields/color-value.d.ts +14 -0
  80. package/dist/fields/color-value.js +1 -0
  81. package/dist/fields/convert.js +1 -1
  82. package/dist/fields/copy-text.d.ts +1 -1
  83. package/dist/fields/copy-text.js +1 -1
  84. package/dist/fields/dashboard.d.ts +143 -0
  85. package/dist/fields/dashboard.js +1 -0
  86. package/dist/fields/field-access.svelte.d.ts +37 -0
  87. package/dist/fields/field-access.svelte.js +1 -0
  88. package/dist/fields/field-ops.js +1 -1
  89. package/dist/fields/filter-model.d.ts +4 -11
  90. package/dist/fields/filter-model.js +1 -1
  91. package/dist/fields/form-logic.d.ts +69 -0
  92. package/dist/fields/form-logic.js +1 -0
  93. package/dist/fields/formula.js +1 -1
  94. package/dist/fields/grid-access.d.ts +8 -0
  95. package/dist/fields/grid-access.js +1 -1
  96. package/dist/fields/index.d.ts +16 -0
  97. package/dist/fields/index.js +1 -1
  98. package/dist/fields/list-view.d.ts +40 -0
  99. package/dist/fields/list-view.js +1 -0
  100. package/dist/fields/mentions.d.ts +50 -0
  101. package/dist/fields/mentions.js +1 -0
  102. package/dist/fields/palette.d.ts +4 -2
  103. package/dist/fields/palette.js +1 -1
  104. package/dist/fields/record-menu.js +1 -1
  105. package/dist/fields/registry.svelte.d.ts +5 -0
  106. package/dist/fields/registry.svelte.js +1 -1
  107. package/dist/fields/time-of-day.d.ts +28 -0
  108. package/dist/fields/time-of-day.js +1 -0
  109. package/dist/fields/view-model.d.ts +24 -2
  110. package/dist/fields/view-model.js +1 -1
  111. package/dist/fields/viewbar/ConditionValue.svelte +3 -3
  112. package/dist/fields/viewbar/ListPanel.svelte +36 -0
  113. package/dist/fields/viewbar/ListPanel.svelte.d.ts +11 -0
  114. package/dist/fields/viewbar/ViewsMenu.svelte +27 -4
  115. package/dist/fields/viewbar/ViewsMenu.svelte.d.ts +6 -0
  116. package/dist/node/studio.js +1 -1
  117. package/dist/version.d.ts +2 -2
  118. package/dist/version.js +1 -1
  119. package/dist/wc/GridFind-DsTvdUXq.js +1 -0
  120. package/dist/wc/GridFooter-D-i8boBh.js +1 -0
  121. package/dist/wc/GridMenus-CYe9Fw2I.js +20 -0
  122. package/dist/wc/PinSplitter-LvyyrLhe.js +6 -0
  123. package/dist/wc/SvChartMenu-XKW_LOYw.js +1 -0
  124. package/dist/wc/SvDateRangeInput-CSOxqTB1.js +1 -0
  125. package/dist/wc/SvDateTimePicker-DvvFs2T9.js +4 -0
  126. package/dist/wc/SvField-BmQphyOs.js +20 -0
  127. package/dist/wc/SvForm-HD7y5vmk.js +46 -0
  128. package/dist/wc/SvGridCellEditor-776KAOe1.js +3 -0
  129. package/dist/wc/SvGridChart-DC7ZUhp8.js +171 -0
  130. package/dist/wc/SvGridChartBuilder-Dd3vWBvq.js +7 -0
  131. package/dist/wc/SvGridChartPanel-CwYjF46U.js +5 -0
  132. package/dist/wc/SvGridChartView-CSF38rBs.js +3 -0
  133. package/dist/wc/SvGridDropdown-4S1G7gsP.js +30 -0
  134. package/dist/wc/SvMenuList-D3ZLXjL_.js +1 -0
  135. package/dist/wc/SvModal-Dk0YwPWp.js +7 -0
  136. package/dist/wc/SvSwitchButton-DdZmc3ew.js +1 -0
  137. package/dist/wc/SvTabs-BI2cQHyw.js +2 -0
  138. package/dist/wc/base-react.d.ts +38 -0
  139. package/dist/wc/base-react.js +1 -0
  140. package/dist/wc/base-vue.d.ts +29 -0
  141. package/dist/wc/base-vue.js +1 -0
  142. package/dist/wc/board-RQp5fHPR.js +21 -0
  143. package/dist/wc/board-view.svelte-CpxuZcEg.js +1 -0
  144. package/dist/wc/card-marks.svelte-QwxIcKcZ.js +1 -0
  145. package/dist/wc/client-DNdLmGcu.js +3 -0
  146. package/dist/wc/createOverlay.svelte-CDw3RXgs.js +1 -0
  147. package/dist/wc/custom-filter-Dp8JxlQu.js +2 -0
  148. package/dist/wc/date-format-DtSmFyEB.js +18 -0
  149. package/dist/wc/editor-registry-CkKfcVLc.js +1 -0
  150. package/dist/wc/export-format-CGfE9_O5.js +5 -0
  151. package/dist/wc/gallery-CNOHNWEJ.js +4 -0
  152. package/dist/wc/gallery-view.svelte-27X-wCQH.js +1 -0
  153. package/dist/wc/grid-extension.svelte-hgqOteka.js +1 -0
  154. package/dist/wc/import-B9mIERCl.js +4 -0
  155. package/dist/wc/js-scroller.svelte-BP8Up6_q.js +1 -0
  156. package/dist/wc/license-CWVWqb-i.js +27 -0
  157. package/dist/wc/list-option-CI4nMshZ.js +1 -0
  158. package/dist/wc/react.d.ts +1 -0
  159. package/dist/wc/react.js +1 -1
  160. package/dist/wc/scheduler-CkVY4od-.js +147 -0
  161. package/dist/wc/scheduler-view.svelte-SzG7rU8b.js +1 -0
  162. package/dist/wc/sparkline-DWRBQubt.js +1 -0
  163. package/dist/wc/sv-base-element.d.ts +87 -0
  164. package/dist/wc/sv-base-element.js +273 -0
  165. package/dist/wc/sv-sheet-element.d.ts +2 -0
  166. package/dist/wc/sv-sheet-element.js +55 -55
  167. package/dist/wc/svelte-virtualizer.svelte-CSBwEZt9.js +1 -0
  168. package/dist/wc/types/sv-base-element.d.ts +87 -0
  169. package/dist/wc/vue.d.ts +1 -0
  170. package/dist/wc/vue.js +1 -1
  171. package/package.json +18 -4
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
- import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{markAllSeen,unseenIn}from"./activity.svelte";import{findFieldUser}from"./sources.svelte";import{recordMenu}from"./record-menu";import{matches}from"./automations.svelte";let{data,columns,views=$bindable([{id:"grid",name:"Grid view",type:"grid"}]),activeView=$bindable(""),onViewsChange,viewTypes,rowHeights,containerHeight=560,onApiReady,bare=false,table,tables,runner,serverRuns,onAutomationsChange,onFormSubmit,newRecord,...grid}=$props();let api=$state.raw(null);const menu=recordMenu(()=>api,()=>api?gridOf(api):void 0);const view=$derived(views.find(v=>v.id===activeView)??views[0]);const type=$derived(view?.type??"grid");const besideGrid=$derived(type==="form"||type==="chart");const types=$derived(viewTypes??["grid","kanban","calendar",...hasGanttView()?["gantt"]:[],"gallery","chart","form"]);const height=$derived(typeof containerHeight==="number"?`${containerHeight}px`:containerHeight);let automationsOpen=$state(false);const automationList=$derived(table?.automations??[]);const highlightFormats=$derived.by(()=>{const t=table;if(!t)return[];const out=[];for(const a of automationList){if(!a.enabled||!a.condition)continue;for(const action of a.actions){if(action.type!=="highlight")continue;out.push({type:"rule",...action.fields?.length?{columns:action.fields}:{},when:({row})=>matches(t,a.condition,row),background:action.background,...action.color?{color:action.color}:{}})}}return out});const UNSEEN="color-mix(in srgb, var(--sg-accent, #2563eb) 20%, transparent)";const unseenFormats=$derived.by(()=>{const tableId=grid.baseTableId;const getRowId=grid.getRowId;if(typeof tableId!=="string"||!tableId||typeof getRowId!=="function")return[];const marks=unseenIn({base:grid.baseScope,tableId});if(!marks.size)return[];const idOf=row=>String(getRowId(row,0));const columns2=new Set;let added=false;for(const m of marks.values()){if(m.added)added=true;for(const c of m.columns)columns2.add(c)}const out=[];if(added)out.push({type:"rule",when:({row})=>!!marks.get(idOf(row))?.added,background:UNSEEN});for(const c of columns2)out.push({type:"rule",columns:[c],when:({row})=>!!marks.get(idOf(row))?.columns.has(c),background:UNSEEN});return out});const changed=$derived.by(()=>{const tableId=grid.baseTableId;if(typeof tableId!=="string"||!tableId)return null;const scope={base:grid.baseScope,tableId};const marks=unseenIn(scope);if(!marks.size)return null;const authors=new Set([...marks.values()].map(m=>m.by??""));const only=authors.size===1?[...authors][0]:"";const who=only?findFieldUser(only)?.name??"someone else":authors.size===1?"someone else":"others";return{label:`${marks.size} changed by ${who}`,onSeen:()=>markAllSeen(scope)}});const conditionalFormats=$derived(highlightFormats.length||unseenFormats.length?[...grid.conditionalFormats??[],...highlightFormats,...unseenFormats]:grid.conditionalFormats);
2
+ import{untrack}from"svelte";import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{markAllSeen,unseenIn}from"./activity.svelte";import{findFieldUser,getLinkedTable}from"./sources.svelte";import{recordMenu}from"./record-menu";import{matches}from"./automations.svelte";import{galleryConfig}from"./view-model";import{newRowValues}from"./field-ops";import{openRecord}from"./editor-request.svelte";let{data,columns,views=$bindable([{id:"grid",name:"Grid view",type:"grid"}]),activeView=$bindable(""),onViewsChange,viewTypes,rowHeights,containerHeight=560,onApiReady,bare=false,table,tables,runner,serverRuns,onAutomationsChange,onFormSubmit,newRecord,lockViews=true,phoneLayout=600,...grid}=$props();let api=$state.raw(null);const menu=recordMenu(()=>api,()=>api?gridOf(api):void 0);const view=$derived(views.find(v=>v.id===activeView)??views[0]);const type=$derived(view?.type??"grid");const besideGrid=$derived(type==="form"||type==="chart"||type==="list"||type==="inbox"||type==="dashboard");const types=$derived(viewTypes??["grid","kanban","calendar",...hasGanttView()?["gantt"]:[],"gallery","list","inbox","chart","dashboard","form"]);const height=$derived(typeof containerHeight==="number"?`${containerHeight}px`:containerHeight);const homeId=$derived(table?.id??"");const dashboardTables=$derived.by(()=>{if(type!=="dashboard")return[];if(tables)return tables();const rows=(api?gridOf(api)?.internalData:void 0)??data;return[{id:"",name:"Records",data:rows,columns}]});function setTiles(tiles){const id=view?.id;if(!id)return;views=views.map(v=>v.id===id?{...v,dashboard:tiles}:v);onViewsChange?.(views)}function openTileRecord(tableId,rowId){const ctrl=api?gridOf(api):void 0;if(tableId===homeId&&ctrl)openRecord({ctrl,rowId});else getLinkedTable(tableId)?.open?.(rowId)}let automationsOpen=$state(false);const automationList=$derived(table?.automations??[]);const highlightFormats=$derived.by(()=>{const t=table;if(!t)return[];const out=[];for(const a of automationList){if(!a.enabled||!a.condition)continue;for(const action of a.actions){if(action.type!=="highlight")continue;out.push({type:"rule",...action.fields?.length?{columns:action.fields}:{},when:({row})=>matches(t,a.condition,row),background:action.background,...action.color?{color:action.color}:{}})}}return out});const UNSEEN="color-mix(in srgb, var(--sg-accent, #2563eb) 20%, transparent)";const unseenFormats=$derived.by(()=>{const tableId=grid.baseTableId;const getRowId=grid.getRowId;if(typeof tableId!=="string"||!tableId||typeof getRowId!=="function")return[];const marks=unseenIn({base:grid.baseScope,tableId});if(!marks.size)return[];const idOf=row=>String(getRowId(row,0));const columns2=new Set;let added=false;for(const m of marks.values()){if(m.added)added=true;for(const c of m.columns)columns2.add(c)}const out=[];if(added)out.push({type:"rule",when:({row})=>!!marks.get(idOf(row))?.added,background:UNSEEN});for(const c of columns2)out.push({type:"rule",columns:[c],when:({row})=>!!marks.get(idOf(row))?.columns.has(c),background:UNSEEN});return out});const changed=$derived.by(()=>{const tableId=grid.baseTableId;if(typeof tableId!=="string"||!tableId)return null;const scope={base:grid.baseScope,tableId};const marks=unseenIn(scope);if(!marks.size)return null;const authors=new Set([...marks.values()].map(m=>m.by??""));const only=authors.size===1?[...authors][0]:"";const who=only?findFieldUser(only)?.name??"someone else":authors.size===1?"someone else":"others";return{label:`${marks.size} changed by ${who}`,onSeen:()=>markAllSeen(scope)}});let width=$state(0);const phone=$derived(phoneLayout===true||phoneLayout!==false&&width>0&&width<(typeof phoneLayout==="number"?phoneLayout:600));const phoneCards=$derived(phone&&type==="grid");let galleryReady=$state(false);$effect(()=>{if(phoneCards&&!galleryReady)void import("../gallery").then(m=>{m.enableGalleryView();galleryReady=true})});$effect(()=>{if(!api||!galleryReady)return;const want=phoneCards;const has=api.getOption("gallery");const v=view;untrack(()=>{const ctrl=gridOf(api);if(!ctrl||!v)return;if(want&&!has?.phone){const cfg=galleryConfig(ctrl,api,v);api.setOption("gallery",{...cfg,cardFields:cfg.cardFields.slice(0,4),cardSize:"large",phone:true})}else if(!want&&has?.phone){api.setOption("gallery",void 0)}})});function addOnPhone(){const ctrl=api?gridOf(api):void 0;if(!ctrl||!ctrl.editingEnabled)return;const cfg=ctrl.props.rowAdder;const defaults=cfg&&typeof cfg==="object"&&typeof cfg.defaults==="function"?cfg.defaults():{};const row=newRowValues(ctrl,defaults);api.addRow(row,"bottom");ctrl.props.onRowAdd?.({row});const id=typeof ctrl.props.getRowId==="function"?String(ctrl.props.getRowId(row,0)):String(row.id??"");if(id)queueMicrotask(()=>openRecord({ctrl,rowId:id,editPrimary:true}))}const conditionalFormats=$derived(highlightFormats.length||unseenFormats.length?[...grid.conditionalFormats??[],...highlightFormats,...unseenFormats]:grid.conditionalFormats);
3
3
  </script>
4
4
 
5
- <div class="sv-fbase" class:is-bare={bare} style:height>
5
+ <div class="sv-fbase" class:is-bare={bare} class:is-phone={phone} style:height bind:clientWidth={width}>
6
6
  {#if api}
7
7
  <SvBaseViewBar
8
8
  {api}
@@ -11,6 +11,7 @@ import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{
11
11
  {onViewsChange}
12
12
  viewTypes={types}
13
13
  {rowHeights}
14
+ {lockViews}
14
15
  automations={runner && table ? { count: automationList.length, onManage: () => (automationsOpen = true) } : null}
15
16
  {changed}
16
17
  />
@@ -24,6 +25,7 @@ import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{
24
25
  {columns}
25
26
  {conditionalFormats}
26
27
  contextMenu={grid.contextMenu ?? menu}
28
+ pinSplitter={grid.pinSplitter ?? true}
27
29
  processCellForClipboard={grid.processCellForClipboard ?? fieldCopyText}
28
30
  containerHeight="100%"
29
31
  onApiReady={(a: any) => {
@@ -32,9 +34,30 @@ import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{
32
34
  }}
33
35
  />
34
36
  </div>
37
+ {#if api && phoneCards && grid.editable && grid.rowAdder !== false}
38
+ <button type="button" class="sv-fbase-fab" aria-label="Add record" title="Add record" onclick={addOnPhone}>
39
+ <svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" /></svg>
40
+ </button>
41
+ {/if}
42
+
43
+ {#if api && type === 'list'}
44
+ {#key view?.id}
45
+ <BaseListView {api} {view} />
46
+ {/key}
47
+ {/if}
48
+ {#if api && type === 'inbox'}
49
+ {#key view?.id}
50
+ <BaseInboxView {api} {view} />
51
+ {/key}
52
+ {/if}
35
53
  {#if api && type === 'chart'}
36
54
  <BaseChartView {api} setting={view?.chart} />
37
55
  {/if}
56
+ {#if api && type === 'dashboard'}
57
+ {#key view?.id}
58
+ <BaseDashboardView tiles={view?.dashboard} tables={dashboardTables} home={homeId} locked={!!view?.locked} onChange={setTiles} onOpen={openTileRecord} />
59
+ {/key}
60
+ {/if}
38
61
  {#if api && type === 'form'}
39
62
 
40
63
  {#key view?.id}
@@ -45,6 +68,8 @@ import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{
45
68
  title={view?.formTitle ?? view?.name}
46
69
  description={view?.formDescription}
47
70
  submitLabel={view?.formSubmitLabel}
71
+ conditions={view?.formConditions}
72
+ prefill={view?.formPrefill === true}
48
73
  defaults={newRecord}
49
74
  onSubmit={(row) => (view ? onFormSubmit?.(row, view.id) : undefined)}
50
75
  />
@@ -66,5 +91,5 @@ import{hasGanttView}from"@svgrid/grid";import{gridOf}from"./grid-access";import{
66
91
  </div>
67
92
 
68
93
  <style>
69
- .sv-fbase{display:flex;flex-direction:column;min-height:0;box-sizing:border-box;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius-lg, 10px);overflow:hidden;background:var(--sg-bg, #fff)}.sv-fbase.is-bare{border:0;border-radius:0}.sv-fbase-body{position:relative;flex:1 1 auto;min-height:0}.sv-fbase-grid{height:100%}.sv-fbase-grid.is-hidden{visibility:hidden;position:absolute;inset:0;pointer-events:none}.sv-fbase-body>:global(.sv-fform-wrap){position:absolute;inset:0}
94
+ .sv-fbase{display:flex;flex-direction:column;min-height:0;box-sizing:border-box;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius-lg, 10px);overflow:hidden;background:var(--sg-bg, #fff)}.sv-fbase.is-bare{border:0;border-radius:0}.sv-fbase-body{position:relative;flex:1 1 auto;min-height:0}.sv-fbase-grid{height:100%}.sv-fbase-grid.is-hidden{visibility:hidden;position:absolute;inset:0;pointer-events:none}.sv-fbase-body>:global(.sv-fform-wrap){position:absolute;inset:0}.sv-fbase{container-type:inline-size}.sv-fbase-fab{position:absolute;right:16px;bottom:16px;z-index:3;display:grid;place-items:center;width:48px;height:48px;padding:0;border:0;border-radius:999px;cursor:pointer;background:var(--sg-accent, #2563eb);color:var(--sg-accent-fg, #fff);box-shadow:0 4px 14px color-mix(in srgb,var(--sg-fg, #0f172a) 25%,transparent)}.sv-fbase-fab:focus-visible{outline:2px solid var(--sg-focus-ring, var(--sg-accent, #2563eb));outline-offset:3px}.sv-fbase.is-phone :global(.sv-grid-gallery-root .sv-gal){padding:10px 10px 80px;gap:10px}
70
95
  </style>
@@ -1,6 +1,6 @@
1
1
  import { type AutomationRun, type AutomationRunner, type BaseAutomation } from './automations.svelte.js';
2
2
  import type { BaseTable } from './base-tables.js';
3
- import type { FieldView, FieldViewType } from './view-model.js';
3
+ import { type FieldView, type FieldViewType } from './view-model.js';
4
4
  type $$ComponentProps = {
5
5
  /** The grid's rows and columns. */
6
6
  data: any[];
@@ -30,6 +30,10 @@ type $$ComponentProps = {
30
30
  onFormSubmit?: (row: Record<string, unknown>, viewId: string) => void | Promise<unknown>;
31
31
  /** Values a record from a form view starts with (`<SvBase tables>` gives an id). */
32
32
  newRecord?: () => Record<string, unknown>;
33
+ /** Whether the person may lock and unlock views (default true). */
34
+ lockViews?: boolean;
35
+ /** Below this width (px) a grid view shows cards; true always, false never. Default 600. */
36
+ phoneLayout?: boolean | number;
33
37
  [prop: string]: any;
34
38
  };
35
39
  declare const BaseTableView: import("svelte").Component<$$ComponentProps, {}, "views" | "activeView">;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activeId,onSwitch,onAdd,onRename,onDuplicate,onDelete,onExportSql,status=null}=$props();let menuOpen=$state(false);let listOpen=$state(false);let renaming=$state(null);let draft=$state("");let deleting=$state(null);let confirmOpen=$state(false);let strip=$state(null);const active=$derived(tables.find(t=>t.id===activeId));function linksTo(t){const out=[];for(const o of tables){if(o.id===t.id)continue;for(const d of o.columns){if(d.fieldType!=="link"||d.fieldProps?.table!==t.id)continue;const name=String(d.header??d.field);out.push(`${o.name}: ${name}`);for(const r of linkReaders(o,d))out.push(`${o.name}: ${String(r.header??r.field)} (reads ${name})`)}}return out}async function startRename(id){menuOpen=false;renaming=id;draft=tables.find(t=>t.id===id)?.name??"";await tick();const input=strip?.querySelector(".sv-btabs-input");input?.focus();input?.select()}function commitRename(){const id=renaming;renaming=null;const name=draft.trim();if(id&&name&&name!==tables.find(t=>t.id===id)?.name)onRename(id,name)}function renameKey(e){if(e.key==="Enter")commitRename();else if(e.key==="Escape")renaming=null}function askDelete(){menuOpen=false;deleting=active??null;confirmOpen=!!deleting}function confirmDelete(){const t=deleting;confirmOpen=false;deleting=null;if(t)onDelete(t.id)}function tabKey(e,i){let to=-1;if(e.key==="ArrowRight")to=(i+1)%tables.length;else if(e.key==="ArrowLeft")to=(i-1+tables.length)%tables.length;else if(e.key==="Home")to=0;else if(e.key==="End")to=tables.length-1;else if(e.key==="F2"){e.preventDefault();void startRename(tables[i].id);return}if(to<0)return;e.preventDefault();onSwitch(tables[to].id);void tick().then(()=>strip?.querySelectorAll('[role="tab"]')[to]?.focus())}const inputValue=e=>e.currentTarget.value;
2
+ import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activeId,onSwitch,onAdd,onRename,onDuplicate,onDelete,onExportSql,status=null,undo=null,trashCount=0,onOpenTrash,onImport,readOnly=false,search=null}=$props();let searchBox=$state(null);export function focusSearch(){searchBox?.focus();return!!searchBox}let menuOpen=$state(false);let listOpen=$state(false);let renaming=$state(null);let draft=$state("");let deleting=$state(null);let confirmOpen=$state(false);let strip=$state(null);const active=$derived(tables.find(t=>t.id===activeId));function linksTo(t){const out=[];for(const o of tables){if(o.id===t.id)continue;for(const d of o.columns){if(d.fieldType!=="link"||d.fieldProps?.table!==t.id)continue;const name=String(d.header??d.field);out.push(`${o.name}: ${name}`);for(const r of linkReaders(o,d))out.push(`${o.name}: ${String(r.header??r.field)} (reads ${name})`)}}return out}async function startRename(id){if(readOnly)return;menuOpen=false;renaming=id;draft=tables.find(t=>t.id===id)?.name??"";await tick();const input=strip?.querySelector(".sv-btabs-input");input?.focus();input?.select()}function commitRename(){const id=renaming;renaming=null;const name=draft.trim();if(id&&name&&name!==tables.find(t=>t.id===id)?.name)onRename(id,name)}function renameKey(e){if(e.key==="Enter")commitRename();else if(e.key==="Escape")renaming=null}function askDelete(){menuOpen=false;deleting=active??null;confirmOpen=!!deleting}function confirmDelete(){const t=deleting;confirmOpen=false;deleting=null;if(t)onDelete(t.id)}function tabKey(e,i){let to=-1;if(e.key==="ArrowRight")to=(i+1)%tables.length;else if(e.key==="ArrowLeft")to=(i-1+tables.length)%tables.length;else if(e.key==="Home")to=0;else if(e.key==="End")to=tables.length-1;else if(e.key==="F2"){e.preventDefault();void startRename(tables[i].id);return}if(to<0)return;e.preventDefault();onSwitch(tables[to].id);void tick().then(()=>strip?.querySelectorAll('[role="tab"]')[to]?.focus())}const inputValue=e=>e.currentTarget.value;
3
3
  </script>
4
4
 
5
5
  <div class="sv-btabs" bind:this={strip}>
@@ -28,7 +28,7 @@ import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activ
28
28
  ondblclick={() => startRename(t.id)}
29
29
  onkeydown={(e) => tabKey(e, i)}>{t.name}</button
30
30
  >
31
- {#if on}
31
+ {#if on && !readOnly}
32
32
  <SvPopover bind:open={menuOpen} arrow={false} placement="bottom-start" ariaLabel="Table actions">
33
33
  {#snippet anchor()}
34
34
  <button type="button" class="sv-btabs-more" aria-label={`${t.name} table options`} aria-haspopup="menu" aria-expanded={menuOpen}>
@@ -38,6 +38,9 @@ import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activ
38
38
  <div class="sv-btabs-menu" role="menu">
39
39
  <button type="button" role="menuitem" class="sv-btabs-item" onclick={() => startRename(t.id)}>Rename table</button>
40
40
  <button type="button" role="menuitem" class="sv-btabs-item" onclick={() => { menuOpen = false; onDuplicate(t.id) }}>Duplicate table</button>
41
+ {#if onImport}
42
+ <button type="button" role="menuitem" class="sv-btabs-item" onclick={() => { menuOpen = false; onImport('append') }}>Import records from a file</button>
43
+ {/if}
41
44
  <button type="button" role="menuitem" class="sv-btabs-item is-danger" disabled={tables.length < 2} title={tables.length < 2 ? 'A base keeps at least one table' : undefined} onclick={askDelete}>Delete table</button>
42
45
  </div>
43
46
  </SvPopover>
@@ -60,22 +63,56 @@ import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activ
60
63
  <span class="sv-btabs-check" aria-hidden="true">{t.id === activeId ? '✓' : ''}</span>{t.name}
61
64
  </button>
62
65
  {/each}
63
- {#if onExportSql}
66
+ {#if onImport || onExportSql}
64
67
  <div class="sv-btabs-sep" role="separator"></div>
68
+ {/if}
69
+ {#if onImport}
70
+ <button type="button" role="menuitem" class="sv-btabs-item" title="A CSV, TSV, Excel or JSON file as a new table, with a field type for each column" onclick={() => { listOpen = false; onImport('new') }}>
71
+ <span class="sv-btabs-check" aria-hidden="true"></span>Import a file as a table
72
+ </button>
73
+ {/if}
74
+ {#if onExportSql}
65
75
  <button type="button" role="menuitem" class="sv-btabs-item" title="The tables, links, records, views and automations, ready for Postgres or Supabase" onclick={() => { listOpen = false; onExportSql() }}>
66
76
  <span class="sv-btabs-check" aria-hidden="true"></span>Download as SQL
67
77
  </button>
68
78
  {/if}
69
79
  </div>
70
80
  </SvPopover>
71
- <button type="button" class="sv-btabs-tool sv-btabs-add" onclick={onAdd}>
72
- <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>
73
- <span>Add table</span>
74
- </button>
81
+ {#if !readOnly}
82
+ <button type="button" class="sv-btabs-tool sv-btabs-add" onclick={onAdd}>
83
+ <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>
84
+ <span>Add table</span>
85
+ </button>
86
+ {/if}
75
87
  </div>
76
88
  {#if status}
77
89
  <span class="sv-btabs-status" class:is-error={status.tone === 'error'} role="status" title={status.title ?? status.text}>{status.text}</span>
78
90
  {/if}
91
+ <div class="sv-btabs-end">
92
+ {#if search}
93
+ <BaseSearch bind:this={searchBox} run={search.run} onPick={search.onPick} />
94
+ {/if}
95
+ {#if readOnly}
96
+ <span class="sv-btabs-badge" title="You can look at these tables but not change them">
97
+ <svg viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" /></svg>
98
+ <span>View only</span>
99
+ </span>
100
+ {/if}
101
+ {#if undo}
102
+ <button type="button" class="sv-btabs-tool sv-btabs-icon" aria-label={undo.undoLabel ? `Undo ${undo.undoLabel}` : 'Undo'} title={undo.undoLabel ? `Undo ${undo.undoLabel} (Ctrl+Z)` : 'Nothing to undo'} disabled={!undo.canUndo} onclick={undo.onUndo}>
103
+ <svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true"><path d="M9 14L4 9l5-5M4 9h10a6 6 0 010 12h-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" /></svg>
104
+ </button>
105
+ <button type="button" class="sv-btabs-tool sv-btabs-icon" aria-label={undo.redoLabel ? `Redo ${undo.redoLabel}` : 'Redo'} title={undo.redoLabel ? `Redo ${undo.redoLabel} (Ctrl+Shift+Z)` : 'Nothing to redo'} disabled={!undo.canRedo} onclick={undo.onRedo}>
106
+ <svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true"><path d="M15 14l5-5-5-5M20 9H10a6 6 0 000 12h3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" /></svg>
107
+ </button>
108
+ {/if}
109
+ {#if onOpenTrash}
110
+ <button type="button" class="sv-btabs-tool sv-btabs-trash" aria-label={`Trash, ${trashCount} ${trashCount === 1 ? 'item' : 'items'}`} title="Deleted records, fields and tables" onclick={onOpenTrash}>
111
+ <svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true"><path d="M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" /></svg>
112
+ {#if trashCount}<span class="sv-btabs-count">{trashCount}</span>{/if}
113
+ </button>
114
+ {/if}
115
+ </div>
79
116
  </div>
80
117
 
81
118
  {#if deleting}
@@ -100,5 +137,5 @@ import{tick}from"svelte";import{linkReaders}from"./base-tables";let{tables,activ
100
137
  {/if}
101
138
 
102
139
  <style>
103
- .sv-btabs{--sv-btabs-h: 33px;display:flex;align-items:flex-end;gap:2px;box-sizing:border-box;height:calc(var(--sv-btabs-h) + 7px);padding:0 6px 0 0;font-family:var(--sg-font, inherit);font-size:13px;line-height:1;background:var(--sg-muted-bg, var(--sg-header-bg, #f5f5f4));box-shadow:inset 0 -1px 0 var(--sg-border, #e7e5e4)}.sv-btabs-list{display:flex;align-items:flex-end;min-width:0;height:100%;padding:0 0 0 8px;overflow-x:auto;scrollbar-width:none}.sv-btabs-list::-webkit-scrollbar{display:none}.sv-btabs-tab{position:relative;flex:none;display:flex;align-items:center;gap:2px;box-sizing:border-box;height:var(--sv-btabs-h);padding:0 6px 1px 4px;border:1px solid transparent;border-bottom:0;border-radius:var(--sg-radius, 6px) var(--sg-radius, 6px) 0 0;color:var(--sg-muted, #78716c);transition:color .12s ease,background-color .12s ease}.sv-btabs-tab:not(.is-active)+.sv-btabs-tab:not(.is-active):before{content:"";position:absolute;left:-2px;top:10px;bottom:10px;width:1px;background:var(--sg-border, #e7e5e4)}.sv-btabs-tab:hover:before,.sv-btabs-tab:hover+.sv-btabs-tab:before{opacity:0}.sv-btabs-tab:not(.is-active):hover{color:var(--sg-fg, #1c1917);background:color-mix(in srgb,var(--sg-bg, #fff) 55%,transparent)}.sv-btabs-tab.is-active{z-index:1;height:calc(var(--sv-btabs-h) + 1px);margin-bottom:-1px;padding-bottom:2px;color:var(--sg-fg, #1c1917);background:var(--sg-bg, #fff);border-color:var(--sg-border, #e7e5e4);box-shadow:inset 0 2px 0 var(--sg-accent, #2563eb)}.sv-btabs-name{max-width:220px;height:26px;padding:0 8px;border:0;border-radius:var(--sg-radius, 6px);background:none;color:inherit;font:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}.is-active .sv-btabs-name{font-weight:600;padding-right:2px}.sv-btabs-more{display:grid;place-items:center;width:22px;height:22px;padding:0;border:0;border-radius:var(--sg-radius, 6px);background:none;color:var(--sg-muted, #78716c);cursor:pointer}.sv-btabs-more:hover{background:color-mix(in srgb,var(--sg-fg, #1c1917) 10%,transparent);color:var(--sg-fg, #1c1917)}.sv-btabs-input{width:160px;height:24px;margin:0 2px;padding:0 6px;box-sizing:border-box;font:inherit;font-weight:600;color:var(--sg-fg, #1c1917);background:var(--sg-input-bg, var(--sg-bg, #fff));border:1px solid var(--sg-accent, #2563eb);border-radius:var(--sg-radius, 6px);outline:none}.sv-btabs-tools{flex:none;display:flex;align-items:center;gap:2px;height:var(--sv-btabs-h);margin-left:0}.sv-btabs-status{flex:0 1 auto;align-self:center;min-width:0;margin-left:auto;padding:0 12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--sg-muted, #78716c)}.sv-btabs-status.is-error{color:var(--sg-danger, #dc2626)}.sv-btabs-tool{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 8px;border:0;border-radius:var(--sg-radius, 6px);background:none;color:var(--sg-muted, #78716c);font:inherit;cursor:pointer;white-space:nowrap;transition:color .12s ease,background-color .12s ease}.sv-btabs-icon{width:26px;padding:0;justify-content:center}.sv-btabs-tool:hover{color:var(--sg-fg, #1c1917);background:color-mix(in srgb,var(--sg-bg, #fff) 55%,transparent)}.sv-btabs-name:focus-visible,.sv-btabs-more:focus-visible,.sv-btabs-tool:focus-visible{outline:2px solid var(--sg-focus-ring, var(--sg-accent, #2563eb));outline-offset:-2px}@media(prefers-reduced-motion:reduce){.sv-btabs-tab,.sv-btabs-tool{transition:none}}.sv-btabs-menu{display:flex;flex-direction:column;min-width:190px;max-height:320px;overflow-y:auto;padding:4px;font-size:13px}.sv-btabs-sep{height:1px;margin:4px 6px;background:var(--sg-border, #e2e8f0)}.sv-btabs-item{display:flex;align-items:center;gap:6px;height:32px;padding:0 10px;text-align:start;border:0;border-radius:6px;background:none;color:var(--sg-fg, #0f172a);font:inherit;cursor:pointer}.sv-btabs-item:hover:not(:disabled),.sv-btabs-item:focus-visible{background:color-mix(in srgb,var(--sg-fg, #0f172a) 6%,transparent);outline:none}.sv-btabs-item:disabled{color:var(--sg-muted, #64748b);cursor:default}.sv-btabs-item.is-danger:not(:disabled){color:var(--sg-danger, #dc2626)}.sv-btabs-item.is-current{font-weight:600}.sv-btabs-check{width:14px;flex:none;color:var(--sg-muted, #64748b)}.sv-btabs-warn{margin:0 0 8px;font-size:14px;color:var(--sg-fg, #0f172a)}.sv-btabs-links{margin:0 0 4px;padding-left:18px;font-size:13px;color:var(--sg-muted, #64748b)}.sv-btabs-foot{display:flex;justify-content:flex-end;gap:8px;width:100%}.sv-btabs-btn{height:32px;padding:0 14px;font:inherit;font-size:13px;cursor:pointer;border-radius:var(--sg-radius, 6px);background:transparent;color:var(--sg-fg, #0f172a);border:1px solid var(--sg-border, #e2e8f0)}.sv-btabs-btn.is-danger{background:var(--sg-danger, #dc2626);border-color:var(--sg-danger, #dc2626);color:#fff}
140
+ .sv-btabs{--sv-btabs-h: 33px;display:flex;align-items:flex-end;gap:2px;box-sizing:border-box;height:calc(var(--sv-btabs-h) + 7px);padding:0 6px 0 0;font-family:var(--sg-font, inherit);font-size:13px;line-height:1;background:var(--sg-muted-bg, var(--sg-header-bg, #f5f5f4));box-shadow:inset 0 -1px 0 var(--sg-border, #e7e5e4)}.sv-btabs-list{display:flex;align-items:flex-end;min-width:0;height:100%;padding:0 0 0 8px;overflow-x:auto;scrollbar-width:none}.sv-btabs-list::-webkit-scrollbar{display:none}.sv-btabs-tab{position:relative;flex:none;display:flex;align-items:center;gap:2px;box-sizing:border-box;height:var(--sv-btabs-h);padding:0 6px 1px 4px;border:1px solid transparent;border-bottom:0;border-radius:var(--sg-radius, 6px) var(--sg-radius, 6px) 0 0;color:var(--sg-muted, #78716c);transition:color .12s ease,background-color .12s ease}.sv-btabs-tab:not(.is-active)+.sv-btabs-tab:not(.is-active):before{content:"";position:absolute;left:-2px;top:10px;bottom:10px;width:1px;background:var(--sg-border, #e7e5e4)}.sv-btabs-tab:hover:before,.sv-btabs-tab:hover+.sv-btabs-tab:before{opacity:0}.sv-btabs-tab:not(.is-active):hover{color:var(--sg-fg, #1c1917);background:color-mix(in srgb,var(--sg-bg, #fff) 55%,transparent)}.sv-btabs-tab.is-active{z-index:1;height:calc(var(--sv-btabs-h) + 1px);margin-bottom:-1px;padding-bottom:2px;color:var(--sg-fg, #1c1917);background:var(--sg-bg, #fff);border-color:var(--sg-border, #e7e5e4);box-shadow:inset 0 2px 0 var(--sg-accent, #2563eb)}.sv-btabs-name{max-width:220px;height:26px;padding:0 8px;border:0;border-radius:var(--sg-radius, 6px);background:none;color:inherit;font:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}.is-active .sv-btabs-name{font-weight:600;padding-right:2px}.sv-btabs-more{display:grid;place-items:center;width:22px;height:22px;padding:0;border:0;border-radius:var(--sg-radius, 6px);background:none;color:var(--sg-muted, #78716c);cursor:pointer}.sv-btabs-more:hover{background:color-mix(in srgb,var(--sg-fg, #1c1917) 10%,transparent);color:var(--sg-fg, #1c1917)}.sv-btabs-input{width:160px;height:24px;margin:0 2px;padding:0 6px;box-sizing:border-box;font:inherit;font-weight:600;color:var(--sg-fg, #1c1917);background:var(--sg-input-bg, var(--sg-bg, #fff));border:1px solid var(--sg-accent, #2563eb);border-radius:var(--sg-radius, 6px);outline:none}.sv-btabs-tools{flex:none;display:flex;align-items:center;gap:2px;height:var(--sv-btabs-h);margin-left:0}.sv-btabs-end{flex:none;display:flex;align-items:center;gap:2px;height:var(--sv-btabs-h);margin-left:auto}.sv-btabs-status~.sv-btabs-end{margin-left:0}.sv-btabs-tool:disabled{opacity:.4;cursor:default;background:none}.sv-btabs-trash{gap:4px;padding:0 6px}.sv-btabs-end>:global(.sv-pop__anchor){margin-right:4px}.sv-btabs-badge{display:inline-flex;align-items:center;gap:5px;height:22px;margin:0 2px;padding:0 8px;border-radius:999px;white-space:nowrap;font-size:12px;color:var(--sg-muted, #78716c);background:color-mix(in srgb,var(--sg-fg, #1c1917) 7%,transparent)}.sv-btabs-count{font-size:12px;font-variant-numeric:tabular-nums}.sv-btabs-status{flex:0 1 auto;align-self:center;min-width:0;margin-left:auto;padding:0 12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--sg-muted, #78716c)}.sv-btabs-status.is-error{color:var(--sg-danger, #dc2626)}.sv-btabs-tool{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 8px;border:0;border-radius:var(--sg-radius, 6px);background:none;color:var(--sg-muted, #78716c);font:inherit;cursor:pointer;white-space:nowrap;transition:color .12s ease,background-color .12s ease}.sv-btabs-icon{width:26px;padding:0;justify-content:center}.sv-btabs-tool:hover{color:var(--sg-fg, #1c1917);background:color-mix(in srgb,var(--sg-bg, #fff) 55%,transparent)}.sv-btabs-name:focus-visible,.sv-btabs-more:focus-visible,.sv-btabs-tool:focus-visible{outline:2px solid var(--sg-focus-ring, var(--sg-accent, #2563eb));outline-offset:-2px}@media(prefers-reduced-motion:reduce){.sv-btabs-tab,.sv-btabs-tool{transition:none}}@container (max-width: 600px){.sv-btabs-add span{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.sv-btabs-add{width:26px;padding:0;justify-content:center}.sv-btabs-badge span{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.sv-btabs-badge{padding:0 6px}.sv-btabs-status{display:none}.sv-btabs-name{max-width:130px}}.sv-btabs-menu{display:flex;flex-direction:column;min-width:190px;max-height:320px;overflow-y:auto;padding:4px;font-size:13px}.sv-btabs-sep{height:1px;margin:4px 6px;background:var(--sg-border, #e2e8f0)}.sv-btabs-item{display:flex;align-items:center;gap:6px;height:32px;padding:0 10px;text-align:start;border:0;border-radius:6px;background:none;color:var(--sg-fg, #0f172a);font:inherit;cursor:pointer}.sv-btabs-item:hover:not(:disabled),.sv-btabs-item:focus-visible{background:color-mix(in srgb,var(--sg-fg, #0f172a) 6%,transparent);outline:none}.sv-btabs-item:disabled{color:var(--sg-muted, #64748b);cursor:default}.sv-btabs-item.is-danger:not(:disabled){color:var(--sg-danger, #dc2626)}.sv-btabs-item.is-current{font-weight:600}.sv-btabs-check{width:14px;flex:none;color:var(--sg-muted, #64748b)}.sv-btabs-warn{margin:0 0 8px;font-size:14px;color:var(--sg-fg, #0f172a)}.sv-btabs-links{margin:0 0 4px;padding-left:18px;font-size:13px;color:var(--sg-muted, #64748b)}.sv-btabs-foot{display:flex;justify-content:flex-end;gap:8px;width:100%}.sv-btabs-btn{height:32px;padding:0 14px;font:inherit;font-size:13px;cursor:pointer;border-radius:var(--sg-radius, 6px);background:transparent;color:var(--sg-fg, #0f172a);border:1px solid var(--sg-border, #e2e8f0)}.sv-btabs-btn.is-danger{background:var(--sg-danger, #dc2626);border-color:var(--sg-danger, #dc2626);color:#fff}
104
141
  </style>
@@ -1,4 +1,5 @@
1
1
  import { type BaseTable } from './base-tables.js';
2
+ import type { BaseSearchGroup } from './base-search.js';
2
3
  type $$ComponentProps = {
3
4
  tables: ReadonlyArray<BaseTable>;
4
5
  activeId: string;
@@ -15,7 +16,30 @@ type $$ComponentProps = {
15
16
  tone?: 'muted' | 'error';
16
17
  title?: string;
17
18
  } | null;
19
+ /** Undo and Redo: whether each can run, what it would do, and the two actions. */
20
+ undo?: {
21
+ canUndo: boolean;
22
+ canRedo: boolean;
23
+ undoLabel: string;
24
+ redoLabel: string;
25
+ onUndo: () => void;
26
+ onRedo: () => void;
27
+ } | null;
28
+ /** How many items are in the trash (the button shows when there is a trash). */
29
+ trashCount?: number;
30
+ onOpenTrash?: () => void;
31
+ /** Import a file: as records of the shown table, or as a new table. */
32
+ onImport?: (mode: 'append' | 'new') => void;
33
+ /** Tabs to look at only: no table menu, renaming or adding, and a "View only" badge. */
34
+ readOnly?: boolean;
35
+ /** The search box: what it runs over the tables, and what opens a record it found. */
36
+ search?: {
37
+ run: (query: string) => BaseSearchGroup[];
38
+ onPick: (table: string, rowId: string) => void;
39
+ } | null;
18
40
  };
19
- declare const BaseTabs: import("svelte").Component<$$ComponentProps, {}, "">;
41
+ declare const BaseTabs: import("svelte").Component<$$ComponentProps, {
42
+ focusSearch: () => boolean;
43
+ }, "">;
20
44
  type BaseTabs = ReturnType<typeof BaseTabs>;
21
45
  export default BaseTabs;
@@ -0,0 +1,63 @@
1
+ <script lang="ts">
2
+ import{trashLabel}from"./base-trash";let{open=$bindable(false),items,tables,days=30,onRestore,onDelete,onEmpty}=$props();let kind=$state("all");let query=$state("");let confirmEmpty=$state(false);const KINDS=[{value:"all",label:"All"},{value:"record",label:"Records"},{value:"field",label:"Fields"},{value:"table",label:"Tables"}];function tableName(item){if(item.kind==="table")return item.table.name;const here=tables.find(t=>t.id===item.table);if(here)return here.name;for(const i of items)if(i.kind==="table"&&i.table.id===item.table)return`${i.table.name} (deleted)`;return"a deleted table"}const shown=$derived.by(()=>{const q=query.trim().toLowerCase();return[...items].filter(i=>kind==="all"||i.kind===kind).filter(i=>!q||trashLabel(i,tables).toLowerCase().includes(q)||tableName(i).toLowerCase().includes(q)).sort((a,b)=>b.deletedAt.localeCompare(a.deletedAt))});const countOf=k=>k==="all"?items.length:items.filter(i=>i.kind===k).length;function ago(iso){const s=Math.max(0,(Date.now()-new Date(iso).getTime())/1e3);if(s<60)return"just now";if(s<3600)return`${Math.floor(s/60)} min ago`;if(s<86400)return`${Math.floor(s/3600)} h ago`;const d=Math.floor(s/86400);return d===1?"yesterday":`${d} days ago`}const kindLabel=k=>k==="record"?"Record":k==="field"?"Field":"Table";const ICON={record:"M4 6h16M4 12h16M4 18h10",field:"M5 4v16M5 4h14v16H5M12 4v16",table:"M3 5h18v14H3zM3 10h18M9 10v9"};
3
+ </script>
4
+
5
+ <SvModal bind:open title="Trash" width={600}>
6
+ <div class="sv-btrash">
7
+ <div class="sv-btrash-bar">
8
+ <div class="sv-btrash-kinds" role="radiogroup" aria-label="Show">
9
+ {#each KINDS as k (k.value)}
10
+ <button type="button" role="radio" aria-checked={kind === k.value} class="sv-btrash-kind" class:is-on={kind === k.value} onclick={() => (kind = k.value)}>
11
+ {k.label} <span class="sv-btrash-n">{countOf(k.value)}</span>
12
+ </button>
13
+ {/each}
14
+ </div>
15
+ <input class="sv-btrash-search" type="search" placeholder="Find in trash" aria-label="Find in trash" bind:value={query} />
16
+ </div>
17
+ {#if !items.length}
18
+ <p class="sv-btrash-empty">The trash is empty. Deleted records, fields and tables come here{days > 0 ? ` and stay ${days} days` : ''}.</p>
19
+ {:else if !shown.length}
20
+ <p class="sv-btrash-empty">Nothing in the trash matches.</p>
21
+ {:else}
22
+ <ul class="sv-btrash-list" aria-label="Deleted items">
23
+ {#each shown as item (item.id)}
24
+ {@const why = cannotRestore(item, tables)}
25
+ {@const user = findFieldUser(item.deletedBy)}
26
+ <li class="sv-btrash-item">
27
+ <svg class="sv-btrash-icon" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><path d={ICON[item.kind]} fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" /></svg>
28
+ <div class="sv-btrash-main">
29
+ <span class="sv-btrash-name">{trashLabel(item, tables)}</span>
30
+ <span class="sv-btrash-meta">
31
+ {kindLabel(item.kind)}{item.kind !== 'table' ? ` in ${tableName(item)}` : item.table.data.length ? `, ${item.table.data.length} records` : ''}
32
+ · {ago(item.deletedAt)}
33
+ {#if user}<span class="sv-btrash-by">by <UserFace {user} size={16} /> {user.name}</span>{/if}
34
+ </span>
35
+ </div>
36
+ <button type="button" class="sv-btrash-btn" disabled={!!why} title={why || undefined} onclick={() => onRestore([item.id])}>Restore</button>
37
+ <button type="button" class="sv-btrash-btn sv-btrash-x" aria-label={`Delete ${trashLabel(item, tables)} forever`} title="Delete forever" onclick={() => onDelete([item.id])}>
38
+ <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" /></svg>
39
+ </button>
40
+ </li>
41
+ {/each}
42
+ </ul>
43
+ {/if}
44
+ </div>
45
+ {#snippet footer()}
46
+ <div class="sv-btrash-foot">
47
+ <span class="sv-btrash-note">{days > 0 ? `Items are deleted for good after ${days} days.` : 'Items stay until the trash is emptied.'}</span>
48
+ {#if shown.length > 1 && shown.some((i) => !cannotRestore(i, tables))}
49
+ <button type="button" class="sv-btrash-btn" onclick={() => onRestore(shown.map((i) => i.id))}>Restore {shown.length === items.length ? 'all' : 'these'}</button>
50
+ {/if}
51
+ {#if confirmEmpty}
52
+ <button type="button" class="sv-btrash-btn" onclick={() => (confirmEmpty = false)}>Keep them</button>
53
+ <button type="button" class="sv-btrash-btn is-danger" onclick={() => { confirmEmpty = false; onEmpty() }}>Delete {items.length} forever</button>
54
+ {:else}
55
+ <button type="button" class="sv-btrash-btn" disabled={!items.length} onclick={() => (confirmEmpty = true)}>Empty trash</button>
56
+ {/if}
57
+ </div>
58
+ {/snippet}
59
+ </SvModal>
60
+
61
+ <style>
62
+ .sv-btrash{display:flex;flex-direction:column;gap:10px;min-height:240px;font-size:13px;color:var(--sg-fg, #1c1917)}.sv-btrash-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.sv-btrash-kinds{display:flex;gap:2px;padding:2px;border-radius:var(--sg-radius, 6px);background:color-mix(in srgb,var(--sg-fg, #0f172a) 7%,transparent)}.sv-btrash-kind{height:26px;padding:0 10px;border:0;border-radius:calc(var(--sg-radius, 6px) - 2px);background:none;color:var(--sg-muted, #78716c);font:inherit;cursor:pointer}.sv-btrash-kind.is-on{background:var(--sg-bg, #fff);color:var(--sg-fg, #1c1917);box-shadow:0 0 0 1px var(--sg-border, #e7e5e4)}.sv-btrash-n{color:var(--sg-muted, #78716c);font-variant-numeric:tabular-nums}.sv-btrash-search{flex:1 1 160px;height:30px;padding:0 10px;box-sizing:border-box;font:inherit;color:var(--sg-fg, #1c1917);background:var(--sg-input-bg, var(--sg-bg, #fff));border:1px solid var(--sg-border, #e7e5e4);border-radius:var(--sg-radius, 6px)}.sv-btrash-empty{margin:32px 0;text-align:center;color:var(--sg-muted, #78716c)}.sv-btrash-list{margin:0;padding:0;list-style:none;max-height:360px;overflow-y:auto}.sv-btrash-item{display:flex;align-items:center;gap:10px;padding:8px 4px;border-bottom:1px solid var(--sg-border, #e7e5e4)}.sv-btrash-icon{flex:none;color:var(--sg-muted, #78716c)}.sv-btrash-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}.sv-btrash-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-btrash-meta{display:flex;flex-wrap:wrap;align-items:center;gap:4px;font-size:12px;color:var(--sg-muted, #78716c)}.sv-btrash-by{display:inline-flex;align-items:center;gap:4px}.sv-btrash-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;width:100%}.sv-btrash-note{margin-right:auto;font-size:12px;color:var(--sg-muted, #78716c)}.sv-btrash-btn{flex:none;height:30px;padding:0 12px;font:inherit;font-size:13px;cursor:pointer;border-radius:var(--sg-radius, 6px);background:transparent;color:var(--sg-fg, #1c1917);border:1px solid var(--sg-border, #e7e5e4)}.sv-btrash-btn:disabled{color:var(--sg-muted, #78716c);cursor:default;opacity:.7}.sv-btrash-x{width:30px;padding:0;display:grid;place-items:center;color:var(--sg-muted, #78716c)}.sv-btrash-x:hover{color:var(--sg-danger, #dc2626)}.sv-btrash-btn.is-danger{background:var(--sg-danger, #dc2626);border-color:var(--sg-danger, #dc2626);color:#fff}.sv-btrash-btn:focus-visible,.sv-btrash-kind:focus-visible{outline:2px solid var(--sg-focus-ring, var(--sg-accent, #2563eb));outline-offset:1px}
63
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { BaseTable } from './base-tables.js';
2
+ import { type BaseTrashItem } from './base-trash.js';
3
+ type $$ComponentProps = {
4
+ open?: boolean;
5
+ items: ReadonlyArray<BaseTrashItem>;
6
+ tables: ReadonlyArray<BaseTable>;
7
+ /** How long an item stays (0: until the trash is emptied). */
8
+ days?: number;
9
+ onRestore: (ids: string[]) => void;
10
+ onDelete: (ids: string[]) => void;
11
+ onEmpty: () => void;
12
+ };
13
+ declare const BaseTrash: import("svelte").Component<$$ComponentProps, {}, "open">;
14
+ type BaseTrash = ReturnType<typeof BaseTrash>;
15
+ export default BaseTrash;
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import{checklistProgress}from"./checklist";let{ctrl,row,column,value}=$props();const p=$derived(checklistProgress(value));const g=$derived(ctrl);const interactive=$derived(!!g?.editingEnabled&&column.columnDef.editable!==false);function open(e){if(!interactive||!e.currentTarget.closest('[role="gridcell"]'))return;const grid=g;const rowId=row.id;const columnId=column.id;setTimeout(()=>{const rowIndex=(grid.allRows??[]).findIndex(r=>r.id===rowId);if(rowIndex>=0)grid.startEditing?.(rowIndex,columnId)})}
3
+ </script>
4
+
5
+
6
+
7
+ <span
8
+ class="sv-fck"
9
+ class:is-interactive={interactive}
10
+ class:is-done={p.total > 0 && p.done === p.total}
11
+ aria-label={p.total ? `${p.done} of ${p.total} done` : 'No items'}
12
+ onclick={open}
13
+ >
14
+ {#if p.total}
15
+ <span class="sv-fck-count">{p.done}/{p.total}</span>
16
+ <span class="sv-fck-bar" aria-hidden="true"><span class="sv-fck-fill" style:width={`${(p.done / p.total) * 100}%`}></span></span>
17
+ {/if}
18
+ </span>
19
+
20
+ <style>
21
+ .sv-fck{display:inline-flex;align-items:center;gap:8px;max-width:100%;min-width:0;height:100%;font-variant-numeric:tabular-nums}.sv-fck.is-interactive{cursor:pointer}.sv-fck-count{flex:none;font-size:12px;color:var(--sg-fg, #0f172a)}.sv-fck-bar{flex:0 1 72px;min-width:24px;height:6px;border-radius:999px;overflow:hidden;background:var(--sg-row-hover-bg, #f1f5f9)}.sv-fck-fill{display:block;height:100%;border-radius:inherit;background:var(--sg-muted, #64748b)}.sv-fck.is-done .sv-fck-fill{background:var(--sg-success, #16a34a)}
22
+ </style>
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checklist cells: "3/5" and a bar for the share done, green once every
3
+ * item is. In an editable grid a click on them opens the checklist editor
4
+ * (a click beside them selects the cell, for a copy); in the record view
5
+ * and a form the box around the cell opens it.
6
+ */
7
+ import type { FieldCellProps } from './registry.svelte.js';
8
+ declare const ChecklistCell: import("svelte").Component<FieldCellProps, {}, "">;
9
+ type ChecklistCell = ReturnType<typeof ChecklistCell>;
10
+ export default ChecklistCell;
@@ -0,0 +1,81 @@
1
+ <script lang="ts">
2
+ import{createDismissableLayer}from"@svgrid/grid";import{onMount,tick}from"svelte";import{newChecklistItemId,toChecklist}from"./checklist";let{value,typed=false,row,columnDef,onCommit,onCancel,onCommitAndMove}=$props();let items=$state(toChecklist(typed?row?.[String(columnDef?.field??"")]:value));let draft=$state(typed?String(value??""):"");let finished=false;const done=$derived(items.filter(i=>i.done).length);const name=$derived(String(columnDef?.header??"Checklist"));let anchor=$state(null);let panel=$state(null);let addBox=$state(null);let rect=$state(null);const PANEL_HEIGHT=300;function place(){const cell=anchor?.closest("td")??anchor;if(!cell)return;const r=cell.getBoundingClientRect();const width=Math.min(Math.max(r.width+2,320),window.innerWidth-16);const left=Math.max(8,Math.min(r.left-1,window.innerWidth-width-8));const top=Math.max(8,Math.min(r.top-1,window.innerHeight-PANEL_HEIGHT-8));rect={top,left,width,maxHeight:window.innerHeight-top-8}}onMount(()=>{place();const takeFocus=()=>{if(!addBox||panel?.contains(document.activeElement))return;addBox.focus({preventScroll:true});addBox.setSelectionRange(draft.length,draft.length)};queueMicrotask(takeFocus);const frame=requestAnimationFrame(takeFocus);const onDown=e=>{const t=e.target;if(finished||panel?.contains(t)||anchor?.contains(t))return;finish("commit")};const onScroll=e=>{if(!panel?.contains(e.target))place()};window.addEventListener("resize",place);window.addEventListener("scroll",onScroll,true);document.addEventListener("pointerdown",onDown,true);const layer=createDismissableLayer({element:()=>[panel??null,anchor??null],onDismiss:()=>{},closeOnEscape:false,closeOnOutside:false});layer.activate();return()=>{layer.release();cancelAnimationFrame(frame);window.removeEventListener("resize",place);window.removeEventListener("scroll",onScroll,true);document.removeEventListener("pointerdown",onDown,true)}});function current(){const t=draft.trim();const kept=items.map(i=>({id:i.id,text:i.text.trim(),done:i.done})).filter(i=>i.text);if(t)kept.push({id:newChecklistItemId(),text:t,done:false});return kept.length?kept:null}function finish(how){if(finished)return;finished=true;if(how==="cancel")return onCancel();const v=current();if((how==="next"||how==="prev")&&onCommitAndMove)onCommitAndMove(v,how==="next"?1:-1);else onCommit(v)}const textOf=e=>e.currentTarget.value;async function focusItem(i){await tick();const el=panel?.querySelector(`[data-item="${i}"]`);if(el)el.focus();else addBox?.focus()}function add(){const t=draft.trim();if(!t)return;items=[...items,{id:newChecklistItemId(),text:t,done:false}];draft=""}function toggle(i){items=items.map((x,j)=>j===i?{...x,done:!x.done}:x)}function rename(i,text){items=items.map((x,j)=>j===i?{...x,text}:x)}function remove(i){items=items.filter((_,j)=>j!==i)}function move(from,to){if(to<0||to>=items.length||from===to)return;const next=items.slice();const[it]=next.splice(from,1);next.splice(to,0,it);items=next}function panelKey(e){if(e.key==="Enter"&&(e.ctrlKey||e.metaKey))finish("commit");else if(e.key==="Escape")finish("cancel");else if(e.key==="Tab")finish(e.shiftKey?"prev":"next");else return false;return true}function onAddKey(e){if(panelKey(e)){}else if(e.key==="Enter")add();else if(e.key==="Backspace"&&!draft&&items.length)void focusItem(items.length-1);else{e.stopPropagation();return}e.preventDefault();e.stopPropagation()}function onItemKey(e,i){if(panelKey(e)){}else if(e.altKey&&(e.key==="ArrowUp"||e.key==="ArrowDown")){const to=i+(e.key==="ArrowUp"?-1:1);move(i,to);void focusItem(Math.max(0,Math.min(items.length-1,to)))}else if(e.key==="Enter")void focusItem(i+1);else if(e.key==="Backspace"&&!items[i].text){remove(i);void focusItem(i-1<0?items.length:i-1)}else{e.stopPropagation();return}e.preventDefault();e.stopPropagation()}let dragging=$state(null);let over=$state(null);function dragStart(e,i){dragging=i;e.dataTransfer?.setData("text/plain",items[i].text);if(e.dataTransfer)e.dataTransfer.effectAllowed="move"}function dragOver(e,i){if(dragging==null)return;e.preventDefault();over=i}function drop(e){e.preventDefault();if(dragging!=null&&over!=null)move(dragging,over);dragging=over=null}const mod=typeof navigator!=="undefined"&&/Mac|iPhone|iPad/.test(navigator.platform)?"Cmd":"Ctrl";
3
+ </script>
4
+
5
+ <span class="sv-fce-cell" bind:this={anchor}>{done}/{items.length}</span>
6
+
7
+ {#if rect}
8
+ <div
9
+ class="sv-fce-panel"
10
+ bind:this={panel}
11
+ use:portalToBody
12
+ role="dialog"
13
+ aria-label={name}
14
+ style:top={`${rect.top}px`}
15
+ style:left={`${rect.left}px`}
16
+ style:width={`${rect.width}px`}
17
+ style:max-height={`${rect.maxHeight}px`}
18
+ >
19
+ <div class="sv-fce-head">
20
+ <span>{items.length ? `${done} of ${items.length} done` : 'No items yet'}</span>
21
+ {#if items.length}
22
+ <span class="sv-fce-bar" aria-hidden="true"><span class="sv-fce-fill" class:is-done={done === items.length} style:width={`${(done / items.length) * 100}%`}></span></span>
23
+ {/if}
24
+ </div>
25
+ {#if items.length}
26
+ <ul class="sv-fce-list" aria-label="Items">
27
+ {#each items as it, i (it.id)}
28
+ <li
29
+ class="sv-fce-item"
30
+ class:is-over={over === i && dragging !== i}
31
+ class:is-dragging={dragging === i}
32
+ ondragover={(e) => dragOver(e, i)}
33
+ ondrop={drop}
34
+ >
35
+ <span
36
+ class="sv-fce-grip"
37
+ draggable="true"
38
+ role="button"
39
+ tabindex="-1"
40
+ aria-label={`Move ${it.text || 'item'}`}
41
+ ondragstart={(e) => dragStart(e, i)}
42
+ ondragend={() => (dragging = over = null)}
43
+ >
44
+ <svg viewBox="0 0 24 24" width="12" height="12" aria-hidden="true"><path d="M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" /></svg>
45
+ </span>
46
+ <input class="sv-fce-check" type="checkbox" checked={it.done} aria-label={`Done: ${it.text}`} onchange={() => toggle(i)} />
47
+ <input
48
+ class="sv-fce-text"
49
+ class:is-done={it.done}
50
+ data-item={i}
51
+ value={it.text}
52
+ aria-label={`Item ${i + 1}`}
53
+ oninput={(e) => rename(i, textOf(e))}
54
+ onkeydown={(e) => onItemKey(e, i)}
55
+ />
56
+ <button type="button" class="sv-fce-x" aria-label={`Delete ${it.text || 'item'}`} onmousedown={(e) => e.preventDefault()} onclick={() => remove(i)}>
57
+ <svg viewBox="0 0 24 24" width="11" height="11" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" /></svg>
58
+ </button>
59
+ </li>
60
+ {/each}
61
+ </ul>
62
+ {/if}
63
+ <input
64
+ bind:this={addBox}
65
+ class="sv-fce-add"
66
+ placeholder="Add an item"
67
+ aria-label="Add an item"
68
+ value={draft}
69
+ oninput={(e) => (draft = textOf(e))}
70
+ onkeydown={onAddKey}
71
+ />
72
+ <div class="sv-fce-foot">
73
+ <span class="sv-fce-keys"><kbd>Alt+↑↓</kbd> move <kbd>{mod}+Enter</kbd> save <kbd>Esc</kbd> cancel</span>
74
+ <button type="button" class="sv-fce-done" onclick={() => finish('commit')}>Done</button>
75
+ </div>
76
+ </div>
77
+ {/if}
78
+
79
+ <style>
80
+ .sv-fce-cell{display:block;padding:0 8px;font-size:12px;font-variant-numeric:tabular-nums}.sv-fce-panel{position:fixed;z-index:2147483646;display:flex;flex-direction:column;gap:6px;box-sizing:border-box;padding:8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius, 6px);background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);box-shadow:0 8px 24px #00000029;font-size:13px}.sv-fce-head{display:flex;align-items:center;gap:10px;padding:0 2px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-fce-bar{flex:1;height:6px;border-radius:999px;overflow:hidden;background:var(--sg-row-hover-bg, #f1f5f9)}.sv-fce-fill{display:block;height:100%;background:var(--sg-muted, #64748b)}.sv-fce-fill.is-done{background:var(--sg-success, #16a34a)}.sv-fce-list{list-style:none;margin:0;padding:0;overflow:auto;min-height:0}.sv-fce-item{display:flex;align-items:center;gap:6px;min-height:30px;padding:0 2px;border-radius:4px;border-top:2px solid transparent}.sv-fce-item:hover{background:var(--sg-row-hover-bg, #f1f5f9)}.sv-fce-item.is-over{border-top-color:var(--sg-accent, #2563eb)}.sv-fce-item.is-dragging{opacity:.5}.sv-fce-grip{display:inline-flex;flex:none;padding:2px;color:var(--sg-muted, #94a3b8);cursor:grab}.sv-fce-check{flex:none;width:15px;height:15px;margin:0;accent-color:var(--sg-accent, #2563eb)}.sv-fce-text{flex:1;min-width:0;height:26px;padding:0 6px;font:inherit;border:1px solid transparent;border-radius:4px;background:none;color:inherit}.sv-fce-text:focus{outline:none;border-color:var(--sg-accent, #2563eb);background:var(--sg-input-bg, var(--sg-bg, #fff))}.sv-fce-text.is-done{text-decoration:line-through;color:var(--sg-muted, #64748b)}.sv-fce-x{display:inline-flex;flex:none;padding:4px;border:0;border-radius:4px;background:none;color:var(--sg-muted, #64748b);cursor:pointer;opacity:0}.sv-fce-item:hover .sv-fce-x,.sv-fce-x:focus-visible{opacity:1}.sv-fce-x:hover{color:var(--sg-fg, #0f172a);background:color-mix(in srgb,currentColor 12%,transparent)}.sv-fce-add{flex:none;height:30px;padding:0 8px;font:inherit;box-sizing:border-box;width:100%;border:1px solid var(--sg-input-border, var(--sg-border, #e2e8f0));border-radius:var(--sg-radius, 6px);background:var(--sg-input-bg, var(--sg-bg, #fff));color:var(--sg-fg, #0f172a)}.sv-fce-add:focus{outline:none;border-color:var(--sg-accent, #2563eb)}.sv-fce-foot{display:flex;align-items:center;gap:8px;padding:0 2px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-fce-keys kbd{padding:0 4px;border:1px solid var(--sg-border, #e2e8f0);border-radius:3px;font:inherit;font-size:11px}.sv-fce-done{margin-inline-start:auto;height:26px;padding:0 12px;border:0;border-radius:var(--sg-radius, 6px);background:var(--sg-accent, #2563eb);color:var(--sg-accent-fg, #fff);font:inherit;font-size:12px;cursor:pointer}
81
+ </style>
@@ -0,0 +1,12 @@
1
+ type $$ComponentProps = {
2
+ value: unknown;
3
+ typed?: boolean;
4
+ row?: unknown;
5
+ columnDef?: Record<string, unknown>;
6
+ onCommit: (v?: unknown) => void;
7
+ onCancel: () => void;
8
+ onCommitAndMove?: (v: unknown, direction: 1 | -1) => void;
9
+ };
10
+ declare const ChecklistEditor: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ type ChecklistEditor = ReturnType<typeof ChecklistEditor>;
12
+ export default ChecklistEditor;
@@ -0,0 +1,13 @@
1
+ <script lang="ts">
2
+ import{parseColor}from"./color-value";let{value}=$props();const hex=$derived(parseColor(value));
3
+ </script>
4
+
5
+ {#if hex}
6
+ <span class="sv-fco"><span class="sv-fco-swatch" style:background={hex} aria-hidden="true"></span><span class="sv-fco-hex">{hex}</span></span>
7
+ {:else if value != null && value !== ''}
8
+ <span class="sv-fco"><span class="sv-fco-hex">{String(value)}</span></span>
9
+ {/if}
10
+
11
+ <style>
12
+ .sv-fco{display:inline-flex;align-items:center;gap:8px;min-width:0}.sv-fco-swatch{flex:none;width:16px;height:16px;border-radius:4px;box-sizing:border-box;border:1px solid color-mix(in srgb,var(--sg-fg, #0f172a) 18%,transparent)}.sv-fco-hex{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,monospace;font-size:12px}
13
+ </style>
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Color cells: a swatch of the color and its hex code. A value that is not
3
+ * a color the field reads shows as text, without a swatch.
4
+ */
5
+ import type { FieldCellProps } from './registry.svelte.js';
6
+ declare const ColorCell: import("svelte").Component<FieldCellProps, {}, "">;
7
+ type ColorCell = ReturnType<typeof ColorCell>;
8
+ export default ColorCell;
@@ -0,0 +1,60 @@
1
+ <script lang="ts">
2
+ import{createDismissableLayer}from"@svgrid/grid";import{onMount,tick}from"svelte";import{OPTION_COLORS}from"./palette";import{parseColor}from"./color-value";let{value,typed=false,columnDef,onCommit,onCancel,onCommitAndMove}=$props();const COLS=10;const start=typed?null:parseColor(value);let text=$state(typed?String(value??""):start??"");const parsed=$derived(parseColor(text));const invalid=$derived(text.trim()!==""&&!parsed);let finished=false;const name=$derived(String(columnDef?.header??"Color"));let anchor=$state(null);let panel=$state(null);let box=$state(null);let rect=$state(null);const PANEL_HEIGHT=230;function place(){const cell=anchor?.closest("td")??anchor;if(!cell)return;const r=cell.getBoundingClientRect();const width=Math.min(284,window.innerWidth-16);const left=Math.max(8,Math.min(r.left-1,window.innerWidth-width-8));const top=Math.max(8,Math.min(r.top-1,window.innerHeight-PANEL_HEIGHT-8));rect={top,left,width}}onMount(()=>{place();const takeFocus=()=>{if(!box||panel?.contains(document.activeElement))return;box.focus({preventScroll:true});if(typed)box.setSelectionRange(text.length,text.length);else box.select()};queueMicrotask(takeFocus);const frame=requestAnimationFrame(takeFocus);const onDown=e=>{const t=e.target;if(finished||panel?.contains(t)||anchor?.contains(t))return;if(parsed||!text.trim())finish("commit");else finish("cancel")};const onScroll=e=>{if(!panel?.contains(e.target))place()};window.addEventListener("resize",place);window.addEventListener("scroll",onScroll,true);document.addEventListener("pointerdown",onDown,true);const layer=createDismissableLayer({element:()=>[panel??null,anchor??null],onDismiss:()=>{},closeOnEscape:false,closeOnOutside:false});layer.activate();return()=>{layer.release();cancelAnimationFrame(frame);window.removeEventListener("resize",place);window.removeEventListener("scroll",onScroll,true);document.removeEventListener("pointerdown",onDown,true)}});function finish(how,picked){if(finished)return;const v=picked!==void 0?picked:text.trim()?parsed:null;if(how!=="cancel"&&picked===void 0&&invalid)return;finished=true;if(how==="cancel")return onCancel();if((how==="next"||how==="prev")&&onCommitAndMove)onCommitAndMove(v,how==="next"?1:-1);else onCommit(v)}function common(e){if(e.key==="Escape")finish("cancel");else if(e.key==="Tab")finish(e.shiftKey?"prev":"next");else return false;return true}function onBoxKey(e){if(common(e)){}else if(e.key==="Enter")finish("commit");else if(e.key==="ArrowDown")void focusSwatch(Math.max(0,OPTION_COLORS.findIndex(c=>c.value===parsed)));else{e.stopPropagation();return}e.preventDefault();e.stopPropagation()}async function focusSwatch(i){await tick();panel?.querySelector(`[data-swatch="${i}"]`)?.focus()}function onSwatchKey(e,i){const n=OPTION_COLORS.length;if(common(e)){}else if(e.key==="Enter"||e.key===" ")finish("commit",OPTION_COLORS[i].value);else if(e.key==="ArrowRight")void focusSwatch((i+1)%n);else if(e.key==="ArrowLeft")void focusSwatch((i-1+n)%n);else if(e.key==="ArrowDown")void focusSwatch(Math.min(n-1,i+COLS));else if(e.key==="ArrowUp"){if(i<COLS)box?.focus();else void focusSwatch(i-COLS)}else{e.stopPropagation();return}e.preventDefault();e.stopPropagation()}const inputValue=e=>e.currentTarget.value;
3
+ </script>
4
+
5
+ <span class="sv-fcoe-cell" bind:this={anchor}>
6
+ {#if parsed}<span class="sv-fcoe-swatch" style:background={parsed}></span>{/if}
7
+ </span>
8
+
9
+ {#if rect}
10
+ <div
11
+ class="sv-fcoe-panel"
12
+ bind:this={panel}
13
+ use:portalToBody
14
+ role="dialog"
15
+ aria-label={name}
16
+ style:top={`${rect.top}px`}
17
+ style:left={`${rect.left}px`}
18
+ style:width={`${rect.width}px`}
19
+ >
20
+ <div class="sv-fcoe-row">
21
+ <span class="sv-fcoe-preview" style:background={parsed ?? 'transparent'} class:is-none={!parsed} aria-hidden="true"></span>
22
+ <input
23
+ bind:this={box}
24
+ class="sv-fcoe-input"
25
+ placeholder="#2d7ff9"
26
+ aria-label="Hex code"
27
+ aria-invalid={invalid}
28
+ spellcheck="false"
29
+ value={text}
30
+ oninput={(e) => (text = inputValue(e))}
31
+ onkeydown={onBoxKey}
32
+ />
33
+ <button type="button" class="sv-fcoe-clear" onmousedown={(e) => e.preventDefault()} onclick={() => finish('commit', null)}>Clear</button>
34
+ </div>
35
+ {#if invalid}<p class="sv-fcoe-error" role="alert">Not a color: use #rrggbb, #rgb, rgb() or a color name</p>{/if}
36
+ <div class="sv-fcoe-grid" role="listbox" aria-label="Colors">
37
+ {#each OPTION_COLORS as c, i (c.value)}
38
+ <button
39
+ type="button"
40
+ class="sv-fcoe-swatch-btn"
41
+ class:is-on={parsed === c.value}
42
+ role="option"
43
+ aria-selected={parsed === c.value}
44
+ aria-label={c.label}
45
+ title={`${c.label} ${c.value}`}
46
+ data-swatch={i}
47
+ tabindex="-1"
48
+ style:background={c.value}
49
+ onmousedown={(e) => e.preventDefault()}
50
+ onclick={() => finish('commit', c.value)}
51
+ onkeydown={(e) => onSwatchKey(e, i)}
52
+ ></button>
53
+ {/each}
54
+ </div>
55
+ </div>
56
+ {/if}
57
+
58
+ <style>
59
+ .sv-fcoe-cell{display:flex;align-items:center;height:100%;padding:0 8px}.sv-fcoe-swatch{width:16px;height:16px;border-radius:4px;border:1px solid color-mix(in srgb,var(--sg-fg, #0f172a) 18%,transparent);box-sizing:border-box}.sv-fcoe-panel{position:fixed;z-index:2147483646;display:flex;flex-direction:column;gap:8px;box-sizing:border-box;padding:8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius, 6px);background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);box-shadow:0 8px 24px #00000029;font-size:13px}.sv-fcoe-row{display:flex;align-items:center;gap:6px}.sv-fcoe-preview{flex:none;width:28px;height:28px;border-radius:var(--sg-radius, 6px);box-sizing:border-box;border:1px solid color-mix(in srgb,var(--sg-fg, #0f172a) 18%,transparent)}.sv-fcoe-preview.is-none{background-image:linear-gradient(135deg,transparent 46%,var(--sg-danger, #dc2626) 46%,var(--sg-danger, #dc2626) 54%,transparent 54%)}.sv-fcoe-input{flex:1;min-width:0;height:28px;padding:0 8px;box-sizing:border-box;font-family:ui-monospace,monospace;font-size:13px;border:1px solid var(--sg-input-border, var(--sg-border, #e2e8f0));border-radius:var(--sg-radius, 6px);background:var(--sg-input-bg, var(--sg-bg, #fff));color:var(--sg-fg, #0f172a)}.sv-fcoe-input:focus{outline:none;border-color:var(--sg-accent, #2563eb)}.sv-fcoe-input[aria-invalid=true]{border-color:var(--sg-danger, #dc2626)}.sv-fcoe-clear{flex:none;height:28px;padding:0 10px;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius, 6px);background:none;color:inherit;font:inherit;font-size:12px;cursor:pointer}.sv-fcoe-error{margin:0;font-size:12px;color:var(--sg-danger, #dc2626)}.sv-fcoe-grid{display:grid;grid-template-columns:repeat(10,1fr);gap:4px}.sv-fcoe-swatch-btn{aspect-ratio:1;min-width:0;padding:0;border:0;border-radius:4px;cursor:pointer}.sv-fcoe-swatch-btn:focus-visible,.sv-fcoe-swatch-btn.is-on{outline:2px solid var(--sg-fg, #0f172a);outline-offset:1px}
60
+ </style>
@@ -0,0 +1,11 @@
1
+ type $$ComponentProps = {
2
+ value: unknown;
3
+ typed?: boolean;
4
+ columnDef?: Record<string, unknown>;
5
+ onCommit: (v?: unknown) => void;
6
+ onCancel: () => void;
7
+ onCommitAndMove?: (v: unknown, direction: 1 | -1) => void;
8
+ };
9
+ declare const ColorEditor: import("svelte").Component<$$ComponentProps, {}, "">;
10
+ type ColorEditor = ReturnType<typeof ColorEditor>;
11
+ export default ColorEditor;