@aquera/nile-elements 1.7.2 → 1.7.3
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.
- package/README.md +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +387 -265
- package/dist/nile-breadcrumb-item/nile-breadcrumb-item.cjs.js +1 -1
- package/dist/nile-breadcrumb-item/nile-breadcrumb-item.cjs.js.map +1 -1
- package/dist/nile-breadcrumb-item/nile-breadcrumb-item.esm.js +8 -6
- package/dist/nile-combobox/group-utils.cjs.js +2 -0
- package/dist/nile-combobox/group-utils.cjs.js.map +1 -0
- package/dist/nile-combobox/group-utils.esm.js +1 -0
- package/dist/nile-combobox/index.cjs.js +1 -1
- package/dist/nile-combobox/index.esm.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.esm.js +77 -4
- package/dist/nile-combobox/nile-combobox.esm.js +13 -8
- package/dist/nile-combobox/renderer.cjs.js +1 -1
- package/dist/nile-combobox/renderer.cjs.js.map +1 -1
- package/dist/nile-combobox/renderer.esm.js +84 -42
- package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.js +4 -2
- package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.js.map +1 -1
- package/dist/src/nile-combobox/group-utils.d.ts +26 -0
- package/dist/src/nile-combobox/group-utils.js +140 -0
- package/dist/src/nile-combobox/group-utils.js.map +1 -0
- package/dist/src/nile-combobox/nile-combobox.css.js +77 -4
- package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.d.ts +33 -0
- package/dist/src/nile-combobox/nile-combobox.js +171 -34
- package/dist/src/nile-combobox/nile-combobox.js.map +1 -1
- package/dist/src/nile-combobox/renderer.d.ts +4 -0
- package/dist/src/nile-combobox/renderer.js +71 -2
- package/dist/src/nile-combobox/renderer.js.map +1 -1
- package/dist/src/nile-combobox/types.d.ts +30 -0
- package/dist/src/nile-combobox/types.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-breadcrumb-item/nile-breadcrumb-item.ts +4 -2
- package/src/nile-combobox/group-utils.ts +157 -0
- package/src/nile-combobox/nile-combobox.css.ts +77 -4
- package/src/nile-combobox/nile-combobox.ts +223 -70
- package/src/nile-combobox/renderer.ts +119 -2
- package/src/nile-combobox/types.ts +36 -0
- package/vscode-html-custom-data.json +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.cjs.js","sources":["../../../src/nile-combobox/renderer.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type { VirtualItem } from '@tanstack/virtual-core';\n\nexport class ComboboxRenderer {\n\n static renderVirtualizedOptions(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n measureElement: (el: Element | null) => void,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n const offsetTop = virtualItems.length > 0 ? virtualItems[0].start : 0;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;height:${totalSize}px;width:100%;\">\n <div style=\"position:absolute;top:0;left:0;width:100%;transform:translateY(${offsetTop}px);\">\n ${repeat(\n virtualItems,\n (vItem) => vItem.key,\n (vItem) => {\n const item = data[vItem.index];\n return ComboboxRenderer.renderMeasuredItem(\n item, vItem.index, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, measureElement, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n );\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderPlainOptions(\n data: any[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n showNoResults: boolean,\n noResultsMessage: string,\n isLoading: boolean,\n onScroll: (e: Event) => void,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n noResultsSubtitle?: string,\n ): TemplateResult {\n if (showNoResults && !isLoading && data.length === 0) {\n return ComboboxRenderer.renderNoResults(noResultsMessage, noResultsSubtitle);\n }\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div class=\"combobox__options-plain\" @scroll=${onScroll}>\n ${data.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n ),\n )}\n </div>\n </div>\n `;\n }\n\n static renderNoResults(noResultsMessage: string, noResultsSubtitle?: string): TemplateResult {\n return html`\n <div part=\"select-options\" class=\"combobox__options\">\n <div part=\"no-results\" class=\"combobox__no-results\">\n <div part=\"no-results-title\" class=\"combobox__no-results-title\">\n ${noResultsMessage || 'No result found'}\n </div>\n ${noResultsSubtitle\n ? html`<div part=\"no-results-subtitle\" class=\"combobox__no-results-subtitle\">${noResultsSubtitle}</div>`\n : ''}\n </div>\n </div>\n `;\n }\n\n static renderNoData(noDataMessage: string): TemplateResult {\n return html`\n <div part=\"select-options\" class=\"combobox__options\">\n <div part=\"no-data\" class=\"combobox__no-results\">\n <div part=\"no-data-title\" class=\"combobox__no-results-title\">\n ${noDataMessage || 'No data available'}\n </div>\n </div>\n </div>\n `;\n }\n\n private static renderMeasuredItem(\n item: any,\n index: number,\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n allowHtmlLabel: boolean,\n measureElement: (el: Element | null) => void,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n if (!item) return html``;\n\n const optionValue = getItemValue(item);\n const displayText = getDisplayText(item);\n const isDisabled = item?.disabled || false;\n const className = item?.className;\n const description = getItemDescription ? getItemDescription(item) : (item?.description ?? '');\n const prefix = getItemPrefix ? getItemPrefix(item) : (item?.prefix ?? '');\n const suffix = getItemSuffix ? getItemSuffix(item) : (item?.suffix ?? '');\n\n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.some(v => String(v) === String(optionValue));\n } else {\n isSelected = String(Array.isArray(value) ? value[0] : value) === String(optionValue);\n }\n\n return html`\n <nile-option\n data-index=${index}\n value=${optionValue}\n .selected=${isSelected}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n class=${classMap({\n option: enableDescription ?? false,\n [className ?? '']: !!className,\n })}\n .description=${description}\n .isDescriptionEnabled=${enableDescription}\n >\n ${unsafeHTML(prefix)}\n ${allowHtmlLabel ? unsafeHTML(displayText) : displayText}\n ${unsafeHTML(suffix)}\n </nile-option>\n `;\n }\n\n static renderItem(\n item: any,\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n if (!item) return html``;\n\n const optionValue = getItemValue(item);\n const displayText = getDisplayText(item);\n const isDisabled = item?.disabled || false;\n const className = item?.className;\n const description = getItemDescription ? getItemDescription(item) : (item?.description ?? '');\n const prefix = getItemPrefix ? getItemPrefix(item) : (item?.prefix ?? '');\n const suffix = getItemSuffix ? getItemSuffix(item) : (item?.suffix ?? '');\n\n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.some(v => String(v) === String(optionValue));\n } else {\n isSelected = String(Array.isArray(value) ? value[0] : value) === String(optionValue);\n }\n\n return html`\n <nile-option\n value=${optionValue}\n .selected=${isSelected}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n class=${classMap({\n option: enableDescription ?? false,\n [className ?? '']: !!className,\n })}\n .description=${description}\n .isDescriptionEnabled=${enableDescription}\n >\n ${unsafeHTML(prefix)}\n ${allowHtmlLabel ? unsafeHTML(displayText) : displayText}\n ${unsafeHTML(suffix)}\n </nile-option>\n `;\n }\n\n static renderVirtualizedGrid(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n gridColumns: number,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n gridColumnWidth?: number,\n ): TemplateResult {\n const offsetTop = virtualItems.length > 0 ? virtualItems[0].start : 0;\n const colTemplate = gridColumnWidth\n ? `repeat(${gridColumns}, ${gridColumnWidth}px)`\n : `repeat(${gridColumns}, 1fr)`;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;height:${totalSize}px;width:${gridColumnWidth ? 'max-content' : '100%'};min-width:100%;\">\n <div style=\"position:absolute;top:0;left:0;width:${gridColumnWidth ? 'max-content' : '100%'};min-width:100%;transform:translateY(${offsetTop}px);\">\n ${repeat(\n virtualItems,\n (vItem) => vItem.key,\n (vItem) => {\n const rowStart = vItem.index * gridColumns;\n const rowItems = data.slice(rowStart, rowStart + gridColumns);\n return html`\n <div class=\"combobox__grid-row\" style=\"display:grid;grid-template-columns:${colTemplate};gap:4px;\">\n ${rowItems.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix,\n ),\n )}\n </div>\n `;\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderHorizontalGrid(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n gridRows: number,\n gridColumnWidth: number,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n ): TemplateResult {\n const offsetLeft = virtualItems.length > 0 ? virtualItems[0].start : 0;\n const rowHeight = 38;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options combobox__options--horizontal ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;width:${totalSize}px;height:${rowHeight * gridRows}px;\">\n <div style=\"position:absolute;top:0;left:0;height:100%;display:flex;transform:translateX(${offsetLeft}px);\">\n ${repeat(\n virtualItems,\n (vCol) => vCol.key,\n (vCol) => {\n const colStart = vCol.index * gridRows;\n const colItems = data.slice(colStart, colStart + gridRows);\n return html`\n <div class=\"combobox__grid-col\" style=\"width:${gridColumnWidth}px;flex-shrink:0;display:flex;flex-direction:column;\">\n ${colItems.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix,\n ),\n )}\n </div>\n `;\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderAddCustomOption(\n searchValue: string,\n multiple: boolean,\n ): TemplateResult {\n return html`\n <nile-option\n value=${searchValue}\n class=\"combobox__add-option\"\n .showCheckbox=${multiple}\n >\n + Add \"${searchValue}\"\n </nile-option>\n `;\n }\n\n static shouldUseVirtualizer(data: any[], gridColumns = 1): boolean {\n if (gridColumns > 1) return true;\n return data.length >= 5;\n }\n}\n"],"names":["ComboboxRenderer","renderVirtualizedOptions","virtualItems","totalSize","data","value","multiple","getDisplayText","getItemValue","isLoading","allowHtmlLabel","measureElement","getItemDescription","getItemPrefix","getItemSuffix","enableDescription","offsetTop","length","start","html","_templateObject","_taggedTemplateLiteral","repeat","vItem","key","item","index","renderMeasuredItem","renderPlainOptions","showNoResults","noResultsMessage","onScroll","noResultsSubtitle","renderNoResults","_templateObject2","map","renderItem","_templateObject3","_templateObject4","renderNoData","noDataMessage","_templateObject5","_s$description","_s$prefix","_s$suffix","_templateObject6","optionValue","displayText","isDisabled","disabled","className","description","prefix","suffix","isSelected","Array","isArray","some","v","String","_templateObject7","classMap","option","unsafeHTML","_s$description2","_s$prefix2","_s$suffix2","_templateObject8","_templateObject9","renderVirtualizedGrid","gridColumns","gridColumnWidth","colTemplate","_templateObject10","rowStart","rowItems","slice","_templateObject11","renderHorizontalGrid","gridRows","offsetLeft","_templateObject12","vCol","colStart","colItems","_templateObject13","renderAddCustomOption","searchValue","_templateObject14","shouldUseVirtualizer","arguments","undefined"],"mappings":"6jEAaaA,CAAAA,kCAAAA,EAAAA,EAAAA,eAAAA,MAAAA,CAAAA,UAAAA,YAAAA,CAAAA,CAAAA,QAAAA,GAAAA,4BAAAA,KAAAA,CAEX,iCAAOC,CACLC,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACAC,EACAC,CACAC,CAAAA,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACAC,EACAC,CACAC,CAAAA,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACAC,GAEA,GAAMC,CAAAA,CAAAA,CAAYd,CAAae,CAAAA,MAAAA,CAAS,EAAIf,CAAa,CAAA,CAAA,CAAA,CAAGgB,KAAQ,CAAA,CAAA,CAEpE,MAAOC,CAA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IAAA,CAAA,CACrD,MAAIpB,CAAAA,CAAAA,CAAc,CACXlE,EAAAA,CAAAA,CAAKa,MAAU,EAAA,CACvB"}
|
|
1
|
+
{"version":3,"file":"renderer.cjs.js","sources":["../../../src/nile-combobox/renderer.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, type TemplateResult } from 'lit';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type { VirtualItem } from '@tanstack/virtual-core';\nimport type { ComboboxRow, ComboboxHeaderRow } from './types';\n\nexport class ComboboxRenderer {\n\n static renderGroupHeader(row: ComboboxHeaderRow): TemplateResult {\n return html`\n <div\n part=\"group-header\"\n class=\"combobox__group-header\"\n role=\"presentation\"\n data-group-id=${row.id}\n style=${`--group-depth:${row.depth}`}\n >\n ${row.prefix\n ? html`<nile-icon\n class=\"combobox__group-prefix\"\n name=${row.prefix}\n size=\"14\"\n method=\"fill\"\n ></nile-icon>`\n : ''}\n <span class=\"combobox__group-label\">${row.label}</span>\n </div>\n `;\n }\n\n static renderRowsPlain(\n rows: ComboboxRow[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n showNoResults: boolean,\n noResultsMessage: string,\n isLoading: boolean,\n onScroll: (e: Event) => void,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n noResultsSubtitle?: string,\n ): TemplateResult {\n if (showNoResults && !isLoading && rows.length === 0) {\n return ComboboxRenderer.renderNoResults(noResultsMessage, noResultsSubtitle);\n }\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div class=\"combobox__options-plain\" @scroll=${onScroll}>\n ${rows.map((row) =>\n row.kind === 'header'\n ? ComboboxRenderer.renderGroupHeader(row)\n : ComboboxRenderer.renderItem(\n row.item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n ),\n )}\n </div>\n </div>\n `;\n }\n\n static renderRowsVirtualized(\n virtualItems: VirtualItem[],\n totalSize: number,\n rows: ComboboxRow[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;height:${totalSize}px;width:100%;\">\n ${repeat(\n virtualItems,\n (vItem) => vItem.key,\n (vItem) => {\n const row = rows[vItem.index];\n if (!row) return html``;\n const posStyle =\n `position:absolute;top:0;left:0;right:0;` +\n `transform:translateY(${vItem.start}px);` +\n `height:${vItem.size}px;`;\n if (row.kind === 'header') {\n return html`\n <div style=${posStyle} class=\"combobox__group-header-slot\">\n ${ComboboxRenderer.renderGroupHeader(row)}\n </div>\n `;\n }\n return html`\n <div style=${posStyle}>\n ${ComboboxRenderer.renderItem(\n row.item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n )}\n </div>\n `;\n },\n )}\n </div>\n </div>\n `;\n }\n\n static renderVirtualizedOptions(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n measureElement: (el: Element | null) => void,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n const offsetTop = virtualItems.length > 0 ? virtualItems[0].start : 0;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;height:${totalSize}px;width:100%;\">\n <div style=\"position:absolute;top:0;left:0;width:100%;transform:translateY(${offsetTop}px);\">\n ${repeat(\n virtualItems,\n (vItem) => vItem.key,\n (vItem) => {\n const item = data[vItem.index];\n return ComboboxRenderer.renderMeasuredItem(\n item, vItem.index, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n );\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderPlainOptions(\n data: any[],\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n showNoResults: boolean,\n noResultsMessage: string,\n isLoading: boolean,\n onScroll: (e: Event) => void,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n noResultsSubtitle?: string,\n ): TemplateResult {\n if (showNoResults && !isLoading && data.length === 0) {\n return ComboboxRenderer.renderNoResults(noResultsMessage, noResultsSubtitle);\n }\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div class=\"combobox__options-plain\" @scroll=${onScroll}>\n ${data.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix, enableDescription,\n ),\n )}\n </div>\n </div>\n `;\n }\n\n static renderNoResults(noResultsMessage: string, noResultsSubtitle?: string): TemplateResult {\n return html`\n <div part=\"select-options\" class=\"combobox__options\">\n <div part=\"no-results\" class=\"combobox__no-results\">\n <div part=\"no-results-title\" class=\"combobox__no-results-title\">\n ${noResultsMessage || 'No result found'}\n </div>\n ${noResultsSubtitle\n ? html`<div part=\"no-results-subtitle\" class=\"combobox__no-results-subtitle\">${noResultsSubtitle}</div>`\n : ''}\n </div>\n </div>\n `;\n }\n\n static renderNoData(noDataMessage: string): TemplateResult {\n return html`\n <div part=\"select-options\" class=\"combobox__options\">\n <div part=\"no-data\" class=\"combobox__no-results\">\n <div part=\"no-data-title\" class=\"combobox__no-results-title\">\n ${noDataMessage || 'No data available'}\n </div>\n </div>\n </div>\n `;\n }\n\n private static renderMeasuredItem(\n item: any,\n index: number,\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n if (!item) return html``;\n\n const optionValue = getItemValue(item);\n const displayText = getDisplayText(item);\n const isDisabled = item?.disabled || false;\n const className = item?.className;\n const description = getItemDescription ? getItemDescription(item) : (item?.description ?? '');\n const prefix = getItemPrefix ? getItemPrefix(item) : (item?.prefix ?? '');\n const suffix = getItemSuffix ? getItemSuffix(item) : (item?.suffix ?? '');\n\n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.some(v => String(v) === String(optionValue));\n } else {\n isSelected = String(Array.isArray(value) ? value[0] : value) === String(optionValue);\n }\n\n return html`\n <nile-option\n data-index=${index}\n value=${optionValue}\n .selected=${isSelected}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n class=${classMap({\n option: enableDescription ?? false,\n [className ?? '']: !!className,\n })}\n .description=${description}\n .isDescriptionEnabled=${enableDescription}\n >\n ${unsafeHTML(prefix)}\n ${allowHtmlLabel ? unsafeHTML(displayText) : displayText}\n ${unsafeHTML(suffix)}\n </nile-option>\n `;\n }\n\n static renderItem(\n item: any,\n value: string | string[],\n multiple: boolean,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n enableDescription?: boolean,\n ): TemplateResult {\n if (!item) return html``;\n\n const optionValue = getItemValue(item);\n const displayText = getDisplayText(item);\n const isDisabled = item?.disabled || false;\n const className = item?.className;\n const description = getItemDescription ? getItemDescription(item) : (item?.description ?? '');\n const prefix = getItemPrefix ? getItemPrefix(item) : (item?.prefix ?? '');\n const suffix = getItemSuffix ? getItemSuffix(item) : (item?.suffix ?? '');\n\n let isSelected = false;\n if (multiple) {\n isSelected = Array.isArray(value) && value.some(v => String(v) === String(optionValue));\n } else {\n isSelected = String(Array.isArray(value) ? value[0] : value) === String(optionValue);\n }\n\n return html`\n <nile-option\n value=${optionValue}\n .selected=${isSelected}\n .disabled=${isDisabled}\n .showCheckbox=${multiple}\n class=${classMap({\n option: enableDescription ?? false,\n [className ?? '']: !!className,\n })}\n .description=${description}\n .isDescriptionEnabled=${enableDescription}\n >\n ${unsafeHTML(prefix)}\n ${allowHtmlLabel ? unsafeHTML(displayText) : displayText}\n ${unsafeHTML(suffix)}\n </nile-option>\n `;\n }\n\n static renderVirtualizedGrid(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n gridColumns: number,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n gridColumnWidth?: number,\n ): TemplateResult {\n const offsetTop = virtualItems.length > 0 ? virtualItems[0].start : 0;\n const colTemplate = gridColumnWidth\n ? `repeat(${gridColumns}, ${gridColumnWidth}px)`\n : `repeat(${gridColumns}, 1fr)`;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;height:${totalSize}px;width:${gridColumnWidth ? 'max-content' : '100%'};min-width:100%;\">\n <div style=\"position:absolute;top:0;left:0;width:${gridColumnWidth ? 'max-content' : '100%'};min-width:100%;transform:translateY(${offsetTop}px);\">\n ${repeat(\n virtualItems,\n (vItem) => vItem.key,\n (vItem) => {\n const rowStart = vItem.index * gridColumns;\n const rowItems = data.slice(rowStart, rowStart + gridColumns);\n return html`\n <div class=\"combobox__grid-row\" style=\"display:grid;grid-template-columns:${colTemplate};gap:4px;\">\n ${rowItems.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix,\n ),\n )}\n </div>\n `;\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderHorizontalGrid(\n virtualItems: VirtualItem[],\n totalSize: number,\n data: any[],\n value: string | string[],\n multiple: boolean,\n gridRows: number,\n gridColumnWidth: number,\n getDisplayText: (item: any) => string,\n getItemValue: (item: any) => string,\n isLoading: boolean,\n allowHtmlLabel: boolean,\n getItemDescription?: (item: any) => string,\n getItemPrefix?: (item: any) => string,\n getItemSuffix?: (item: any) => string,\n ): TemplateResult {\n const offsetLeft = virtualItems.length > 0 ? virtualItems[0].start : 0;\n const rowHeight = 38;\n\n return html`\n <div\n part=\"select-options\"\n class=\"combobox__options combobox__options--horizontal ${isLoading ? 'loading' : ''}\"\n >\n <div style=\"position:relative;width:${totalSize}px;height:${rowHeight * gridRows}px;\">\n <div style=\"position:absolute;top:0;left:0;height:100%;display:flex;transform:translateX(${offsetLeft}px);\">\n ${repeat(\n virtualItems,\n (vCol) => vCol.key,\n (vCol) => {\n const colStart = vCol.index * gridRows;\n const colItems = data.slice(colStart, colStart + gridRows);\n return html`\n <div class=\"combobox__grid-col\" style=\"width:${gridColumnWidth}px;flex-shrink:0;display:flex;flex-direction:column;\">\n ${colItems.map((item: any) =>\n ComboboxRenderer.renderItem(\n item, value, multiple, getDisplayText, getItemValue,\n allowHtmlLabel, getItemDescription, getItemPrefix,\n getItemSuffix,\n ),\n )}\n </div>\n `;\n },\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n static renderAddCustomOption(\n searchValue: string,\n multiple: boolean,\n ): TemplateResult {\n return html`\n <nile-option\n value=${searchValue}\n class=\"combobox__add-option\"\n .showCheckbox=${multiple}\n >\n + Add \"${searchValue}\"\n </nile-option>\n `;\n }\n\n static shouldUseVirtualizer(data: any[], gridColumns = 1): boolean {\n if (gridColumns > 1) return true;\n return data.length >= 5;\n }\n}\n"],"names":["ComboboxRenderer","s","_classCallCheck","_createClass","key","value","renderGroupHeader","row","html","_templateObject","_taggedTemplateLiteral","id","depth","prefix","_templateObject2","label","renderRowsPlain","rows","multiple","getDisplayText","getItemValue","showNoResults","noResultsMessage","isLoading","onScroll","allowHtmlLabel","getItemDescription","getItemPrefix","getItemSuffix","enableDescription","noResultsSubtitle","length","renderNoResults","_templateObject3","map","kind","renderItem","item","renderRowsVirtualized","virtualItems","totalSize","_templateObject4","repeat","vItem","index","_templateObject5","posStyle","concat","start","size","_templateObject6","_templateObject7","renderVirtualizedOptions","data","measureElement","offsetTop","_templateObject8","renderMeasuredItem","renderPlainOptions","_templateObject9","_templateObject10","_templateObject11","renderNoData","noDataMessage","_templateObject12","_templateObject13","optionValue","displayText","isDisabled","disabled","className","description","_e$description","_e$prefix","suffix","isSelected","Array","isArray","some","v","String","_templateObject14","classMap","option","unsafeHTML","_e$description2","_e$prefix2","_e$suffix2","_templateObject15","_templateObject16","renderVirtualizedGrid","gridColumns","gridColumnWidth","colTemplate","_templateObject17","rowStart","rowItems","slice","_templateObject18","renderHorizontalGrid","gridRows","offsetLeft","_templateObject19","vCol","colStart","colItems","_templateObject20","renderAddCustomOption","searchValue","_templateObject21","shouldUseVirtualizer","arguments","undefined"],"mappings":"2rEAcaA,CAEX,kCAAAC,EAAA,EAAAC,eAAA,MAAAD,CAAA,UAAAE,YAAA,CAAAF,CAAA,QAAAG,GAAA,qBAAAC,KAAA,CAAA,QAAA,CAAAC,iBAAOA,CAAkBC,CAAAA,CAAAA,CACvB,MAAOC,CAAAA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A,CAAAA,CAEA,MAAOV,CAAAA,CAAI,CAAAqG,iBAAA,GAAAA,iBAAA,CAAAnG,sBAAA,8KAECkG,CAAAA,CAEQ1F,CAAAA,CAEP0F,CAAAA,EAGd,CAED,GAAAxG,GAAA,wBAAAC,KAAA,SAAA,CAAAyG,oBAAOA,CAAqBzD,CAAAA,CAA2B,IAAdsC,CAAAA,CAAc,CAAAoB,SAAA,CAAAhF,MAAA,IAAAgF,SAAA,MAAAC,SAAA,CAAAD,SAAA,IAAA,CAAA,CACrD,MAAIpB,CAAAA,CAAAA,CAAc,CACXtC,EAAAA,CAAAA,CAAKtB,MAAU,EAAA,CACvB"}
|
|
@@ -1,105 +1,147 @@
|
|
|
1
|
-
import{html as t}from"lit";import{unsafeHTML as
|
|
1
|
+
import{html as t}from"lit";import{unsafeHTML as o}from"lit/directives/unsafe-html.js";import{classMap as i}from"lit/directives/class-map.js";import{repeat as e}from"lit/directives/repeat.js";class s{static renderGroupHeader(o){return t`
|
|
2
|
+
<div
|
|
3
|
+
part="group-header"
|
|
4
|
+
class="combobox__group-header"
|
|
5
|
+
role="presentation"
|
|
6
|
+
data-group-id=${o.id}
|
|
7
|
+
style=${`--group-depth:${o.depth}`}
|
|
8
|
+
>
|
|
9
|
+
${o.prefix?t`<nile-icon
|
|
10
|
+
class="combobox__group-prefix"
|
|
11
|
+
name=${o.prefix}
|
|
12
|
+
size="14"
|
|
13
|
+
method="fill"
|
|
14
|
+
></nile-icon>`:""}
|
|
15
|
+
<span class="combobox__group-label">${o.label}</span>
|
|
16
|
+
</div>
|
|
17
|
+
`}static renderRowsPlain(o,i,e,r,n,l,a,d,p,c,$,v,b,u,m){return l&&!d&&0===o.length?s.renderNoResults(a,m):t`
|
|
2
18
|
<div
|
|
3
19
|
part="select-options"
|
|
4
|
-
class="combobox__options ${
|
|
20
|
+
class="combobox__options ${d?"loading":""}"
|
|
21
|
+
>
|
|
22
|
+
<div class="combobox__options-plain" @scroll=${p}>
|
|
23
|
+
${o.map((t=>"header"===t.kind?s.renderGroupHeader(t):s.renderItem(t.item,i,e,r,n,c,$,v,b,u)))}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
`}static renderRowsVirtualized(o,i,r,n,l,a,d,p,c,$,v,b,u){return t`
|
|
27
|
+
<div
|
|
28
|
+
part="select-options"
|
|
29
|
+
class="combobox__options ${p?"loading":""}"
|
|
30
|
+
>
|
|
31
|
+
<div style="position:relative;height:${i}px;width:100%;">
|
|
32
|
+
${e(o,(t=>t.key),(o=>{const i=r[o.index];if(!i)return t``;const e=`position:absolute;top:0;left:0;right:0;transform:translateY(${o.start}px);height:${o.size}px;`;return"header"===i.kind?t`
|
|
33
|
+
<div style=${e} class="combobox__group-header-slot">
|
|
34
|
+
${s.renderGroupHeader(i)}
|
|
35
|
+
</div>
|
|
36
|
+
`:t`
|
|
37
|
+
<div style=${e}>
|
|
38
|
+
${s.renderItem(i.item,n,l,a,d,c,$,v,b,u)}
|
|
39
|
+
</div>
|
|
40
|
+
`}))}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
`}static renderVirtualizedOptions(o,i,r,n,l,a,d,p,c,$,v,b,u,m){const x=o.length>0?o[0].start:0;return t`
|
|
44
|
+
<div
|
|
45
|
+
part="select-options"
|
|
46
|
+
class="combobox__options ${p?"loading":""}"
|
|
5
47
|
>
|
|
6
|
-
<div style="position:relative;height:${
|
|
48
|
+
<div style="position:relative;height:${i}px;width:100%;">
|
|
7
49
|
<div style="position:absolute;top:0;left:0;width:100%;transform:translateY(${x}px);">
|
|
8
|
-
${
|
|
50
|
+
${e(o,(t=>t.key),(t=>{const o=r[t.index];return s.renderMeasuredItem(o,t.index,n,l,a,d,c,v,b,u,m)}))}
|
|
9
51
|
</div>
|
|
10
52
|
</div>
|
|
11
53
|
</div>
|
|
12
|
-
`}static renderPlainOptions(i,
|
|
54
|
+
`}static renderPlainOptions(o,i,e,r,n,l,a,d,p,c,$,v,b,u,m){return l&&!d&&0===o.length?s.renderNoResults(a,m):t`
|
|
13
55
|
<div
|
|
14
56
|
part="select-options"
|
|
15
57
|
class="combobox__options ${d?"loading":""}"
|
|
16
58
|
>
|
|
17
|
-
<div class="combobox__options-plain" @scroll=${
|
|
18
|
-
${
|
|
59
|
+
<div class="combobox__options-plain" @scroll=${p}>
|
|
60
|
+
${o.map((t=>s.renderItem(t,i,e,r,n,c,$,v,b,u)))}
|
|
19
61
|
</div>
|
|
20
62
|
</div>
|
|
21
|
-
`}static renderNoResults(i
|
|
63
|
+
`}static renderNoResults(o,i){return t`
|
|
22
64
|
<div part="select-options" class="combobox__options">
|
|
23
65
|
<div part="no-results" class="combobox__no-results">
|
|
24
66
|
<div part="no-results-title" class="combobox__no-results-title">
|
|
25
|
-
${
|
|
67
|
+
${o||"No result found"}
|
|
26
68
|
</div>
|
|
27
|
-
${
|
|
69
|
+
${i?t`<div part="no-results-subtitle" class="combobox__no-results-subtitle">${i}</div>`:""}
|
|
28
70
|
</div>
|
|
29
71
|
</div>
|
|
30
|
-
`}static renderNoData(
|
|
72
|
+
`}static renderNoData(o){return t`
|
|
31
73
|
<div part="select-options" class="combobox__options">
|
|
32
74
|
<div part="no-data" class="combobox__no-results">
|
|
33
75
|
<div part="no-data-title" class="combobox__no-results-title">
|
|
34
|
-
${
|
|
76
|
+
${o||"No data available"}
|
|
35
77
|
</div>
|
|
36
78
|
</div>
|
|
37
79
|
</div>
|
|
38
|
-
`}static renderMeasuredItem(s,
|
|
80
|
+
`}static renderMeasuredItem(e,s,r,n,l,a,d,p,c,$,v){if(!e)return t``;const b=a(e),u=l(e),m=e?.disabled||!1,x=e?.className,_=p?p(e):e?.description??"",h=c?c(e):e?.prefix??"",g=$?$(e):e?.suffix??"";let f=!1;return f=n?Array.isArray(r)&&r.some((t=>String(t)===String(b))):String(Array.isArray(r)?r[0]:r)===String(b),t`
|
|
39
81
|
<nile-option
|
|
40
|
-
data-index=${
|
|
41
|
-
value=${
|
|
42
|
-
.selected=${
|
|
43
|
-
.disabled=${
|
|
82
|
+
data-index=${s}
|
|
83
|
+
value=${b}
|
|
84
|
+
.selected=${f}
|
|
85
|
+
.disabled=${m}
|
|
44
86
|
.showCheckbox=${n}
|
|
45
|
-
class=${
|
|
46
|
-
.description=${
|
|
47
|
-
.isDescriptionEnabled=${
|
|
87
|
+
class=${i({option:v??!1,[x??""]:!!x})}
|
|
88
|
+
.description=${_}
|
|
89
|
+
.isDescriptionEnabled=${v}
|
|
48
90
|
>
|
|
49
|
-
${
|
|
50
|
-
${d?
|
|
51
|
-
${
|
|
91
|
+
${o(h)}
|
|
92
|
+
${d?o(u):u}
|
|
93
|
+
${o(g)}
|
|
52
94
|
</nile-option>
|
|
53
|
-
`}static renderItem(s,
|
|
95
|
+
`}static renderItem(e,s,r,n,l,a,d,p,c,$){if(!e)return t``;const v=l(e),b=n(e),u=e?.disabled||!1,m=e?.className,x=d?d(e):e?.description??"",_=p?p(e):e?.prefix??"",h=c?c(e):e?.suffix??"";let g=!1;return g=r?Array.isArray(s)&&s.some((t=>String(t)===String(v))):String(Array.isArray(s)?s[0]:s)===String(v),t`
|
|
54
96
|
<nile-option
|
|
55
97
|
value=${v}
|
|
56
98
|
.selected=${g}
|
|
57
99
|
.disabled=${u}
|
|
58
100
|
.showCheckbox=${r}
|
|
59
|
-
class=${
|
|
101
|
+
class=${i({option:$??!1,[m??""]:!!m})}
|
|
60
102
|
.description=${x}
|
|
61
103
|
.isDescriptionEnabled=${$}
|
|
62
104
|
>
|
|
63
|
-
${
|
|
64
|
-
${a?
|
|
65
|
-
${
|
|
105
|
+
${o(_)}
|
|
106
|
+
${a?o(b):b}
|
|
107
|
+
${o(h)}
|
|
66
108
|
</nile-option>
|
|
67
|
-
`}static renderVirtualizedGrid(i,
|
|
109
|
+
`}static renderVirtualizedGrid(o,i,r,n,l,a,d,p,c,$,v,b,u,m){const x=o.length>0?o[0].start:0,_=m?`repeat(${a}, ${m}px)`:`repeat(${a}, 1fr)`;return t`
|
|
68
110
|
<div
|
|
69
111
|
part="select-options"
|
|
70
|
-
class="combobox__options ${
|
|
112
|
+
class="combobox__options ${c?"loading":""}"
|
|
71
113
|
>
|
|
72
|
-
<div style="position:relative;height:${
|
|
114
|
+
<div style="position:relative;height:${i}px;width:${m?"max-content":"100%"};min-width:100%;">
|
|
73
115
|
<div style="position:absolute;top:0;left:0;width:${m?"max-content":"100%"};min-width:100%;transform:translateY(${x}px);">
|
|
74
|
-
${
|
|
116
|
+
${e(o,(t=>t.key),(o=>{const i=o.index*a,e=r.slice(i,i+a);return t`
|
|
75
117
|
<div class="combobox__grid-row" style="display:grid;grid-template-columns:${_};gap:4px;">
|
|
76
|
-
${
|
|
118
|
+
${e.map((t=>s.renderItem(t,n,l,d,p,$,v,b,u)))}
|
|
77
119
|
</div>
|
|
78
120
|
`}))}
|
|
79
121
|
</div>
|
|
80
122
|
</div>
|
|
81
123
|
</div>
|
|
82
|
-
`}static renderHorizontalGrid(i,
|
|
124
|
+
`}static renderHorizontalGrid(o,i,r,n,l,a,d,p,c,$,v,b,u,m){const x=o.length>0?o[0].start:0;return t`
|
|
83
125
|
<div
|
|
84
126
|
part="select-options"
|
|
85
127
|
class="combobox__options combobox__options--horizontal ${$?"loading":""}"
|
|
86
128
|
>
|
|
87
|
-
<div style="position:relative;width:${
|
|
129
|
+
<div style="position:relative;width:${i}px;height:${38*a}px;">
|
|
88
130
|
<div style="position:absolute;top:0;left:0;height:100%;display:flex;transform:translateX(${x}px);">
|
|
89
|
-
${
|
|
131
|
+
${e(o,(t=>t.key),(o=>{const i=o.index*a,e=r.slice(i,i+a);return t`
|
|
90
132
|
<div class="combobox__grid-col" style="width:${d}px;flex-shrink:0;display:flex;flex-direction:column;">
|
|
91
|
-
${
|
|
133
|
+
${e.map((t=>s.renderItem(t,n,l,p,c,v,b,u,m)))}
|
|
92
134
|
</div>
|
|
93
135
|
`}))}
|
|
94
136
|
</div>
|
|
95
137
|
</div>
|
|
96
138
|
</div>
|
|
97
|
-
`}static renderAddCustomOption(i
|
|
139
|
+
`}static renderAddCustomOption(o,i){return t`
|
|
98
140
|
<nile-option
|
|
99
|
-
value=${
|
|
141
|
+
value=${o}
|
|
100
142
|
class="combobox__add-option"
|
|
101
|
-
.showCheckbox=${
|
|
143
|
+
.showCheckbox=${i}
|
|
102
144
|
>
|
|
103
|
-
+ Add "${
|
|
145
|
+
+ Add "${o}"
|
|
104
146
|
</nile-option>
|
|
105
|
-
`}static shouldUseVirtualizer(t,
|
|
147
|
+
`}static shouldUseVirtualizer(t,o=1){return o>1||t.length>=5}}export{s as C};
|
|
@@ -44,13 +44,15 @@ let NileBreadcrumbItem = class NileBreadcrumbItem extends NileElement {
|
|
|
44
44
|
}
|
|
45
45
|
render() {
|
|
46
46
|
return html `
|
|
47
|
-
|
|
47
|
+
<div part="item"
|
|
48
48
|
class=${classMap({
|
|
49
49
|
'nile-breadcrumb-item__slot-text': !this.isLast,
|
|
50
50
|
'nile-breadcrumb-item__last-slot-text': this.isLast,
|
|
51
51
|
})}
|
|
52
52
|
@click=${this.handleClick}
|
|
53
|
-
|
|
53
|
+
>
|
|
54
|
+
<slot></slot>
|
|
55
|
+
</div>
|
|
54
56
|
<nile-icon
|
|
55
57
|
name=${this.separator}
|
|
56
58
|
aria-label=${this.separator}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nile-breadcrumb-item.js","sourceRoot":"","sources":["../../../src/nile-breadcrumb-item/nile-breadcrumb-item.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,IAAI,GAGL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD;;;;;GAKG;AAEI,IAAM,kBAAkB,GAAxB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AC;YACf,6BAA6B,EAAE,IAAI;YACnC,oCAAoC,EAAE,IAAI,CAAC,MAAM;SAClD,CAAC;;;KAGL,CAAC;IACJ,CAAC;CAGF,CAAA;AA9CkB;IAAhB,KAAK,EAAE;kDAAwB;AAWJ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA0E;AApB1F,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAuD9B;;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, state, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './nile-breadcrumb-item.css';\nimport NileElement from '../internal/nile-element';\n/**\n * Nile BreadCrumb Item component.\n *\n * @tag nile-breadcrumb-item\n *\n */\n@customElement('nile-breadcrumb-item')\nexport class NileBreadcrumbItem extends NileElement {\n /**\n * The styles for BreadcrumbItem\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @state() private isLast = false;\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n\n @property({ type: String }) separator = 'var(--nile-icon-arrow-right, var(--ng-icon-chevron-right))';\n\n private handleClick() {\n if (this.isLast) {\n return;\n }\n this.emit('nile-click-item');\n }\n\n public render(): TemplateResult {\n return html`\n <div part=\"item\"\n class=${classMap({\n 'nile-breadcrumb-item__slot-text': !this.isLast,\n 'nile-breadcrumb-item__last-slot-text': this.isLast,\n })}\n @click=${this.handleClick}\n >\n <slot></slot>\n </div>\n <nile-icon\n name=${this.separator}\n aria-label=${this.separator}\n method=\"var(--nile-svg-method-fill, var(--ng-svg-method-stroke))\"\n color=\"var(--nile-colors-dark-500, var(--ng-colors-fg-quaternary-400))\"\n class=${classMap({\n 'nile-breadcrumb-item__arrow': true,\n 'nile-breadcrumb-item__arrow-hidden': this.isLast,\n })}\n size=\"14\"\n ></nile-icon>\n `;\n }\n\n /* #endregion */\n}\n\nexport default NileBreadcrumbItem;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-breadcrumb-item': NileBreadcrumbItem;\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { ComboboxDataItem, ComboboxGroupItem, ComboboxRow, ComboboxOptionRow } from './types';
|
|
8
|
+
export declare function isGroup(item: any): item is ComboboxGroupItem;
|
|
9
|
+
export declare function hasGroups(data: any[]): boolean;
|
|
10
|
+
export declare function countOptionsDeep(group: ComboboxGroupItem): number;
|
|
11
|
+
export declare function flattenRows(data: ComboboxDataItem[]): ComboboxRow[];
|
|
12
|
+
export declare function getOptionRows(rows: ComboboxRow[]): ComboboxOptionRow[];
|
|
13
|
+
/**
|
|
14
|
+
* Filter rows by a query.
|
|
15
|
+
*
|
|
16
|
+
* Rules:
|
|
17
|
+
* - An option row is kept if its searchText matches.
|
|
18
|
+
* - If a group's label matches, the entire subtree (header + all descendant
|
|
19
|
+
* options + nested headers) is kept.
|
|
20
|
+
* - Otherwise a header is kept only if at least one descendant option matches.
|
|
21
|
+
* - Empty groups (no surviving descendants) are dropped.
|
|
22
|
+
*/
|
|
23
|
+
export declare function filterRows(data: ComboboxDataItem[], query: string, getSearchText: (item: any) => string): {
|
|
24
|
+
rows: ComboboxRow[];
|
|
25
|
+
visibleOptionCount: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export function isGroup(item) {
|
|
8
|
+
return !!item && typeof item === 'object' && item.type === 'group' && Array.isArray(item.options);
|
|
9
|
+
}
|
|
10
|
+
export function hasGroups(data) {
|
|
11
|
+
if (!Array.isArray(data))
|
|
12
|
+
return false;
|
|
13
|
+
for (const item of data) {
|
|
14
|
+
if (isGroup(item))
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export function countOptionsDeep(group) {
|
|
20
|
+
let n = 0;
|
|
21
|
+
for (const child of group.options) {
|
|
22
|
+
if (isGroup(child))
|
|
23
|
+
n += countOptionsDeep(child);
|
|
24
|
+
else
|
|
25
|
+
n += 1;
|
|
26
|
+
}
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
29
|
+
export function flattenRows(data) {
|
|
30
|
+
const rows = [];
|
|
31
|
+
const walk = (items, depth, parentIds) => {
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
if (isGroup(item)) {
|
|
34
|
+
rows.push({
|
|
35
|
+
kind: 'header',
|
|
36
|
+
id: item.id,
|
|
37
|
+
label: item.label,
|
|
38
|
+
prefix: item.prefix,
|
|
39
|
+
depth,
|
|
40
|
+
optionCount: countOptionsDeep(item),
|
|
41
|
+
});
|
|
42
|
+
walk(item.options, depth + 1, [...parentIds, item.id]);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
rows.push({
|
|
46
|
+
kind: 'option',
|
|
47
|
+
item: item,
|
|
48
|
+
depth,
|
|
49
|
+
parentIds,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
walk(Array.isArray(data) ? data : [], 0, []);
|
|
55
|
+
return rows;
|
|
56
|
+
}
|
|
57
|
+
export function getOptionRows(rows) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const r of rows)
|
|
60
|
+
if (r.kind === 'option')
|
|
61
|
+
out.push(r);
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Filter rows by a query.
|
|
66
|
+
*
|
|
67
|
+
* Rules:
|
|
68
|
+
* - An option row is kept if its searchText matches.
|
|
69
|
+
* - If a group's label matches, the entire subtree (header + all descendant
|
|
70
|
+
* options + nested headers) is kept.
|
|
71
|
+
* - Otherwise a header is kept only if at least one descendant option matches.
|
|
72
|
+
* - Empty groups (no surviving descendants) are dropped.
|
|
73
|
+
*/
|
|
74
|
+
export function filterRows(data, query, getSearchText) {
|
|
75
|
+
const q = (query || '').trim().toLowerCase();
|
|
76
|
+
if (!q) {
|
|
77
|
+
const rows = flattenRows(data);
|
|
78
|
+
return { rows, visibleOptionCount: getOptionRows(rows).length };
|
|
79
|
+
}
|
|
80
|
+
const matchedOption = (item) => {
|
|
81
|
+
const text = (getSearchText(item) || '').toString().toLowerCase();
|
|
82
|
+
return text.includes(q);
|
|
83
|
+
};
|
|
84
|
+
const walk = (item, ancestorLabelMatched) => {
|
|
85
|
+
if (isGroup(item)) {
|
|
86
|
+
const labelMatched = item.label.toLowerCase().includes(q);
|
|
87
|
+
const keepAll = labelMatched || ancestorLabelMatched;
|
|
88
|
+
const children = [];
|
|
89
|
+
for (const child of item.options) {
|
|
90
|
+
const sub = walk(child, keepAll);
|
|
91
|
+
if (sub)
|
|
92
|
+
children.push(sub);
|
|
93
|
+
}
|
|
94
|
+
if (children.length === 0 && !keepAll)
|
|
95
|
+
return null;
|
|
96
|
+
// If keepAll but nothing came back (empty group), still emit so user sees label.
|
|
97
|
+
return { kind: 'group', group: item, children };
|
|
98
|
+
}
|
|
99
|
+
if (ancestorLabelMatched || matchedOption(item)) {
|
|
100
|
+
return { kind: 'option', item: item };
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
};
|
|
104
|
+
const tops = [];
|
|
105
|
+
for (const top of data) {
|
|
106
|
+
const r = walk(top, false);
|
|
107
|
+
if (r)
|
|
108
|
+
tops.push(r);
|
|
109
|
+
}
|
|
110
|
+
// Materialize back to flat rows.
|
|
111
|
+
const rows = [];
|
|
112
|
+
const emit = (results, depth, parentIds) => {
|
|
113
|
+
for (const r of results) {
|
|
114
|
+
if (!r)
|
|
115
|
+
continue;
|
|
116
|
+
if (r.kind === 'group') {
|
|
117
|
+
rows.push({
|
|
118
|
+
kind: 'header',
|
|
119
|
+
id: r.group.id,
|
|
120
|
+
label: r.group.label,
|
|
121
|
+
prefix: r.group.prefix,
|
|
122
|
+
depth,
|
|
123
|
+
optionCount: countOptionsDeep(r.group),
|
|
124
|
+
});
|
|
125
|
+
emit(r.children, depth + 1, [...parentIds, r.group.id]);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
rows.push({
|
|
129
|
+
kind: 'option',
|
|
130
|
+
item: r.item,
|
|
131
|
+
depth,
|
|
132
|
+
parentIds,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
emit(tops, 0, []);
|
|
138
|
+
return { rows, visibleOptionCount: getOptionRows(rows).length };
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=group-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-utils.js","sourceRoot":"","sources":["../../../src/nile-combobox/group-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,UAAU,OAAO,CAAC,IAAS;IAC/B,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpG,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAW;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OA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ACvB,IAAI,CAAC,IAAI,CAAC;oBACR,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE;oBACd,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK;oBACpB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM;oBACtB,KAAK;oBACL,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC;iBACvC,CAAC,CAAC;gBACH,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC;oBACR,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,KAAK;oBACL,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAElB,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAClE,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type {\n ComboboxDataItem,\n ComboboxGroupItem,\n ComboboxOptionItem,\n ComboboxRow,\n ComboboxHeaderRow,\n ComboboxOptionRow,\n} from './types';\n\nexport function isGroup(item: any): item is ComboboxGroupItem {\n return !!item && typeof item === 'object' && item.type === 'group' && Array.isArray(item.options);\n}\n\nexport function hasGroups(data: any[]): boolean {\n if (!Array.isArray(data)) return false;\n for (const item of data) {\n if (isGroup(item)) return true;\n }\n return false;\n}\n\nexport function countOptionsDeep(group: ComboboxGroupItem): number {\n let n = 0;\n for (const child of group.options) {\n if (isGroup(child)) n += countOptionsDeep(child);\n else n += 1;\n }\n return n;\n}\n\nexport function flattenRows(data: ComboboxDataItem[]): ComboboxRow[] {\n const rows: ComboboxRow[] = [];\n const walk = (items: ComboboxDataItem[], depth: number, parentIds: string[]) => {\n for (const item of items) {\n if (isGroup(item)) {\n rows.push({\n kind: 'header',\n id: item.id,\n label: item.label,\n prefix: item.prefix,\n depth,\n optionCount: countOptionsDeep(item),\n } as ComboboxHeaderRow);\n walk(item.options, depth + 1, [...parentIds, item.id]);\n } else {\n rows.push({\n kind: 'option',\n item: item as ComboboxOptionItem,\n depth,\n parentIds,\n } as ComboboxOptionRow);\n }\n }\n };\n walk(Array.isArray(data) ? data : [], 0, []);\n return rows;\n}\n\nexport function getOptionRows(rows: ComboboxRow[]): ComboboxOptionRow[] {\n const out: ComboboxOptionRow[] = [];\n for (const r of rows) if (r.kind === 'option') out.push(r);\n return out;\n}\n\n/**\n * Filter rows by a query.\n *\n * Rules:\n * - An option row is kept if its searchText matches.\n * - If a group's label matches, the entire subtree (header + all descendant\n * options + nested headers) is kept.\n * - Otherwise a header is kept only if at least one descendant option matches.\n * - Empty groups (no surviving descendants) are dropped.\n */\nexport function filterRows(\n data: ComboboxDataItem[],\n query: string,\n getSearchText: (item: any) => string,\n): { rows: ComboboxRow[]; visibleOptionCount: number } {\n const q = (query || '').trim().toLowerCase();\n if (!q) {\n const rows = flattenRows(data);\n return { rows, visibleOptionCount: getOptionRows(rows).length };\n }\n\n const matchedOption = (item: ComboboxOptionItem): boolean => {\n const text = (getSearchText(item) || '').toString().toLowerCase();\n return text.includes(q);\n };\n\n // Walk the tree, returning a filtered subtree (or null when nothing survives).\n type FilterResult =\n | { kind: 'option'; item: ComboboxOptionItem }\n | { kind: 'group'; group: ComboboxGroupItem; children: FilterResult[] }\n | null;\n\n const walk = (item: ComboboxDataItem, ancestorLabelMatched: boolean): FilterResult => {\n if (isGroup(item)) {\n const labelMatched = item.label.toLowerCase().includes(q);\n const keepAll = labelMatched || ancestorLabelMatched;\n const children: FilterResult[] = [];\n for (const child of item.options) {\n const sub = walk(child, keepAll);\n if (sub) children.push(sub);\n }\n if (children.length === 0 && !keepAll) return null;\n // If keepAll but nothing came back (empty group), still emit so user sees label.\n return { kind: 'group', group: item, children };\n }\n if (ancestorLabelMatched || matchedOption(item as ComboboxOptionItem)) {\n return { kind: 'option', item: item as ComboboxOptionItem };\n }\n return null;\n };\n\n const tops: FilterResult[] = [];\n for (const top of data) {\n const r = walk(top, false);\n if (r) tops.push(r);\n }\n\n // Materialize back to flat rows.\n const rows: ComboboxRow[] = [];\n const emit = (results: FilterResult[], depth: number, parentIds: string[]) => {\n for (const r of results) {\n if (!r) continue;\n if (r.kind === 'group') {\n rows.push({\n kind: 'header',\n id: r.group.id,\n label: r.group.label,\n prefix: r.group.prefix,\n depth,\n optionCount: countOptionsDeep(r.group),\n });\n emit(r.children, depth + 1, [...parentIds, r.group.id]);\n } else {\n rows.push({\n kind: 'option',\n item: r.item,\n depth,\n parentIds,\n });\n }\n }\n };\n emit(tops, 0, []);\n\n return { rows, visibleOptionCount: getOptionRows(rows).length };\n}\n"]}
|