@aceshooting/lyra-ui 28.1.0 → 28.1.1

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 (70) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/components/agent-tools/commit-card/commit-card.class.d.ts +2 -2
  3. package/dist/components/agent-tools/commit-card/commit-card.class.js +7 -8
  4. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  5. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +1 -1
  6. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +4 -4
  7. package/dist/components/charts/chart/box-plot.class.d.ts +1 -1
  8. package/dist/components/charts/chart/box-plot.class.js +12 -12
  9. package/dist/components/charts/chart/chart.class.d.ts +1 -1
  10. package/dist/components/charts/chart/chart.class.js +13 -13
  11. package/dist/components/charts/chart/lite-chart.class.d.ts +1 -1
  12. package/dist/components/charts/chart/lite-chart.class.js +8 -8
  13. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  14. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  15. package/dist/components/data/data-grid/data-grid-processing.js +1 -1
  16. package/dist/components/data/gauge/gauge.class.js +1 -1
  17. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +1 -1
  18. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +2 -2
  19. package/dist/components/data/heatmap/heatmap-label-cache.js +1 -0
  20. package/dist/components/data/heatmap/heatmap.class.d.ts +2 -2
  21. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  22. package/dist/components/data/stat/stat.class.d.ts +11 -9
  23. package/dist/components/data/stat/stat.class.js +4 -2
  24. package/dist/components/data/tree/tree.class.js +1 -1
  25. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  26. package/dist/components/forms/color-picker/color-picker.class.js +3 -3
  27. package/dist/components/forms/combobox/combobox.class.d.ts +2 -4
  28. package/dist/components/forms/combobox/combobox.class.js +1 -1
  29. package/dist/components/forms/emoji-picker/emoji-picker.class.js +5 -5
  30. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  31. package/dist/components/forms/select/select.class.js +4 -3
  32. package/dist/components/forms/toggle-group/toggle-group.class.js +1 -1
  33. package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
  34. package/dist/components/layout/filter-bar/filter-bar.class.js +3 -3
  35. package/dist/components/layout/menu/menu.class.js +1 -1
  36. package/dist/components/layout/menubar/menubar.class.js +1 -1
  37. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +1 -1
  38. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  39. package/dist/components/layout/page/page.class.js +1 -1
  40. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  41. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +1 -1
  42. package/dist/components/media/file-input/file-input.class.js +1 -1
  43. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  44. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.d.ts +1 -1
  45. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +2 -2
  46. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  47. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  48. package/dist/components/retrieval/graph/graph-canvas.js +1 -1
  49. package/dist/components/retrieval/graph-legend/graph-legend.class.js +2 -2
  50. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +1 -1
  51. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  52. package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +1 -1
  53. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +4 -4
  54. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +1 -1
  55. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  56. package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
  57. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
  58. package/dist/internal/native-modal-carrier.js +2 -2
  59. package/dist/internal/overlay-manager.d.ts +2 -0
  60. package/dist/internal/overlay-manager.js +1 -1
  61. package/dist/internal/package-metadata.js +1 -1
  62. package/llms/components/lr-color-picker.md +2 -0
  63. package/llms/components/lr-commit-card.md +3 -2
  64. package/llms/components/lr-select.md +2 -0
  65. package/llms/components/lr-stat.md +4 -0
  66. package/llms/peers.md +1 -1
  67. package/llms/shared/ai-and-peers.md +44 -0
  68. package/llms/shared.md +44 -0
  69. package/package.json +5 -5
  70. package/registrations.json +1 -1
