@svgrid/enterprise 3.1.44 → 3.1.45

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 (49) hide show
  1. package/dist/cdn/svgrid-enterprise.svelte-external.js +1 -1
  2. package/dist/designer/assets/{index-CltOvNJn.js → index-BQO-FqUG.js} +214 -214
  3. package/dist/designer/index.html +1 -1
  4. package/dist/fields/BaseTableView.svelte +3 -2
  5. package/dist/fields/FieldEditor.svelte +1 -1
  6. package/dist/fields/FieldEditor.svelte.d.ts +3 -0
  7. package/dist/fields/FieldsHeaderEnd.svelte +1 -1
  8. package/dist/fields/FormulaInput.svelte +122 -0
  9. package/dist/fields/FormulaInput.svelte.d.ts +10 -0
  10. package/dist/fields/FormulaInputHarness.svelte +5 -0
  11. package/dist/fields/FormulaInputHarness.svelte.d.ts +11 -0
  12. package/dist/fields/NumberEditor.svelte +1 -1
  13. package/dist/fields/PasteFields.svelte +33 -0
  14. package/dist/fields/PasteFields.svelte.d.ts +6 -0
  15. package/dist/fields/PropertyInput.svelte +4 -8
  16. package/dist/fields/SvBase.svelte +1 -1
  17. package/dist/fields/SvBase.svelte.d.ts +7 -0
  18. package/dist/fields/SvBaseViewBar.svelte +2 -2
  19. package/dist/fields/base-import.js +2 -2
  20. package/dist/fields/celebrate.d.ts +29 -0
  21. package/dist/fields/celebrate.js +1 -0
  22. package/dist/fields/cell-colors.svelte.d.ts +17 -0
  23. package/dist/fields/cell-colors.svelte.js +1 -0
  24. package/dist/fields/editor-request.svelte.d.ts +7 -0
  25. package/dist/fields/excel-habits.svelte.d.ts +98 -0
  26. package/dist/fields/excel-habits.svelte.js +1 -0
  27. package/dist/fields/formula-docs.d.ts +24 -0
  28. package/dist/fields/formula-docs.js +1 -0
  29. package/dist/fields/index.d.ts +1 -0
  30. package/dist/fields/index.js +1 -1
  31. package/dist/fields/messages/fields.d.ts +28 -0
  32. package/dist/fields/messages/fields.js +1 -1
  33. package/dist/fields/messages/record.d.ts +1 -0
  34. package/dist/fields/messages/record.js +1 -1
  35. package/dist/fields/messages/shell.d.ts +22 -0
  36. package/dist/fields/messages/shell.js +1 -1
  37. package/dist/fields/messages/viewbar.d.ts +9 -0
  38. package/dist/fields/messages/viewbar.js +1 -1
  39. package/dist/fields/messages.svelte.d.ts +60 -0
  40. package/dist/fields/view-model.d.ts +3 -0
  41. package/dist/fields/view-model.js +1 -1
  42. package/dist/fields/viewbar/ColorPanel.svelte +54 -2
  43. package/dist/fields/viewbar/ColorPanel.svelte.d.ts +3 -0
  44. package/dist/node/studio.js +1 -1
  45. package/dist/version.d.ts +2 -2
  46. package/dist/version.js +1 -1
  47. package/dist/wc/sv-base-element.js +100 -96
  48. package/dist/wc/sv-sheet-element.js +43 -43
  49. package/package.json +3 -3
