@aquera/nile-elements 2.0.4 → 2.0.5
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 +5 -0
- package/demo/nxtgen-classes.css +594 -0
- package/demo/nxtgen-dark.css +240 -21
- package/demo/nxtgen-utilities.css +594 -0
- package/demo/nxtgen.css +55 -0
- package/dist/index.js +51 -47
- 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 +28 -15
- package/dist/nile-combobox/nile-combobox.esm.js +11 -8
- package/dist/nile-combobox/portal-manager.cjs.js +1 -1
- package/dist/nile-combobox/portal-manager.cjs.js.map +1 -1
- package/dist/nile-combobox/portal-manager.esm.js +1 -1
- 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 +31 -43
- package/dist/src/nile-combobox/nile-combobox.css.js +28 -15
- package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.js +49 -10
- package/dist/src/nile-combobox/nile-combobox.js.map +1 -1
- package/dist/src/nile-combobox/portal-manager.js +2 -22
- package/dist/src/nile-combobox/portal-manager.js.map +1 -1
- package/dist/src/nile-combobox/renderer.d.ts +2 -3
- package/dist/src/nile-combobox/renderer.js +14 -45
- package/dist/src/nile-combobox/renderer.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +11 -3
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.cjs.js +1 -1
- package/dist/version.cjs.js.map +1 -1
- package/dist/version.esm.js +1 -1
- package/package.json +2 -1
- package/scripts/replace-version.cjs +12 -10
- package/src/nile-combobox/nile-combobox.css.ts +28 -15
- package/src/nile-combobox/nile-combobox.ts +61 -12
- package/src/nile-combobox/portal-manager.ts +4 -22
- package/src/nile-combobox/renderer.ts +26 -69
- package/src/version.ts +11 -2
|
@@ -190,28 +190,8 @@ export class ComboboxPortalManager {
|
|
|
190
190
|
}
|
|
191
191
|
if (!listbox || !listbox.isConnected)
|
|
192
192
|
return;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (virtualized && virtualized.isConnected) {
|
|
196
|
-
const fewItems = this.component.filteredData?.length < 5;
|
|
197
|
-
if (fewItems) {
|
|
198
|
-
virtualized.style.overflowY = 'hidden';
|
|
199
|
-
virtualized.style.maxHeight = 'none';
|
|
200
|
-
listbox.style.overflowY = 'hidden';
|
|
201
|
-
listbox.style.maxHeight = 'fit-content';
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
virtualized.style.overflowY = 'auto';
|
|
205
|
-
virtualized.style.maxHeight = '';
|
|
206
|
-
listbox.style.overflowY = 'auto';
|
|
207
|
-
listbox.style.maxHeight = '';
|
|
208
|
-
}
|
|
209
|
-
virtualized.scrollTop = 0;
|
|
210
|
-
}
|
|
211
|
-
const virtualizer = listbox.querySelector('lit-virtualizer');
|
|
212
|
-
if (virtualizer && virtualizer.isConnected) {
|
|
213
|
-
virtualizer.scrollTop = 0;
|
|
214
|
-
}
|
|
193
|
+
const scroller = listbox.querySelector('.combobox__options-scroll');
|
|
194
|
+
(scroller ?? listbox).scrollTop = 0;
|
|
215
195
|
});
|
|
216
196
|
}
|
|
217
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal-manager.js","sourceRoot":"","sources":["../../../src/nile-combobox/portal-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WA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AC1C,CAAC;qBAAM,CAAC;oBACN,WAAW,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;oBACrC,WAAW,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;oBACjC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;oBACjC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;gBAC/B,CAAC;gBACD,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC;YAC5B,CAAC;YAED,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAgB,CAAC;YAC5E,IAAI,WAAW,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;gBAC3C,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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 {\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n size,\n platform,\n type Placement,\n type MiddlewareData,\n type ComputePositionConfig,\n} from '@floating-ui/dom';\nimport { PortalUtils } from '../nile-select/portal-utils';\n\nexport class ComboboxPortalManager {\n private portalContainer: HTMLElement | null = null;\n private originalListboxParent: HTMLElement | null = null;\n private measuredPopupHeight: number | null = null;\n private component: any;\n private cleanupAutoUpdate: (() => void) | null = null;\n private currentPlacement: Placement = 'bottom';\n\n constructor(component: any) {\n this.component = component;\n }\n\n get portalContainerElement(): HTMLElement | null {\n return this.portalContainer;\n }\n\n private createPortalContainer(): HTMLElement {\n const container = document.createElement('div');\n container.style.position = 'absolute';\n container.style.zIndex = '9999';\n container.style.pointerEvents = 'none';\n container.className = 'nile-combobox-portal';\n return container;\n }\n\n private async computePosition(): Promise<void> {\n if (!this.portalContainer) return;\n\n const referenceElement = this.component.combobox || this.component;\n const floatingElement = this.portalContainer;\n\n try {\n const boundary = PortalUtils.findBoundaryElements(referenceElement);\n const initialPlacement = PortalUtils.getOptimalPlacement(referenceElement);\n\n const { x, y, placement } = await computePosition(\n referenceElement,\n floatingElement,\n {\n placement: initialPlacement,\n strategy: 'fixed',\n middleware: [\n offset(4),\n size({\n apply: ({ availableWidth, availableHeight, elements, rects }) => {\n const maxHeight = PortalUtils.calculateOptimalHeight(\n rects.reference,\n window.innerHeight,\n this.currentPlacement,\n );\n elements.floating.style.maxWidth = `${availableWidth}px`;\n elements.floating.style.maxHeight = `${maxHeight}px`;\n elements.floating.style.setProperty('--auto-size-available-width', `${availableWidth}px`);\n elements.floating.style.setProperty('--auto-size-available-height', `${maxHeight}px`);\n },\n padding: 10,\n boundary,\n }),\n flip({\n fallbackPlacements: ['bottom', 'top', 'bottom-start', 'top-start'],\n fallbackStrategy: 'bestFit',\n padding: 10,\n boundary,\n }),\n shift({ padding: 10, crossAxis: true, boundary }),\n ],\n platform,\n },\n );\n\n const referenceRect = referenceElement.getBoundingClientRect();\n Object.assign(floatingElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed',\n pointerEvents: 'auto',\n width: `${referenceRect.width}px`,\n });\n\n this.currentPlacement = placement;\n const placementClass = placement.split('-')[0];\n floatingElement.className = `nile-combobox-portal combobox__listbox--${placementClass}`;\n } catch {\n this.fallbackPositioning();\n }\n }\n\n private fallbackPositioning(): void {\n if (!this.portalContainer) return;\n\n const ref = this.component.combobox || this.component;\n const rect = ref.getBoundingClientRect();\n const vh = window.innerHeight;\n const spaceBelow = vh - rect.bottom;\n const spaceAbove = rect.top;\n\n let top: number;\n let maxH: number;\n let cls: string;\n\n if (spaceAbove > spaceBelow) {\n maxH = Math.max(spaceAbove - 20, 100);\n top = Math.max(rect.top - maxH - 4, 10);\n cls = 'top';\n } else {\n maxH = Math.max(spaceBelow - 20, 100);\n top = rect.bottom + 4;\n cls = 'bottom';\n }\n\n Object.assign(this.portalContainer.style, {\n left: `${rect.left}px`,\n top: `${top}px`,\n width: `${rect.width}px`,\n maxHeight: `${maxH}px`,\n pointerEvents: 'auto',\n });\n this.portalContainer.className = `nile-combobox-portal combobox__listbox--${cls}`;\n this.portalContainer.style.setProperty('--auto-size-available-height', `${maxH}px`);\n this.portalContainer.style.setProperty('--auto-size-available-width', `${rect.width}px`);\n }\n\n private extractStylesAsCSS(styles: any): string {\n if (typeof styles === 'string') return styles;\n if (Array.isArray(styles)) return styles.map(s => this.extractStylesAsCSS(s)).join('\\n');\n if (styles && typeof styles === 'object' && styles.cssText) return styles.cssText;\n return '';\n }\n\n private injectStyles(): void {\n if (!this.portalContainer) return;\n const styleId = `nile-combobox-styles-${Math.random().toString(36).substring(2, 11)}`;\n if (document.getElementById(styleId)) return;\n\n const componentStyles = (this.component.constructor as any).styles;\n if (!componentStyles) return;\n\n const el = document.createElement('style');\n el.id = styleId;\n el.textContent = this.extractStylesAsCSS(componentStyles);\n document.head.appendChild(el);\n (this.portalContainer as any).__injectedStyleId = styleId;\n }\n\n setupPortal(): void {\n if (!this.component.portal) return;\n\n this.component.updateComplete.then(() => {\n const listbox = this.component.shadowRoot?.querySelector('#listbox') as HTMLElement;\n if (!listbox) return;\n\n this.originalListboxParent = listbox.parentElement as HTMLElement;\n this.portalContainer = this.createPortalContainer();\n this.portalContainer.appendChild(listbox);\n document.body.appendChild(this.portalContainer);\n this.injectStyles();\n listbox.style.display = '';\n this.computePosition();\n\n this.cleanupAutoUpdate = autoUpdate(\n this.component,\n this.portalContainer,\n () => this.computePosition(),\n { ancestorScroll: true, ancestorResize: true, elementResize: true, layoutShift: true, animationFrame: true },\n );\n });\n }\n\n cleanupPortal(): void {\n if (this.cleanupAutoUpdate) {\n this.cleanupAutoUpdate();\n this.cleanupAutoUpdate = null;\n }\n\n if (this.portalContainer && this.portalContainer.parentNode) {\n const listbox = this.portalContainer.querySelector('#listbox') as HTMLElement;\n if (listbox && this.originalListboxParent) {\n this.originalListboxParent.appendChild(listbox);\n listbox.style.display = this.component.portal ? 'none' : '';\n }\n\n const sid = (this.portalContainer as any).__injectedStyleId;\n if (sid) document.getElementById(sid)?.remove();\n\n this.portalContainer.parentNode.removeChild(this.portalContainer);\n }\n\n this.portalContainer = null;\n this.originalListboxParent = null;\n this.measuredPopupHeight = null;\n this.currentPlacement = 'bottom';\n }\n\n updatePosition(): void {\n if (this.component.portal && this.portalContainer) {\n this.computePosition();\n }\n }\n\n resetMeasuredHeight(): void {\n this.measuredPopupHeight = null;\n }\n\n async resetScrollPosition(): Promise<void> {\n await this.component.updateComplete;\n\n requestAnimationFrame(() => {\n let listbox: HTMLElement | null = null;\n\n if (this.component.portal && this.portalContainer) {\n listbox = this.portalContainer.querySelector('#listbox') as HTMLElement;\n } else {\n listbox = this.component.shadowRoot?.querySelector('#listbox') as HTMLElement;\n }\n\n if (!listbox || !listbox.isConnected) return;\n listbox.scrollTop = 0;\n\n const virtualized = listbox.querySelector('.virtualized') as HTMLElement;\n if (virtualized && virtualized.isConnected) {\n const fewItems = this.component.filteredData?.length < 5;\n if (fewItems) {\n virtualized.style.overflowY = 'hidden';\n virtualized.style.maxHeight = 'none';\n listbox.style.overflowY = 'hidden';\n listbox.style.maxHeight = 'fit-content';\n } else {\n virtualized.style.overflowY = 'auto';\n virtualized.style.maxHeight = '';\n listbox.style.overflowY = 'auto';\n listbox.style.maxHeight = '';\n }\n virtualized.scrollTop = 0;\n }\n\n const virtualizer = listbox.querySelector('lit-virtualizer') as HTMLElement;\n if (virtualizer && virtualizer.isConnected) {\n virtualizer.scrollTop = 0;\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"portal-manager.js","sourceRoot":"","sources":["../../../src/nile-combobox/portal-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;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,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;QAEpC,qBAAqB,CAAC,GAAG,EAAE;YACzB,IAAI,OAAO,GAAuB,IAAI,CAAC;YAEvC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBAClD,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAgB,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAgB,CAAC;YAChF,CAAC;YAED,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW;gBAAE,OAAO;YAE7C,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CACpC,2BAA2B,CACN,CAAC;YACxB,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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 {\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n size,\n platform,\n type Placement,\n type MiddlewareData,\n type ComputePositionConfig,\n} from '@floating-ui/dom';\nimport { PortalUtils } from '../nile-select/portal-utils';\n\nexport class ComboboxPortalManager {\n private portalContainer: HTMLElement | null = null;\n private originalListboxParent: HTMLElement | null = null;\n private measuredPopupHeight: number | null = null;\n private component: any;\n private cleanupAutoUpdate: (() => void) | null = null;\n private currentPlacement: Placement = 'bottom';\n\n constructor(component: any) {\n this.component = component;\n }\n\n get portalContainerElement(): HTMLElement | null {\n return this.portalContainer;\n }\n\n private createPortalContainer(): HTMLElement {\n const container = document.createElement('div');\n container.style.position = 'absolute';\n container.style.zIndex = '9999';\n container.style.pointerEvents = 'none';\n container.className = 'nile-combobox-portal';\n return container;\n }\n\n private async computePosition(): Promise<void> {\n if (!this.portalContainer) return;\n\n const referenceElement = this.component.combobox || this.component;\n const floatingElement = this.portalContainer;\n\n try {\n const boundary = PortalUtils.findBoundaryElements(referenceElement);\n const initialPlacement = PortalUtils.getOptimalPlacement(referenceElement);\n\n const { x, y, placement } = await computePosition(\n referenceElement,\n floatingElement,\n {\n placement: initialPlacement,\n strategy: 'fixed',\n middleware: [\n offset(4),\n size({\n apply: ({ availableWidth, availableHeight, elements, rects }) => {\n const maxHeight = PortalUtils.calculateOptimalHeight(\n rects.reference,\n window.innerHeight,\n this.currentPlacement,\n );\n elements.floating.style.maxWidth = `${availableWidth}px`;\n elements.floating.style.maxHeight = `${maxHeight}px`;\n elements.floating.style.setProperty('--auto-size-available-width', `${availableWidth}px`);\n elements.floating.style.setProperty('--auto-size-available-height', `${maxHeight}px`);\n },\n padding: 10,\n boundary,\n }),\n flip({\n fallbackPlacements: ['bottom', 'top', 'bottom-start', 'top-start'],\n fallbackStrategy: 'bestFit',\n padding: 10,\n boundary,\n }),\n shift({ padding: 10, crossAxis: true, boundary }),\n ],\n platform,\n },\n );\n\n const referenceRect = referenceElement.getBoundingClientRect();\n Object.assign(floatingElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed',\n pointerEvents: 'auto',\n width: `${referenceRect.width}px`,\n });\n\n this.currentPlacement = placement;\n const placementClass = placement.split('-')[0];\n floatingElement.className = `nile-combobox-portal combobox__listbox--${placementClass}`;\n } catch {\n this.fallbackPositioning();\n }\n }\n\n private fallbackPositioning(): void {\n if (!this.portalContainer) return;\n\n const ref = this.component.combobox || this.component;\n const rect = ref.getBoundingClientRect();\n const vh = window.innerHeight;\n const spaceBelow = vh - rect.bottom;\n const spaceAbove = rect.top;\n\n let top: number;\n let maxH: number;\n let cls: string;\n\n if (spaceAbove > spaceBelow) {\n maxH = Math.max(spaceAbove - 20, 100);\n top = Math.max(rect.top - maxH - 4, 10);\n cls = 'top';\n } else {\n maxH = Math.max(spaceBelow - 20, 100);\n top = rect.bottom + 4;\n cls = 'bottom';\n }\n\n Object.assign(this.portalContainer.style, {\n left: `${rect.left}px`,\n top: `${top}px`,\n width: `${rect.width}px`,\n maxHeight: `${maxH}px`,\n pointerEvents: 'auto',\n });\n this.portalContainer.className = `nile-combobox-portal combobox__listbox--${cls}`;\n this.portalContainer.style.setProperty('--auto-size-available-height', `${maxH}px`);\n this.portalContainer.style.setProperty('--auto-size-available-width', `${rect.width}px`);\n }\n\n private extractStylesAsCSS(styles: any): string {\n if (typeof styles === 'string') return styles;\n if (Array.isArray(styles)) return styles.map(s => this.extractStylesAsCSS(s)).join('\\n');\n if (styles && typeof styles === 'object' && styles.cssText) return styles.cssText;\n return '';\n }\n\n private injectStyles(): void {\n if (!this.portalContainer) return;\n const styleId = `nile-combobox-styles-${Math.random().toString(36).substring(2, 11)}`;\n if (document.getElementById(styleId)) return;\n\n const componentStyles = (this.component.constructor as any).styles;\n if (!componentStyles) return;\n\n const el = document.createElement('style');\n el.id = styleId;\n el.textContent = this.extractStylesAsCSS(componentStyles);\n document.head.appendChild(el);\n (this.portalContainer as any).__injectedStyleId = styleId;\n }\n\n setupPortal(): void {\n if (!this.component.portal) return;\n\n this.component.updateComplete.then(() => {\n const listbox = this.component.shadowRoot?.querySelector('#listbox') as HTMLElement;\n if (!listbox) return;\n\n this.originalListboxParent = listbox.parentElement as HTMLElement;\n this.portalContainer = this.createPortalContainer();\n this.portalContainer.appendChild(listbox);\n document.body.appendChild(this.portalContainer);\n this.injectStyles();\n listbox.style.display = '';\n this.computePosition();\n\n this.cleanupAutoUpdate = autoUpdate(\n this.component,\n this.portalContainer,\n () => this.computePosition(),\n { ancestorScroll: true, ancestorResize: true, elementResize: true, layoutShift: true, animationFrame: true },\n );\n });\n }\n\n cleanupPortal(): void {\n if (this.cleanupAutoUpdate) {\n this.cleanupAutoUpdate();\n this.cleanupAutoUpdate = null;\n }\n\n if (this.portalContainer && this.portalContainer.parentNode) {\n const listbox = this.portalContainer.querySelector('#listbox') as HTMLElement;\n if (listbox && this.originalListboxParent) {\n this.originalListboxParent.appendChild(listbox);\n listbox.style.display = this.component.portal ? 'none' : '';\n }\n\n const sid = (this.portalContainer as any).__injectedStyleId;\n if (sid) document.getElementById(sid)?.remove();\n\n this.portalContainer.parentNode.removeChild(this.portalContainer);\n }\n\n this.portalContainer = null;\n this.originalListboxParent = null;\n this.measuredPopupHeight = null;\n this.currentPlacement = 'bottom';\n }\n\n updatePosition(): void {\n if (this.component.portal && this.portalContainer) {\n this.computePosition();\n }\n }\n\n resetMeasuredHeight(): void {\n this.measuredPopupHeight = null;\n }\n\n async resetScrollPosition(): Promise<void> {\n await this.component.updateComplete;\n\n requestAnimationFrame(() => {\n let listbox: HTMLElement | null = null;\n\n if (this.component.portal && this.portalContainer) {\n listbox = this.portalContainer.querySelector('#listbox') as HTMLElement;\n } else {\n listbox = this.component.shadowRoot?.querySelector('#listbox') as HTMLElement;\n }\n\n if (!listbox || !listbox.isConnected) return;\n\n const scroller = listbox.querySelector(\n '.combobox__options-scroll',\n ) as HTMLElement | null;\n (scroller ?? listbox).scrollTop = 0;\n });\n }\n}\n"]}
|
|
@@ -10,12 +10,11 @@ import type { ComboboxRow, ComboboxHeaderRow } from './types';
|
|
|
10
10
|
export declare class ComboboxRenderer {
|
|
11
11
|
static renderGroupHeader(row: ComboboxHeaderRow): TemplateResult;
|
|
12
12
|
static renderRowsPlain(rows: ComboboxRow[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, showNoResults: boolean, noResultsMessage: string, isLoading: boolean, onScroll: (e: Event) => void, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean, noResultsSubtitle?: string): TemplateResult;
|
|
13
|
-
static renderRowsVirtualized(virtualItems: VirtualItem[], totalSize: number, rows: ComboboxRow[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean): TemplateResult;
|
|
14
|
-
static renderVirtualizedOptions(virtualItems: VirtualItem[], totalSize: number, data: any[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean,
|
|
13
|
+
static renderRowsVirtualized(virtualItems: VirtualItem[], totalSize: number, rows: ComboboxRow[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean, stickyOverlay?: TemplateResult, stickyIndex?: number): TemplateResult;
|
|
14
|
+
static renderVirtualizedOptions(virtualItems: VirtualItem[], totalSize: number, data: any[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean): TemplateResult;
|
|
15
15
|
static renderPlainOptions(data: any[], value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, showNoResults: boolean, noResultsMessage: string, isLoading: boolean, onScroll: (e: Event) => void, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean, noResultsSubtitle?: string): TemplateResult;
|
|
16
16
|
static renderNoResults(noResultsMessage: string, noResultsSubtitle?: string): TemplateResult;
|
|
17
17
|
static renderNoData(noDataMessage: string): TemplateResult;
|
|
18
|
-
private static renderMeasuredItem;
|
|
19
18
|
static renderItem(item: any, value: string | string[], multiple: boolean, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, enableDescription?: boolean): TemplateResult;
|
|
20
19
|
static renderVirtualizedGrid(virtualItems: VirtualItem[], totalSize: number, data: any[], value: string | string[], multiple: boolean, gridColumns: number, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string, gridColumnWidth?: number): TemplateResult;
|
|
21
20
|
static renderHorizontalGrid(virtualItems: VirtualItem[], totalSize: number, data: any[], value: string | string[], multiple: boolean, gridRows: number, gridColumnWidth: number, getDisplayText: (item: any) => string, getItemValue: (item: any) => string, isLoading: boolean, allowHtmlLabel: boolean, getItemDescription?: (item: any) => string, getItemPrefix?: (item: any) => string, getItemSuffix?: (item: any) => string): TemplateResult;
|
|
@@ -47,13 +47,14 @@ export class ComboboxRenderer {
|
|
|
47
47
|
</div>
|
|
48
48
|
`;
|
|
49
49
|
}
|
|
50
|
-
static renderRowsVirtualized(virtualItems, totalSize, rows, value, multiple, getDisplayText, getItemValue, isLoading, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription) {
|
|
50
|
+
static renderRowsVirtualized(virtualItems, totalSize, rows, value, multiple, getDisplayText, getItemValue, isLoading, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription, stickyOverlay, stickyIndex = -1) {
|
|
51
51
|
return html `
|
|
52
52
|
<div
|
|
53
53
|
part="select-options"
|
|
54
54
|
class="combobox__options ${isLoading ? 'loading' : ''}"
|
|
55
55
|
>
|
|
56
56
|
<div style="position:relative;height:${totalSize}px;width:100%;">
|
|
57
|
+
${stickyOverlay ?? ''}
|
|
57
58
|
${repeat(virtualItems, (vItem) => vItem.key, (vItem) => {
|
|
58
59
|
const row = rows[vItem.index];
|
|
59
60
|
if (!row)
|
|
@@ -62,8 +63,9 @@ export class ComboboxRenderer {
|
|
|
62
63
|
`transform:translateY(${vItem.start}px);` +
|
|
63
64
|
`height:${vItem.size}px;`;
|
|
64
65
|
if (row.kind === 'header') {
|
|
66
|
+
const headerStyle = vItem.index === stickyIndex ? `${posStyle}visibility:hidden;` : posStyle;
|
|
65
67
|
return html `
|
|
66
|
-
<div style=${
|
|
68
|
+
<div style=${headerStyle} class="combobox__group-header-slot">
|
|
67
69
|
${ComboboxRenderer.renderGroupHeader(row)}
|
|
68
70
|
</div>
|
|
69
71
|
`;
|
|
@@ -78,20 +80,24 @@ export class ComboboxRenderer {
|
|
|
78
80
|
</div>
|
|
79
81
|
`;
|
|
80
82
|
}
|
|
81
|
-
static renderVirtualizedOptions(virtualItems, totalSize, data, value, multiple, getDisplayText, getItemValue, isLoading, allowHtmlLabel,
|
|
82
|
-
const offsetTop = virtualItems.length > 0 ? virtualItems[0].start : 0;
|
|
83
|
+
static renderVirtualizedOptions(virtualItems, totalSize, data, value, multiple, getDisplayText, getItemValue, isLoading, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription) {
|
|
83
84
|
return html `
|
|
84
85
|
<div
|
|
85
86
|
part="select-options"
|
|
86
87
|
class="combobox__options ${isLoading ? 'loading' : ''}"
|
|
87
88
|
>
|
|
88
89
|
<div style="position:relative;height:${totalSize}px;width:100%;">
|
|
89
|
-
|
|
90
|
-
${repeat(virtualItems, (vItem) => vItem.key, (vItem) => {
|
|
90
|
+
${repeat(virtualItems, (vItem) => vItem.key, (vItem) => {
|
|
91
91
|
const item = data[vItem.index];
|
|
92
|
-
|
|
92
|
+
const posStyle = `position:absolute;top:0;left:0;right:0;` +
|
|
93
|
+
`transform:translateY(${vItem.start}px);` +
|
|
94
|
+
`height:${vItem.size}px;`;
|
|
95
|
+
return html `
|
|
96
|
+
<div style=${posStyle}>
|
|
97
|
+
${ComboboxRenderer.renderItem(item, value, multiple, getDisplayText, getItemValue, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription)}
|
|
98
|
+
</div>
|
|
99
|
+
`;
|
|
93
100
|
})}
|
|
94
|
-
</div>
|
|
95
101
|
</div>
|
|
96
102
|
</div>
|
|
97
103
|
`;
|
|
@@ -136,43 +142,6 @@ export class ComboboxRenderer {
|
|
|
136
142
|
</div>
|
|
137
143
|
`;
|
|
138
144
|
}
|
|
139
|
-
static renderMeasuredItem(item, index, value, multiple, getDisplayText, getItemValue, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription) {
|
|
140
|
-
if (!item)
|
|
141
|
-
return html ``;
|
|
142
|
-
const optionValue = getItemValue(item);
|
|
143
|
-
const displayText = getDisplayText(item);
|
|
144
|
-
const isDisabled = item?.disabled || false;
|
|
145
|
-
const className = item?.className;
|
|
146
|
-
const description = getItemDescription ? getItemDescription(item) : (item?.description ?? '');
|
|
147
|
-
const prefix = getItemPrefix ? getItemPrefix(item) : (item?.prefix ?? '');
|
|
148
|
-
const suffix = getItemSuffix ? getItemSuffix(item) : (item?.suffix ?? '');
|
|
149
|
-
let isSelected = false;
|
|
150
|
-
if (multiple) {
|
|
151
|
-
isSelected = Array.isArray(value) && value.some(v => String(v) === String(optionValue));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
isSelected = String(Array.isArray(value) ? value[0] : value) === String(optionValue);
|
|
155
|
-
}
|
|
156
|
-
return html `
|
|
157
|
-
<nile-option
|
|
158
|
-
data-index=${index}
|
|
159
|
-
value=${optionValue}
|
|
160
|
-
.selected=${isSelected}
|
|
161
|
-
.disabled=${isDisabled}
|
|
162
|
-
.showCheckbox=${multiple}
|
|
163
|
-
class=${classMap({
|
|
164
|
-
option: enableDescription ?? false,
|
|
165
|
-
[className ?? '']: !!className,
|
|
166
|
-
})}
|
|
167
|
-
.description=${description}
|
|
168
|
-
.isDescriptionEnabled=${enableDescription}
|
|
169
|
-
>
|
|
170
|
-
${unsafeHTML(prefix)}
|
|
171
|
-
${allowHtmlLabel ? unsafeHTML(displayText) : displayText}
|
|
172
|
-
${unsafeHTML(suffix)}
|
|
173
|
-
</nile-option>
|
|
174
|
-
`;
|
|
175
|
-
}
|
|
176
145
|
static renderItem(item, value, multiple, getDisplayText, getItemValue, allowHtmlLabel, getItemDescription, getItemPrefix, getItemSuffix, enableDescription) {
|
|
177
146
|
if (!item)
|
|
178
147
|
return html ``;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/nile-combobox/renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIlD,MAAM,OAAO,gBAAgB;IAE3B,MAAM,CAAC,iBAAiB,CAAC,GAAsB;QAC7C,OAAO,IAAI,CAAA;;;;;wBAKS,GAAG,CAAC,EAAE;gBACd,iBAAiB,GAAG,CAAC,KAAK,EAAE;;UAElC,GAAG,CAAC,MAAM;YACV,CAAC,CAAC,IAAI,CAAA;;qBAEK,GAAG,CAAC,MAAM;;;0BAGL;YAChB,CAAC,CAAC,EAAE;8CACgC,GAAG,CAAC,KAAK;;KAElD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,eAAe,CACpB,IAAmB,EACnB,KAAwB,EACxB,QAAiB,EACjB,cAAqC,EACrC,YAAmC,EACnC,aAAsB,EACtB,gBAAwB,EACxB,SAAkB,EAClB,QAA4B,EAC5B,cAAuB,EACvB,kBAA0C,EAC1C,aAAqC,E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AC;QACjC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","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"]}
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/nile-combobox/renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIlD,MAAM,OAAO,gBAAgB;IAE3B,MAAM,CAAC,iBAAiB,CAAC,GAAsB;QAC7C,OAAO,IAAI,CAAA;;;;;wBAKS,GAAG,CAAC,EAAE;gBACd,iBAAiB,GAAG,CAAC,KAAK,EAAE;;UAElC,GAAG,CAAC,MAAM;YACV,CAAC,CAAC,IAAI,CAAA;;qBAEK,GAAG,CAAC,MAAM;;;0BAGL;YAChB,CAAC,CAAC,EAAE;8CACgC,GAAG,CAAC,KAAK;;KAElD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,eAAe,CACpB,IAAmB,EACnB,KAAwB,EACxB,QAAiB,EACjB,cAAqC,EACrC,YAAmC,EACnC,aAAsB,EACtB,gBAAwB,EACxB,SAAkB,EAClB,QAA4B,EAC5B,cAAuB,EACvB,kBAA0C,EAC1C,aAAqC,EACrC,aAAqC,EACrC,iBAA2B,EAC3B,iBAA0B;QAE1B,IAAI,aAAa,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO,gBAAgB,CAAC,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,IAAI,CAAA;;;m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,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAA;iEACsC,eAAe;sBAC1D,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAC3B,gBAAgB,CAAC,UAAU,CACzB,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EACnD,cAAc,EAAE,kBAAkB,EAAE,aAAa,EACjD,aAAa,CACd,CACF;;iBAEJ,CAAC;QACJ,CAAC,CACF;;;;KAIR,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,qBAAqB,CAC1B,WAAmB,EACnB,QAAiB;QAEjB,OAAO,IAAI,CAAA;;gBAEC,WAAW;;wBAEH,QAAQ;;iBAEf,WAAW;;KAEvB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,IAAW,EAAE,WAAW,GAAG,CAAC;QACtD,IAAI,WAAW,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","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 stickyOverlay?: TemplateResult,\n stickyIndex = -1,\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 ${stickyOverlay ?? ''}\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 const headerStyle =\n vItem.index === stickyIndex ? `${posStyle}visibility:hidden;` : posStyle;\n return html`\n <div style=${headerStyle} 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 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 item = data[vItem.index];\n const posStyle =\n `position:absolute;top:0;left:0;right:0;` +\n `transform:translateY(${vItem.start}px);` +\n `height:${vItem.size}px;`;\n return html`\n <div style=${posStyle}>\n ${ComboboxRenderer.renderItem(\n 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 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 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"]}
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const NILE_ELEMENTS_VERSION = "__NILE_ELEMENTS_VERSION__";
|
|
2
|
-
export declare const NILE_VERSION
|
|
2
|
+
export declare const NILE_VERSION: string;
|
package/dist/src/version.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
// Version utility
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Version utility.
|
|
2
|
+
//
|
|
3
|
+
// NILE_ELEMENTS_VERSION is this package's own version and is still substituted
|
|
4
|
+
// at build time by scripts/replace-version.cjs.
|
|
5
|
+
//
|
|
6
|
+
// NILE_VERSION is read from the installed @aquera/nile at runtime, so publishing
|
|
7
|
+
// @aquera/nile on its own is enough to update window.nileVersion - consumers do
|
|
8
|
+
// not need a rebuild of this package to pick up a new tokens version.
|
|
9
|
+
import { NILE_VERSION as INSTALLED_NILE_VERSION } from '@aquera/nile/lib/version.js';
|
|
10
|
+
export const NILE_ELEMENTS_VERSION = '2.0.5';
|
|
11
|
+
export const NILE_VERSION = INSTALLED_NILE_VERSION;
|
|
4
12
|
// Set global versions for runtime access
|
|
5
13
|
if (typeof window !== 'undefined') {
|
|
6
14
|
window.nileElementsVersion = NILE_ELEMENTS_VERSION;
|
package/dist/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,+
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,EAAE;AACF,+EAA+E;AAC/E,gDAAgD;AAChD,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,sEAAsE;AACtE,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErF,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD,yCAAyC;AACzC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACjC,MAAc,CAAC,mBAAmB,GAAG,qBAAqB,CAAC;IAC3D,MAAc,CAAC,WAAW,GAAG,YAAY,CAAC;IAC3C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,CAAC;AACzE,CAAC","sourcesContent":["// Version utility.\n//\n// NILE_ELEMENTS_VERSION is this package's own version and is still substituted\n// at build time by scripts/replace-version.cjs.\n//\n// NILE_VERSION is read from the installed @aquera/nile at runtime, so publishing\n// @aquera/nile on its own is enough to update window.nileVersion - consumers do\n// not need a rebuild of this package to pick up a new tokens version.\nimport { NILE_VERSION as INSTALLED_NILE_VERSION } from '@aquera/nile/lib/version.js';\n\nexport const NILE_ELEMENTS_VERSION = '2.0.5';\nexport const NILE_VERSION = INSTALLED_NILE_VERSION;\n\n// Set global versions for runtime access\nif (typeof window !== 'undefined') {\n (window as any).nileElementsVersion = NILE_ELEMENTS_VERSION;\n (window as any).nileVersion = NILE_VERSION;\n window.process = window.process || { env: { NODE_ENV: 'production' } };\n}\n"]}
|