@evotecit/canopyx 0.3.15 → 0.3.18

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 (118) hide show
  1. package/CanopyX.Html/Assets/canopyx-board.css +50 -0
  2. package/CanopyX.Html/Assets/canopyx-board.js +39 -0
  3. package/CanopyX.Html/Assets/canopyx-buckets.js +15 -0
  4. package/CanopyX.Html/Assets/canopyx-calculations.css +7 -0
  5. package/CanopyX.Html/Assets/canopyx-calculations.js +52 -0
  6. package/CanopyX.Html/Assets/canopyx-calendar-edit.js +3 -3
  7. package/CanopyX.Html/Assets/canopyx-calendar.css +5 -24
  8. package/CanopyX.Html/Assets/canopyx-calendar.js +14 -19
  9. package/CanopyX.Html/Assets/canopyx-cell-range.js +16 -14
  10. package/CanopyX.Html/Assets/canopyx-changes.css +6 -24
  11. package/CanopyX.Html/Assets/canopyx-changes.js +18 -15
  12. package/CanopyX.Html/Assets/canopyx-compare.css +37 -0
  13. package/CanopyX.Html/Assets/canopyx-compare.js +12 -0
  14. package/CanopyX.Html/Assets/canopyx-data.js +3 -3
  15. package/CanopyX.Html/Assets/canopyx-editing.css +2 -2
  16. package/CanopyX.Html/Assets/canopyx-editing.js +2 -2
  17. package/CanopyX.Html/Assets/canopyx-enhance.js +4 -4
  18. package/CanopyX.Html/Assets/canopyx-export.js +54 -13
  19. package/CanopyX.Html/Assets/canopyx-facets.css +14 -5
  20. package/CanopyX.Html/Assets/canopyx-facets.js +19 -15
  21. package/CanopyX.Html/Assets/canopyx-filter-editor.css +71 -85
  22. package/CanopyX.Html/Assets/canopyx-filter-editor.js +20 -16
  23. package/CanopyX.Html/Assets/canopyx-flow-checks.css +2 -0
  24. package/CanopyX.Html/Assets/canopyx-flow-checks.js +5 -4
  25. package/CanopyX.Html/Assets/canopyx-flow-dialog.css +2 -0
  26. package/CanopyX.Html/Assets/canopyx-flow-dialog.js +1 -1
  27. package/CanopyX.Html/Assets/canopyx-flow-entry.css +136 -12
  28. package/CanopyX.Html/Assets/canopyx-flow-entry.js +5 -5
  29. package/CanopyX.Html/Assets/canopyx-flow-facts.js +2 -0
  30. package/CanopyX.Html/Assets/canopyx-flow-module.mjs +5 -5
  31. package/CanopyX.Html/Assets/canopyx-flow.js +8 -7
  32. package/CanopyX.Html/Assets/canopyx-format-editor.js +2 -2
  33. package/CanopyX.Html/Assets/canopyx-formatting.js +10 -9
  34. package/CanopyX.Html/Assets/canopyx-grid-module.mjs +185 -131
  35. package/CanopyX.Html/Assets/canopyx-grid.css +228 -96
  36. package/CanopyX.Html/Assets/canopyx-grid.js +185 -131
  37. package/CanopyX.Html/Assets/canopyx-grouping.css +22 -15
  38. package/CanopyX.Html/Assets/canopyx-grouping.js +24 -17
  39. package/CanopyX.Html/Assets/canopyx-interactive.css +197 -74
  40. package/CanopyX.Html/Assets/canopyx-interactive.js +38 -45
  41. package/CanopyX.Html/Assets/canopyx-labels-de.js +177 -9
  42. package/CanopyX.Html/Assets/canopyx-labels-es.js +177 -9
  43. package/CanopyX.Html/Assets/canopyx-labels-fr.js +176 -8
  44. package/CanopyX.Html/Assets/canopyx-labels-it.js +176 -8
  45. package/CanopyX.Html/Assets/canopyx-labels-pl.js +176 -8
  46. package/CanopyX.Html/Assets/canopyx-layouts.css +48 -20
  47. package/CanopyX.Html/Assets/canopyx-layouts.js +36 -14
  48. package/CanopyX.Html/Assets/canopyx-link.js +2 -2
  49. package/CanopyX.Html/Assets/canopyx-live.css +1 -3
  50. package/CanopyX.Html/Assets/canopyx-live.js +20 -15
  51. package/CanopyX.Html/Assets/canopyx-matrix.css +1 -8
  52. package/CanopyX.Html/Assets/canopyx-matrix.js +11 -11
  53. package/CanopyX.Html/Assets/canopyx-module.mjs +38 -45
  54. package/CanopyX.Html/Assets/canopyx-office-export.js +2936 -0
  55. package/CanopyX.Html/Assets/canopyx-path.css +45 -0
  56. package/CanopyX.Html/Assets/canopyx-path.js +28 -0
  57. package/CanopyX.Html/Assets/canopyx-pivot.css +75 -0
  58. package/CanopyX.Html/Assets/canopyx-pivot.js +72 -0
  59. package/CanopyX.Html/Assets/canopyx-plan.css +56 -0
  60. package/CanopyX.Html/Assets/canopyx-plan.js +67 -0
  61. package/CanopyX.Html/Assets/canopyx-presenters.js +2 -2
  62. package/CanopyX.Html/Assets/canopyx-record-panel.css +11 -2
  63. package/CanopyX.Html/Assets/canopyx-record-panel.js +18 -12
  64. package/CanopyX.Html/Assets/canopyx-reporting-module.mjs +225 -164
  65. package/CanopyX.Html/Assets/canopyx-reporting.css +240 -107
  66. package/CanopyX.Html/Assets/canopyx-reporting.js +225 -164
  67. package/CanopyX.Html/Assets/canopyx-stack.css +35 -0
  68. package/CanopyX.Html/Assets/canopyx-stack.js +24 -0
  69. package/CanopyX.Html/Assets/canopyx-time-slider.css +18 -0
  70. package/CanopyX.Html/Assets/canopyx-time-slider.js +27 -0
  71. package/CanopyX.Html/Assets/canopyx-timeline.js +6 -5
  72. package/CanopyX.Html/Assets/canopyx-tree-tools.css +36 -35
  73. package/CanopyX.Html/Assets/canopyx-tree-tools.js +15 -12
  74. package/CanopyX.Html/Assets/canopyx-ui-menu.css +41 -0
  75. package/CanopyX.Html/Assets/canopyx-ui-menu.js +64 -0
  76. package/CanopyX.Html/Assets/canopyx-ui-navigation.css +73 -0
  77. package/CanopyX.Html/Assets/canopyx-ui-navigation.js +39 -0
  78. package/CanopyX.Html/Assets/canopyx-ui-overlays.css +79 -0
  79. package/CanopyX.Html/Assets/canopyx-ui-overlays.js +42 -0
  80. package/CanopyX.Html/Assets/canopyx-ui-picker.css +12 -0
  81. package/CanopyX.Html/Assets/canopyx-ui-picker.js +6 -0
  82. package/CanopyX.Html/Assets/canopyx-ui-stepper.css +174 -0
  83. package/CanopyX.Html/Assets/canopyx-ui-stepper.js +48 -0
  84. package/CanopyX.Html/Assets/canopyx-ui-tabs.css +153 -0
  85. package/CanopyX.Html/Assets/canopyx-ui-tabs.js +47 -0
  86. package/CanopyX.Html/Assets/canopyx-values.css +5 -0
  87. package/CanopyX.Html/Assets/canopyx-values.js +13 -0
  88. package/CanopyX.Html/Assets/canopyx-view-intents.css +12 -0
  89. package/CanopyX.Html/Assets/canopyx-view-intents.js +56 -0
  90. package/CanopyX.Html/Assets/canopyx.css +197 -71
  91. package/CanopyX.Html/Assets/canopyx.js +29 -19
  92. package/JavaScript/board.d.ts +30 -0
  93. package/JavaScript/changes.d.ts +4 -1
  94. package/JavaScript/facets.d.ts +5 -3
  95. package/JavaScript/flow.d.ts +6 -0
  96. package/JavaScript/grid.d.ts +153 -17
  97. package/JavaScript/hosts.d.ts +14 -1
  98. package/JavaScript/index.d.ts +4 -2
  99. package/JavaScript/live.d.ts +2 -0
  100. package/JavaScript/locales/de.mjs +177 -9
  101. package/JavaScript/locales/es.mjs +177 -9
  102. package/JavaScript/locales/fr.mjs +176 -8
  103. package/JavaScript/locales/it.mjs +176 -8
  104. package/JavaScript/locales/pl.mjs +176 -8
  105. package/JavaScript/matrix.d.ts +4 -1
  106. package/JavaScript/path.d.ts +33 -0
  107. package/JavaScript/pivot.d.ts +135 -0
  108. package/JavaScript/plan.d.ts +23 -0
  109. package/JavaScript/protocol.d.ts +16 -3
  110. package/JavaScript/records.d.ts +20 -4
  111. package/JavaScript/stack.d.ts +28 -0
  112. package/JavaScript/time-slider.d.ts +58 -0
  113. package/JavaScript/ui.d.ts +261 -0
  114. package/JavaScript/view-intents.d.ts +45 -0
  115. package/README.md +22 -3
  116. package/ThirdParty/OfficeIMO/LICENSE +21 -0
  117. package/ThirdParty/OfficeIMO/README.md +13 -0
  118. package/package.json +76 -3