@@ -487,6 +487,34 @@ export declare const BASE_MESSAGES: {
487
487
  readonly 'fields.insertField': "Insert a field";
488
488
  readonly 'fields.functions': "Functions";
489
489
  readonly 'fields.hideFunctions': "Hide functions";
490
+ readonly 'fields.formulaAskPlaceholder': "Describe it, such as \"total with 20% VAT\"";
491
+ readonly 'fields.formulaAskLabel': "Describe the formula in your own words";
492
+ readonly 'fields.formulaAskButton': "Write it";
493
+ readonly 'fields.formulaAskWorking': "Writing…";
494
+ readonly 'fields.formulaAiFailed': "The AI could not write a formula that works. Try describing it another way.";
495
+ readonly 'fields.formulaSuggestions': "Suggestions";
496
+ readonly 'fields.formulaFieldHint': "Field";
497
+ readonly 'fields.formulaPreview': "Result:";
498
+ readonly 'fields.formulaUnnamed': "Unnamed record";
499
+ readonly 'fields.formulaEmpty': "(empty)";
500
+ readonly 'fields.formulaTrue': "true";
501
+ readonly 'fields.formulaFalse': "false";
502
+ readonly 'fields.formulaTips': "Tips";
503
+ readonly 'fields.formulaHideTips': "Hide tips";
504
+ readonly 'fields.formulaTip1': "Start with a field: click its name below, or type { and pick it from the list.";
505
+ readonly 'fields.formulaTip2': "Do math as in a spreadsheet, with field names instead of cells:";
506
+ readonly 'fields.formulaTip3': "Put text in quotes, and join pieces with &:";
507
+ readonly 'fields.formulaTip4': "Choose between two answers with IF:";
508
+ readonly 'fields.formulaTip5': "No = at the start, and commas between the parts of a function. The result for your first records shows as you type.";
509
+ readonly 'fields.formulaTip6': "Not sure how? Describe what you want in the box at the top, and AI writes the formula for you.";
510
+ readonly 'fields.formulaFindFunction': "Find a function";
511
+ readonly 'fields.formulaNoFunction': "No function matches";
512
+ readonly 'fields.formulaGroup.logic': "Logic";
513
+ readonly 'fields.formulaGroup.text': "Text";
514
+ readonly 'fields.formulaGroup.numbers': "Numbers";
515
+ readonly 'fields.formulaGroup.dates': "Dates";
516
+ readonly 'fields.formulaGroup.lists': "Lists";
517
+ readonly 'fields.formulaGroup.records': "Records";
490
518
  readonly 'fields.optionsList': "Options";
491
519
  readonly 'fields.colorOf': "Color of {name}";
492
520
  readonly 'fields.colorOfOption': "Color of option {n}";
@@ -905,6 +933,7 @@ export declare const BASE_MESSAGES: {
905
933
  readonly 'record.noOptions': "No options";
906
934
  readonly 'record.notADuration': "Not a duration (1:30, 1h 30m)";
907
935
  readonly 'record.notANumber': "Not a number";
936
+ readonly 'record.formulaInNumber': "This field holds numbers. Press Enter to see how a formula field works this out.";
908
937
  readonly 'record.noNegative': "Negative numbers are not allowed";
909
938
  readonly 'record.durationLabel': "Duration ({format})";
910
939
  readonly 'record.amountIn': "Amount in {symbol}";
@@ -1210,6 +1239,15 @@ export declare const BASE_MESSAGES: {
1210
1239
  readonly 'viewbar.colorBySelect': "Color records the same as a single select field";
1211
1240
  readonly 'viewbar.colorByConditions': "Color records that match a condition; the first match wins";
1212
1241
  readonly 'viewbar.notColored': "Rows are not colored";
1242
+ readonly 'viewbar.colorTabRows': "Rows";
1243
+ readonly 'viewbar.colorTabCells': "Cells";
1244
+ readonly 'viewbar.colorCellsHelp': "Color a field's cell while its value matches a condition. For one field, the first match wins.";
1245
+ readonly 'viewbar.noCellColors': "No cells are colored";
1246
+ readonly 'viewbar.addCellRule': "Add a rule";
1247
+ readonly 'viewbar.coloredCells': "Colored cells";
1248
+ readonly 'viewbar.highlightByHand': "Mark records by hand";
1249
+ readonly 'viewbar.highlightByHandHelp': "Adds a Highlight field and colors each row by the color picked in it.";
1250
+ readonly 'viewbar.highlightField': "Highlight";
1213
1251
  readonly 'viewbar.chart': "Chart";
1214
1252
  readonly 'viewbar.type': "Type";
1215
1253
  readonly 'viewbar.chooseField': "Choose a field";
@@ -1561,6 +1599,28 @@ export declare const BASE_MESSAGES: {
1561
1599
  readonly 'shell.pasteLeftOut.one': "\"{text}\" does not fit {field}, so that cell keeps its value.";
1562
1600
  readonly 'shell.pasteLeftOut.other': "{count} values do not fit their fields, so those cells keep their values.";
1563
1601
  readonly 'shell.pasteLoading': "The view is still loading, so nothing was pasted. Paste again when the rows are shown.";
1602
+ readonly 'shell.formulaInField': "In a base, a formula is a field of its own: it works out a value for every record at once.";
1603
+ readonly 'shell.formulaMakeField': "Make a formula field";
1604
+ readonly 'shell.formulaIsSummary': "The summary bar under the table works this out for {field}, and keeps it up to date as records change.";
1605
+ readonly 'shell.formulaShowSummary': "Show it for {field}";
1606
+ readonly 'shell.sumShown': "The sum of {field} is in the summary bar under the table. It keeps up as records change.";
1607
+ readonly 'shell.sumNotNumbers': "{field} does not hold numbers, so there is nothing to add up. Select a number field and press Alt+= again.";
1608
+ readonly 'shell.sumNoBar': "A base adds up a field in the summary bar under the table, and this view does not show one.";
1609
+ readonly 'shell.totalRecord': "No total record needed: the summary bar under the table adds up each number field, and keeps up as records change.";
1610
+ readonly 'shell.totalShowSums': "Show the sums";
1611
+ readonly 'shell.formatInBase': "A base keeps no bold or colors typed into cells, so every screen reads the same data. Color rows or cells by what they hold with Color in the toolbar.";
1612
+ readonly 'shell.formatOpenColor': "Open Color";
1613
+ readonly 'shell.pasteNoField.one': "One column of the paste had no field to go in, so it was left out.";
1614
+ readonly 'shell.pasteNoField.other': "{count} columns of the paste had no field to go in, so they were left out.";
1615
+ readonly 'shell.pasteNamesLeftOut': "The first line holds the names of the fields, so it is not pasted as a record.";
1616
+ readonly 'shell.pasteFieldsTitle.one': "Add a field for this paste?";
1617
+ readonly 'shell.pasteFieldsTitle.other': "Add {count} fields for this paste?";
1618
+ readonly 'shell.pasteFieldsBody.one': "The paste has one more column than the table has from here. Add a field for it:";
1619
+ readonly 'shell.pasteFieldsBody.other': "The paste has {count} more columns than the table has from here. Add a field for each:";
1620
+ readonly 'shell.pasteFirstLineNames': "The first line holds the names of the fields";
1621
+ readonly 'shell.pasteWithout': "Paste without them";
1622
+ readonly 'shell.pasteAddFields.one': "Add the field and paste";
1623
+ readonly 'shell.pasteAddFields.other': "Add {count} fields and paste";
1564
1624
  readonly 'shell.pasteNewTitle': "New records";
1565
1625
  readonly 'shell.pasteNewAsk': "This paste runs past the last record. Add {records}?";
1566
1626
  readonly 'shell.pasteNewConfirm': "Add records";
@@ -8,6 +8,7 @@
8
8
  import { type RowColorConfig } from '@svgrid/grid';
9
9
  import { type FieldCondition, type FieldFilter, type LinkNames } from './filter-model.js';
10
10
  import { type FieldColumn } from './grid-access.js';
11
+ import { type CellColorRule } from './cell-colors.svelte.js';
11
12
  import type { ChartSetting } from './chart-view.js';
12
13
  import type { DashboardTile } from './dashboard.js';
13
14
  export type FieldViewType = 'grid' | 'kanban' | 'calendar' | 'timeline' | 'gantt' | 'gallery' | 'chart' | 'form' | 'list' | 'inbox' | 'dashboard' | 'tree' | 'pivot';
@@ -43,6 +44,8 @@ export type FieldView = {
43
44
  state?: Record<string, unknown>;
44
45
  rowHeight?: number;
45
46
  color?: ColorSetting;
47
+ /** Cells colored while they match a condition on their own field (the Color panel's Cells). */
48
+ cellColors?: CellColorRule[];
46
49
  /** Kanban: the single select or user field the cards stack by. */
47
50
  stackBy?: string;
48
51
  /** Calendar, timeline and Gantt: the date field a record starts on, and the one it ends on. */
@@ -1 +1 @@
1
- import{toast as ae}from"@svgrid/grid";import{compileFieldFilter as le,setFilterWords as fe}from"./filter-model.js";import{cellText as ue,fieldColumns as M,primaryIdOf as P,writeCell as C}from"./grid-access.js";import{fieldPropsOf as E,originalColumn as I}from"./registry.svelte.js";import{getFieldUsers as Q,getLinkedTable as K,linkedRows as pe}from"./sources.svelte.js";import{canEditField as ce}from"./field-access.svelte.js";import{chooseRowColor as me,chosenRowColor as be,clearRowColorChoice as ge}from"./row-color-choice.svelte.js";import{defId as N,filterWithout as he,newRowValues as H,recordCopyValues as J}from"./field-ops.js";import{openRecord as F}from"./editor-request.svelte.js";import{rowColorOf as ye,rowMarkColor as we}from"./row-colors.js";import{recordHeightOf as ve}from"./row-height.js";import{orderWithReturned as Me}from"./column-order.js";import{askDeleteRecord as B}from"./record-delete.svelte.js";import{cardRecordMenu as Te}from"./record-menu.js";import{commentsOf as Oe}from"./activity.svelte.js";import{VIEW_MOVE as Ce}from"./base-history.js";import{canCommentIn as ke,canCreateIn as z,canDeleteIn as $}from"./base-permissions.js";import{bm as p}from"./messages.svelte.js";import{boardLanes as Se,calendarDays as Fe,flatRecords as De,ganttRows as Re}from"./view-feed.svelte.js";import{boardWalk as Ae,calendarWalk as xe,listWalk as X,walkOfIds as Ie}from"./record-walk.js";fe((e,n)=>{const t=p(e);return t===e?n:t});export const VIEW_TYPES=[{type:"grid",get label(){return p("viewbar.typeGrid")},icon:"M3 5h18v14H3zM3 10h18M3 15h18M9 5v14"},{type:"tree",get label(){return p("viewbar.typeTree")},icon:"M4 5h7M9 11h7M9 17h7M6 5v12h3M6 11h3"},{type:"kanban",get label(){return p("viewbar.typeKanban")},icon:"M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z"},{type:"calendar",get label(){return p("viewbar.typeCalendar")},icon:"M4 6h16v14H4zM4 10h16M8 3v4M16 3v4"},{type:"timeline",get label(){return p("viewbar.typeTimeline")},icon:"M3 4v16M6 7h8M9 12h11M6 17h6"},{type:"gantt",get label(){return p("viewbar.typeGantt")},icon:"M4 5h9M7 10h11M10 15h8M4 20h16"},{type:"gallery",get label(){return p("viewbar.typeGallery")},icon:"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z"},{type:"chart",get label(){return p("viewbar.typeChart")},icon:"M4 20h16M6 20V11M11 20V5M16 20v-7"},{type:"pivot",get label(){return p("viewbar.typePivot")},icon:"M4 4h16v16H4zM4 9h16M9 4v16M13 13h4M13 17h4"},{type:"form",get label(){return p("viewbar.typeForm")},icon:"M6 3h12v18H6zM9 8h6M9 12h6M9 16h3"},{type:"list",get label(){return p("viewbar.typeList")},icon:"M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01"},{type:"inbox",get label(){return p("viewbar.typeInbox")},icon:"M3 13h5l1.5 3h5l1.5-3h5M5.5 5h13L21 13v6H3v-6z"},{type:"dashboard",get label(){return p("viewbar.typeDashboard")},icon:"M4 4h7v9H4zM13 4h7v5h-7zM13 11h7v9h-7zM4 15h7v5H4z"}],viewTypeInfo=e=>VIEW_TYPES.find(n=>n.type===e)??VIEW_TYPES[0];let ze=0;export const newViewId=()=>`view-${Date.now().toString(36)}-${ze+=1}`;export function sortLabels(e){const n=e?.fieldType,t=e?.cellDataType;return n==="checkbox"||t==="boolean"?["☐ → ☑","☑ → ☐"]:n==="singleSelect"?[p("viewbar.sortFirstLast"),p("viewbar.sortLastFirst")]:n==="checklist"?[p("viewbar.sortDoneUp"),p("viewbar.sortDoneDown")]:n==="color"?[p("viewbar.sortHueUp"),p("viewbar.sortHueDown")]:t==="number"||t==="date"||t==="dateString"||["number","currency","percent","rating","duration","timer","autoNumber","count","date","createdTime","lastModifiedTime","timeOfDay"].includes(n??"")||n==="ai"&&e?.fieldProps?.output==="number"?["1 → 9","9 → 1"]:[p("viewbar.sortAZ"),p("viewbar.sortZA")]}export function colorSettingOf(e,n){const t=ye(e);return t?"field"in t?{mode:"field",field:t.field}:n?.mode==="conditions"?n:{mode:"none"}:n?.mode==="conditions"?n:{mode:"none"}}export function rowColorFor(e,n,t){if(n.mode==="none")return null;const o=e?.props?.rowColor?.target,i=o?{target:o}:{};if(n.mode==="field")return{field:n.field,...i};const a=new Map(M(e).map(l=>[l.id,l])),s=(l,r)=>{const c=a.get(r),m=c.def.fieldFn;return m?m(l):l?.[c.field]},d=n.rules.map(l=>{if(!a.has(l.condition.column))return null;const r=le({kind:"fieldFilter",conjunction:"and",conditions:[l.condition]},s,t);return r?{color:l.color,when:c=>r(c)}:null}).filter(l=>!!l);return d.length?{rules:d,...i}:null}export function applyColor(e,n,t){me(e,rowColorFor(e,n,t))}function b(e,n,t){const o=e?.props?.getRowId;if(o)return String(o(t,-1));const i=n.getRowId(t);return i==null?String(t?.id??""):String(i)}export function lanesFor(e){const n=[{id:"",title:p("viewbar.uncategorized"),hideWhenEmpty:!0}];if(e.fieldType==="user"){for(const o of Q())n.push({id:o.id,title:o.name});return n}const t=E(I(e.def));for(const o of t.options??[])n.push({id:o.value,title:o.value,...o.color?{color:o.color}:{}});return n}export const stackableColumns=e=>M(e).filter(n=>n.fieldType==="singleSelect"||n.fieldType==="user"&&!n.def.fieldProps?.multiple),laneColumns=e=>M(e).filter(n=>n.fieldType==="singleSelect"||n.fieldType==="user"||n.fieldType==="link");function _(e,n){const t=n?.[e.field],o=Array.isArray(t)?t[0]:t;return o==null||o===""?"":String(typeof o=="object"?o.id??"":o)}function ee(e,n){if(n==="")return p("viewbar.uncategorized");if(e.fieldType==="user")return Q().find(t=>String(t.id)===n)?.name??n;if(e.fieldType==="link"){const t=K(E(I(e.def)).table),o=t?pe(t,n)[0]:void 0;return o&&t?String(o[t.primaryField]??n):n}return n}function ne(e,n,t,o){const i=n?.[e.field];if(!(Array.isArray(i)||e.fieldType==="link"||e.fieldType==="user"&&!!e.def.fieldProps?.multiple))return o===""?null:o;const d=(Array.isArray(i)?i:i==null||i===""?[]:[i]).map(l=>String(l&&typeof l=="object"?l.id??"":l)).filter(l=>l!==t&&l!==o);return o===""?d:[o,...d]}export const dateColumns=e=>M(e).filter(n=>n.fieldType==="date"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString"),progressColumns=e=>M(e).filter(n=>n.fieldType==="percent"||n.fieldType==="number"&&E(I(n.def)).format==="percent"),dependencyColumns=e=>M(e).filter(n=>{if(n.fieldType!=="link")return!1;const t=K(E(I(n.def)).table);if(!t)return!1;if(t.records)return t.id===e.props?.baseTableId;const o=typeof t.rows=="function"?t.rows():t.rows;return o===e.internalData||o.length>0&&o[0]===e.internalData?.[0]});export function applyGanttSettings(e,n,t,o){const i=P(e),a=o??M(e).find(s=>s.id===i)?.field;t.type==="gantt"?n.setOption("gantt",de(e,n,t,a)):t.type==="calendar"?n.setOption("scheduler",U(e,n,t,a)):t.type==="timeline"&&n.setOption("scheduler",oe(e,n,t,a))}export const coverColumns=e=>M(e).filter(n=>n.fieldType==="attachment");const D=e=>e?.props?.baseFeed??null;function Y(e,n,t,o=!1){if(D(e)&&typeof e.props.baseServerAdd=="function")return void e.props.baseServerAdd(t,o);n.addRow(t,"bottom"),e.props.onRowAdd?.({row:t}),o&&queueMicrotask(()=>{const i=b(e,n,t);e.props.baseFilling?.(i),F({ctrl:e,rowId:i,editPrimary:!0})})}const Ee=200;function Le(e,n,t,o){const i=(e.allRowsBeforePagination??e.allRows??[]).filter(d=>!e.isGroupRow?.(d)&&d.original),a=new Set(o.map(d=>d.id)),s=d=>{const l=d.original[t.field],r=l==null?"":String(l);return a.has(r)?r:""};return o.flatMap(d=>i.filter(l=>s(l)===d.id).map(l=>b(e,n,l.original)))}export function boardConfig(e,n,t){const o=M(e),i=o.find(r=>r.id===t.stackBy);if(!i)return;const a=o.find(r=>r.id===P(e)),s=D(e),d=lanesFor(i),l=s?Se(s,i):null;return{groupBy:i.field,lanes:d,text:_e,...l?{server:l,walk:Ae(s,d,l,r=>b(e,n,r))}:{walk:Ie(()=>Le(e,n,i,d))},...a?{titleField:a.field}:{},cardFields:o.filter(r=>r.visible&&r!==a&&r!==i).slice(0,3).map(r=>r.field),searchable:!1,virtualized:!!s||(e.props?.data?.length??0)>Ee,moveCards:T(e)&&R(i),controlled:!0,otherLane:"",onCardMove:r=>{r.toLane!==r.fromLane&&L(e,()=>C(e,b(e,n,r.row),i.id,r.toLane===""?null:r.toLane))},onCardClick:r=>F({ctrl:e,rowId:b(e,n,r)}),onCardEdit:r=>F({ctrl:e,rowId:b(e,n,r)}),commentCount:r=>Oe(e,b(e,n,r)).length,onCommentsOpen:r=>F({ctrl:e,rowId:b(e,n,r),focus:"comment"}),cellGrid:cardGrid(e),onCardReorder:r=>{const c=(n.getState?.()?.sorting??[])[0],m=c?o.find(S=>S.id===c.id):void 0;if(!(!!m&&(m.fieldType==="number"||m.fieldType==="rating"||m.fieldType==="currency"||m.fieldType==="percent")&&R(m)&&T(e)))return s&&ae.info(p("viewbar.sortToOrder")),!1;const u=S=>Number(S?.[m.field]),h=u(r.before),y=u(r.after),O=c.desc?-1:1,A=r.before&&r.after?(h+y)/2:r.before?h+O:r.after?y-O:NaN;if(!Number.isFinite(A))return!1;const x=b(e,n,r.row);return L(e,()=>C(e,x,m.id,A)),s&&n.getOption("board")?.server?.seat(r.laneId,x,r.before?b(e,n,r.before):null),!0},cardMenu:(r,c)=>{const m=!!e.editingEnabled;return[{label:p("viewbar.expandRecord"),onSelect:()=>F({ctrl:e,rowId:b(e,n,r)})},...ke(e)?[{label:p("viewbar.comment"),onSelect:()=>F({ctrl:e,rowId:b(e,n,r),focus:"comment"})}]:[],...m?[...R(i)?[{label:p("viewbar.moveTo"),children:c.lanes.map(v=>({label:v.title??(v.id||p("viewbar.empty")),onSelect:()=>c.moveTo(v.id)}))}]:[],...z(e)?[{label:p("viewbar.duplicateRecord"),onSelect:()=>re(e,n,r)}]:[],...$(e)?[{separator:!0},{label:p("viewbar.deleteRecord"),onSelect:()=>B({ctrl:e,api:n,row:r})}]:[]]:[]]},composer:T(e)&&z(e),onCardAdd:!T(e)||!z(e)?void 0:(r,c)=>{const m=M(e).find(y=>y.id===P(e)),v=e.props.rowAdder,u=v&&typeof v=="object"&&typeof v.defaults=="function"?v.defaults():{},h=H(e,{...u,[i.field]:r===""?null:r,...m&&c?{[m.field]:c}:{}});Y(e,n,h)}}}export function galleryConfig(e,n,t){const o=M(e),i=o.find(r=>r.id===P(e))??o.find(r=>r.visible),a=o.find(r=>r.id===t.coverField),s=D(e),d=s?De(s):null,l=Te(()=>n,()=>e);return{...d?{server:d,walk:X(s,d,r=>b(e,n,r))}:{},...a?{coverField:a.field}:{},...i?{titleField:i.field}:{},cardFields:o.filter(r=>r.visible&&r!==i&&r!==a).map(r=>r.field),searchable:!1,onCardClick:r=>F({ctrl:e,rowId:b(e,n,r)}),cardMenu:r=>l(r,b(e,n,r)),isSelected:r=>!!e.isRowSelected?.(b(e,n,r),r),text:We,cellGrid:cardGrid(e)}}const We={get records(){return p("viewbar.recordsList")},get cardActions(){return p("viewbar.board.cardActions")},get selected(){return p("viewbar.selectedCard")},get untitled(){return p("viewbar.untitled")}};export function cardGrid(e){return(n,t=!1)=>new Proxy(e,{get:(o,i)=>{if(i==="getColumnWidth")return()=>n;if(i==="editingEnabled")return!1;if(i==="insideButton")return t;const a=Reflect.get(o,i,o);return typeof a=="function"?a.bind(o):a}})}const V=e=>e.fieldType==="date"&&!e.def.fieldProps?.time||e.def.cellDataType==="dateString";function k(e,n){if(!V(e))return n.toISOString();const t=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())}`}function Pe(e,n,t){if(t?.mode==="conditions"){const a=rowColorFor(e,t)?.rules;return a?.length?{colorOf:s=>a.find(d=>d.when(s))?.color}:{}}if(t?.mode!=="field")return{};const o=n.find(a=>a.field===t.field);if(!o||o.fieldType!=="singleSelect")return{};const i=lanesFor(o).filter(a=>a.id!==""&&a.color).map(({id:a,title:s,color:d})=>({id:a,title:s,color:d}));return i.length?{calendars:i,calendarField:o.field}:{}}function He(e,n,t,o,i){const s=(n.listFields?.length?n.listFields.map(d=>e.find(l=>l.id===d)).filter(d=>!!d):e.filter(d=>d.visible)).filter(d=>d.field!==t&&d.id!==o&&d.id!==i).slice(0,2);return s.length?{detailsOf:d=>s.map(l=>{const r=d,c=l.def.fieldFn;return ue(l,c?c(r):r?.[l.field],d)}).filter(l=>l!==""&&l!==p("viewbar.valueUnchecked")).join(" · ")}:{}}const _e=Object.defineProperties({},Object.fromEntries(["board","addCard","addCardTo","cardTitle","noCards","cardActions","clearFilters","blocked","age","comments","writeComment","deleteComment","addSubtask","rename","cancel","save","grabbed","dropped","movedTo","movedUp","movedDown","movedPosition","cancelled","wipLimit","cannotMove","cardBlocked","selected","deselected"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.board.${e}`)}]))),te=Object.defineProperties({},Object.fromEntries(["month","week","day","agenda","today","previous","next","allDay","more","noEvents","eventsColumn","edit","duplicate","delete","moveGrabbed","moveDone","moveCancelled","moveBlocked"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.calendar.${e}`)}]))),Ve=Object.defineProperties({},{...Object.getOwnPropertyDescriptors(te),...Object.fromEntries(["timelineDay","timelineWeek","timelineMonth","timelineYear"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.calendar.${e}`)}]))}),je=Object.defineProperties({},Object.fromEntries(["expandAll","collapseAll","expandTask","collapseTask","zoomIn","zoomOut","zoomDay","zoomWeek","zoomMonth","zoomQuarter","zoomYear","tableLabel","chartLabel","resizeTable","days","progress","slack","start","finish","progressPercent","task","milestone","day","daysCount","open","openTask","edit","addSubtask","delete","deleteTask","removeLink","taskActions","save","cancel","onBaseline","laterThanBaseline","aheadOfBaseline","dragProgress","linkFromStart","linkFromFinish","workingDays","onCriticalPath","daysOfSlack","notMet","peak","loadOf","moveGrabbed","moveDone","moveCancelled","resized","progressSet"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.gantt.${e}`)}])));function U(e,n,t,o,i){const a=M(e),s=a.find(u=>u.id===t.dateField);if(!s)return;const d=a.find(u=>u.id===t.endField),l=!!i&&R(i),r=u=>{const h=b(e,n,u.row);L(e,()=>{if(C(e,h,s.id,k(s,u.start)),d&&C(e,h,d.id,u.end.getTime()>u.start.getTime()?q(d,u.end):k(d,u.start)),i&&l&&u.toResource!=null){const y=u.fromResource??_(i,u.row);u.toResource!==y&&C(e,h,i.id,ne(i,u.row,y,u.toResource))}}),e.props.baseReflow?.()},c=(u,h)=>({[s.field]:k(s,u),...d?{[d.field]:h.getTime()>u.getTime()?q(d,h):k(d,u)}:{}}),m=T(e)&&R(s)&&(!d||R(d)),v=i===void 0?D(e):null;return{...v?{server:Fe(v,s,d,(u,h)=>e.props.baseOpenDay?.(u,h)),walk:xe(v,s,u=>b(e,n,u))}:{},searchable:!1,text:te,editable:m,history:m&&!ie(e),controlled:!0,tooltip:!0,onEventOpen:u=>F({ctrl:e,rowId:b(e,n,u)}),onEventDelete:T(e)?u=>B({ctrl:e,api:n,row:u}):void 0,startField:s.field,...d?{endField:d.field}:{},...o?{titleField:o}:{},...V(s)?{allDay:!0}:{},...Pe(e,a,t.color),...He(a,t,o,s.id,d?.id),onEventMove:r,...d?{onEventResize:r}:{resizable:!1},onEventAdd:!T(e)||!z(e)?void 0:(u,h,y)=>{const O=e.props.rowAdder,A=O&&typeof O=="object"&&typeof O.defaults=="function"?O.defaults():{},x=i&&l&&y?{[i.field]:ne(i,{},void 0,y)}:{},S=H(e,{...A,...x,...c(u,h)});Y(e,n,S,!0)},onEventDuplicate:!T(e)||!z(e)?void 0:(u,h,y)=>re(e,n,u,c(h,y))}}const Ge={day:"timelineDay",week:"timelineWeek",month:"timelineMonth",year:"timelineYear"};function oe(e,n,t,o){const i=laneColumns(e).find(d=>d.id===t.laneField)??null,a=U(e,n,t,o,i);if(!a)return;let s;if(i&&(i.fieldType==="singleSelect"||i.fieldType==="user")){const d=e.props?.data??[];s=lanesFor(i).filter(r=>r.id!==""||d.some(c=>_(i,c)==="")).map(({id:r,title:c,color:m})=>({id:r,title:c,...m?{color:m}:{}}));const l=new Set(s.map(r=>r.id));for(const r of d){const c=_(i,r);l.has(c)||(l.add(c),s.push({id:c,title:ee(i,c)}))}}return{...a,views:["timelineDay","timelineWeek","timelineMonth","timelineYear"],initialView:Ge[t.zoom??""]??"timelineMonth",text:Ve,...i?{resourceField:i.field,resourceOf:d=>_(i,d),resourceTitle:d=>ee(i,d),resourceLegend:!1,...s?{resources:s}:{}}:{}}}const R=e=>e.def.editable!==!1&&ce(I(e.def),E(I(e.def))),T=e=>e.props.editable!==!1&&!!(e.props.editable??e.props.enableInlineEditing);let Ne=0,j=null;function L(e,n){const t=e.historyGroupId;j||(j=`${Ce}${Ne+=1}`,queueMicrotask(()=>j=null)),e.historyGroupId=t??j;try{n()}finally{e.historyGroupId=t}}const ie=e=>!!e.props?.baseTableId;function q(e,n){return V(e)?k(e,new Date(n.getFullYear(),n.getMonth(),n.getDate()-1)):k(e,n)}function re(e,n,t,o={}){if(!z(e))return;const i=b(e,n,t),a=e.internalData,s=a.findIndex(l=>b(e,n,l)===i);if((e.props.rowModel||D(e))&&typeof e.props.baseServerAdd=="function"){const{__group:l,...r}=J(e,s<0?t:a[s]);return e.props.baseServerAdd({...r,...o})}if(s<0)return;const d=H(e,{...J(e,a[s]),...o});n.addRow(d,s+1),e.props.onRowAdd?.({row:d})}export function deleteRecord(e,n,t){if(!$(e))return;const o=b(e,n,t),i=e.internalData,a=i.findIndex(d=>b(e,n,d)===o);if(a<0)return;const s=i[a];!e.props.rowModel&&!D(e)&&n.removeRows([a]),e.props.onRowsDelete?.({rows:[s],ids:[o],data:e.internalData})}const Be=124,Z=new WeakMap;function de(e,n,t,o){Z.delete(e);const i=M(e),a=i.find(f=>f.id===t.dateField);if(!a)return;const s=i.find(f=>f.id===t.endField),d=i.find(f=>f.id===t.progressField),l=i.find(f=>f.id===t.dependencyField&&f.fieldType==="link"),c=[(f=>i.find(g=>g.field===f)?.id)(o),a.id,s?.id].filter(f=>!!f),m=f=>b(e,n,f),v=!!e.props?.basePhone,u=t.color&&t.color.mode!=="none"?f=>we(e,f)??void 0:void 0,h=f=>q(s,f),y=(f,g,w)=>{C(e,f,a.id,k(a,g)),s&&C(e,f,s.id,w.getTime()>g.getTime()?h(w):k(s,g))},O=!!(d&&E(I(d.def)).points),A=f=>{const w=e.internalData.find(W=>m(W)===f)?.[l.field];return Array.isArray(w)?w.map(String):w==null||w===""?[]:[String(w)]},x=T(e)&&R(a)&&(!s||R(s)),S=D(e),G=S?Re(S,a,s,l):null;return{...G?{server:G,walk:X(S,G.list,m)}:{},searchable:!1,startField:a.field,...s?{endField:s.field}:{},...o?{titleField:o}:{},tableColumns:v?c.slice(0,1):[...new Set(c),"__duration"],...v?{tableWidth:Be}:{},tableColumnWidths:Object.fromEntries([a,s].filter(f=>!!f).map(f=>[f.id,V(f)?144:176])),...u?{colorOf:u}:{},...t.zoom?{zoom:t.zoom}:{},tooltip:!0,text:je,pickUpToMove:!0,respectWorkingTime:!1,editable:x,history:x&&!ie(e),controlled:!0,onTaskOpen:f=>F({ctrl:e,rowId:m(f)}),onTaskMove:f=>{L(e,()=>{y(m(f.row),f.start,f.end);for(const g of f.subtree??[])y(m(g.row),g.start,g.end)}),e.props.baseReflow?.()},onTaskResize:f=>{L(e,()=>y(m(f.row),f.start,f.end)),e.props.baseReflow?.()},onDependenciesChange:f=>{L(e,()=>{for(const g of f)y(g.id,g.start,g.end)}),e.props.baseReflow?.()},...d?{progressField:d.field,...O?{}:{progressValue:f=>Number(f?.[d.field]??0)*100},onProgressChange:f=>C(e,m(f.row),d.id,O?f.progress:f.progress/100)}:{},...l?{predecessorField:l.field,onDependencyAdd:f=>{const g=A(f.to);g.includes(f.from)||C(e,f.to,l.id,[...g,f.from])},onDependencyRemove:f=>{const[g,w]=f.split("->");g&&w&&C(e,w,l.id,A(w).filter(W=>W!==g))}}:{},onZoomChange:f=>{Z.set(e,f)},onTaskAdd:!T(e)||!z(e)?void 0:(f,g)=>{const w=e.props.rowAdder,W=w&&typeof w=="object"&&typeof w.defaults=="function"?w.defaults():{},se=H(e,{...W,[a.field]:k(a,f),...s?{[s.field]:g.getTime()>f.getTime()?h(g):k(s,f)}:{}});Y(e,n,se,!0)},onTaskDelete:T(e)&&$(e)?f=>B({ctrl:e,api:n,row:f}):void 0}}const $e=e=>e.state?.advancedFilter??null;export function viewsWithoutFields(e,n,t=""){const o=[],i=e?.map(a=>{const s=$e(a),d=he(s,n);return d===s?a:(o.push({table:t,view:a.id,was:s,now:d}),{...a,state:{...a.state,advancedFilter:d}})});return{views:o.length?i:e,changes:o}}export function filterChangesOf(e,n){return n.flatMap(t=>{const o=e.find(s=>s.id===t.id);if(!o)return[];const i=new Set(t.columns.map(s=>N(s))),a=new Set(o.columns.map(s=>N(s)).filter(s=>!i.has(s)));return a.size?viewsWithoutFields(t.views,s=>a.has(s),t.id).changes:[]})}export function applyViewFilters(e,n,t){return e.map(o=>{const i=n.filter(a=>a.table===o.id);return i.length?{...o,views:o.views?.map(a=>{const s=i.find(d=>d.view===a.id);return s?{...a,state:{...a.state,advancedFilter:s[t]}}:a})}:o})}export const PLAIN_STATE={sorting:[],grouping:[],hiddenColumns:[],advancedFilter:null};export function captureView(e,n,t){const o={...n.getState()};delete o.pagination,delete o.chart,delete o.charts,delete o.chartActive,delete o.globalFilter;const i=ve(n.getOption("rowHeight")),a=t.type==="gantt"?Z.get(e):void 0,{color:s,...d}=t,l=be(e)===void 0?void 0:colorSettingOf(e,t.color);return{...d,state:o,...typeof i=="number"?{rowHeight:i}:{},...a?{zoom:a}:{},...l?{color:l}:{}}}const Ye=e=>(e?.internalColumns??[]).filter(n=>n.field!=null).map(n=>N(n));export function applyView(e,n,t,o={}){const i={...PLAIN_STATE,...t.state??{},globalFilter:""};Array.isArray(i.columnOrder)&&i.columnOrder.length&&(i.columnOrder=Me(i.columnOrder,Ye(e))),n.setState(i),D(e)?.readQuery?.();const a=t.state;a?.grouping?.length&&a.expanded===void 0&&setTimeout(()=>{e.props?.rowModel||n.expandAllGroups?.()},0),t.rowHeight!=null&&n.setOption("rowHeight",t.rowHeight),t.color?applyColor(e,t.color,o.linkNames):ge(e),n.setOption("board",t.type==="kanban"?boardConfig(e,n,t):void 0),n.setOption("gallery",t.type==="gallery"?galleryConfig(e,n,t):void 0);const s=P(e),d=o.primaryField??M(e).find(l=>l.id===s)?.field;n.setOption("scheduler",t.type==="calendar"?U(e,n,t,d):t.type==="timeline"?oe(e,n,t,d):void 0),n.setOption("gantt",t.type==="gantt"?de(e,n,t,d):void 0)}
1
+ import{toast as ae}from"@svgrid/grid";import{compileFieldFilter as le,setFilterWords as fe}from"./filter-model.js";import{cellText as ue,fieldColumns as M,primaryIdOf as P,writeCell as C}from"./grid-access.js";import{fieldPropsOf as E,originalColumn as I}from"./registry.svelte.js";import{getFieldUsers as Q,getLinkedTable as K,linkedRows as pe}from"./sources.svelte.js";import{canEditField as ce}from"./field-access.svelte.js";import{chooseRowColor as me,chosenRowColor as be,clearRowColorChoice as ge}from"./row-color-choice.svelte.js";import{cellRulesOf as he,setCellRules as ye}from"./cell-colors.svelte.js";import{defId as N,filterWithout as we,newRowValues as H,recordCopyValues as J}from"./field-ops.js";import{openRecord as F}from"./editor-request.svelte.js";import{rowColorOf as ve,rowMarkColor as Me}from"./row-colors.js";import{recordHeightOf as Te}from"./row-height.js";import{orderWithReturned as Oe}from"./column-order.js";import{askDeleteRecord as B}from"./record-delete.svelte.js";import{cardRecordMenu as Ce}from"./record-menu.js";import{commentsOf as ke}from"./activity.svelte.js";import{VIEW_MOVE as Se}from"./base-history.js";import{canCommentIn as Fe,canCreateIn as z,canDeleteIn as $}from"./base-permissions.js";import{bm as p}from"./messages.svelte.js";import{boardLanes as De,calendarDays as Re,flatRecords as Ae,ganttRows as xe}from"./view-feed.svelte.js";import{boardWalk as Ie,calendarWalk as ze,listWalk as X,walkOfIds as Ee}from"./record-walk.js";fe((e,n)=>{const t=p(e);return t===e?n:t});export const VIEW_TYPES=[{type:"grid",get label(){return p("viewbar.typeGrid")},icon:"M3 5h18v14H3zM3 10h18M3 15h18M9 5v14"},{type:"tree",get label(){return p("viewbar.typeTree")},icon:"M4 5h7M9 11h7M9 17h7M6 5v12h3M6 11h3"},{type:"kanban",get label(){return p("viewbar.typeKanban")},icon:"M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z"},{type:"calendar",get label(){return p("viewbar.typeCalendar")},icon:"M4 6h16v14H4zM4 10h16M8 3v4M16 3v4"},{type:"timeline",get label(){return p("viewbar.typeTimeline")},icon:"M3 4v16M6 7h8M9 12h11M6 17h6"},{type:"gantt",get label(){return p("viewbar.typeGantt")},icon:"M4 5h9M7 10h11M10 15h8M4 20h16"},{type:"gallery",get label(){return p("viewbar.typeGallery")},icon:"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z"},{type:"chart",get label(){return p("viewbar.typeChart")},icon:"M4 20h16M6 20V11M11 20V5M16 20v-7"},{type:"pivot",get label(){return p("viewbar.typePivot")},icon:"M4 4h16v16H4zM4 9h16M9 4v16M13 13h4M13 17h4"},{type:"form",get label(){return p("viewbar.typeForm")},icon:"M6 3h12v18H6zM9 8h6M9 12h6M9 16h3"},{type:"list",get label(){return p("viewbar.typeList")},icon:"M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01"},{type:"inbox",get label(){return p("viewbar.typeInbox")},icon:"M3 13h5l1.5 3h5l1.5-3h5M5.5 5h13L21 13v6H3v-6z"},{type:"dashboard",get label(){return p("viewbar.typeDashboard")},icon:"M4 4h7v9H4zM13 4h7v5h-7zM13 11h7v9h-7zM4 15h7v5H4z"}],viewTypeInfo=e=>VIEW_TYPES.find(n=>n.type===e)??VIEW_TYPES[0];let Le=0;export const newViewId=()=>`view-${Date.now().toString(36)}-${Le+=1}`;export function sortLabels(e){const n=e?.fieldType,t=e?.cellDataType;return n==="checkbox"||t==="boolean"?["☐ → ☑","☑ → ☐"]:n==="singleSelect"?[p("viewbar.sortFirstLast"),p("viewbar.sortLastFirst")]:n==="checklist"?[p("viewbar.sortDoneUp"),p("viewbar.sortDoneDown")]:n==="color"?[p("viewbar.sortHueUp"),p("viewbar.sortHueDown")]:t==="number"||t==="date"||t==="dateString"||["number","currency","percent","rating","duration","timer","autoNumber","count","date","createdTime","lastModifiedTime","timeOfDay"].includes(n??"")||n==="ai"&&e?.fieldProps?.output==="number"?["1 → 9","9 → 1"]:[p("viewbar.sortAZ"),p("viewbar.sortZA")]}export function colorSettingOf(e,n){const t=ve(e);return t?"field"in t?{mode:"field",field:t.field}:n?.mode==="conditions"?n:{mode:"none"}:n?.mode==="conditions"?n:{mode:"none"}}export function rowColorFor(e,n,t){if(n.mode==="none")return null;const o=e?.props?.rowColor?.target,r=o?{target:o}:{};if(n.mode==="field")return{field:n.field,...r};const a=new Map(M(e).map(f=>[f.id,f])),s=(f,i)=>{const c=a.get(i),m=c.def.fieldFn;return m?m(f):f?.[c.field]},d=n.rules.map(f=>{if(!a.has(f.condition.column))return null;const i=le({kind:"fieldFilter",conjunction:"and",conditions:[f.condition]},s,t);return i?{color:f.color,when:c=>i(c)}:null}).filter(f=>!!f);return d.length?{rules:d,...r}:null}export function applyColor(e,n,t){me(e,rowColorFor(e,n,t))}function b(e,n,t){const o=e?.props?.getRowId;if(o)return String(o(t,-1));const r=n.getRowId(t);return r==null?String(t?.id??""):String(r)}export function lanesFor(e){const n=[{id:"",title:p("viewbar.uncategorized"),hideWhenEmpty:!0}];if(e.fieldType==="user"){for(const o of Q())n.push({id:o.id,title:o.name});return n}const t=E(I(e.def));for(const o of t.options??[])n.push({id:o.value,title:o.value,...o.color?{color:o.color}:{}});return n}export const stackableColumns=e=>M(e).filter(n=>n.fieldType==="singleSelect"||n.fieldType==="user"&&!n.def.fieldProps?.multiple),laneColumns=e=>M(e).filter(n=>n.fieldType==="singleSelect"||n.fieldType==="user"||n.fieldType==="link");function _(e,n){const t=n?.[e.field],o=Array.isArray(t)?t[0]:t;return o==null||o===""?"":String(typeof o=="object"?o.id??"":o)}function ee(e,n){if(n==="")return p("viewbar.uncategorized");if(e.fieldType==="user")return Q().find(t=>String(t.id)===n)?.name??n;if(e.fieldType==="link"){const t=K(E(I(e.def)).table),o=t?pe(t,n)[0]:void 0;return o&&t?String(o[t.primaryField]??n):n}return n}function ne(e,n,t,o){const r=n?.[e.field];if(!(Array.isArray(r)||e.fieldType==="link"||e.fieldType==="user"&&!!e.def.fieldProps?.multiple))return o===""?null:o;const d=(Array.isArray(r)?r:r==null||r===""?[]:[r]).map(f=>String(f&&typeof f=="object"?f.id??"":f)).filter(f=>f!==t&&f!==o);return o===""?d:[o,...d]}export const dateColumns=e=>M(e).filter(n=>n.fieldType==="date"||n.def.cellDataType==="date"||n.def.cellDataType==="dateString"),progressColumns=e=>M(e).filter(n=>n.fieldType==="percent"||n.fieldType==="number"&&E(I(n.def)).format==="percent"),dependencyColumns=e=>M(e).filter(n=>{if(n.fieldType!=="link")return!1;const t=K(E(I(n.def)).table);if(!t)return!1;if(t.records)return t.id===e.props?.baseTableId;const o=typeof t.rows=="function"?t.rows():t.rows;return o===e.internalData||o.length>0&&o[0]===e.internalData?.[0]});export function applyGanttSettings(e,n,t,o){const r=P(e),a=o??M(e).find(s=>s.id===r)?.field;t.type==="gantt"?n.setOption("gantt",de(e,n,t,a)):t.type==="calendar"?n.setOption("scheduler",U(e,n,t,a)):t.type==="timeline"&&n.setOption("scheduler",oe(e,n,t,a))}export const coverColumns=e=>M(e).filter(n=>n.fieldType==="attachment");const D=e=>e?.props?.baseFeed??null;function Y(e,n,t,o=!1){if(D(e)&&typeof e.props.baseServerAdd=="function")return void e.props.baseServerAdd(t,o);n.addRow(t,"bottom"),e.props.onRowAdd?.({row:t}),o&&queueMicrotask(()=>{const r=b(e,n,t);e.props.baseFilling?.(r),F({ctrl:e,rowId:r,editPrimary:!0})})}const We=200;function Pe(e,n,t,o){const r=(e.allRowsBeforePagination??e.allRows??[]).filter(d=>!e.isGroupRow?.(d)&&d.original),a=new Set(o.map(d=>d.id)),s=d=>{const f=d.original[t.field],i=f==null?"":String(f);return a.has(i)?i:""};return o.flatMap(d=>r.filter(f=>s(f)===d.id).map(f=>b(e,n,f.original)))}export function boardConfig(e,n,t){const o=M(e),r=o.find(i=>i.id===t.stackBy);if(!r)return;const a=o.find(i=>i.id===P(e)),s=D(e),d=lanesFor(r),f=s?De(s,r):null;return{groupBy:r.field,lanes:d,text:je,...f?{server:f,walk:Ie(s,d,f,i=>b(e,n,i))}:{walk:Ee(()=>Pe(e,n,r,d))},...a?{titleField:a.field}:{},cardFields:o.filter(i=>i.visible&&i!==a&&i!==r).slice(0,3).map(i=>i.field),searchable:!1,virtualized:!!s||(e.props?.data?.length??0)>We,moveCards:T(e)&&R(r),controlled:!0,otherLane:"",onCardMove:i=>{i.toLane!==i.fromLane&&L(e,()=>C(e,b(e,n,i.row),r.id,i.toLane===""?null:i.toLane))},onCardClick:i=>F({ctrl:e,rowId:b(e,n,i)}),onCardEdit:i=>F({ctrl:e,rowId:b(e,n,i)}),commentCount:i=>ke(e,b(e,n,i)).length,onCommentsOpen:i=>F({ctrl:e,rowId:b(e,n,i),focus:"comment"}),cellGrid:cardGrid(e),onCardReorder:i=>{const c=(n.getState?.()?.sorting??[])[0],m=c?o.find(S=>S.id===c.id):void 0;if(!(!!m&&(m.fieldType==="number"||m.fieldType==="rating"||m.fieldType==="currency"||m.fieldType==="percent")&&R(m)&&T(e)))return s&&ae.info(p("viewbar.sortToOrder")),!1;const u=S=>Number(S?.[m.field]),h=u(i.before),y=u(i.after),O=c.desc?-1:1,A=i.before&&i.after?(h+y)/2:i.before?h+O:i.after?y-O:NaN;if(!Number.isFinite(A))return!1;const x=b(e,n,i.row);return L(e,()=>C(e,x,m.id,A)),s&&n.getOption("board")?.server?.seat(i.laneId,x,i.before?b(e,n,i.before):null),!0},cardMenu:(i,c)=>{const m=!!e.editingEnabled;return[{label:p("viewbar.expandRecord"),onSelect:()=>F({ctrl:e,rowId:b(e,n,i)})},...Fe(e)?[{label:p("viewbar.comment"),onSelect:()=>F({ctrl:e,rowId:b(e,n,i),focus:"comment"})}]:[],...m?[...R(r)?[{label:p("viewbar.moveTo"),children:c.lanes.map(v=>({label:v.title??(v.id||p("viewbar.empty")),onSelect:()=>c.moveTo(v.id)}))}]:[],...z(e)?[{label:p("viewbar.duplicateRecord"),onSelect:()=>ie(e,n,i)}]:[],...$(e)?[{separator:!0},{label:p("viewbar.deleteRecord"),onSelect:()=>B({ctrl:e,api:n,row:i})}]:[]]:[]]},composer:T(e)&&z(e),onCardAdd:!T(e)||!z(e)?void 0:(i,c)=>{const m=M(e).find(y=>y.id===P(e)),v=e.props.rowAdder,u=v&&typeof v=="object"&&typeof v.defaults=="function"?v.defaults():{},h=H(e,{...u,[r.field]:i===""?null:i,...m&&c?{[m.field]:c}:{}});Y(e,n,h)}}}export function galleryConfig(e,n,t){const o=M(e),r=o.find(i=>i.id===P(e))??o.find(i=>i.visible),a=o.find(i=>i.id===t.coverField),s=D(e),d=s?Ae(s):null,f=Ce(()=>n,()=>e);return{...d?{server:d,walk:X(s,d,i=>b(e,n,i))}:{},...a?{coverField:a.field}:{},...r?{titleField:r.field}:{},cardFields:o.filter(i=>i.visible&&i!==r&&i!==a).map(i=>i.field),searchable:!1,onCardClick:i=>F({ctrl:e,rowId:b(e,n,i)}),cardMenu:i=>f(i,b(e,n,i)),isSelected:i=>!!e.isRowSelected?.(b(e,n,i),i),text:He,cellGrid:cardGrid(e)}}const He={get records(){return p("viewbar.recordsList")},get cardActions(){return p("viewbar.board.cardActions")},get selected(){return p("viewbar.selectedCard")},get untitled(){return p("viewbar.untitled")}};export function cardGrid(e){return(n,t=!1)=>new Proxy(e,{get:(o,r)=>{if(r==="getColumnWidth")return()=>n;if(r==="editingEnabled")return!1;if(r==="insideButton")return t;const a=Reflect.get(o,r,o);return typeof a=="function"?a.bind(o):a}})}const V=e=>e.fieldType==="date"&&!e.def.fieldProps?.time||e.def.cellDataType==="dateString";function k(e,n){if(!V(e))return n.toISOString();const t=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())}`}function _e(e,n,t){if(t?.mode==="conditions"){const a=rowColorFor(e,t)?.rules;return a?.length?{colorOf:s=>a.find(d=>d.when(s))?.color}:{}}if(t?.mode!=="field")return{};const o=n.find(a=>a.field===t.field);if(!o||o.fieldType!=="singleSelect")return{};const r=lanesFor(o).filter(a=>a.id!==""&&a.color).map(({id:a,title:s,color:d})=>({id:a,title:s,color:d}));return r.length?{calendars:r,calendarField:o.field}:{}}function Ve(e,n,t,o,r){const s=(n.listFields?.length?n.listFields.map(d=>e.find(f=>f.id===d)).filter(d=>!!d):e.filter(d=>d.visible)).filter(d=>d.field!==t&&d.id!==o&&d.id!==r).slice(0,2);return s.length?{detailsOf:d=>s.map(f=>{const i=d,c=f.def.fieldFn;return ue(f,c?c(i):i?.[f.field],d)}).filter(f=>f!==""&&f!==p("viewbar.valueUnchecked")).join(" · ")}:{}}const je=Object.defineProperties({},Object.fromEntries(["board","addCard","addCardTo","cardTitle","noCards","cardActions","clearFilters","blocked","age","comments","writeComment","deleteComment","addSubtask","rename","cancel","save","grabbed","dropped","movedTo","movedUp","movedDown","movedPosition","cancelled","wipLimit","cannotMove","cardBlocked","selected","deselected"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.board.${e}`)}]))),te=Object.defineProperties({},Object.fromEntries(["month","week","day","agenda","today","previous","next","allDay","more","noEvents","eventsColumn","edit","duplicate","delete","moveGrabbed","moveDone","moveCancelled","moveBlocked"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.calendar.${e}`)}]))),Ge=Object.defineProperties({},{...Object.getOwnPropertyDescriptors(te),...Object.fromEntries(["timelineDay","timelineWeek","timelineMonth","timelineYear"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.calendar.${e}`)}]))}),Ne=Object.defineProperties({},Object.fromEntries(["expandAll","collapseAll","expandTask","collapseTask","zoomIn","zoomOut","zoomDay","zoomWeek","zoomMonth","zoomQuarter","zoomYear","tableLabel","chartLabel","resizeTable","days","progress","slack","start","finish","progressPercent","task","milestone","day","daysCount","open","openTask","edit","addSubtask","delete","deleteTask","removeLink","taskActions","save","cancel","onBaseline","laterThanBaseline","aheadOfBaseline","dragProgress","linkFromStart","linkFromFinish","workingDays","onCriticalPath","daysOfSlack","notMet","peak","loadOf","moveGrabbed","moveDone","moveCancelled","resized","progressSet"].map(e=>[e,{enumerable:!0,get:()=>p(`viewbar.gantt.${e}`)}])));function U(e,n,t,o,r){const a=M(e),s=a.find(u=>u.id===t.dateField);if(!s)return;const d=a.find(u=>u.id===t.endField),f=!!r&&R(r),i=u=>{const h=b(e,n,u.row);L(e,()=>{if(C(e,h,s.id,k(s,u.start)),d&&C(e,h,d.id,u.end.getTime()>u.start.getTime()?q(d,u.end):k(d,u.start)),r&&f&&u.toResource!=null){const y=u.fromResource??_(r,u.row);u.toResource!==y&&C(e,h,r.id,ne(r,u.row,y,u.toResource))}}),e.props.baseReflow?.()},c=(u,h)=>({[s.field]:k(s,u),...d?{[d.field]:h.getTime()>u.getTime()?q(d,h):k(d,u)}:{}}),m=T(e)&&R(s)&&(!d||R(d)),v=r===void 0?D(e):null;return{...v?{server:Re(v,s,d,(u,h)=>e.props.baseOpenDay?.(u,h)),walk:ze(v,s,u=>b(e,n,u))}:{},searchable:!1,text:te,editable:m,history:m&&!re(e),controlled:!0,tooltip:!0,onEventOpen:u=>F({ctrl:e,rowId:b(e,n,u)}),onEventDelete:T(e)?u=>B({ctrl:e,api:n,row:u}):void 0,startField:s.field,...d?{endField:d.field}:{},...o?{titleField:o}:{},...V(s)?{allDay:!0}:{},..._e(e,a,t.color),...Ve(a,t,o,s.id,d?.id),onEventMove:i,...d?{onEventResize:i}:{resizable:!1},onEventAdd:!T(e)||!z(e)?void 0:(u,h,y)=>{const O=e.props.rowAdder,A=O&&typeof O=="object"&&typeof O.defaults=="function"?O.defaults():{},x=r&&f&&y?{[r.field]:ne(r,{},void 0,y)}:{},S=H(e,{...A,...x,...c(u,h)});Y(e,n,S,!0)},onEventDuplicate:!T(e)||!z(e)?void 0:(u,h,y)=>ie(e,n,u,c(h,y))}}const Be={day:"timelineDay",week:"timelineWeek",month:"timelineMonth",year:"timelineYear"};function oe(e,n,t,o){const r=laneColumns(e).find(d=>d.id===t.laneField)??null,a=U(e,n,t,o,r);if(!a)return;let s;if(r&&(r.fieldType==="singleSelect"||r.fieldType==="user")){const d=e.props?.data??[];s=lanesFor(r).filter(i=>i.id!==""||d.some(c=>_(r,c)==="")).map(({id:i,title:c,color:m})=>({id:i,title:c,...m?{color:m}:{}}));const f=new Set(s.map(i=>i.id));for(const i of d){const c=_(r,i);f.has(c)||(f.add(c),s.push({id:c,title:ee(r,c)}))}}return{...a,views:["timelineDay","timelineWeek","timelineMonth","timelineYear"],initialView:Be[t.zoom??""]??"timelineMonth",text:Ge,...r?{resourceField:r.field,resourceOf:d=>_(r,d),resourceTitle:d=>ee(r,d),resourceLegend:!1,...s?{resources:s}:{}}:{}}}const R=e=>e.def.editable!==!1&&ce(I(e.def),E(I(e.def))),T=e=>e.props.editable!==!1&&!!(e.props.editable??e.props.enableInlineEditing);let $e=0,j=null;function L(e,n){const t=e.historyGroupId;j||(j=`${Se}${$e+=1}`,queueMicrotask(()=>j=null)),e.historyGroupId=t??j;try{n()}finally{e.historyGroupId=t}}const re=e=>!!e.props?.baseTableId;function q(e,n){return V(e)?k(e,new Date(n.getFullYear(),n.getMonth(),n.getDate()-1)):k(e,n)}function ie(e,n,t,o={}){if(!z(e))return;const r=b(e,n,t),a=e.internalData,s=a.findIndex(f=>b(e,n,f)===r);if((e.props.rowModel||D(e))&&typeof e.props.baseServerAdd=="function"){const{__group:f,...i}=J(e,s<0?t:a[s]);return e.props.baseServerAdd({...i,...o})}if(s<0)return;const d=H(e,{...J(e,a[s]),...o});n.addRow(d,s+1),e.props.onRowAdd?.({row:d})}export function deleteRecord(e,n,t){if(!$(e))return;const o=b(e,n,t),r=e.internalData,a=r.findIndex(d=>b(e,n,d)===o);if(a<0)return;const s=r[a];!e.props.rowModel&&!D(e)&&n.removeRows([a]),e.props.onRowsDelete?.({rows:[s],ids:[o],data:e.internalData})}const Ye=124,Z=new WeakMap;function de(e,n,t,o){Z.delete(e);const r=M(e),a=r.find(l=>l.id===t.dateField);if(!a)return;const s=r.find(l=>l.id===t.endField),d=r.find(l=>l.id===t.progressField),f=r.find(l=>l.id===t.dependencyField&&l.fieldType==="link"),c=[(l=>r.find(g=>g.field===l)?.id)(o),a.id,s?.id].filter(l=>!!l),m=l=>b(e,n,l),v=!!e.props?.basePhone,u=t.color&&t.color.mode!=="none"?l=>Me(e,l)??void 0:void 0,h=l=>q(s,l),y=(l,g,w)=>{C(e,l,a.id,k(a,g)),s&&C(e,l,s.id,w.getTime()>g.getTime()?h(w):k(s,g))},O=!!(d&&E(I(d.def)).points),A=l=>{const w=e.internalData.find(W=>m(W)===l)?.[f.field];return Array.isArray(w)?w.map(String):w==null||w===""?[]:[String(w)]},x=T(e)&&R(a)&&(!s||R(s)),S=D(e),G=S?xe(S,a,s,f):null;return{...G?{server:G,walk:X(S,G.list,m)}:{},searchable:!1,startField:a.field,...s?{endField:s.field}:{},...o?{titleField:o}:{},tableColumns:v?c.slice(0,1):[...new Set(c),"__duration"],...v?{tableWidth:Ye}:{},tableColumnWidths:Object.fromEntries([a,s].filter(l=>!!l).map(l=>[l.id,V(l)?144:176])),...u?{colorOf:u}:{},...t.zoom?{zoom:t.zoom}:{},tooltip:!0,text:Ne,pickUpToMove:!0,respectWorkingTime:!1,editable:x,history:x&&!re(e),controlled:!0,onTaskOpen:l=>F({ctrl:e,rowId:m(l)}),onTaskMove:l=>{L(e,()=>{y(m(l.row),l.start,l.end);for(const g of l.subtree??[])y(m(g.row),g.start,g.end)}),e.props.baseReflow?.()},onTaskResize:l=>{L(e,()=>y(m(l.row),l.start,l.end)),e.props.baseReflow?.()},onDependenciesChange:l=>{L(e,()=>{for(const g of l)y(g.id,g.start,g.end)}),e.props.baseReflow?.()},...d?{progressField:d.field,...O?{}:{progressValue:l=>Number(l?.[d.field]??0)*100},onProgressChange:l=>C(e,m(l.row),d.id,O?l.progress:l.progress/100)}:{},...f?{predecessorField:f.field,onDependencyAdd:l=>{const g=A(l.to);g.includes(l.from)||C(e,l.to,f.id,[...g,l.from])},onDependencyRemove:l=>{const[g,w]=l.split("->");g&&w&&C(e,w,f.id,A(w).filter(W=>W!==g))}}:{},onZoomChange:l=>{Z.set(e,l)},onTaskAdd:!T(e)||!z(e)?void 0:(l,g)=>{const w=e.props.rowAdder,W=w&&typeof w=="object"&&typeof w.defaults=="function"?w.defaults():{},se=H(e,{...W,[a.field]:k(a,l),...s?{[s.field]:g.getTime()>l.getTime()?h(g):k(s,l)}:{}});Y(e,n,se,!0)},onTaskDelete:T(e)&&$(e)?l=>B({ctrl:e,api:n,row:l}):void 0}}const Ue=e=>e.state?.advancedFilter??null;export function viewsWithoutFields(e,n,t=""){const o=[],r=e?.map(a=>{const s=Ue(a),d=we(s,n);return d===s?a:(o.push({table:t,view:a.id,was:s,now:d}),{...a,state:{...a.state,advancedFilter:d}})});return{views:o.length?r:e,changes:o}}export function filterChangesOf(e,n){return n.flatMap(t=>{const o=e.find(s=>s.id===t.id);if(!o)return[];const r=new Set(t.columns.map(s=>N(s))),a=new Set(o.columns.map(s=>N(s)).filter(s=>!r.has(s)));return a.size?viewsWithoutFields(t.views,s=>a.has(s),t.id).changes:[]})}export function applyViewFilters(e,n,t){return e.map(o=>{const r=n.filter(a=>a.table===o.id);return r.length?{...o,views:o.views?.map(a=>{const s=r.find(d=>d.view===a.id);return s?{...a,state:{...a.state,advancedFilter:s[t]}}:a})}:o})}export const PLAIN_STATE={sorting:[],grouping:[],hiddenColumns:[],advancedFilter:null};export function captureView(e,n,t){const o={...n.getState()};delete o.pagination,delete o.chart,delete o.charts,delete o.chartActive,delete o.globalFilter;const r=Te(n.getOption("rowHeight")),a=t.type==="gantt"?Z.get(e):void 0,{color:s,cellColors:d,...f}=t,i=be(e)===void 0?void 0:colorSettingOf(e,t.color),c=he(e);return{...f,state:o,...typeof r=="number"?{rowHeight:r}:{},...a?{zoom:a}:{},...i?{color:i}:{},...c.length?{cellColors:c}:{}}}const qe=e=>(e?.internalColumns??[]).filter(n=>n.field!=null).map(n=>N(n));export function applyView(e,n,t,o={}){const r={...PLAIN_STATE,...t.state??{},globalFilter:""};Array.isArray(r.columnOrder)&&r.columnOrder.length&&(r.columnOrder=Oe(r.columnOrder,qe(e))),n.setState(r),D(e)?.readQuery?.();const a=t.state;a?.grouping?.length&&a.expanded===void 0&&setTimeout(()=>{e.props?.rowModel||n.expandAllGroups?.()},0),t.rowHeight!=null&&n.setOption("rowHeight",t.rowHeight),t.color?applyColor(e,t.color,o.linkNames):ge(e),ye(e,t.cellColors??[]),n.setOption("board",t.type==="kanban"?boardConfig(e,n,t):void 0),n.setOption("gallery",t.type==="gallery"?galleryConfig(e,n,t):void 0);const s=P(e),d=o.primaryField??M(e).find(f=>f.id===s)?.field;n.setOption("scheduler",t.type==="calendar"?U(e,n,t,d):t.type==="timeline"?oe(e,n,t,d):void 0),n.setOption("gantt",t.type==="gantt"?de(e,n,t,d):void 0)}
@@ -1,8 +1,53 @@
1
1
  <script lang="ts">