@@ -1,2 +1,2 @@
1
- import{getCollator,resolveIntlLocale}from"../../../internal/intl-cache.js";import{UNSAFE_LEADING}from"../../utility/export-button/csv.js";function columnId(column,_index){return typeof column.id=="string"&&column.id.trim()!==""?column.id:typeof column.field=="string"&&column.field.trim()!==""?column.field:""}function pathValue(value,path){if(!path)return;let current=value;for(const segment of path.split(".")){if(typeof current!="object"||current===null)return;current=current[segment]}return current}function columnValue(column,row){return column.value?column.value(row):column.field?pathValue(row,column.field):void 0}function comparableText(value){if(value==null)return"";if(value instanceof Date)return Number.isFinite(value.getTime())?value.toISOString():"";if(Array.isArray(value))return value.map(comparableText).join(" ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function numericDate(value){if(value instanceof Date)return Number.isFinite(value.getTime())?value.getTime():void 0;if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(typeof value=="string"){const parsed=Date.parse(value);return Number.isFinite(parsed)?parsed:void 0}}function finiteValue(value){if(typeof value=="string"&&value.trim()==="")return;const number=typeof value=="number"?value:Number(value);return Number.isFinite(number)?number:void 0}function valuesFromFilter(value){return Array.isArray(value)?value:value instanceof Set?[...value]:value==null||value===""?[]:[value]}function valuesFromCell(value){return Array.isArray(value)?value:value instanceof Set?[...value]:[value]}function sameValue(left,right,locale){return Object.is(left,right)?!0:getCollator(locale,{sensitivity:"base",numeric:!0}).compare(comparableText(left),comparableText(right))===0}const DATE_ONLY=/^(\d{4})-(\d{2})-(\d{2})$/;function localCalendarDay(value){if(typeof value!="string")return;const match=DATE_ONLY.exec(value.trim());if(!match)return;const year=Number(match[1]),month=Number(match[2])-1,day=Number(match[3]),date=new Date(0);return date.setFullYear(year,month,day),date.setHours(0,0,0,0),date.getFullYear()===year&&date.getMonth()===month&&date.getDate()===day?date.getTime():void 0}function matchesRange(value,filter,date){if(!Array.isArray(filter))return!0;const[rawStart,rawEnd]=filter,read=date?candidate=>localCalendarDay(candidate)??numericDate(candidate):finiteValue,current=read(value);if(current===void 0)return!1;const start=read(rawStart),end=read(rawEnd);if(start!==void 0&&current<start)return!1;if(end!==void 0){if(date){const inclusiveEnd=new Date(end);if(inclusiveEnd.setHours(23,59,59,999),current>inclusiveEnd.getTime())return!1}else if(current>end)return!1}return!0}function matchesFilter(row,column,filter,locale){const intlLocale=resolveIntlLocale(locale),value=columnValue(column,row);if(column.filterFn)return!!column.filterFn(value,filter,row);const type=column.filterType??"text",collator=getCollator(intlLocale,{sensitivity:"base",numeric:!0});if(type==="number-range")return matchesRange(value,filter,!1);if(type==="date-range")return matchesRange(value,filter,!0);if(type==="equals")return collator.compare(comparableText(value),comparableText(filter))===0;const needles=valuesFromFilter(filter);if(needles.length===0)return!0;const values=valuesFromCell(value);return type==="set"||type==="includes-any"?needles.some(needle=>values.some(candidate=>sameValue(candidate,needle,locale))):type==="includes-all"?needles.every(needle=>values.some(candidate=>sameValue(candidate,needle,locale))):comparableText(value).toLocaleLowerCase(intlLocale).includes(comparableText(filter).toLocaleLowerCase(intlLocale))}function filterRows(rows,columns,filters,locale){if(filters.length===0)return[...rows];const byId=new Map(columns.map((column,index)=>[columnId(column,index),column]));return rows.filter(row=>filters.every(filter=>{const column=byId.get(filter.id);return!column||matchesFilter(row,column,filter.value,locale)}))}function searchRows(rows,columns,term,locale,searchFn){const intlLocale=resolveIntlLocale(locale),needle=term.trim();if(!needle)return[...rows];const searchable=columns.filter(column=>(column.field||column.value)&&column.searchable!==!1);return rows.filter(row=>searchable.some(column=>{const value=columnValue(column,row);return searchFn?!!searchFn(value,needle,row):comparableText(value).toLocaleLowerCase(intlLocale).includes(needle.toLocaleLowerCase(intlLocale))}))}function undefinedRank(column,left,right){const leftMissing=left==null||typeof left=="number"&&!Number.isFinite(left),rightMissing=right==null||typeof right=="number"&&!Number.isFinite(right);if(leftMissing===rightMissing)return;const policy=column.sortUndefined??"last";return leftMissing===(policy==="first"||policy===-1)?-1:1}function cellText(cell){return cell.text??=comparableText(cell.value)}function cellTime(cell){return cell.time===void 0&&(cell.time=numericDate(cell.value)??null),cell.time??void 0}function cellComparator(column,locale){const comparator=column.comparator;if(comparator)return(left,right,leftRow,rightRow)=>comparator(left.value,right.value,leftRow,rightRow);const algorithm=column.sortFn??"alphanumeric",caseSensitive=algorithm==="alphanumericCaseSensitive"||algorithm==="textCaseSensitive",numeric=algorithm==="alphanumeric"||algorithm==="alphanumericCaseSensitive";let collator;return(left,right)=>{if(algorithm==="datetime"){const leftTime=cellTime(left),rightTime=cellTime(right);if(leftTime!==void 0&&rightTime!==void 0)return leftTime-rightTime}return algorithm==="basic"&&typeof left.value=="number"&&typeof right.value=="number"?left.value-right.value:(collator??=getCollator(locale,{sensitivity:caseSensitive?"variant":"base",numeric}),collator.compare(cellText(left),cellText(right)))}}function sortRows(rows,columns,sorting,locale){if(sorting.length===0)return[...rows];const byId=new Map(columns.map((column,index)=>[columnId(column,index),column])),active=[];for(const sort of sorting){const column=byId.get(sort.id);column&&active.push({desc:sort.desc,column,compare:cellComparator(column,locale)})}return rows.map((row,index)=>({row,index,cells:active.map(({column})=>({value:columnValue(column,row)}))})).sort((left,right)=>{for(let position=0;position<active.length;position+=1){const{desc,column,compare}=active[position],leftCell=left.cells[position],rightCell=right.cells[position],missing=undefinedRank(column,leftCell.value,rightCell.value);if(missing!==void 0)return typeof(column.sortUndefined??"last")=="string"?missing:desc?-missing:missing;const compared=compare(leftCell,rightCell,left.row,right.row);if(compared!==0)return desc?-compared:compared}return left.index-right.index}).map(({row})=>row)}function aggregateValues(aggregation,rows,values){if(typeof aggregation=="function")return aggregation(rows,values);if(aggregation==="count")return rows.length;const defined=values.filter(value=>value!=null);if(aggregation==="unique")return[...new Set(defined)];if(aggregation==="uniqueCount")return new Set(defined).size;const numeric=defined.map(finiteValue).filter(value=>value!==void 0);if(numeric.length===0)return aggregation==="extent"?[]:void 0;const sorted=[...numeric].sort((left,right)=>left-right);let scale=0;for(const value of numeric)scale=Math.max(scale,Math.abs(value));let scaledTotal=0;if(scale>0)for(const value of numeric)scaledTotal+=value/scale;if(aggregation==="sum"){const sum=scale===0?0:scaledTotal*scale;return Number.isFinite(sum)?sum:void 0}if(aggregation==="min")return sorted[0];if(aggregation==="max")return sorted.at(-1);if(aggregation==="mean"){const mean=scale===0?0:scaledTotal/numeric.length*scale;return Number.isFinite(mean)?mean:void 0}if(aggregation==="median"){const middle=Math.floor(sorted.length/2);if(sorted.length%2!==0)return sorted[middle];const left=sorted[middle-1]??0,right=sorted[middle]??0,median=Math.sign(left)===Math.sign(right)?left+(right-left)/2:left/2+right/2;return Number.isFinite(median)?median:void 0}return[sorted[0],sorted.at(-1)]}function csvCell(value,delimiter,escapeFormulas){let text=comparableText(value);return escapeFormulas&&typeof value!="number"&&UNSAFE_LEADING.test(text)&&(text=`'${text}`),(text.includes(delimiter)||/[\x22\r\n]/u.test(text))&&(text=`"${text.replaceAll('"','""')}"`),text}function rowsAsDelimited(rows,columns,options={}){const delimiter=options.delimiter??",",includeHeaders=options.includeHeaders??!0,escapeFormulas=options.escapeFormulas??!0,requested=options.columnIds?new Set(options.columnIds):void 0,visible=columns.filter((column,index)=>column.hidden!==!0&&(!requested||requested.has(columnId(column,index)))),lines=[];includeHeaders&&lines.push(visible.map((column,index)=>csvCell(column.label??columnId(column,index),delimiter,!1)).join(delimiter));for(const row of rows)lines.push(visible.map(column=>csvCell(columnValue(column,row),delimiter,escapeFormulas)).join(delimiter));return lines.join(`\r
1
+ import{getCollator,resolveIntlLocale}from"../../../internal/intl-cache.js";import{UNSAFE_LEADING}from"../../utility/export-button/csv.js";function columnId(column,_index){return typeof column.id=="string"&&column.id.trim()!==""?column.id:typeof column.field=="string"&&column.field.trim()!==""?column.field:""}function pathValue(value,path){if(!path)return;let current=value;for(const segment of path.split(".")){if(typeof current!="object"||current===null)return;current=current[segment]}return current}function columnValue(column,row){return column.value?column.value(row):column.field?pathValue(row,column.field):void 0}function comparableText(value){if(value==null)return"";if(value instanceof Date)return Number.isFinite(value.getTime())?value.toISOString():"";if(Array.isArray(value))return value.map(comparableText).join(" ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function numericDate(value){if(value instanceof Date)return Number.isFinite(value.getTime())?value.getTime():void 0;if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(typeof value=="string"){const parsed=Date.parse(value);return Number.isFinite(parsed)?parsed:void 0}}function finiteValue(value){if(typeof value=="string"&&value.trim()==="")return;const number=typeof value=="number"?value:Number(value);return Number.isFinite(number)?number:void 0}function valuesFromFilter(value){return Array.isArray(value)?value:value instanceof Set?[...value]:value==null||value===""?[]:[value]}function valuesFromCell(value){return Array.isArray(value)?value:value instanceof Set?[...value]:[value]}function sameValue(left,right,collator){return Object.is(left,right)?!0:collator().compare(comparableText(left),comparableText(right))===0}const DATE_ONLY=/^(\d{4})-(\d{2})-(\d{2})$/;function localCalendarDay(value){if(typeof value!="string")return;const match=DATE_ONLY.exec(value.trim());if(!match)return;const year=Number(match[1]),month=Number(match[2])-1,day=Number(match[3]),date=new Date(0);return date.setFullYear(year,month,day),date.setHours(0,0,0,0),date.getFullYear()===year&&date.getMonth()===month&&date.getDate()===day?date.getTime():void 0}function matchesRange(value,filter,date){if(!Array.isArray(filter))return!0;const[rawStart,rawEnd]=filter,read=date?candidate=>localCalendarDay(candidate)??numericDate(candidate):finiteValue,current=read(value);if(current===void 0)return!1;const start=read(rawStart),end=read(rawEnd);if(start!==void 0&&current<start)return!1;if(end!==void 0){if(date){const inclusiveEnd=new Date(end);if(inclusiveEnd.setHours(23,59,59,999),current>inclusiveEnd.getTime())return!1}else if(current>end)return!1}return!0}function matchesFilter(row,column,filter,locale){const intlLocale=resolveIntlLocale(locale),value=columnValue(column,row);if(column.filterFn)return!!column.filterFn(value,filter,row);const type=column.filterType??"text";if(type==="number-range")return matchesRange(value,filter,!1);if(type==="date-range")return matchesRange(value,filter,!0);let collator;const comparison=()=>collator??=getCollator(intlLocale,{sensitivity:"base",numeric:!0});if(type==="equals")return comparison().compare(comparableText(value),comparableText(filter))===0;const needles=valuesFromFilter(filter);if(needles.length===0)return!0;const values=valuesFromCell(value);return type==="set"||type==="includes-any"?needles.some(needle=>values.some(candidate=>sameValue(candidate,needle,comparison))):type==="includes-all"?needles.every(needle=>values.some(candidate=>sameValue(candidate,needle,comparison))):comparableText(value).toLocaleLowerCase(intlLocale).includes(comparableText(filter).toLocaleLowerCase(intlLocale))}function filterRows(rows,columns,filters,locale){if(filters.length===0)return[...rows];const byId=new Map(columns.map((column,index)=>[columnId(column,index),column]));return rows.filter(row=>filters.every(filter=>{const column=byId.get(filter.id);return!column||matchesFilter(row,column,filter.value,locale)}))}function searchRows(rows,columns,term,locale,searchFn){const intlLocale=resolveIntlLocale(locale),needle=term.trim();if(!needle)return[...rows];const searchable=columns.filter(column=>(column.field||column.value)&&column.searchable!==!1),normalizedNeedle=searchFn?"":needle.toLocaleLowerCase(intlLocale);return rows.filter(row=>searchable.some(column=>{const value=columnValue(column,row);return searchFn?!!searchFn(value,needle,row):comparableText(value).toLocaleLowerCase(intlLocale).includes(normalizedNeedle)}))}function undefinedRank(column,left,right){const leftMissing=left==null||typeof left=="number"&&!Number.isFinite(left),rightMissing=right==null||typeof right=="number"&&!Number.isFinite(right);if(leftMissing===rightMissing)return;const policy=column.sortUndefined??"last";return leftMissing===(policy==="first"||policy===-1)?-1:1}function cellText(cell){return cell.text??=comparableText(cell.value)}function cellTime(cell){return cell.time===void 0&&(cell.time=numericDate(cell.value)??null),cell.time??void 0}function cellComparator(column,locale){const comparator=column.comparator;if(comparator)return(left,right,leftRow,rightRow)=>comparator(left.value,right.value,leftRow,rightRow);const algorithm=column.sortFn??"alphanumeric",caseSensitive=algorithm==="alphanumericCaseSensitive"||algorithm==="textCaseSensitive",numeric=algorithm==="alphanumeric"||algorithm==="alphanumericCaseSensitive";let collator;return(left,right)=>{if(algorithm==="datetime"){const leftTime=cellTime(left),rightTime=cellTime(right);if(leftTime!==void 0&&rightTime!==void 0)return leftTime-rightTime}return algorithm==="basic"&&typeof left.value=="number"&&typeof right.value=="number"?left.value-right.value:(collator??=getCollator(locale,{sensitivity:caseSensitive?"variant":"base",numeric}),collator.compare(cellText(left),cellText(right)))}}function sortRows(rows,columns,sorting,locale){if(sorting.length===0)return[...rows];const byId=new Map(columns.map((column,index)=>[columnId(column,index),column])),active=[];for(const sort of sorting){const column=byId.get(sort.id);column&&active.push({desc:sort.desc,column,compare:cellComparator(column,locale)})}return rows.map((row,index)=>({row,index,cells:active.map(({column})=>({value:columnValue(column,row)}))})).sort((left,right)=>{for(let position=0;position<active.length;position+=1){const{desc,column,compare}=active[position],leftCell=left.cells[position],rightCell=right.cells[position],missing=undefinedRank(column,leftCell.value,rightCell.value);if(missing!==void 0)return typeof(column.sortUndefined??"last")=="string"?missing:desc?-missing:missing;const compared=compare(leftCell,rightCell,left.row,right.row);if(compared!==0)return desc?-compared:compared}return left.index-right.index}).map(({row})=>row)}function aggregateValues(aggregation,rows,values){if(typeof aggregation=="function")return aggregation(rows,values);if(aggregation==="count")return rows.length;const defined=values.filter(value=>value!=null);if(aggregation==="unique")return[...new Set(defined)];if(aggregation==="uniqueCount")return new Set(defined).size;const numeric=defined.map(finiteValue).filter(value=>value!==void 0);if(numeric.length===0)return aggregation==="extent"?[]:void 0;if(aggregation==="sum"||aggregation==="mean"){let scale=0;for(const value of numeric)scale=Math.max(scale,Math.abs(value));let scaledTotal=0;if(scale>0)for(const value of numeric)scaledTotal+=value/scale;const result=scale===0?0:aggregation==="sum"?scaledTotal*scale:scaledTotal/numeric.length*scale;return Number.isFinite(result)?result:void 0}if(aggregation==="median"){const sorted=[...numeric].sort((left2,right2)=>left2-right2),middle=Math.floor(sorted.length/2);if(sorted.length%2!==0)return sorted[middle];const left=sorted[middle-1]??0,right=sorted[middle]??0,median=Math.sign(left)===Math.sign(right)?left+(right-left)/2:left/2+right/2;return Number.isFinite(median)?median:void 0}let minimum=numeric[0],maximum=minimum;for(const value of numeric)value<minimum&&(minimum=value),value>=maximum&&(maximum=value);return aggregation==="min"?minimum:aggregation==="max"?maximum:[minimum,maximum]}function csvCell(value,delimiter,escapeFormulas){let text=comparableText(value);return escapeFormulas&&typeof value!="number"&&UNSAFE_LEADING.test(text)&&(text=`'${text}`),(text.includes(delimiter)||/[\x22\r\n]/u.test(text))&&(text=`"${text.replaceAll('"','""')}"`),text}function rowsAsDelimited(rows,columns,options={}){const delimiter=options.delimiter??",",includeHeaders=options.includeHeaders??!0,escapeFormulas=options.escapeFormulas??!0,requested=options.columnIds?new Set(options.columnIds):void 0,visible=columns.filter((column,index)=>column.hidden!==!0&&(!requested||requested.has(columnId(column,index)))),lines=[];includeHeaders&&lines.push(visible.map((column,index)=>csvCell(column.label??columnId(column,index),delimiter,!1)).join(delimiter));for(const row of rows)lines.push(visible.map(column=>csvCell(columnValue(column,row),delimiter,escapeFormulas)).join(delimiter));return lines.join(`\r
2
2
  `)}export{aggregateValues,columnId,columnValue,filterRows,matchesFilter,pathValue,rowsAsDelimited,searchRows,sortRows};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{nativeSvgTitle}from"../../../internal/svg-title.js";import{html,nothing,svg}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{normalizeReflectedOptionalSize,optionalSizeConverter}from"../../../internal/variants.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{chartValueFractionDigits}from"../../charts/chart/chart-number-format.js";import{finiteNumber,finiteRatio}from"../../../internal/numbers.js";import{styles}from"./gauge.styles.js";import{LYRA_DEFAULT_gaugeLabel,LYRA_DEFAULT_gaugeValueLabel}from"../../../internal/default-strings/data.generated.js";const SWEEP_DEG=270,START_DEG=135,RADIUS=40,CENTER=50,STROKE=10,LINEAR_STROKE=6,LINEAR_BAR_Y=15,LINEAR_TEXT_Y=8,LINEAR_LENGTH=100,RADIAL_VALUE_CHARACTERS=9,RADIAL_LABEL_CHARACTERS=12,LINEAR_VALUE_CHARACTERS=10,LINEAR_LABEL_CHARACTERS=10;function abbreviateSvgText(value,maxCharacters){const characters=Array.from(value);return characters.length<=maxCharacters?value:`${characters.slice(0,maxCharacters-1).join("")}…`}function polarToCartesian(angleDeg){const rad=angleDeg*Math.PI/180;return[CENTER+RADIUS*Math.cos(rad),CENTER+RADIUS*Math.sin(rad)]}function arcPath(startDeg,endDeg){const[sx,sy]=polarToCartesian(startDeg),[ex,ey]=polarToCartesian(endDeg),largeArc=endDeg-startDeg>180?1:0;return`M ${sx} ${sy} A ${RADIUS} ${RADIUS} 0 ${largeArc} 1 ${ex} ${ey}`}const RADIAL_ARC_D=arcPath(START_DEG,START_DEG+SWEEP_DEG),RADIAL_ARC_LENGTH=SWEEP_DEG/360*2*Math.PI*RADIUS,RING_CIRCUMFERENCE=2*Math.PI*RADIUS;class LyraGauge extends LyraElement{constructor(){super(...arguments),this.value=0,this.min=0,this.max=100,this.shape="radial",this.label="",this.withoutValue=!1,this.variant="brand",this.thresholds=[],this.appliedAriaLabel=null,this.explicitAriaLabel=null,this.authorRole=null,this.syncingGeneratedRole=!1,this.serverRendered=!1}static{this.defaultStrings={...super.defaultStrings,gaugeLabel:LYRA_DEFAULT_gaugeLabel,gaugeValueLabel:LYRA_DEFAULT_gaugeValueLabel}}static{this.styles=[LyraElement.styles,contextualSizes,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}get size(){return this._size}set size(next){const normalized=normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}connectedCallback(){this.serverRendered||=!this.hasUpdated&&this.shadowRoot!==null,super.connectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),!(name!=="role"||oldValue===value||this.syncingGeneratedRole)&&(!this.hasUpdated&&this.shadowRoot&&(value==="meter"||value==="img")||(this.authorRole=value,this.requestUpdate()))}get domain(){const min=finiteNumber(this.min,0),max=finiteNumber(this.max,100);return{lo:Math.min(min,max),hi:Math.max(min,max)}}get ratio(){if(!Number.isFinite(this.value))return 0;const{lo,hi}=this.domain;return finiteRatio(this.value,lo,hi)}get effectiveVariant(){if(Number.isFinite(this.value)&&this.thresholds.length>0){const sorted=[...this.thresholds.filter(threshold=>Number.isFinite(threshold.at))].sort((a,b)=>finiteNumber(a.at,0)-finiteNumber(b.at,0));let matched;for(const threshold of sorted)finiteNumber(threshold.at,0)<=this.value&&(matched=threshold.variant);if(matched)return matched}return this.variant}get displayText(){return this.valueText||(Number.isFinite(this.value)?getNumberFormat(this.effectiveLocale,{maximumFractionDigits:chartValueFractionDigits(this.value)}).format(this.value):"")}truncatedTooltip(fullText,renderedText,renderedLabel){return renderedText===fullText&&renderedLabel===(this.label??"")?"":this.label&&fullText?this.localize("gaugeValueLabel",void 0,{label:this.label,value:fullText}):this.label||fullText}willUpdate(changed){super.willUpdate(changed),this.setAttribute("data-effective-variant",this.effectiveVariant);const{lo,hi}=this.domain,finiteTrio=Number.isFinite(this.value)&&Number.isFinite(lo)&&Number.isFinite(hi)&&lo!==hi;if(this.authorRole===null){this.syncingGeneratedRole=!0;try{this.setAttribute("role",finiteTrio?"meter":"img")}finally{this.syncingGeneratedRole=!1}}if(finiteTrio){const clamped=Math.min(hi,Math.max(lo,this.value));this.setAttribute("aria-valuenow",String(clamped)),this.setAttribute("aria-valuemin",String(lo)),this.setAttribute("aria-valuemax",String(hi))}else this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax");const defaultName=this.label||this.localize("gaugeLabel"),fallbackValueLabel=this.displayText&&(!Number.isFinite(this.value)||lo===hi)?this.localize("gaugeValueLabel",void 0,{label:defaultName,value:this.displayText}):defaultName,currentAriaLabel=this.getAttribute("aria-label");!this.hasUpdated&&this.serverRendered&&currentAriaLabel===(finiteTrio?defaultName:fallbackValueLabel)&&(this.appliedAriaLabel=currentAriaLabel),currentAriaLabel!==this.appliedAriaLabel&&(this.explicitAriaLabel=currentAriaLabel);const nextAriaLabel=this.explicitAriaLabel||(finiteTrio?defaultName:fallbackValueLabel);this.setAttribute("aria-label",nextAriaLabel),this.appliedAriaLabel=nextAriaLabel,finiteTrio&&this.valueText?this.setAttribute("aria-valuetext",this.valueText):this.removeAttribute("aria-valuetext")}renderRadial(){const fullText=this.displayText,text=abbreviateSvgText(fullText,RADIAL_VALUE_CHARACTERS),label=abbreviateSvgText(this.label??"",RADIAL_LABEL_CHARACTERS),tooltip=this.truncatedTooltip(fullText,text,label),dashoffset=RADIAL_ARC_LENGTH*(1-this.ratio);return html`<svg
1
+ import{__decorate}from"tslib";import{nativeSvgTitle}from"../../../internal/svg-title.js";import{html,nothing,svg}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{normalizeReflectedOptionalSize,optionalSizeConverter}from"../../../internal/variants.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{chartValueFractionDigits}from"../../charts/chart/chart-number-format.js";import{finiteNumber,finiteRatio}from"../../../internal/numbers.js";import{styles}from"./gauge.styles.js";import{LYRA_DEFAULT_gaugeLabel,LYRA_DEFAULT_gaugeValueLabel}from"../../../internal/default-strings/data.generated.js";const SWEEP_DEG=270,START_DEG=135,RADIUS=40,CENTER=50,STROKE=10,LINEAR_STROKE=6,LINEAR_BAR_Y=15,LINEAR_TEXT_Y=8,LINEAR_LENGTH=100,RADIAL_VALUE_CHARACTERS=9,RADIAL_LABEL_CHARACTERS=12,LINEAR_VALUE_CHARACTERS=10,LINEAR_LABEL_CHARACTERS=10;function abbreviateSvgText(value,maxCharacters){const characters=Array.from(value);return characters.length<=maxCharacters?value:`${characters.slice(0,maxCharacters-1).join("")}…`}function polarToCartesian(angleDeg){const rad=angleDeg*Math.PI/180;return[CENTER+RADIUS*Math.cos(rad),CENTER+RADIUS*Math.sin(rad)]}function arcPath(startDeg,endDeg){const[sx,sy]=polarToCartesian(startDeg),[ex,ey]=polarToCartesian(endDeg),largeArc=endDeg-startDeg>180?1:0;return`M ${sx} ${sy} A ${RADIUS} ${RADIUS} 0 ${largeArc} 1 ${ex} ${ey}`}const RADIAL_ARC_D=arcPath(START_DEG,START_DEG+SWEEP_DEG),RADIAL_ARC_LENGTH=SWEEP_DEG/360*2*Math.PI*RADIUS,RING_CIRCUMFERENCE=2*Math.PI*RADIUS;class LyraGauge extends LyraElement{constructor(){super(...arguments),this.value=0,this.min=0,this.max=100,this.shape="radial",this.label="",this.withoutValue=!1,this.variant="brand",this.thresholds=[],this.appliedAriaLabel=null,this.explicitAriaLabel=null,this.authorRole=null,this.syncingGeneratedRole=!1,this.serverRendered=!1}static{this.defaultStrings={...super.defaultStrings,gaugeLabel:LYRA_DEFAULT_gaugeLabel,gaugeValueLabel:LYRA_DEFAULT_gaugeValueLabel}}static{this.styles=[LyraElement.styles,contextualSizes,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}get size(){return this._size}set size(next){const normalized=normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}connectedCallback(){this.serverRendered||=!this.hasUpdated&&this.shadowRoot!==null,super.connectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),!(name!=="role"||oldValue===value||this.syncingGeneratedRole)&&(!this.hasUpdated&&this.shadowRoot&&(value==="meter"||value==="img")||(this.authorRole=value,this.requestUpdate()))}get domain(){const min=finiteNumber(this.min,0),max=finiteNumber(this.max,100);return{lo:Math.min(min,max),hi:Math.max(min,max)}}get ratio(){if(!Number.isFinite(this.value))return 0;const{lo,hi}=this.domain;return finiteRatio(this.value,lo,hi)}get effectiveVariant(){if(Number.isFinite(this.value)&&this.thresholds.length>0){let matchedAt=Number.NEGATIVE_INFINITY,matched;if(this.thresholds.forEach(threshold=>{const rawAt=threshold.at;if(!Number.isFinite(rawAt))return;const at=finiteNumber(rawAt,0);at<=this.value&&at>=matchedAt&&(matchedAt=at,matched=threshold.variant)}),matched)return matched}return this.variant}get displayText(){return this.valueText||(Number.isFinite(this.value)?getNumberFormat(this.effectiveLocale,{maximumFractionDigits:chartValueFractionDigits(this.value)}).format(this.value):"")}truncatedTooltip(fullText,renderedText,renderedLabel){return renderedText===fullText&&renderedLabel===(this.label??"")?"":this.label&&fullText?this.localize("gaugeValueLabel",void 0,{label:this.label,value:fullText}):this.label||fullText}willUpdate(changed){super.willUpdate(changed),this.setAttribute("data-effective-variant",this.effectiveVariant);const{lo,hi}=this.domain,finiteTrio=Number.isFinite(this.value)&&Number.isFinite(lo)&&Number.isFinite(hi)&&lo!==hi;if(this.authorRole===null){this.syncingGeneratedRole=!0;try{this.setAttribute("role",finiteTrio?"meter":"img")}finally{this.syncingGeneratedRole=!1}}if(finiteTrio){const clamped=Math.min(hi,Math.max(lo,this.value));this.setAttribute("aria-valuenow",String(clamped)),this.setAttribute("aria-valuemin",String(lo)),this.setAttribute("aria-valuemax",String(hi))}else this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax");const defaultName=this.label||this.localize("gaugeLabel"),fallbackValueLabel=this.displayText&&(!Number.isFinite(this.value)||lo===hi)?this.localize("gaugeValueLabel",void 0,{label:defaultName,value:this.displayText}):defaultName,currentAriaLabel=this.getAttribute("aria-label");!this.hasUpdated&&this.serverRendered&&currentAriaLabel===(finiteTrio?defaultName:fallbackValueLabel)&&(this.appliedAriaLabel=currentAriaLabel),currentAriaLabel!==this.appliedAriaLabel&&(this.explicitAriaLabel=currentAriaLabel);const nextAriaLabel=this.explicitAriaLabel||(finiteTrio?defaultName:fallbackValueLabel);this.setAttribute("aria-label",nextAriaLabel),this.appliedAriaLabel=nextAriaLabel,finiteTrio&&this.valueText?this.setAttribute("aria-valuetext",this.valueText):this.removeAttribute("aria-valuetext")}renderRadial(){const fullText=this.displayText,text=abbreviateSvgText(fullText,RADIAL_VALUE_CHARACTERS),label=abbreviateSvgText(this.label??"",RADIAL_LABEL_CHARACTERS),tooltip=this.truncatedTooltip(fullText,text,label),dashoffset=RADIAL_ARC_LENGTH*(1-this.ratio);return html`<svg
2
2
  part="base"
3
3
  viewBox="0 0 100 100"
4
4
  aria-hidden="true"
@@ -265,4 +265,4 @@ focus(options?:FocusOptions):void;
265
265
  blur():void;
266
266
  /** Forwards host clicks to the first rendered control so callers can interact with this wrapper
267
267
  * as if it exposed a single root control. */
268
- click():void;private setValue;private onValueCommit;private addRelationshipType;private removeRelationshipType;private addNodeType;private removeNodeType;private captureChipRemovalFocus;private markTouched;private runQuery;private saveQuery;private loadQuery;private deleteQuery;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private hopOptions;private labelForType;protected createRenderRoot():HTMLElement|DocumentFragment;private renderTypeFilter;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-graph-query-builder':LyraGraphQueryBuilder;}}
268
+ click():void;private setValue;private onValueCommit;private addRelationshipType;private removeRelationshipType;private addNodeType;private removeNodeType;private captureChipRemovalFocus;private markTouched;private runQuery;private saveQuery;private loadQuery;private deleteQuery;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private hopOptions;protected createRenderRoot():HTMLElement|DocumentFragment;private renderTypeFilter;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-graph-query-builder':LyraGraphQueryBuilder;}}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{BUILDER_CHILD_EVENTS,containShadowChildEvent}from"../../../internal/child-event-containment.js";import{boundedRecordString,normalizeLabeledOptions}from"../../../internal/record-normalize.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel}from"../../../internal/default-strings/data.generated.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return boundedRecordString(value,MAX_TEXT)}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){return Array.isArray(value)?normalizeLabeledOptions(value,MAX_TYPES,MAX_TEXT):EMPTY_OPTIONS}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change","lr-query-run-request","lr-query-run","lr-query-save-request","lr-query-save","lr-query-load-request","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){if(value===this.relationshipOptionsSource||value===this._relationshipTypeOptions)return;this.relationshipOptionsSource=value;const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){if(value===this.nodeOptionsSource||value===this._nodeTypeOptions)return;this.nodeOptionsSource=value;const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){if(value===this.savedQueriesSource||value===this._savedQueries)return;this.savedQueriesSource=value;const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.slotPresence=new SlotPresenceController(this),this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.syncValidityCustomStates())},this.onValueCommit=event=>{event.stopPropagation(),this.effectiveDisabled||emitValueEvents(this,"change",Object.freeze({value:this._value}),detail=>this.emit("lr-change",detail))},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.syncFormState()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,this.releaseExternalDescription(),super.disconnectedCallback()}syncExternalDescription(){const target=this.isConnected?this.renderRoot.querySelector('[part="base"]')??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get value(){return this._value}set value(next){if(next===this.valueSource||next===this._value)return;this.valueSource=next;const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.validityController.checkValidity(()=>this.syncFormState())}reportValidity(){return this.validityController.syncConstraints(),this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.syncFormState(),this.requestUpdate())}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.isConnected?this.shadowRoot:null);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next,committed=!0){if(this.effectiveDisabled)return;this.hasInteracted=!0,this.value=next;const detail=Object.freeze({value:this._value});emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),committed&&emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=shadowFocusTarget(this),expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!==tag("chip")||active.getAttribute("value")!==value||active.closest(tag("chip-group"))?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-query-run-request",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-query-save-request",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-query-load-request",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-query-delete-request",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=shadowFocusTarget(this);if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot(),this.syncExternalDescription();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] ${tag("chip")}`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}labelForType(options,value){return options.find(o=>o.value===value)?.label??value}createRenderRoot(){const root=super.createRenderRoot();for(const type of BUILDER_CHILD_EVENTS)root.addEventListener(type,containShadowChildEvent);return root}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),available=options.filter(o=>!selected.includes(o.value));return html`
1
+ import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{BUILDER_CHILD_EVENTS,containShadowChildEvent}from"../../../internal/child-event-containment.js";import{boundedRecordString,normalizeLabeledOptions}from"../../../internal/record-normalize.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{deepActiveElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{styles}from"./graph-query-builder.styles.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{LYRA_DEFAULT_graphQueryBuilderLabel,LYRA_DEFAULT_graphQueryDeleteWithContext,LYRA_DEFAULT_graphQueryDirectionLabel,LYRA_DEFAULT_graphQueryEndLabel,LYRA_DEFAULT_graphQueryHopRangeInvalid,LYRA_DEFAULT_graphQueryLoadWithContext,LYRA_DEFAULT_graphQueryMaxHopsLabel,LYRA_DEFAULT_graphQueryMinHopsLabel,LYRA_DEFAULT_graphQueryNodeTypeLabel,LYRA_DEFAULT_graphQueryRelationshipTypeLabel,LYRA_DEFAULT_graphQueryRun,LYRA_DEFAULT_graphQuerySaveButton,LYRA_DEFAULT_graphQuerySaveNameLabel,LYRA_DEFAULT_graphQuerySavedQueriesLabel,LYRA_DEFAULT_graphQueryStartLabel}from"../../../internal/default-strings/data.generated.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_neighborDirectionBoth,LYRA_DEFAULT_neighborDirectionIn,LYRA_DEFAULT_neighborDirectionOut,LYRA_DEFAULT_noData,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const MAX_TYPES=500,MAX_SAVED_QUERIES=200,MAX_TEXT=256,EMPTY_STRINGS=Object.freeze([]),EMPTY_VALUE=Object.freeze({startId:"",endId:"",relationshipTypes:EMPTY_STRINGS,nodeTypes:EMPTY_STRINGS,direction:"both",minHops:1,maxHops:1}),EMPTY_OPTIONS=Object.freeze([]),EMPTY_SAVED=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return boundedRecordString(value,MAX_TEXT)}function stringArray(value){return Array.isArray(value)?Object.freeze([...new Set(value.slice(0,MAX_TYPES).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)).filter(Boolean))]):EMPTY_STRINGS}function normalizeGraphQuery(value){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,direction=ownValue(record,"direction");return Object.freeze({startId:boundedString(ownValue(record,"startId")),endId:boundedString(ownValue(record,"endId")),relationshipTypes:stringArray(ownValue(record,"relationshipTypes")),nodeTypes:stringArray(ownValue(record,"nodeTypes")),direction:direction==="out"||direction==="in"||direction==="both"?direction:"both",minHops:finiteInteger(typeof ownValue(record,"minHops")=="number"?ownValue(record,"minHops"):EMPTY_VALUE.minHops,EMPTY_VALUE.minHops,1,20),maxHops:finiteInteger(typeof ownValue(record,"maxHops")=="number"?ownValue(record,"maxHops"):EMPTY_VALUE.maxHops,EMPTY_VALUE.maxHops,1,20)})}function normalizeTypeOptions(value){return Array.isArray(value)?normalizeLabeledOptions(value,MAX_TYPES,MAX_TEXT):EMPTY_OPTIONS}function normalizeSavedQueries(value){if(!Array.isArray(value))return EMPTY_SAVED;const ids=new Set,result=[];for(const candidate of value.slice(0,MAX_SAVED_QUERIES)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));id.trim().length===0||ids.has(id)||(ids.add(id),result.push(Object.freeze({id,name:boundedString(ownValue(candidate,"name")),query:normalizeGraphQuery(ownValue(candidate,"query"))})))}return Object.freeze(result)}class LyraGraphQueryBuilder extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,graphQueryBuilderLabel:LYRA_DEFAULT_graphQueryBuilderLabel,graphQueryDeleteWithContext:LYRA_DEFAULT_graphQueryDeleteWithContext,graphQueryDirectionLabel:LYRA_DEFAULT_graphQueryDirectionLabel,graphQueryEndLabel:LYRA_DEFAULT_graphQueryEndLabel,graphQueryHopRangeInvalid:LYRA_DEFAULT_graphQueryHopRangeInvalid,graphQueryLoadWithContext:LYRA_DEFAULT_graphQueryLoadWithContext,graphQueryMaxHopsLabel:LYRA_DEFAULT_graphQueryMaxHopsLabel,graphQueryMinHopsLabel:LYRA_DEFAULT_graphQueryMinHopsLabel,graphQueryNodeTypeLabel:LYRA_DEFAULT_graphQueryNodeTypeLabel,graphQueryRelationshipTypeLabel:LYRA_DEFAULT_graphQueryRelationshipTypeLabel,graphQueryRun:LYRA_DEFAULT_graphQueryRun,graphQuerySaveButton:LYRA_DEFAULT_graphQuerySaveButton,graphQuerySaveNameLabel:LYRA_DEFAULT_graphQuerySaveNameLabel,graphQuerySavedQueriesLabel:LYRA_DEFAULT_graphQuerySavedQueriesLabel,graphQueryStartLabel:LYRA_DEFAULT_graphQueryStartLabel,neighborDirectionBoth:LYRA_DEFAULT_neighborDirectionBoth,neighborDirectionIn:LYRA_DEFAULT_neighborDirectionIn,neighborDirectionOut:LYRA_DEFAULT_neighborDirectionOut,noData:LYRA_DEFAULT_noData,select:LYRA_DEFAULT_select}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change","lr-query-run-request","lr-query-run","lr-query-save-request","lr-query-save","lr-query-load-request","lr-query-load"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get relationshipTypeOptions(){return this._relationshipTypeOptions}set relationshipTypeOptions(value){if(value===this.relationshipOptionsSource||value===this._relationshipTypeOptions)return;this.relationshipOptionsSource=value;const previous=this._relationshipTypeOptions;this._relationshipTypeOptions=normalizeTypeOptions(value),this.requestUpdate("relationshipTypeOptions",previous)}get nodeTypeOptions(){return this._nodeTypeOptions}set nodeTypeOptions(value){if(value===this.nodeOptionsSource||value===this._nodeTypeOptions)return;this.nodeOptionsSource=value;const previous=this._nodeTypeOptions;this._nodeTypeOptions=normalizeTypeOptions(value),this.requestUpdate("nodeTypeOptions",previous)}get savedQueries(){return this._savedQueries}set savedQueries(value){if(value===this.savedQueriesSource||value===this._savedQueries)return;this.savedQueriesSource=value;const previous=this._savedQueries;this._savedQueries=normalizeSavedQueries(value),this.requestUpdate("savedQueries",previous)}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}constructor(){super(),this._relationshipTypeOptions=EMPTY_OPTIONS,this._nodeTypeOptions=EMPTY_OPTIONS,this._savedQueries=EMPTY_SAVED,this.hopLimit=6,this.label="",this.hint="",this.errorText="",this._errors={},this.touchedFields=new Set,this.saveName="",this.slotPresence=new SlotPresenceController(this),this.labelId=nextId("graph-query-builder-label"),this.hintId=nextId("graph-query-builder-hint"),this.errorId=nextId("graph-query-builder-error"),this._fieldsetDisabled=!1,this._name="",this._value=EMPTY_VALUE,this.defaultValue=normalizeGraphQuery(EMPTY_VALUE),this.defaultValueCaptured=!1,this._disabled=!1,this.hasInteracted=!1,this.removalFocusGeneration=0,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.syncValidityCustomStates())},this.onValueCommit=event=>{event.stopPropagation(),this.effectiveDisabled||emitValueEvents(this,"change",Object.freeze({value:this._value}),detail=>this.emit("lr-change",detail))},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.syncFormState()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription()}disconnectedCallback(){this.removalFocusGeneration++,this.pendingRemovalFocus=void 0,this.releaseExternalDescription(),super.disconnectedCallback()}syncExternalDescription(){const target=this.isConnected?this.renderRoot.querySelector('[part="base"]')??null:null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby")}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get value(){return this._value}set value(next){if(next===this.valueSource||next===this._value)return;this.valueSource=next;const old=this._value;this._value=normalizeGraphQuery(next),this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this.validityController&&this.syncFormState(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&this.validity.customError&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}[VALIDITY_ANCHOR](){const firstInvalidPart=Object.keys(this._errors)[0];if(!(!firstInvalidPart||!this.renderRoot))return this.renderRoot.querySelector(`[part="${firstInvalidPart}"]`)??void 0}computeValidation(){const errors={},flags={};return this._value.startId.trim()||(errors["start-input"]=this.localize("fieldRequired"),flags.valueMissing=!0),this._value.minHops>this._value.maxHops&&(errors["max-hops"]=this.localize("graphQueryHopRangeInvalid"),flags.rangeUnderflow=!0),{errors,flags}}syncFormState(){const{errors,flags}=this.computeValidation();this._errors=errors;let formValue=null;try{formValue=JSON.stringify(this._value)}catch{formValue=null}if(this.internals.setFormValue(formValue,formValue),this.barredFromValidation||Object.keys(flags).length===0)this.validityController.setValidity({});else{const message=Object.values(errors)[0]??"";this.validityController.setValidity(flags,message)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncValidityCustomStates(){syncValidityStates(this.internals,{required:!0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}checkValidity(){return this.validityController.checkValidity(()=>this.syncFormState())}reportValidity(){return this.validityController.syncConstraints(),this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.captureDefaultValue(),this.value=this.defaultValue,this.touchedFields=new Set,this.saveName=""}captureDefaultValue(){this.defaultValueCaptured||(this.defaultValue=normalizeGraphQuery(this._value),this.defaultValueCaptured=!0)}formStateRestoreCallback(state2,_mode){let restored=EMPTY_VALUE;if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=normalizeGraphQuery(parsed))}catch{}this.value=restored}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(this.syncFormState(),this.requestUpdate())}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focusFirstControl(options){if(!this.renderRoot||this.liveDisabled)return;(this.renderRoot.querySelector('[part="start-input"]')||this.renderRoot.querySelector('[part="end-input"]')||this.renderRoot.querySelector('[part="min-hops"]')||this.renderRoot.querySelector('[part="max-hops"]')||this.renderRoot.querySelector('[part="direction"]')||this.renderRoot.querySelector('[part="save-name-input"]'))?.focus(options)}focus(options){this.focusFirstControl(options)}blur(){const active=deepActiveElementIn(this.isConnected?this.shadowRoot:null);active&&typeof active.blur=="function"&&active.blur()}click(){this.focusFirstControl()}setValue(next,committed=!0){if(this.effectiveDisabled)return;this.hasInteracted=!0,this.value=next;const detail=Object.freeze({value:this._value});emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),committed&&emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}addRelationshipType(type){!type||this._value.relationshipTypes.includes(type)||this.setValue({...this._value,relationshipTypes:[...this._value.relationshipTypes,type]})}removeRelationshipType(type){this.captureChipRemovalFocus("relationship",type,this._value.relationshipTypes),this.setValue({...this._value,relationshipTypes:this._value.relationshipTypes.filter(t=>t!==type)})}addNodeType(type){!type||this._value.nodeTypes.includes(type)||this.setValue({...this._value,nodeTypes:[...this._value.nodeTypes,type]})}removeNodeType(type){this.captureChipRemovalFocus("node-type",type,this._value.nodeTypes),this.setValue({...this._value,nodeTypes:this._value.nodeTypes.filter(t=>t!==type)})}captureChipRemovalFocus(group,value,selected){const active=shadowFocusTarget(this),expectedPart=group==="relationship"?"relationship-chips":"node-type-chips";if(active?.localName!==tag("chip")||active.getAttribute("value")!==value||active.closest(tag("chip-group"))?.getAttribute("part")!==expectedPart)return;const index=selected.indexOf(value),survivors=selected.filter(candidate=>candidate!==value),targetValue=survivors[Math.min(Math.max(index,0),survivors.length-1)];this.pendingRemovalFocus={kind:"chip",group,targetValue},this.removalFocusGeneration++}markTouched(part){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(part)&&(this.touchedFields=new Set(this.touchedFields).add(part))}runQuery(){if(this.effectiveDisabled||!this.reportValidity())return;const detail=()=>Object.freeze({query:normalizeGraphQuery(this._value)});this.emit("lr-query-run-request",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-run",detail())}saveQuery(){if(this.effectiveDisabled)return;const name=this.saveName.trim();if(!name)return;const detail=()=>Object.freeze({name,query:normalizeGraphQuery(this._value)});this.emit("lr-query-save-request",detail(),{cancelable:!0}).defaultPrevented||(this.saveName="",this.emit("lr-query-save",detail()))}loadQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id,query:normalizeGraphQuery(item.query)});this.emit("lr-query-load-request",detail(),{cancelable:!0}).defaultPrevented||(this.setValue({...EMPTY_VALUE,...item.query}),this.emit("lr-query-load",detail()))}deleteQuery(item){if(this.effectiveDisabled)return;const detail=()=>Object.freeze({queryId:item.id});this.emit("lr-query-delete-request",detail(),{cancelable:!0}).defaultPrevented||this.emit("lr-query-delete",detail())}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.captureDefaultValue(),!changed.has("savedQueries"))return;const active=shadowFocusTarget(this);if(active?.getAttribute("part")!=="saved-delete-button")return;const focusedId=active.closest("[data-query-id]")?.dataset.queryId;if(!focusedId||this.savedQueries.some(item=>item.id===focusedId))return;const index=(changed.get("savedQueries")??[]).findIndex(item=>item.id===focusedId),target=this.savedQueries[Math.min(Math.max(index,0),this.savedQueries.length-1)];this.pendingRemovalFocus={kind:"saved",targetId:target?.id},this.removalFocusGeneration++}updated(changed){super.updated(changed),this.publishValiditySnapshot(),this.syncExternalDescription();const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const generation=this.removalFocusGeneration;this.scheduleAfterUpdate(()=>{if(!(generation!==this.removalFocusGeneration||!this.isConnected)){if(pending.kind==="chip"){if(pending.targetValue){const part=pending.group==="relationship"?"relationship-chips":"node-type-chips",chip=[...this.shadowRoot?.querySelectorAll(`[part="${part}"] ${tag("chip")}`)??[]].find(candidate=>candidate.getAttribute("value")===pending.targetValue);if(chip){chip.focus();return}}const pickerPart=pending.group==="relationship"?"relationship-picker":"node-type-picker";this.shadowRoot?.querySelector(`[part="${pickerPart}"]`)?.focus();return}if(pending.targetId){const action=[...this.shadowRoot?.querySelectorAll("[data-query-id]")??[]].find(candidate=>candidate.dataset.queryId===pending.targetId)?.querySelector('[part="saved-delete-button"]');if(action){action.focus();return}}this.shadowRoot?.querySelector('[part="save-name-input"]')?.focus()}},"graph-query-removal-focus")}hopOptions(){const limit=finiteInteger(this.hopLimit,6,1,20),options=new Set(Array.from({length:limit},(_,i)=>i+1));return options.add(this._value.minHops),options.add(this._value.maxHops),[...options].sort((a,b)=>a-b)}createRenderRoot(){const root=super.createRenderRoot();for(const type of BUILDER_CHILD_EVENTS)root.addEventListener(type,containShadowChildEvent);return root}renderTypeFilter(kind,options,selected,add,remove,disabled){const pickerPart=kind==="relationship"?"relationship-picker":"node-type-picker",chipsPart=kind==="relationship"?"relationship-chips":"node-type-chips",pickerLabel=kind==="relationship"?this.localize("graphQueryRelationshipTypeLabel"):this.localize("graphQueryNodeTypeLabel"),selectedValues=new Set(selected),selectedLabels=new Map,available=options.filter(option=>{const value=option.value;return selectedValues.has(value)?(selectedLabels.has(value)||selectedLabels.set(value,option.label),!1):!0});return html`
2
2
  <div part="filter-group" data-kind=${kind}>
3
3
  <lr-select
4
4
  part=${pickerPart}
@@ -15,7 +15,7 @@ import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/valu
15
15
  ?removable=${!disabled}
16
16
  value=${t}
17
17
  @lr-remove=${event=>{event.stopPropagation(),remove(t)}}
18
- >${this.labelForType(options,t)}</lr-chip
18
+ >${selectedLabels.get(t)??t}</lr-chip
19
19
  >`)}
20
20
  </lr-chip-group>
21
21
  </div>
@@ -0,0 +1 @@
1
+ const MAX_ENTRIES=1024,MAX_TEXT_UNITS=65536;class HeatmapLabelCache{constructor(){this.widths=new Map,this.clipped=new Map,this.entries=0,this.textUnits=0}key(ctx,text,width){if(typeof text!="string"||text.length>65536)return;const values=[ctx.font,ctx.direction,ctx.fontKerning,ctx.fontStretch,ctx.fontVariantCaps,ctx.letterSpacing,ctx.wordSpacing,ctx.textRendering,text,width];let units=0;for(const value of values)if(typeof value=="string"&&(units+=value.length),units>65536)return;return JSON.stringify(values)}remember(map,key,value,units=key.length){this.entries>=1024||this.textUnits+units>65536||(map.set(key,value),this.entries+=1,this.textUnits+=units)}width(ctx,text){const key=this.key(ctx,text);if(key===void 0)return ctx.measureText(text).width;const cached=this.widths.get(key);if(cached!==void 0)return cached;const width=ctx.measureText(text).width;return this.remember(this.widths,key,width),width}clip(ctx,text,width,compute){const key=this.key(ctx,text,width);if(key===void 0)return compute();const cached=this.clipped.get(key);if(cached!==void 0)return cached;const result=compute();return this.remember(this.clipped,key,result,key.length+result.length),result}}export{HeatmapLabelCache};
@@ -441,7 +441,7 @@ set calendarGeometry(_value:Readonly<LyraHeatmapCalendarGeometry> |undefined);pr
441
441
  * omits no-data cells (the `-1`/non-finite sentinel `isNoData()` already honors for painting),
442
442
  * the same way the canvas draw path skips them.
443
443
  */
444
- exportData(format:LyraHeatmapExportFormat):string;private exportCsv;private lastPaintedMatrixGeometry?;private get matrixPadTop();private measureColLabelHeight;private measureRowLabelWidth;private ellipsize;private resolvedCalendarWeekdayLabelWidth;private get calendarPadLeft();private measureCalendarWeekdayLabelWidth;private get matrixRowLabels();private get matrixColLabels();private get matrixValues();private get calendarDays();private get calendarData();private _cellSize?;
444
+ exportData(format:LyraHeatmapExportFormat):string;private exportCsv;private lastPaintedMatrixGeometry?;private get matrixPadTop();private measureColLabelHeight;private measureRowLabelWidth;private labelCache?;private withLabelCache;private labelWidth;private ellipsize;private ellipsizeLabel;private resolvedCalendarWeekdayLabelWidth;private get calendarPadLeft();private measureCalendarWeekdayLabelWidth;private get matrixRowLabels();private get matrixColLabels();private get matrixValues();private get calendarDays();private get calendarData();private _cellSize?;
445
445
  /**
446
446
  * Effective per-cell size (CSS px). Originally matrix-mode only; now also
447
447
  * governs calendar mode's cell size (replacing the previously hardcoded
@@ -664,7 +664,7 @@ cellColor?:(pos:MatrixCellPos|CalendarCellPos,value:number)=>string|undefined;pr
664
664
  * fallback color and prevent the custom legend gradient from being assigned. */
665
665
  colorSteps?:readonly string[];private get calendarColumnX();private get calendarRowY();private canvas?;private resizeObserver?;private intersectionObserver?;private drawFrameRequest?;private dprQuery?;private dprChangeListener?;constructor();private calendarSpacingTrackingArmed?;private explicitCalendarSpacingProperties?;requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:PropertyDeclaration):void;private explicitCalendarSpacing;private cachedValueRange;private cachedMatrixData;private cachedCalendarGrid;private cachedCalendarSortedValues;private cachedCalendarCellsByPos;private cachedCalendarCellsByDate;private cachedAnnotations;private warnOnLegendRampMismatch;private cachedLegendStops;private cachedColorSteps;private cachedCalendarAnnotationDates;private cachedMatrixAnnotationPositions;private decorationProjectionTruncated;private cachedCalendarDateByPos;private cachedColumnGeometry?;private cachedRowGeometry?;private cachedAccessiblePositions;private cachedAccessiblePositionsByKey;private cachedAccessiblePositionIndexByKey;private cachedRamp;private canvasHasContent;private canvasVisible;private drawDirty;private overlayRevision;private hoverCell;private focusedCell;private liveText;private accessibleTargetSizePx;private pendingAccessibleFocus;private pendingAccessibleFocusOrigin;private restoringAccessibleFocus;private accessibleFocusGeneration;private readonly announcements;private authorRole;private authorAriaLabel;private generatedAriaLabel;private syncingGeneratedSemantics;private hasSyncedDescribedByElements;attributeChangedCallback(name:string,oldValue:string|null,value:string|null):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private watchDpr;private clearDprWatcher;private onDprChange;protected willUpdate(changed:PropertyValues):void;private rebuildBoundedDecorations;private get projectionTruncated();private get cellProjectionTruncated();private projectedCellCount;private projectionDescription;private rebuildCanonicalMatrixData;private selectedCellDescription;private computeValueRange;private localizedValueLabel;private formatNumericValue;private syncExternalDescription;protected updated(changed:PropertyValues):void;
666
666
  /** Redraws canvas content after an upstream token or theme change. */
667
- refreshTheme():void;private paintedTheme?;private themeSignature;private onThemeSignal;private refreshAccessibleTargetSize;private scaleEndpoints;private labelColor;private labelFont;private stickyLabelBg;private noDataFill;private focusRingColor;private annotationColor;private selectedColor;private strokeCellState;private isSelectedPos;private draw;private requestDraw;private syncDeferredFitFrame;private repaintFocusRing;private scheduleDraw;private cancelDrawFrame;private resolveColorStep;private colorRamp;private calendarCellSize;private calendarSpacing;private clampFitCellSize;private columnXFor;private rowYFor;private calendarColumnPositions;private calendarRowPositions;private weekdayLabels;private paintCalendarAxisLabels;private drawCalendar;private matrixCellSize;private matrixRowHeight;private matrixCellShape;private calendarCellShape;private fillMatrixCell;private paintMatrixCell;private paintMatrixFocusOverlays;private focusRepaintBounds;private repaintMatrixFocusCell;private paintCalendarCell;private fillCalendarCell;private recordCalendarGeometry;private paintCalendarFocusOverlays;private repaintCalendarFocusCell;private drawMatrix;private paintMatrixRowLabels;private paintMatrixColLabels;private paintFrozenLabelBands;private frozenBandCanvas;private sizeCanvas;private paintFrozenBand;private hitTest;private matrixNavigationGeometry;private calendarNavigationGeometry;private hitTestMatrix;private firstInteractiveMatrixCell;private nextInteractiveMatrixCell;private firstInteractiveCalendarCell;private nextInteractiveCalendarCell;private hitTestCalendar;private calendarCellAt;private calendarValueAt;private calendarDateAt;private calendarPos;private cellRect;private accessibleCellRect;private defaultCellText;private matrixCellText;private calendarCellText;private valueAt;private resolveCellText;private isCellInteractive;
667
+ refreshTheme():void;private paintedTheme?;private themeSignature;private onThemeSignal;private refreshAccessibleTargetSize;private scaleEndpoints;private labelColor;private labelFont;private stickyLabelBg;private noDataFill;private focusRingColor;private annotationColor;private selectedColor;private strokeCellState;private isSelectedPos;private draw;private requestDraw;private syncDeferredFitFrame;private repaintFocusRing;private scheduleDraw;private cancelDrawFrame;private resolveColorStep;private colorRamp;private calendarCellSize;private calendarSpacing;private clampFitCellSize;private columnXFor;private rowYFor;private calendarColumnPositions;private calendarRowPositions;private weekdayLabels;private paintCalendarAxisLabels;private drawCalendar;private paintCalendar;private matrixCellSize;private matrixRowHeight;private matrixCellShape;private calendarCellShape;private fillMatrixCell;private paintMatrixCell;private paintMatrixFocusOverlays;private focusRepaintBounds;private repaintMatrixFocusCell;private paintMatrixFocusCell;private paintCalendarCell;private fillCalendarCell;private recordCalendarGeometry;private paintCalendarFocusOverlays;private repaintCalendarFocusCell;private paintCalendarFocusCell;private drawMatrix;private paintMatrix;private paintMatrixRowLabels;private paintMatrixColLabels;private paintFrozenLabelBands;private frozenBandCanvas;private sizeCanvas;private paintFrozenBand;private hitTest;private matrixNavigationGeometry;private calendarNavigationGeometry;private hitTestMatrix;private firstInteractiveMatrixCell;private nextInteractiveMatrixCell;private firstInteractiveCalendarCell;private nextInteractiveCalendarCell;private hitTestCalendar;private calendarCellAt;private calendarValueAt;private calendarDateAt;private calendarPos;private cellRect;private accessibleCellRect;private defaultCellText;private matrixCellText;private calendarCellText;private valueAt;private resolveCellText;private isCellInteractive;
668
668
  /** Refreshes the aria-hidden shadow mirror and shared light-DOM sink for a newly-focused cell.
669
669
  * The selected state goes through the same `heatmapSelectedCellLabel`
670
670
  * template as the host aria-label, so a locale can place the "selected"