@@ -1,4 +1,4 @@
1
- (function(global){"use strict";const installed=new WeakSet();const part={version:"d3795e4b933d83a8",install(context){if(installed.has(context.DataGrid.prototype))return;const{toneVariable,DataGrid,h,setText,setClass,fill,gridFreeze,gridDateInputMoment,cellValue,cellText,foldText,toneOf,numberFormat,gridButton,gridOption,gridInputLabel,gridIcon,gridDecorateButton,GRID_REPORTING,loadPart,definePart,announceMenu,boundedPattern,wildcardMatch,svgIcon,overlayTheme}=context;const FORMAT_OPERATORS={eq:1,ne:1,gt:1,ge:1,lt:1,le:1,contains:1,notContains:1,startsWith:1,endsWith:1,like:1,notLike:1,matches:1,notMatches:1,in:-1,notIn:-1,between:2,betweenExclusive:2,isNull:0,isNotNull:0,olderThan:1,withinLast:1};const FORMAT_TYPES=["text","number","boolean","date"],FORMAT_DAY=86400000;function formatError(message){throw new Error("CanopyX: "+message)}
1
+ (function(global){"use strict";const installed=new WeakSet();const part={version:"7d7402e30ec311ca",install(context){if(installed.has(context.DataGrid.prototype))return;const{toneVariable,DataGrid,h,setText,setClass,fill,gridFreeze,gridDateInputMoment,cellValue,cellText,foldText,toneOf,numberFormat,gridButton,gridVariant,gridOption,gridInputLabel,gridIcon,gridDecorateButton,GRID_REPORTING,loadPart,definePart,announceMenu,boundedPattern,wildcardMatch,svgIcon,overlayTheme}=context;const FORMAT_OPERATORS={eq:1,ne:1,gt:1,ge:1,lt:1,le:1,contains:1,notContains:1,startsWith:1,endsWith:1,like:1,notLike:1,matches:1,notMatches:1,in:-1,notIn:-1,between:2,betweenExclusive:2,isNull:0,isNotNull:0,olderThan:1,withinLast:1};const FORMAT_TYPES=["text","number","boolean","date"],FORMAT_DAY=86400000;function formatError(message){throw new Error("CanopyX: "+message)}
2
2
  function formatKeys(value,keys,what){if(!value||typeof value!=="object"||Array.isArray(value)||Object.keys(value).some(key=>!keys.includes(key)))formatError("invalid "+what+".")}
3
3
  const formatCultures=new Map();function formatCulture(culture){let entry=formatCultures.get(culture);if(!entry){let tag;try{tag=Intl.getCanonicalLocales(culture)[0]}catch(_){formatError("unknown culture '"+culture+"'.")}
4
4
  const parts=new Intl.NumberFormat(tag).formatToParts(12345.6),part=type=>(parts.find(item=>item.type===type)||{}).value;entry={tag,group:part("group")||",",decimal:part("decimal")||".",accent:new Intl.Collator(tag,{sensitivity:"accent"}),variant:new Intl.Collator(tag,{sensitivity:"variant"})};if(formatCultures.size<64)formatCultures.set(culture,entry)}
@@ -17,7 +17,7 @@ formatError("invalid formatting condition.");const patterned=op==="like"||op==="
17
17
  formatError("formatting condition '"+op+"' has the wrong number of values.");if(values.some(value=>!(typeof value==="string"&&value.length<=4096||typeof value==="boolean"||Number.isFinite(value))))
18
18
  formatError("condition values are text, finite numbers or booleans.");const culture=predicate.culture?formatCulture(predicate.culture):null,exact=!!predicate.caseSensitive;const type=op==="olderThan"||op==="withinLast"?"date":predicate.type||(column.kind==="number"?"number":column.kind==="datetime"?"date":null);if((op==="olderThan"||op==="withinLast")&&!(typeof values[0]==="number"&&values[0]>=0&&values[0]<=36500))
19
19
  formatError("relative dates take a number of days from 0 to 36500.");const text=value=>typeof value==="string"?exact?value:culture?value.toLocaleLowerCase(culture.tag):foldText(value):value;const read=(cells,id)=>text(formatCoerce(cellValue(cells[id]),type,culture));const collator=culture&&(exact?culture.variant:culture.accent);const order=(a,b)=>typeof a==="string"&&typeof b==="string"&&collator?collator.compare(a,b):a<b?-1:a>b?1:0;let operands=[],pattern=null;if(patterned){const source=String(values[0]);if(source.length>256)formatError("patterns have at most 256 characters.");try{pattern=op==="like"||op==="notLike"?{test:value=>wildcardMatch(source,value,exact)}:boundedPattern(source,exact)}
20
- catch(_){formatError("invalid pattern '"+source+"'.")}}else if(op==="olderThan"||op==="withinLast")operands=[values[0]*FORMAT_DAY];else operands=values.map(value=>{const typed=text(formatCoerce(value,type,culture));if(typed===null)formatError("value '"+value+"' does not convert to " +(type||"text")+ ".");return typed});if((op==="between"||op==="betweenExclusive")&&order(operands[0],operands[1])>0)formatError("a range starts with its lower value.");const id=column.id,otherId=other&&other.id,set=arity<0&&!collator?new Set(operands):null;const member=value=>set?set.has(value):operands.some(operand=>typeof operand===typeof value&&order(value,operand)===0);budget.relative||=op==="olderThan"||op==="withinLast";return row=>{const value=read(row.cells,id);if(op==="isNull")return value===null;if(op==="isNotNull"||value===null)return op==="isNotNull"&&value!==null;const operand=other?read(row.cells,otherId):operands[0];if(operand===null)return false;switch(op){case "eq":return order(value,operand)===0&&typeof value===typeof operand;case "ne":return!(order(value,operand)===0&&typeof value===typeof operand);case "gt":return order(value,operand)>0;case "ge":return order(value,operand)>=0;case "lt":return order(value,operand)<0;case "le":return order(value,operand)<=0;case "in":return member(value);case "notIn":return!member(value);case "between":return order(value,operand)>=0&&order(value,operands[1])<=0;case "betweenExclusive":return order(value,operand)>0&&order(value,operands[1])<0;case "contains":return String(value).includes(String(operand));case "notContains":return!String(value).includes(String(operand));case "startsWith":return String(value).startsWith(String(operand));case "endsWith":return String(value).endsWith(String(operand));case "like":case "matches":return pattern.test(String(value).slice(0,4096));case "notLike":case "notMatches":return!pattern.test(String(value).slice(0,4096));case "olderThan":return value<Date.now()- operand;case "withinLast":{const now=Date.now();return value>=now-operand&&value<=now}}
20
+ catch(_){formatError("invalid pattern '"+source+"'.")}}else if(op==="olderThan"||op==="withinLast")operands=[values[0]*FORMAT_DAY];else operands=values.map(value=>{const typed=text(formatCoerce(value,type,culture));if(typed===null)formatError("value '"+value+"' does not convert to " +(type||"text")+ ".");return typed});if((op==="between"||op==="betweenExclusive")&&order(operands[0],operands[1])>0)formatError("a range starts with its lower value.");const id=column.id,otherId=other&&other.id,set=arity<0&&!collator?new Set(operands):null;const member=value=>set?set.has(value):operands.some(operand=>typeof operand===typeof value&&order(value,operand)===0);budget.relative||=op==="olderThan"||op==="withinLast";return row=>{const value=read(row.cells,id);if(op==="isNull")return value===null;if(op==="isNotNull"||value===null)return op==="isNotNull"&&value!==null;const operand=other?read(row.cells,otherId):operands[0];if(operand===null)return false;switch(op){case "eq":return order(value,operand)===0&&typeof value===typeof operand;case "ne":return!(order(value,operand)===0&&typeof value===typeof operand);case "gt":return order(value,operand)>0;case "ge":return order(value,operand)>=0;case "lt":return order(value,operand)<0;case "le":return order(value,operand)<=0;case "in":return member(value);case "notIn":return!member(value);case "between":return order(value,operand)>=0&&order(value,operands[1])<=0;case "betweenExclusive":return order(value,operand)>0&&order(value,operands[1])<0;case "contains":return String(value).includes(String(operand));case "notContains":return!String(value).includes(String(operand));case "startsWith":return String(value).startsWith(String(operand));case "endsWith":return String(value).endsWith(String(operand));case "like":case "matches":return pattern.test(String(value).slice(0,4096));case "notLike":case "notMatches":return!pattern.test(String(value).slice(0,4096));case "olderThan":return value<budget.now()- operand;case "withinLast":{const now=budget.now();return value>=now-operand&&value<=now}}
21
21
  return false}}
22
22
  function formatGroup(group,columns,budget,depth){if(depth>8||++budget.groups>64)formatError("formatting conditions exceed eight levels or 64 groups.");formatKeys(group,["operator","filters","groups"],"formatting condition group");const filters=group.filters??[],groups=group.groups??[];if(!["and","or","none"].includes(group.operator)||!Array.isArray(filters)||!Array.isArray(groups)||!filters.length&&!groups.length)
23
23
  formatError("invalid or empty formatting condition group.");const tests=[...filters.map(filter=>formatPredicate(filter,columns,budget)),...groups.map(child=>formatGroup(child,columns,budget,depth+1))];const count=tests.length;if(group.operator==="and")return row=>{for(let i=0;i<count;i++)if(!tests[i](row))return false;return true};const any=row=>{for(let i=0;i<count;i++)if(tests[i](row))return true;return false};return group.operator==="or"?any:row=>!any(row)}
@@ -37,11 +37,11 @@ if(style.bands!==undefined){const bands=style.bands;if(!Array.isArray(bands)||!b
37
37
  formatError("threshold bands rise, and only the last may be open.")})}
38
38
  if(!["tone","icon","badge","cue","className","css",...visuals].some(name=>style[name]!==undefined&&style[name]!=="none"))
39
39
  formatError("a formatting rule needs a style.")}
40
- function formatCompile(rules,grid){if(!Array.isArray(rules)||rules.length>64)formatError("a grid has at most 64 formatting rules.");const columns=new Map(grid.columns.map(column=>[column.id,column])),ids=new Set();return rules.map((rule,index)=>{formatKeys(rule,["id","label","description","enabled","when","column","target","columns","details","style","stopIfTrue"],"formatting rule");if(typeof rule.id!=="string"||!/^[A-Za-z0-9][\w.:-]{0,63}$/.test(rule.id) || ids.has(rule.id)) formatError("formatting rules need unique identifiers.");
40
+ function formatCompile(rules,grid,now=Date.now){if(!Array.isArray(rules)||rules.length>64)formatError("a grid has at most 64 formatting rules.");const columns=new Map(grid.columns.map(column=>[column.id,column])),ids=new Set();return rules.map((rule,index)=>{formatKeys(rule,["id","label","description","enabled","when","column","target","columns","details","style","stopIfTrue"],"formatting rule");if(typeof rule.id!=="string"||!/^[A-Za-z0-9][\w.:-]{0,63}$/.test(rule.id) || ids.has(rule.id)) formatError("formatting rules need unique identifiers.");
41
41
  ids.add(rule.id);formatText(rule.label,200);formatText(rule.description,1000);const target=rule.target??"cell";if(!["cell","row","columns"].includes(target)||["enabled","details","stopIfTrue"].some(name=>rule[name]!==undefined&&typeof rule[name]!=="boolean")||
42
42
  rule.column!==undefined&&!columns.has(rule.column)||target==="cell"&&rule.column===undefined)
43
43
  formatError("formatting rule '"+rule.id+"' needs a declared column for its target.");const targets=target==="columns"?rule.columns:target==="cell"?[rule.column]:[];if(target==="columns"?!Array.isArray(targets)||!targets.length||targets.length>64||new Set(targets).size!==targets.length||targets.some(id=>!columns.has(id)):rule.columns!==undefined)
44
- formatError("formatting rule '"+rule.id+"' names its columns once each.");formatStyle(rule.style,{target,column:rule.column});const budget={predicates:0,groups:0},test=rule.when===undefined?null:formatGroup(rule.when,columns,budget,1);return{id:rule.id,index,label:rule.label,description:rule.description||rule.label||rule.id,enabled:rule.enabled!==false,test,target,column:rule.column,columns:targets,details:rule.details!==false,stop:!!rule.stopIfTrue,style:rule.style,relative:!!budget.relative}})}
44
+ formatError("formatting rule '"+rule.id+"' names its columns once each.");formatStyle(rule.style,{target,column:rule.column});const budget={predicates:0,groups:0,now},test=rule.when===undefined?null:formatGroup(rule.when,columns,budget,1);return{id:rule.id,index,label:rule.label,description:rule.description||rule.label||rule.id,enabled:rule.enabled!==false,test,target,column:rule.column,columns:targets,details:rule.details!==false,stop:!!rule.stopIfTrue,style:rule.style,relative:!!budget.relative}})}
45
45
  function formatOptions(options){if(options===undefined)return{};formatKeys(options,["legend","editor"],"formatting options");if(["legend","editor"].some(name=>options[name]!==undefined&&typeof options[name]!=="boolean"))formatError("formatting options are booleans.");return{legend:!!options.legend,editor:!!options.editor}}
46
46
  function formatStats(grid){const inline=grid.view.source.kind==="inline"&&(!grid.opts.source||grid.enhanceStore),key=inline?"inline:" +(grid.enhanceStore?.version??0)+ ":"+grid.view.rows.length:grid.queryEpoch+":" +(grid.snapshot?.revision||"")+ ":" +[...grid.pages.keys()].join(",");if(grid.formatStatsKey===key)return grid.formatStatsCache;const wanted=new Set(grid.formatCompiled.filter(rule=>rule.style.bar||rule.style.scale).map(rule=>rule.column)),stats=new Map();if(wanted.size){const rows=inline?grid.view.rows:[...grid.rowCache.values()].map(row=>row.h);for(const id of wanted){let min=Infinity,max=-Infinity;for(const row of rows){const value=formatCoerce(cellValue(row.cells[id]),"number");if(value!==null){if(value<min)min=value;if(value>max)max=value}}
47
47
  stats.set(id,min<=max?{min,max}:null)}}
@@ -56,9 +56,10 @@ return out}
56
56
  function formatMerge(into,rule,style){const target=into||{rules:[],descriptions:[]};for(const name of["tone","emphasis","icon","badge","cue","className","css","bar","scale","band"])
57
57
  if(target[name]===undefined&&style[name]!==undefined)target[name]=style[name];target.rules.push(rule.id);if(rule.description&&!target.descriptions.includes(rule.description))target.descriptions.push(rule.description);if(style.band&&!target.descriptions.includes(style.band))target.descriptions.push(style.band);target.details=target.details||rule.details;return target}
58
58
  function formatFinish(target){if(!target)return target;if(target.icon===undefined&&target.tone&&!target.badge&&!target.cue&&!target.bar&&!target.scale)target.icon="auto";const name=target.icon==="auto"?FORMAT_TONE_ICONS[target.tone]||"dot":target.icon;target.glyph=name&&name!=="none"?FORMAT_ICONS[name]||name:null;return target}
59
- Object.assign(DataGrid.prototype,{formatResult(data,details=false){const rules=this.formatCompiled;if(!rules||!rules.length)return null;const cache=details?this.formatDetailCache||=new WeakMap():this.formatCache;const stats=formatStats(this),cached=cache.get(data);if(cached&&cached.version===this.formatVersion)return cached.result;let row=null,cells=null;for(const rule of rules){if(!rule.enabled||rule.test&&!rule.test(data))continue;const style=formatResolve(rule,data,stats);if(style&&(!details||rule.details)){if(rule.target==="row")row=formatMerge(row,rule,style);else for(const id of rule.columns)(cells||=new Map()).set(id,formatMerge(cells.get(id),rule,style))}
59
+ function formatEvaluate(rules,stats,data,details=false){let row=null,cells=null;for(const rule of rules){if(!rule.enabled||rule.test&&!rule.test(data))continue;const style=formatResolve(rule,data,stats);if(style&&(!details||rule.details)){if(rule.target==="row")row=formatMerge(row,rule,style);else for(const id of rule.columns)(cells||=new Map()).set(id,formatMerge(cells.get(id),rule,style))}
60
60
  if(rule.stop)break}
61
- if(cells)for(const target of cells.values())formatFinish(target);const result=row||cells?{row:formatFinish(row),cells:cells||new Map()}:null;cache.set(data,{version:this.formatVersion,result});return result}});const FORMAT_RANK={danger:5,warning:4,info:3,success:2,neutral:1,muted:1};function formatUndo(fx){for(const node of fx.nodes)node.remove();for(const name of fx.props)fx.element.style.removeProperty(name);for(const name of fx.classes)fx.element.classList.remove(name)}
61
+ if(cells)for(const target of cells.values())formatFinish(target);return row||cells?{row:formatFinish(row),cells:cells||new Map()}:null}
62
+ Object.assign(DataGrid.prototype,{formatResult(data,details=false){const rules=this.formatCompiled;if(!rules||!rules.length)return null;const cache=details?this.formatDetailCache||=new WeakMap():this.formatCache;const stats=formatStats(this),cached=cache.get(data);if(cached&&cached.version===this.formatVersion)return cached.result;const result=formatEvaluate(rules,stats,data,details);cache.set(data,{version:this.formatVersion,result});return result}});const FORMAT_RANK={danger:5,warning:4,info:3,success:2,neutral:1,muted:1};function formatUndo(fx){for(const node of fx.nodes)node.remove();for(const name of fx.props)fx.element.style.removeProperty(name);for(const name of fx.classes)fx.element.classList.remove(name)}
62
63
  function formatClearSlot(slot){if(slot.fx){formatUndo(slot.fx);slot.fx=null}
63
64
  for(const child of slot.childSlots||[])formatClearSlot(child)}
64
65
  function formatClear(element){for(const slot of element._cells||[])if(slot)formatClearSlot(slot);if(element._fx){formatUndo(element._fx);element._fx=null}}
@@ -66,7 +67,7 @@ function formatEffects(element){return{element,nodes:[],props:[],classes:[]}}
66
67
  function formatDecorate(element,target,fx,before,emphasis){const add=name=>{if(!element.classList.contains(name)){element.classList.add(name);fx.classes.push(name)}};const prop=(target,name,value)=>{target.style.setProperty(name,value);if(target===element)fx.props.push(name)};const node=(tag,className,text)=>{const item=h(tag,className);if(text)setText(item,text);fx.nodes.push(item);return item};if(target.tone&&emphasis){add("cx-fmt-" +(target.bar||target.scale?"text":target.emphasis||emphasis));prop(element,"--cx-fmt",formatToneVar(target.tone))}
67
68
  if(target.scale){add("cx-fmt-scale");prop(element,"--cx-fmt-scale",target.scale)}
68
69
  if(target.className)for(const name of target.className.split(/\s+/)) if (name) add(name);
69
- if(target.css)for(const name of Object.keys(target.css))prop(element,name,target.css[name]);if(target.glyph){const icon=node("span","cx-fmt-icon",target.glyph);icon.setAttribute("aria-hidden","true");if(target.tone)prop(icon,"--cx-fmt",formatToneVar(target.tone));element.insertBefore(icon,before&&before.parentNode===element?before:element.firstChild)}
70
+ if(target.css)for(const name of Object.keys(target.css))prop(element,name,target.css[name]);if(target.glyph){const icon=node("span","cx-fmt-icon",target.glyph);icon.setAttribute("aria-hidden","true");if(target.tone)prop(icon,"--cx-fmt",formatToneVar(target.tone));const line=element.querySelector(":scope > .cx-phone-primary")||element;line.insertBefore(icon,before&&before.parentNode===line?before:line.firstChild)}
70
71
  if(target.bar){add("cx-fmt-barred");if(!target.bar.show)add("cx-fmt-novalue");const bar=node("span","cx-fmt-bar");bar.setAttribute("aria-hidden","true");prop(bar,"--cx-fmt-w",(target.bar.width*100).toFixed(1)+ "%");prop(bar,"--cx-fmt",formatToneVar(target.bar.tone));element.insertBefore(bar,element.firstChild)}
71
72
  if(target.badge){const badge=node("span","cx-badge cx-fmt-badge",target.badge),tone=toneOf(target.tone||"neutral");badge.className +=tone.cls;if(tone.host){prop(badge,"--cx-t",toneVariable(tone.host));prop(badge,"--cx-t-bg",toneVariable(tone.host,true))}
72
73
  element.appendChild(badge)}
@@ -85,7 +86,7 @@ width=Math.ceil(width+2*pad+4);need=Math.max(need,width);if(flag)floor=Math.max(
85
86
  if(floor){column.formatMinW=column.minW;column.minW=Math.max(column.minW||0,Math.min(floor,420))}
86
87
  return need>result.width||floor>result.width?Object.freeze({...result,width:Math.max(result.width,Math.min(Math.max(need,floor),420))}):result};DataGrid.prototype.formatRefit=function(){this.fitKey=null;if(this.sized&&this.grid.clientWidth)this.applyWidths()};function formatDrawer(grid,dialog){let effects=[];const paint=()=>{effects.forEach(formatUndo);effects=[];const head=dialog.querySelector(".cx-drawer-h"),title=head&&head.querySelector("h4"),data=dialog._cxRecord;if(!dialog.isConnected||!title||!data||!grid.formatCompiled||!grid.formatCompiled.length)return;const result=grid.formatResult(data,true);if(!result)return;if(result.row){const fx=formatEffects(head);effects.push(fx);formatDecorate(head,{tone:result.row.tone,descriptions:result.row.descriptions,glyph:result.row.glyph},fx,title,"accent")}
87
88
  for(const field of grid.drawerFields(dialog)){const target=field.column&&result.cells.get(field.column.id);if(!target||!target.details)continue;const fx=formatEffects(field.value);effects.push(fx);formatDecorate(field.value,target,fx,field.value.firstChild,"fill")}};dialog.addEventListener("cx-drawer-paint",paint);dialog.addEventListener("close",()=>{effects.forEach(formatUndo);effects=[]},{once:true})}
88
- DataGrid.drawerHook(20,function(dialog){formatDrawer(this,dialog)});const FORMAT_EDITOR=definePart(DataGrid,"format-editor","formatting rule editor",()=>({DataGrid,h,setText,fill,gridButton,gridOption,gridDateInputMoment,gridInputLabel,gridIcon,gridDecorateButton,announceMenu,formatCompile,formatToneVar,formatError,FORMAT_ICONS,FORMAT_TONE_ICONS,FORMAT_OPERATORS,svgIcon,overlayTheme}));function formatPick(labels){const own={};for(const name of Object.keys(FORMAT_LABELS))own[name]=Object.hasOwn(labels,name)?labels[name]:FORMAT_LABELS[name];return own}
89
+ DataGrid.drawerHook(20,function(dialog){formatDrawer(this,dialog)});const FORMAT_EDITOR=definePart(DataGrid,"format-editor","formatting rule editor",()=>({DataGrid,h,setText,fill,gridButton,gridVariant,gridOption,gridDateInputMoment,gridInputLabel,gridIcon,gridDecorateButton,announceMenu,formatCompile,formatToneVar,formatError,FORMAT_ICONS,FORMAT_TONE_ICONS,FORMAT_OPERATORS,svgIcon,overlayTheme}));function formatPick(labels){const own={};for(const name of Object.keys(FORMAT_LABELS))own[name]=Object.hasOwn(labels,name)?labels[name]:FORMAT_LABELS[name];return own}
89
90
  Object.assign(DataGrid.prototype,{validateFormatRules(rules){formatCompile(rules,this)},startFormatting(){if(this.formatStarted||this.destroyed)return;this.formatStarted=true;this.formatVersion=1;this.formatCache=new WeakMap();this.formatLabels=formatPick(this.labels);try{this.formatOptions=formatOptions(this.view.formatting);this.formatCompiled=formatCompile(this.view.formatRules||[],this)}
90
91
  catch(error){this.formatOptions=this.formatOptions||{};this.formatCompiled=[];this.emit("error",{error})}
91
92
  this.formatRules=gridFreeze(JSON.parse(JSON.stringify(this.formatCompiled.length?this.view.formatRules:[])));this.formatEdited=false;this.formatLegendShown=!!this.formatOptions.legend;if(this.formatOptions.editor&&this.overflow){const entry=gridButton(this.formatLabels.formatRules,()=>this.openFormatRules().catch(error=>this.emit("error",{error})));entry.classList.add("cx-grid-format-rules");entry.setAttribute("aria-haspopup","dialog");this.overflow.panel.insertBefore(entry,this.overflow.panel.querySelector(".cx-grid-details, .cx-grid-print"))}
@@ -98,5 +99,5 @@ this.formatLabels.formatAbove+" "+numberFormat(this.lang).format(rule.style.band
98
99
  this.formatLabels.formatUpTo+" "+numberFormat(this.lang).format(band.upperBound))),{tone:band.tone,icon:band.icon??rule.style.icon}));else key(rule.label,rule.style,rule.description)}
99
100
  if(!legend.isConnected)this.host.insertBefore(legend,this.notice)}});function formatExported(target){if(!target)return undefined;const out={rules:target.rules.slice()};for(const name of["tone","badge","cue","band"])if(target[name]!==undefined)out[name]=target[name];if(target.glyph)out.icon=target.glyph;if(target.bar)out.bar={fraction:Math.round(target.bar.width*1000)/ 1000, tone: target.bar.tone };
100
101
  if(target.scale)out.color=target.scale;if(target.descriptions.length)out.description=target.descriptions.join(", ");return out}
101
- GRID_REPORTING.formatRecord=(grid,row,record)=>{const result=grid.formatResult&&grid.formatResult(row);if(!result)return record;const cells={};for(const[id,cell]of Object.entries(record.cells)){const format=formatExported(result.cells.get(id));cells[id]=format?{...cell,format}:cell}
102
+ const FORMAT_EXPORTS=new WeakMap(),FORMAT_PREPARE_EXPORT=DataGrid.prototype.prepareExport;DataGrid.prototype.prepareExport=function(options){const capture=FORMAT_PREPARE_EXPORT.call(this,options),now=Date.now(),rules=this.getFormatRules();const compiled=formatCompile(rules,this,()=>now),stats=compiled.length&&this.formatCompiled?formatStats(this):new Map();FORMAT_EXPORTS.set(capture.request,{rules:compiled,stats:new Map([...stats].map(([id,range])=>[id,range&&{...range}]))});return capture};GRID_REPORTING.copyExportFormatting=(from,to)=>{if(FORMAT_EXPORTS.has(from))FORMAT_EXPORTS.set(to,FORMAT_EXPORTS.get(from))};GRID_REPORTING.formatRecord=(grid,row,record,request)=>{const capture=FORMAT_EXPORTS.get(request),result=capture&&formatEvaluate(capture.rules,capture.stats,row);if(!result)return record;const cells={};for(const[id,cell]of Object.entries(record.cells)){const format=formatExported(result.cells.get(id));cells[id]=format?{...cell,format}:cell}
102
103
  return gridFreeze({...record,cells,...(result.row?{format:formatExported(result.row)}:{})})};installed.add(context.DataGrid.prototype)}};(global.CanopyXParts||=[]).push(["formatting",part])})(typeof window!=="undefined"?window:globalThis);