2
- import{panelFocus}from"./panel-focus";import{filterKindOf,newCondition,operatorsFor,defaultValue}from"../filter-model";import{fieldColumns}from"../grid-access";import{BRIGHT,safeColor}from"../palette";import ConditionValue from"./ConditionValue.svelte";import{bm}from"../messages.svelte";const MODES=["none","field","conditions"];const modeLabel=m=>m==="none"?bm("viewbar.none"):m==="field"?bm("viewbar.selectField"):bm("viewbar.conditions");let{ctrl,setting,onChange}=$props();const selects=$derived(fieldColumns(ctrl).filter(c=>c.fieldType==="singleSelect"));const columns=$derived(fieldColumns(ctrl).filter(c=>filterKindOf(c.def)));const rules=$derived(setting.mode==="conditions"?setting.rules:[]);function mode(m){if(m==="none")return onChange({mode:"none"});if(m==="field")return selects[0]?onChange({mode:"field",field:selects[0].field}):void 0;onChange({mode:"conditions",rules:rules.length?rules:[]})}function setRules(next){onChange({mode:"conditions",rules:next})}function addRule(){const c=columns[0];const condition=c&&newCondition(c.id,c.def);if(!condition)return;setRules([...rules,{color:BRIGHT[rules.length%BRIGHT.length].value,condition}])}const put=(i,r)=>setRules(r?rules.map((x,j)=>j===i?r:x):rules.filter((_,j)=>j!==i));function changeOp(c,op){return{...c,op,value:defaultValue(c.kind,op)}}
2
+ import{panelFocus}from"./panel-focus";import{filterKindOf,newCondition,operatorsFor,defaultValue}from"../filter-model";import{fieldColumns}from"../grid-access";import{BRIGHT,safeColor}from"../palette";import ConditionValue from"./ConditionValue.svelte";import{bm}from"../messages.svelte";import{addField}from"../field-ops";const MODES=["none","field","conditions"];const modeLabel=m=>m==="none"?bm("viewbar.none"):m==="field"?bm("viewbar.selectField"):bm("viewbar.conditions");let{ctrl,setting,onChange,cellRules=[],onCellsChange}=$props();let tab=$state(cellRules.length&&setting.mode==="none"?"cells":"rows");const HIGHLIGHTS=[{hue:"#fcb400",light:"#ffd66e"},{hue:"#f82b60",light:"#ff9eb7"},{hue:"#20c933",light:"#93e088"},{hue:"#2d7ff9",light:"#9cc7ff"}];const highlightName=$derived(bm("viewbar.highlightField"));const mayAddFields=$derived(ctrl?.props?.columnAdder!==false&&ctrl?.props?.editable!==false);const highlightField=$derived(selects.find(c=>c.header.trim().toLowerCase()===highlightName.trim().toLowerCase()));function markByHand(){if(highlightField)return onChange({mode:"field",field:highlightField.field});if(!mayAddFields)return;const options=HIGHLIGHTS.map(h=>({value:BRIGHT.find(b=>b.value===h.hue)?.label??h.hue,color:h.light}));const def=addField(ctrl,{name:highlightName,fieldType:"singleSelect",fieldProps:{options}},"end");onChange({mode:"field",field:String(def.field??def.id)})}function setCells(next){onCellsChange?.(next)}function addCellRule(){const c=columns[0];const condition=c&&newCondition(c.id,c.def);if(!condition)return;setCells([...cellRules,{color:BRIGHT[(cellRules.length+4)%BRIGHT.length].value,condition}])}const putCell=(i,r)=>setCells(r?cellRules.map((x,j)=>j===i?r:x):cellRules.filter((_,j)=>j!==i));const selects=$derived(fieldColumns(ctrl).filter(c=>c.fieldType==="singleSelect"));const columns=$derived(fieldColumns(ctrl).filter(c=>filterKindOf(c.def)));const rules=$derived(setting.mode==="conditions"?setting.rules:[]);function mode(m){if(m==="none")return onChange({mode:"none"});if(m==="field")return selects[0]?onChange({mode:"field",field:selects[0].field}):void 0;onChange({mode:"conditions",rules:rules.length?rules:[]})}function setRules(next){onChange({mode:"conditions",rules:next})}function addRule(){const c=columns[0];const condition=c&&newCondition(c.id,c.def);if(!condition)return;setRules([...rules,{color:BRIGHT[rules.length%BRIGHT.length].value,condition}])}const put=(i,r)=>setRules(r?rules.map((x,j)=>j===i?r:x):rules.filter((_,j)=>j!==i));function changeOp(c,op){return{...c,op,value:defaultValue(c.kind,op)}}
3
3
  </script>
4
4
 
5
5
  <div class="sv-fvb-panel sv-fvb-panel-wide sv-fcolor" use:panelFocus>
6
+ {#if onCellsChange}
7
+ <div class="sv-fcolor-tabs" role="tablist" aria-label={bm('viewbar.color')}>
8
+ <button type="button" role="tab" class="sv-fcolor-tab" class:is-on={tab === 'rows'} aria-selected={tab === 'rows'} onclick={() => (tab = 'rows')}>{bm('viewbar.colorTabRows')}</button>
9
+ <button type="button" role="tab" class="sv-fcolor-tab" class:is-on={tab === 'cells'} aria-selected={tab === 'cells'} onclick={() => (tab = 'cells')}>{bm('viewbar.colorTabCells')}</button>
10
+ </div>
11
+ {/if}
12
+ {#if tab === 'cells' && onCellsChange}
13
+ <p class="sv-fvb-title">{bm('viewbar.colorCellsHelp')}</p>
14
+ {#each cellRules as r, i (i)}
15
+ {@const col = columns.find((x) => x.id === r.condition.column)}
16
+ <div class="sv-fcolor-row">
17
+ <label class="sv-fcolor-swatch" style:background={safeColor(r.color)} title={bm('viewbar.color')}>
18
+ <select aria-label={bm('viewbar.color')} value={r.color} onchange={(e) => putCell(i, { ...r, color: (e.currentTarget as HTMLSelectElement).value })}>
19
+ {#each BRIGHT as b (b.value)}<option value={b.value}>{b.label}</option>{/each}
20
+ </select>
21
+ </label>
22
+ <select
23
+ class="sv-fvb-select"
24
+ aria-label={bm('viewbar.field')}
25
+ value={r.condition.column}
26
+ onchange={(e) => {
27
+ const c = columns.find((x) => x.id === (e.currentTarget as HTMLSelectElement).value)
28
+ const condition = c && newCondition(c.id, c.def)
29
+ if (condition) putCell(i, { ...r, condition })
30
+ }}
31
+ >
32
+ {#each columns as x (x.id)}<option value={x.id}>{x.header}</option>{/each}
33
+ </select>
34
+ <select class="sv-fvb-select" aria-label={bm('viewbar.operator')} value={r.condition.op} onchange={(e) => putCell(i, { ...r, condition: changeOp(r.condition, (e.currentTarget as HTMLSelectElement).value as FilterOp) })}>
35
+ {#each operatorsFor(r.condition.kind) as o (o.op)}<option value={o.op}>{o.label}</option>{/each}
36
+ </select>
37
+ <span class="sv-fcolor-value">
38
+ {#if col}<ConditionValue column={col} condition={r.condition} onChange={(value) => putCell(i, { ...r, condition: { ...r.condition, value } })} />{/if}
39
+ </span>
40
+ <button type="button" class="sv-fvb-icon-btn" aria-label={bm('viewbar.removeCondition')} onclick={() => putCell(i, null)}>
41
+ <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>
42
+ </button>
43
+ </div>
44
+ {:else}
45
+ <p class="sv-fvb-empty">{bm('viewbar.noCellColors')}</p>
46
+ {/each}
47
+ <div class="sv-fvb-foot">
48
+ <button type="button" class="sv-fvb-text-btn" disabled={!columns.length} onclick={addCellRule}>{bm('viewbar.addCellRule')}</button>
49
+ </div>
50
+ {:else}
6
51
  <div class="sv-fcolor-modes" role="radiogroup" aria-label={bm('viewbar.colorRows')}>
7
52
  {#each MODES as m (m)}
8
53
  <button
@@ -61,8 +106,15 @@ import{panelFocus}from"./panel-focus";import{filterKindOf,newCondition,operators
61
106
  {:else}
62
107
  <p class="sv-fvb-empty">{bm('viewbar.notColored')}</p>
63
108
  {/if}
109
+ {#if setting.mode !== 'field' && (mayAddFields || highlightField)}
110
+ <div class="sv-fcolor-hand">
111
+ <button type="button" class="sv-fvb-text-btn" onclick={markByHand}>{bm('viewbar.highlightByHand')}</button>
112
+ <span class="sv-fcolor-hint">{bm('viewbar.highlightByHandHelp')}</span>
113
+ </div>
114
+ {/if}
115
+ {/if}
64
116
  </div>
65
117
 
66
118
  <style>
67
- .sv-fcolor{width:560px;max-width:100%}.sv-fcolor-modes{display:inline-flex;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;padding:2px;margin-bottom:8px}.sv-fcolor-mode{border:0;border-radius:6px;padding:3px 10px;background:none;color:inherit;font:inherit;cursor:pointer}.sv-fcolor-mode.is-on{background:color-mix(in srgb,var(--sg-accent, #2563eb) 14%,transparent);color:var(--sg-fg, #0f172a)}.sv-fcolor-mode:disabled{opacity:.45;cursor:default}.sv-fcolor-row{display:grid;grid-template-columns:24px 130px 120px minmax(0,1fr) 28px;gap:6px;align-items:start;margin:6px 0}.sv-fcolor-row>:global(*){min-width:0}.sv-fcolor-swatch{position:relative;width:22px;height:22px;margin-top:3px;border-radius:6px;cursor:pointer}.sv-fcolor-swatch select{position:absolute;inset:0;opacity:0;cursor:pointer}
119
+ .sv-fcolor{width:560px;max-width:100%}.sv-fcolor-tabs{display:flex;gap:2px;border-bottom:1px solid var(--sg-border, #e2e8f0);margin:-2px 0 10px}.sv-fcolor-tab{border:0;border-bottom:2px solid transparent;margin-bottom:-1px;padding:4px 10px 6px;background:none;color:var(--sg-muted, #64748b);font:inherit;cursor:pointer}.sv-fcolor-tab.is-on{color:var(--sg-fg, #0f172a);border-bottom-color:var(--sg-accent, #2563eb)}.sv-fcolor-hand{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px;margin-top:10px;padding-top:8px;border-top:1px solid var(--sg-border, #e2e8f0)}.sv-fcolor-hint{font-size:12px;color:var(--sg-muted, #64748b)}.sv-fcolor-modes{display:inline-flex;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;padding:2px;margin-bottom:8px}.sv-fcolor-mode{border:0;border-radius:6px;padding:3px 10px;background:none;color:inherit;font:inherit;cursor:pointer}.sv-fcolor-mode.is-on{background:color-mix(in srgb,var(--sg-accent, #2563eb) 14%,transparent);color:var(--sg-fg, #0f172a)}.sv-fcolor-mode:disabled{opacity:.45;cursor:default}.sv-fcolor-row{display:grid;grid-template-columns:24px 130px 120px minmax(0,1fr) 28px;gap:6px;align-items:start;margin:6px 0}.sv-fcolor-row>:global(*){min-width:0}.sv-fcolor-swatch{position:relative;width:22px;height:22px;margin-top:3px;border-radius:6px;cursor:pointer}.sv-fcolor-swatch select{position:absolute;inset:0;opacity:0;cursor:pointer}
68
120
  </style>
@@ -1,8 +1,11 @@
1
1
  import type { ColorSetting } from '../view-model.js';
2
+ import type { CellColorRule } from '../cell-colors.svelte.js';
2
3
  type $$ComponentProps = {
3
4
  ctrl: any;
4
5
  setting: ColorSetting;
5
6
  onChange: (s: ColorSetting) => void;
7
+ cellRules?: ReadonlyArray<CellColorRule>;
8
+ onCellsChange?: (rules: CellColorRule[]) => void;
6
9
  };
7
10
  declare const ColorPanel: import("svelte").Component<$$ComponentProps, {}, "">;
8
11
  type ColorPanel = ReturnType<typeof ColorPanel>;
@@ -913,7 +913,7 @@ ${E}
913
913
  @keyframes st-home-spin { to { transform: rotate(360deg); } }
914
914
  </style>
915
915
  `}}function Ka(e){for(const r of e)je(r);const t=new Map(e.map(r=>[r.name,r])),a=e.map(r=>{const o=Eu(r,t);return{schema:Fu(r,o),infos:o}});return{entries:a,seed:Du(a)}}function fo(e,t={}){const{entries:a,seed:r}=Ka(e),{file:o,needs:n}=em(a,r,t.sources,t.supabaseConn,t.serverMemory),i=[Lu(a),o];(n.supabase||t.supabaseAuth)&&!n.supabaseUrl&&(t.supabaseConn?.url||t.supabaseConn?.key)&&(n.supabaseUrl=t.supabaseConn.url,n.supabaseKey=t.supabaseConn.key),(n.supabase||t.supabaseAuth)&&i.push(tm(n));for(const s of n.sqlRoutes)i.push(Hu(s.schema,s.table,s.dialect,{access:t.accessEnabled,audit:t.auditEnabled,screenIds:t.screensByEntity?.get(s.schema.name)??[],triggers:t.triggers?.[s.schema.name],dbSchema:s.dbSchema,tenantField:t.tenantField&&t.tenantScoped?.(s.schema.name)!==!1?t.tenantField:void 0}));if(n.memoryRoutes.length){i.push(Gu(n.memoryRoutes));for(const s of n.memoryRoutes)i.push(Vu(s.schema,{access:t.accessEnabled,audit:t.auditEnabled,screenIds:t.screensByEntity?.get(s.schema.name)??[],triggers:t.triggers?.[s.schema.name],tenantField:t.tenantField&&t.tenantScoped?.(s.schema.name)!==!1?t.tenantField:void 0}))}return{files:i,prepared:a.map(s=>s.schema)}}function am(e){if(e.length===0)throw new Error("emitStudioApp: no schemas to emit");const{files:t,prepared:a}=fo(e),r=a.map(n=>{const i=z(n);return{href:`/${i.route}`,label:i.label}}),o={path:"src/custom.css",description:"Your custom styles (imported after app.css so it overrides).",userOwned:!0,contents:`/* Your custom styles. Imported after app.css, so these rules override the defaults. */
916
- `};return[...t,...a.map(n=>Ni(n)),Mi(r),ji(r),o]}function rm(e){return e.fields.some(t=>!!t.when&&(!!t.when.visible||!!t.when.disabled||!!t.when.required))}var om="3.1.44",nm="3.0.36",V=(e,t)=>e.some(a=>a.config.kind===t),qi=e=>`activeTab_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,aa=(e,t)=>`${e}-${t}`,zi=e=>`accOpen_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,ra=(e,t)=>`${e}-s${t}`,oa=e=>`md_${e.replace(/[^a-zA-Z0-9]/g,"_")}_rows`;function im(e){switch(e.type){case"number":{const t=e.decimals;return t!=null?`{ type: 'number', options: { minimumFractionDigits: ${t}, maximumFractionDigits: ${t} } }`:"{ type: 'number' }"}case"currency":return`{ type: 'currency', currency: ${S(e.currency||"USD")} }`;case"percent":{const t=["type: 'percent'"];return e.valueIsPercentPoints&&t.push("valueIsPercentPoints: true"),e.decimals!=null&&t.push(`options: { minimumFractionDigits: ${e.decimals}, maximumFractionDigits: ${e.decimals} }`),`{ ${t.join(", ")} }`}case"date":case"datetime":return e.pattern?`{ type: '${e.type}', pattern: ${S(e.pattern)} }`:`{ type: '${e.type}' }`}}function sm(e,t,a,r){if(t.config.kind!=="grid")return`schemaToColumns(${e})`;const o=t.config,n=t.id.replace(/-/g,"_"),i=o.columns.filter(b=>b.show),s=new Set(i.map(b=>b.field)),d=new Set,l=i.map(b=>{const y=r?.get(b.field);return{c:b,col:y&&!s.has(y)?y:b.field}}).filter(b=>!d.has(b.col)&&!!d.add(b.col)),c=o.editing==="inline"?"":", editable: false";if(l.length===0)return c?`schemaToColumns(${e}).map((c) => ({ ...c${c} }))`:`schemaToColumns(${e})`;const p=l.map(b=>`'${b.col}'`),u=l.map(({c:b,col:y})=>{const w=[];return b.header&&w.push(`header: ${JSON.stringify(b.header)}`),b.width!=null&&w.push(`width: ${b.width}`),b.align&&w.push(`align: '${b.align}'`),b.aggregate&&w.push(`aggregate: '${b.aggregate}'`),o.treeData&&b.field===o.treeData.labelField&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(treeCell_${n}, { value: ctx.getValue(), row: ctx.row.original })`):b.cellType&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(${Gi(n,b.field)}, { value: ctx.getValue() })`):b.format&&w.push(`format: ${im(b.format)}`),w.length?`'${y}': { ${w.join(", ")} }`:null}).filter(b=>!!b),m=u.length?` const ov: Record<string, Partial<(typeof all)[number]>> = { ${u.join(", ")} };`:"",g=u.length?", ...(ov[String(c.field)] ?? {})":"",h=`[${p.join(", ")}].map((f) => all.find((c) => c.field === f)).filter((c): c is (typeof all)[number] => !!c)`;return`(() => { const all = schemaToColumns(${e});${m} return ${c||g?`${h}.map((c) => ({ ...c${c}${g} }))`:h} })()`}function Ae(e,t){const a=[`grid-column: span ${ei(e)}`,"min-width: 0"];t&&a.push(t);const r=ti(e.style);return r&&a.push(r),`style="${a.join("; ")}"`}var lm=e=>e&&e.replace(/[^#a-zA-Z0-9(),.%\s_-]/g,"").slice(0,40)||"var(--sg-accent)";function Ue(e,t){const a=[t,Xn(e)].filter(Boolean).join(" ");return a?` class="${a}"`:""}function Ha(e){const t=Ta(e.className);return t?` ${t}`:""}function dm(e){const t=Fe(e);if(t==="grid"){const a=ui(e),r=a.maxWidth?` max-width: ${a.maxWidth}px; margin-inline: auto;`:"";return` .st-screen { grid-template-columns: repeat(12, 1fr); gap: ${a.rowGap}px ${a.colGap}px; align-items: ${a.align};${r} }
916
+ `};return[...t,...a.map(n=>Ni(n)),Mi(r),ji(r),o]}function rm(e){return e.fields.some(t=>!!t.when&&(!!t.when.visible||!!t.when.disabled||!!t.when.required))}var om="3.1.45",nm="3.0.37",V=(e,t)=>e.some(a=>a.config.kind===t),qi=e=>`activeTab_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,aa=(e,t)=>`${e}-${t}`,zi=e=>`accOpen_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,ra=(e,t)=>`${e}-s${t}`,oa=e=>`md_${e.replace(/[^a-zA-Z0-9]/g,"_")}_rows`;function im(e){switch(e.type){case"number":{const t=e.decimals;return t!=null?`{ type: 'number', options: { minimumFractionDigits: ${t}, maximumFractionDigits: ${t} } }`:"{ type: 'number' }"}case"currency":return`{ type: 'currency', currency: ${S(e.currency||"USD")} }`;case"percent":{const t=["type: 'percent'"];return e.valueIsPercentPoints&&t.push("valueIsPercentPoints: true"),e.decimals!=null&&t.push(`options: { minimumFractionDigits: ${e.decimals}, maximumFractionDigits: ${e.decimals} }`),`{ ${t.join(", ")} }`}case"date":case"datetime":return e.pattern?`{ type: '${e.type}', pattern: ${S(e.pattern)} }`:`{ type: '${e.type}' }`}}function sm(e,t,a,r){if(t.config.kind!=="grid")return`schemaToColumns(${e})`;const o=t.config,n=t.id.replace(/-/g,"_"),i=o.columns.filter(b=>b.show),s=new Set(i.map(b=>b.field)),d=new Set,l=i.map(b=>{const y=r?.get(b.field);return{c:b,col:y&&!s.has(y)?y:b.field}}).filter(b=>!d.has(b.col)&&!!d.add(b.col)),c=o.editing==="inline"?"":", editable: false";if(l.length===0)return c?`schemaToColumns(${e}).map((c) => ({ ...c${c} }))`:`schemaToColumns(${e})`;const p=l.map(b=>`'${b.col}'`),u=l.map(({c:b,col:y})=>{const w=[];return b.header&&w.push(`header: ${JSON.stringify(b.header)}`),b.width!=null&&w.push(`width: ${b.width}`),b.align&&w.push(`align: '${b.align}'`),b.aggregate&&w.push(`aggregate: '${b.aggregate}'`),o.treeData&&b.field===o.treeData.labelField&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(treeCell_${n}, { value: ctx.getValue(), row: ctx.row.original })`):b.cellType&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(${Gi(n,b.field)}, { value: ctx.getValue() })`):b.format&&w.push(`format: ${im(b.format)}`),w.length?`'${y}': { ${w.join(", ")} }`:null}).filter(b=>!!b),m=u.length?` const ov: Record<string, Partial<(typeof all)[number]>> = { ${u.join(", ")} };`:"",g=u.length?", ...(ov[String(c.field)] ?? {})":"",h=`[${p.join(", ")}].map((f) => all.find((c) => c.field === f)).filter((c): c is (typeof all)[number] => !!c)`;return`(() => { const all = schemaToColumns(${e});${m} return ${c||g?`${h}.map((c) => ({ ...c${c}${g} }))`:h} })()`}function Ae(e,t){const a=[`grid-column: span ${ei(e)}`,"min-width: 0"];t&&a.push(t);const r=ti(e.style);return r&&a.push(r),`style="${a.join("; ")}"`}var lm=e=>e&&e.replace(/[^#a-zA-Z0-9(),.%\s_-]/g,"").slice(0,40)||"var(--sg-accent)";function Ue(e,t){const a=[t,Xn(e)].filter(Boolean).join(" ");return a?` class="${a}"`:""}function Ha(e){const t=Ta(e.className);return t?` ${t}`:""}function dm(e){const t=Fe(e);if(t==="grid"){const a=ui(e),r=a.maxWidth?` max-width: ${a.maxWidth}px; margin-inline: auto;`:"";return` .st-screen { grid-template-columns: repeat(12, 1fr); gap: ${a.rowGap}px ${a.colGap}px; align-items: ${a.align};${r} }
917
917
  @media (max-width: ${a.mobileBreakpoint}px) { .st-screen { grid-template-columns: 1fr; gap: 12px; } }
918
918
  `}if(t==="stack"){const a=mi(e),r=a.maxWidth?` max-width: ${a.maxWidth}px;${a.align==="center"?" margin-inline: auto;":""}`:"",o=a.minHeight?`
919
919
  .st-stack > * { min-height: ${a.minHeight}px; }`:"",n=a.dividers?`
package/dist/version.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * `version.test.ts` asserts this matches `package.json`, so the two cannot drift.
12
12
  */
13
- export declare const SVGRID_VERSION = "3.1.44";
13
+ export declare const SVGRID_VERSION = "3.1.45";
14
14
  /**
15
15
  * The version of `@svgrid/grid`, which releases on its own line: enterprise is
16
16
  * on 3.1.x while the grid is on 3.0.x.
@@ -23,4 +23,4 @@ export declare const SVGRID_VERSION = "3.1.44";
23
23
  *
24
24
  * `version.test.ts` asserts this matches packages/grid/package.json.
25
25
  */
26
- export declare const GRID_VERSION = "3.0.36";
26
+ export declare const GRID_VERSION = "3.0.37";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const SVGRID_VERSION="3.1.44",GRID_VERSION="3.0.36";
1
+ export const SVGRID_VERSION="3.1.45",GRID_VERSION="3.0.37";