@toolbox-web/grid 1.11.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1224 -1110
- package/all.js.map +1 -1
- package/index.js +2000 -1700
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +21 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/aria.d.ts +52 -0
- package/lib/core/internal/aria.d.ts.map +1 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -1
- package/lib/core/internal/idle-scheduler.d.ts +0 -27
- package/lib/core/internal/idle-scheduler.d.ts.map +1 -1
- package/lib/core/internal/loading.d.ts +0 -38
- package/lib/core/internal/loading.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +6 -0
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/style-injector.d.ts +0 -8
- package/lib/core/internal/style-injector.d.ts.map +1 -1
- package/lib/core/internal/utils.d.ts +6 -4
- package/lib/core/internal/utils.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/internal/virtualization.d.ts +177 -23
- package/lib/core/internal/virtualization.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +50 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +18 -0
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +16 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +56 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +7 -5
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +379 -278
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +14 -1
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +8 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +59 -60
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -0
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +88 -69
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +17 -0
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +24 -0
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +203 -128
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +2 -2
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +2 -2
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +13 -0
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +65 -49
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +5 -5
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +27 -25
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +18 -16
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(m,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("../../core/plugin/base-plugin"),require("../../core/types")):typeof define=="function"&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/types"],h):(m=typeof globalThis<"u"?globalThis:m||self,h(m.TbwGridPlugin_contextMenu={},m.TbwGrid,m.TbwGrid))})(this,(function(m,h,S){"use strict";const x="@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:var(--tbw-context-menu-shadow, 0 2px 10px var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";function g(s,n){return(typeof s=="function"?s(n):s).filter(t=>!(t.hidden===!0||typeof t.hidden=="function"&&t.hidden(n)))}function z(s,n){return s.disabled===!0?!0:typeof s.disabled=="function"?s.disabled(n):!1}function v(s,n,l,t=S.DEFAULT_GRID_ICONS.submenuArrow){const i=document.createElement("div");i.className="tbw-context-menu",i.setAttribute("role","menu");for(const o of s){if(o.separator){const r=document.createElement("div");r.className="tbw-context-menu-separator",r.setAttribute("role","separator"),i.appendChild(r);continue}const e=document.createElement("div");e.className="tbw-context-menu-item",o.cssClass&&e.classList.add(o.cssClass),e.setAttribute("role","menuitem"),e.setAttribute("data-id",o.id);const u=z(o,n);if(u&&(e.classList.add("disabled"),e.setAttribute("aria-disabled","true")),o.icon){const r=document.createElement("span");r.className="tbw-context-menu-icon",r.innerHTML=o.icon,e.appendChild(r)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=o.name,e.appendChild(a),o.shortcut){const r=document.createElement("span");r.className="tbw-context-menu-shortcut",r.textContent=o.shortcut,e.appendChild(r)}if(o.subMenu?.length){const r=document.createElement("span");r.className="tbw-context-menu-arrow",typeof t=="string"?r.innerHTML=t:t instanceof HTMLElement&&r.appendChild(t.cloneNode(!0)),e.appendChild(r),e.addEventListener("mouseenter",()=>{if(e.querySelector(".tbw-context-menu")||!o.subMenu)return;const
|
|
1
|
+
(function(m,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("../../core/plugin/base-plugin"),require("../../core/types")):typeof define=="function"&&define.amd?define(["exports","../../core/plugin/base-plugin","../../core/types"],h):(m=typeof globalThis<"u"?globalThis:m||self,h(m.TbwGridPlugin_contextMenu={},m.TbwGrid,m.TbwGrid))})(this,(function(m,h,S){"use strict";const x="@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:var(--tbw-context-menu-shadow, 0 2px 10px var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";function g(s,n){return(typeof s=="function"?s(n):s).filter(t=>!(t.hidden===!0||typeof t.hidden=="function"&&t.hidden(n)))}function z(s,n){return s.disabled===!0?!0:typeof s.disabled=="function"?s.disabled(n):!1}function v(s,n,l,t=S.DEFAULT_GRID_ICONS.submenuArrow){const i=document.createElement("div");i.className="tbw-context-menu",i.setAttribute("role","menu");for(const o of s){if(o.separator){const r=document.createElement("div");r.className="tbw-context-menu-separator",r.setAttribute("role","separator"),i.appendChild(r);continue}const e=document.createElement("div");e.className="tbw-context-menu-item",o.cssClass&&e.classList.add(o.cssClass),e.setAttribute("role","menuitem"),e.setAttribute("data-id",o.id);const u=z(o,n);if(u&&(e.classList.add("disabled"),e.setAttribute("aria-disabled","true")),o.icon){const r=document.createElement("span");r.className="tbw-context-menu-icon",r.innerHTML=o.icon,e.appendChild(r)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=o.name,e.appendChild(a),o.shortcut){const r=document.createElement("span");r.className="tbw-context-menu-shortcut",r.textContent=o.shortcut,e.appendChild(r)}if(o.subMenu?.length){const r=document.createElement("span");r.className="tbw-context-menu-arrow",typeof t=="string"?r.innerHTML=t:t instanceof HTMLElement&&r.appendChild(t.cloneNode(!0)),e.appendChild(r),e.addEventListener("mouseenter",()=>{if(e.querySelector(".tbw-context-menu")||!o.subMenu)return;const w=g(o.subMenu,n),d=v(w,n,l,t);d.classList.add("tbw-context-submenu"),d.style.position="absolute",d.style.left="100%",d.style.top="0",e.style.position="relative",e.appendChild(d)}),e.addEventListener("mouseleave",()=>{const c=e.querySelector(".tbw-context-menu");c&&c.remove()})}!u&&o.action&&!o.subMenu&&e.addEventListener("click",r=>{r.stopPropagation(),l(o)}),i.appendChild(e)}return i}function M(s,n,l){s.style.position="fixed",s.style.left=`${n}px`,s.style.top=`${l}px`,s.style.visibility="hidden",s.style.zIndex="10000";const t=s.getBoundingClientRect(),i=window.innerWidth,o=window.innerHeight;let e=n,u=l;n+t.width>i&&(e=n-t.width),l+t.height>o&&(u=l-t.height),e=Math.max(0,e),u=Math.max(0,u),s.style.left=`${e}px`,s.style.top=`${u}px`,s.style.visibility="visible"}let f=null,p=null,b=null,y=0;const E=[{id:"copy",name:"Copy",shortcut:"Ctrl+C",action:s=>{s.grid?.plugins?.clipboard?.copy?.()}},{separator:!0,id:"sep1",name:""},{id:"export-csv",name:"Export CSV",action:s=>{s.grid?.plugins?.export?.exportCsv?.()}}];class C extends h.BaseGridPlugin{name="contextMenu";get defaultConfig(){return{items:E}}isOpen=!1;position={x:0,y:0};params=null;menuElement=null;attach(n){super.attach(n),this.installGlobalHandlers(),y++}detach(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null),this.isOpen=!1,this.params=null,this.uninstallGlobalHandlers()}static CSS_VARS_TO_COPY=["--tbw-color-panel-bg","--tbw-color-fg","--tbw-color-fg-muted","--tbw-color-border","--tbw-color-row-hover","--tbw-color-shadow","--tbw-color-danger","--tbw-border-radius","--tbw-font-family","--tbw-font-size-sm","--tbw-font-size-xs","--tbw-font-size-2xs","--tbw-spacing-xs","--tbw-icon-size","--tbw-menu-min-width","--tbw-menu-item-padding","--tbw-menu-item-gap","--tbw-context-menu-bg","--tbw-context-menu-fg","--tbw-context-menu-border","--tbw-context-menu-radius","--tbw-context-menu-shadow","--tbw-context-menu-hover","--tbw-context-menu-danger","--tbw-context-menu-muted","--tbw-context-menu-min-width","--tbw-context-menu-font-size","--tbw-context-menu-font-family","--tbw-context-menu-item-padding","--tbw-context-menu-item-gap","--tbw-context-menu-icon-size","--tbw-context-menu-shortcut-size","--tbw-context-menu-arrow-size"];copyGridStyles(n){const l=this.gridElement;if(!l)return;const t=getComputedStyle(l),i=[],o=t.getPropertyValue("color-scheme").trim();o&&i.push(`color-scheme: ${o}`);for(const e of C.CSS_VARS_TO_COPY){const u=t.getPropertyValue(e).trim();u&&i.push(`${e}: ${u}`)}if(i.length>0){const e=n.getAttribute("style")||"";n.setAttribute("style",e+i.join("; ")+";")}}installGlobalHandlers(){!b&&typeof document<"u"&&typeof x=="string"&&x&&(b=document.createElement("style"),b.id="tbw-context-menu-styles",b.textContent=x,document.head.appendChild(b)),f||(f=()=>{document.querySelectorAll(".tbw-context-menu").forEach(l=>l.remove())},document.addEventListener("click",f)),p||(p=n=>{n.key==="Escape"&&document.querySelectorAll(".tbw-context-menu").forEach(t=>t.remove())},document.addEventListener("keydown",p))}uninstallGlobalHandlers(){y--,!(y>0)&&(f&&(document.removeEventListener("click",f),f=null),p&&(document.removeEventListener("keydown",p),p=null),b&&(b.remove(),b=null))}afterRender(){const n=this.gridElement;if(!n)return;const l=n.querySelector(".tbw-grid-root");l&&l.getAttribute("data-context-menu-bound")!=="true"&&(l.setAttribute("data-context-menu-bound","true"),l.addEventListener("contextmenu",t=>{const i=t;i.preventDefault();const o=i.target,e=o.closest("[data-row][data-col]"),u=o.closest(".header-cell");let a;if(e){const c=parseInt(e.getAttribute("data-row")??"-1",10),w=parseInt(e.getAttribute("data-col")??"-1",10),d=this.columns[w],I=this.rows[c];a={row:I,rowIndex:c,column:d,columnIndex:w,field:d?.field??"",value:I?.[d?.field]??null,isHeader:!1,event:i}}else if(u){const c=parseInt(u.getAttribute("data-col")??"-1",10),w=this.columns[c];a={row:null,rowIndex:-1,column:w,columnIndex:c,field:w?.field??"",value:null,isHeader:!0,event:i}}else return;this.params=a,this.position={x:i.clientX,y:i.clientY};const r=g(this.config.items??E,a);r.length&&(this.menuElement&&this.menuElement.remove(),this.menuElement=v(r,a,c=>{c.action&&c.action(a),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),this.copyGridStyles(this.menuElement),M(this.menuElement,i.clientX,i.clientY),this.isOpen=!0,this.emit("context-menu-open",{params:a,items:r}))}))}showMenu(n,l,t){const i={row:t.row??null,rowIndex:t.rowIndex??-1,column:t.column??null,columnIndex:t.columnIndex??-1,field:t.field??"",value:t.value??null,isHeader:t.isHeader??!1,event:t.event??new MouseEvent("contextmenu")},o=g(this.config.items??E,i);this.menuElement&&this.menuElement.remove(),this.menuElement=v(o,i,e=>{e.action&&e.action(i),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),this.copyGridStyles(this.menuElement),M(this.menuElement,n,l),this.isOpen=!0}hideMenu(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null,this.isOpen=!1)}isMenuOpen(){return this.isOpen}}m.ContextMenuPlugin=C,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=context-menu.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/context-menu/menu.ts","../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"sourcesContent":["/**\n * Context Menu Rendering Logic\n *\n * Pure functions for building and positioning context menus.\n */\n\nimport type { IconValue } from '../../core/types';\nimport { DEFAULT_GRID_ICONS } from '../../core/types';\nimport type { ContextMenuItem, ContextMenuParams } from './types';\n\n/**\n * Build the visible menu items by resolving dynamic items and filtering hidden ones.\n *\n * @param items - Menu items configuration (array or factory function)\n * @param params - Context menu parameters for evaluating dynamic properties\n * @returns Filtered array of visible menu items\n */\nexport function buildMenuItems(\n items: ContextMenuItem[] | ((params: ContextMenuParams) => ContextMenuItem[]),\n params: ContextMenuParams\n): ContextMenuItem[] {\n const menuItems = typeof items === 'function' ? items(params) : items;\n\n return menuItems.filter((item) => {\n if (item.hidden === true) return false;\n if (typeof item.hidden === 'function' && item.hidden(params)) return false;\n return true;\n });\n}\n\n/**\n * Check if a menu item is disabled.\n *\n * @param item - The menu item to check\n * @param params - Context menu parameters for evaluating dynamic disabled state\n * @returns True if the item is disabled\n */\nexport function isItemDisabled(item: ContextMenuItem, params: ContextMenuParams): boolean {\n if (item.disabled === true) return true;\n if (typeof item.disabled === 'function') return item.disabled(params);\n return false;\n}\n\n/**\n * Create the menu DOM element from a list of menu items.\n *\n * @param items - Array of menu items to render\n * @param params - Context menu parameters for evaluating dynamic properties\n * @param onAction - Callback when a menu item action is triggered\n * @param submenuArrow - Optional custom submenu arrow icon\n * @returns The created menu element\n */\nexport function createMenuElement(\n items: ContextMenuItem[],\n params: ContextMenuParams,\n onAction: (item: ContextMenuItem) => void,\n submenuArrow: IconValue = DEFAULT_GRID_ICONS.submenuArrow\n): HTMLElement {\n const menu = document.createElement('div');\n menu.className = 'tbw-context-menu';\n menu.setAttribute('role', 'menu');\n\n for (const item of items) {\n if (item.separator) {\n const separator = document.createElement('div');\n separator.className = 'tbw-context-menu-separator';\n separator.setAttribute('role', 'separator');\n menu.appendChild(separator);\n continue;\n }\n\n const menuItem = document.createElement('div');\n menuItem.className = 'tbw-context-menu-item';\n if (item.cssClass) menuItem.classList.add(item.cssClass);\n menuItem.setAttribute('role', 'menuitem');\n menuItem.setAttribute('data-id', item.id);\n\n const disabled = isItemDisabled(item, params);\n if (disabled) {\n menuItem.classList.add('disabled');\n menuItem.setAttribute('aria-disabled', 'true');\n }\n\n if (item.icon) {\n const icon = document.createElement('span');\n icon.className = 'tbw-context-menu-icon';\n icon.innerHTML = item.icon;\n menuItem.appendChild(icon);\n }\n\n const label = document.createElement('span');\n label.className = 'tbw-context-menu-label';\n label.textContent = item.name;\n menuItem.appendChild(label);\n\n if (item.shortcut) {\n const shortcut = document.createElement('span');\n shortcut.className = 'tbw-context-menu-shortcut';\n shortcut.textContent = item.shortcut;\n menuItem.appendChild(shortcut);\n }\n\n if (item.subMenu?.length) {\n const arrow = document.createElement('span');\n arrow.className = 'tbw-context-menu-arrow';\n // Use provided submenu arrow icon (string or HTMLElement)\n if (typeof submenuArrow === 'string') {\n arrow.innerHTML = submenuArrow;\n } else if (submenuArrow instanceof HTMLElement) {\n arrow.appendChild(submenuArrow.cloneNode(true));\n }\n menuItem.appendChild(arrow);\n\n // Add submenu on hover\n menuItem.addEventListener('mouseenter', () => {\n const existingSubMenu = menuItem.querySelector('.tbw-context-menu');\n if (existingSubMenu) return;\n if (!item.subMenu) return;\n\n const subMenuItems = buildMenuItems(item.subMenu, params);\n const subMenu = createMenuElement(subMenuItems, params, onAction, submenuArrow);\n subMenu.classList.add('tbw-context-submenu');\n subMenu.style.position = 'absolute';\n subMenu.style.left = '100%';\n subMenu.style.top = '0';\n menuItem.style.position = 'relative';\n menuItem.appendChild(subMenu);\n });\n\n menuItem.addEventListener('mouseleave', () => {\n const subMenu = menuItem.querySelector('.tbw-context-menu');\n if (subMenu) subMenu.remove();\n });\n }\n\n if (!disabled && item.action && !item.subMenu) {\n menuItem.addEventListener('click', (e) => {\n e.stopPropagation();\n onAction(item);\n });\n }\n\n menu.appendChild(menuItem);\n }\n\n return menu;\n}\n\n/**\n * Position the menu at the given viewport coordinates.\n * Menu is rendered in document.body with fixed positioning for top-layer behavior.\n *\n * @param menu - The menu element to position\n * @param x - Desired X coordinate (viewport)\n * @param y - Desired Y coordinate (viewport)\n */\nexport function positionMenu(menu: HTMLElement, x: number, y: number): void {\n // Use fixed positioning for top-layer behavior\n menu.style.position = 'fixed';\n menu.style.left = `${x}px`;\n menu.style.top = `${y}px`;\n menu.style.visibility = 'hidden';\n menu.style.zIndex = '10000';\n\n // Force layout to get dimensions\n const menuRect = menu.getBoundingClientRect();\n\n // Calculate visible area within viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n let left = x;\n let top = y;\n\n // Check if menu overflows right edge of viewport\n if (x + menuRect.width > viewportWidth) {\n left = x - menuRect.width;\n }\n // Check if menu overflows bottom edge of viewport\n if (y + menuRect.height > viewportHeight) {\n top = y - menuRect.height;\n }\n\n // Ensure we don't go negative\n left = Math.max(0, left);\n top = Math.max(0, top);\n\n menu.style.left = `${left}px`;\n menu.style.top = `${top}px`;\n menu.style.visibility = 'visible';\n}\n","/**\n * Context Menu Plugin (Class-based)\n *\n * Provides right-click context menu functionality for tbw-grid.\n * Supports custom menu items, submenus, icons, shortcuts, and dynamic item generation.\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport contextMenuStyles from './context-menu.css?inline';\nimport { buildMenuItems, createMenuElement, positionMenu } from './menu';\nimport type { ContextMenuConfig, ContextMenuItem, ContextMenuParams } from './types';\n\n/** Global click handler reference for cleanup */\nlet globalClickHandler: ((e: Event) => void) | null = null;\n/** Global keydown handler reference for cleanup */\nlet globalKeydownHandler: ((e: KeyboardEvent) => void) | null = null;\n/** Global stylesheet for context menu (injected once) */\nlet globalStyleSheet: HTMLStyleElement | null = null;\n/** Reference count for instances using global handlers */\nlet globalHandlerRefCount = 0;\n\n/** Default menu items when none are configured */\nconst defaultItems: ContextMenuItem[] = [\n {\n id: 'copy',\n name: 'Copy',\n shortcut: 'Ctrl+C',\n action: (params) => {\n const grid = (params as ContextMenuParams & { grid?: { plugins?: { clipboard?: { copy?: () => void } } } }).grid;\n grid?.plugins?.clipboard?.copy?.();\n },\n },\n { separator: true, id: 'sep1', name: '' },\n {\n id: 'export-csv',\n name: 'Export CSV',\n action: (params) => {\n const grid = (params as ContextMenuParams & { grid?: { plugins?: { export?: { exportCsv?: () => void } } } })\n .grid;\n grid?.plugins?.export?.exportCsv?.();\n },\n },\n];\n\n/**\n * Context Menu Plugin for tbw-grid\n *\n * Adds a customizable right-click menu to grid cells. Build anything from simple\n * copy/paste actions to complex nested menus with conditional visibility, icons,\n * and keyboard shortcuts.\n *\n * ## Installation\n *\n * ```ts\n * import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';\n * ```\n *\n * ## Menu Item Structure\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `id` | `string` | Unique item identifier |\n * | `name` | `string` | Display label |\n * | `icon` | `string` | Icon class or HTML |\n * | `shortcut` | `string` | Keyboard shortcut hint |\n * | `action` | `(params) => void` | Click handler |\n * | `disabled` | `boolean \\| (params) => boolean` | Disable condition |\n * | `visible` | `boolean \\| (params) => boolean` | Visibility condition |\n * | `items` | `MenuItem[]` | Submenu items |\n * | `separator` | `boolean` | Create a divider line |\n *\n * ## Menu Context (params)\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `rowIndex` | `number` | Clicked row index |\n * | `colIndex` | `number` | Clicked column index |\n * | `field` | `string` | Column field name |\n * | `value` | `any` | Cell value |\n * | `row` | `any` | Full row data |\n * | `column` | `ColumnConfig` | Column configuration |\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-context-menu-bg` | `var(--tbw-color-panel-bg)` | Menu background |\n * | `--tbw-context-menu-fg` | `var(--tbw-color-fg)` | Menu text color |\n * | `--tbw-context-menu-hover` | `var(--tbw-color-row-hover)` | Item hover background |\n *\n * @example Basic Context Menu\n * ```ts\n * import '@toolbox-web/grid';\n * import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';\n *\n * grid.gridConfig = {\n * plugins: [\n * new ContextMenuPlugin({\n * items: [\n * { id: 'copy', name: 'Copy', shortcut: 'Ctrl+C', action: (ctx) => navigator.clipboard.writeText(ctx.value) },\n * { separator: true, id: 'sep1', name: '' },\n * { id: 'delete', name: 'Delete', action: (ctx) => removeRow(ctx.rowIndex) },\n * ],\n * }),\n * ],\n * };\n * ```\n *\n * @example Conditional Menu Items\n * ```ts\n * new ContextMenuPlugin({\n * items: [\n * { id: 'edit', name: 'Edit', visible: (ctx) => ctx.column.editable === true },\n * { id: 'delete', name: 'Delete', disabled: (ctx) => ctx.row.locked === true },\n * ],\n * })\n * ```\n *\n * @see {@link ContextMenuConfig} for configuration options\n * @see {@link ContextMenuItem} for menu item structure\n * @see {@link ContextMenuParams} for action callback parameters\n *\n * @internal Extends BaseGridPlugin\n */\nexport class ContextMenuPlugin extends BaseGridPlugin<ContextMenuConfig> {\n /** @internal */\n readonly name = 'contextMenu';\n\n /** @internal */\n protected override get defaultConfig(): Partial<ContextMenuConfig> {\n return {\n items: defaultItems,\n };\n }\n\n // #region Internal State\n private isOpen = false;\n private position = { x: 0, y: 0 };\n private params: ContextMenuParams | null = null;\n private menuElement: HTMLElement | null = null;\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override attach(grid: import('../../core/plugin/base-plugin').GridElement): void {\n super.attach(grid);\n this.installGlobalHandlers();\n globalHandlerRefCount++;\n }\n\n /** @internal */\n override detach(): void {\n if (this.menuElement) {\n this.menuElement.remove();\n this.menuElement = null;\n }\n this.isOpen = false;\n this.params = null;\n this.uninstallGlobalHandlers();\n }\n // #endregion\n\n // #region Private Methods\n\n /**\n * CSS variables to copy from the grid element to the context menu.\n * Includes both base variables and context-menu specific overrides.\n */\n private static readonly CSS_VARS_TO_COPY = [\n // Base palette (for themes that only set base vars)\n '--tbw-color-panel-bg',\n '--tbw-color-fg',\n '--tbw-color-fg-muted',\n '--tbw-color-border',\n '--tbw-color-row-hover',\n '--tbw-color-shadow',\n '--tbw-color-danger',\n '--tbw-border-radius',\n '--tbw-font-family',\n '--tbw-font-size-sm',\n '--tbw-font-size-xs',\n '--tbw-font-size-2xs',\n '--tbw-spacing-xs',\n '--tbw-icon-size',\n '--tbw-menu-min-width',\n '--tbw-menu-item-padding',\n '--tbw-menu-item-gap',\n // Context menu specific overrides\n '--tbw-context-menu-bg',\n '--tbw-context-menu-fg',\n '--tbw-context-menu-border',\n '--tbw-context-menu-radius',\n '--tbw-context-menu-shadow',\n '--tbw-context-menu-hover',\n '--tbw-context-menu-danger',\n '--tbw-context-menu-muted',\n '--tbw-context-menu-min-width',\n '--tbw-context-menu-font-size',\n '--tbw-context-menu-font-family',\n '--tbw-context-menu-item-padding',\n '--tbw-context-menu-item-gap',\n '--tbw-context-menu-icon-size',\n '--tbw-context-menu-shortcut-size',\n '--tbw-context-menu-arrow-size',\n ];\n\n /**\n * Copy CSS custom properties from the grid element to the menu element.\n * This allows the context menu (appended to document.body) to inherit\n * theme variables set on tbw-grid.\n */\n private copyGridStyles(menuElement: HTMLElement): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n const computed = getComputedStyle(gridEl);\n const styles: string[] = [];\n\n // Copy color-scheme so light-dark() can resolve in the context menu\n const colorScheme = computed.getPropertyValue('color-scheme').trim();\n if (colorScheme) {\n styles.push(`color-scheme: ${colorScheme}`);\n }\n\n for (const varName of ContextMenuPlugin.CSS_VARS_TO_COPY) {\n const value = computed.getPropertyValue(varName).trim();\n if (value) {\n styles.push(`${varName}: ${value}`);\n }\n }\n\n if (styles.length > 0) {\n // Append to existing inline styles (don't overwrite)\n const existing = menuElement.getAttribute('style') || '';\n menuElement.setAttribute('style', existing + styles.join('; ') + ';');\n }\n }\n\n private installGlobalHandlers(): void {\n // Inject global stylesheet for context menu (once)\n // Only inject if we have valid CSS text (Vite's ?inline import)\n // When importing from source without Vite, the import is a module object, not a string\n if (\n !globalStyleSheet &&\n typeof document !== 'undefined' &&\n typeof contextMenuStyles === 'string' &&\n contextMenuStyles\n ) {\n globalStyleSheet = document.createElement('style');\n globalStyleSheet.id = 'tbw-context-menu-styles';\n globalStyleSheet.textContent = contextMenuStyles;\n document.head.appendChild(globalStyleSheet);\n }\n\n // Close menu on click outside\n if (!globalClickHandler) {\n globalClickHandler = () => {\n const menus = document.querySelectorAll('.tbw-context-menu');\n menus.forEach((menu) => menu.remove());\n };\n document.addEventListener('click', globalClickHandler);\n }\n\n // Close on escape\n if (!globalKeydownHandler) {\n globalKeydownHandler = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n const menus = document.querySelectorAll('.tbw-context-menu');\n menus.forEach((menu) => menu.remove());\n }\n };\n document.addEventListener('keydown', globalKeydownHandler);\n }\n }\n\n /**\n * Clean up global handlers when the last instance detaches.\n * Uses reference counting to ensure handlers persist while any grid uses the plugin.\n */\n private uninstallGlobalHandlers(): void {\n globalHandlerRefCount--;\n if (globalHandlerRefCount > 0) return;\n\n // Last instance - clean up all global resources\n if (globalClickHandler) {\n document.removeEventListener('click', globalClickHandler);\n globalClickHandler = null;\n }\n if (globalKeydownHandler) {\n document.removeEventListener('keydown', globalKeydownHandler);\n globalKeydownHandler = null;\n }\n if (globalStyleSheet) {\n globalStyleSheet.remove();\n globalStyleSheet = null;\n }\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n const container = gridEl.children[0];\n if (!container) return;\n\n // Check if handler already attached\n if (container.getAttribute('data-context-menu-bound') === 'true') return;\n container.setAttribute('data-context-menu-bound', 'true');\n\n container.addEventListener('contextmenu', (e: Event) => {\n const event = e as MouseEvent;\n event.preventDefault();\n\n const target = event.target as HTMLElement;\n const cell = target.closest('[data-row][data-col]');\n const header = target.closest('.header-cell');\n\n let params: ContextMenuParams;\n\n if (cell) {\n const rowIndex = parseInt(cell.getAttribute('data-row') ?? '-1', 10);\n const colIndex = parseInt(cell.getAttribute('data-col') ?? '-1', 10);\n const column = this.columns[colIndex];\n const row = this.rows[rowIndex];\n\n params = {\n row,\n rowIndex,\n column,\n columnIndex: colIndex,\n field: column?.field ?? '',\n value: row?.[column?.field as keyof typeof row] ?? null,\n isHeader: false,\n event,\n };\n } else if (header) {\n const colIndex = parseInt(header.getAttribute('data-col') ?? '-1', 10);\n const column = this.columns[colIndex];\n\n params = {\n row: null,\n rowIndex: -1,\n column,\n columnIndex: colIndex,\n field: column?.field ?? '',\n value: null,\n isHeader: true,\n event,\n };\n } else {\n return;\n }\n\n this.params = params;\n this.position = { x: event.clientX, y: event.clientY };\n\n const items = buildMenuItems(this.config.items ?? defaultItems, params);\n if (!items.length) return;\n\n if (this.menuElement) {\n this.menuElement.remove();\n }\n\n this.menuElement = createMenuElement(\n items,\n params,\n (item) => {\n if (item.action) {\n item.action(params);\n }\n this.menuElement?.remove();\n this.menuElement = null;\n this.isOpen = false;\n },\n this.gridIcons.submenuArrow,\n );\n\n document.body.appendChild(this.menuElement);\n this.copyGridStyles(this.menuElement);\n positionMenu(this.menuElement, event.clientX, event.clientY);\n this.isOpen = true;\n\n this.emit('context-menu-open', { params, items });\n });\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Programmatically show the context menu at the specified position.\n * @param x - X coordinate\n * @param y - Y coordinate\n * @param params - Partial context menu parameters\n */\n showMenu(x: number, y: number, params: Partial<ContextMenuParams>): void {\n const fullParams: ContextMenuParams = {\n row: params.row ?? null,\n rowIndex: params.rowIndex ?? -1,\n column: params.column ?? null,\n columnIndex: params.columnIndex ?? -1,\n field: params.field ?? '',\n value: params.value ?? null,\n isHeader: params.isHeader ?? false,\n event: params.event ?? new MouseEvent('contextmenu'),\n };\n\n const items = buildMenuItems(this.config.items ?? defaultItems, fullParams);\n\n if (this.menuElement) {\n this.menuElement.remove();\n }\n\n this.menuElement = createMenuElement(\n items,\n fullParams,\n (item) => {\n if (item.action) item.action(fullParams);\n this.menuElement?.remove();\n this.menuElement = null;\n this.isOpen = false;\n },\n this.gridIcons.submenuArrow,\n );\n\n document.body.appendChild(this.menuElement);\n this.copyGridStyles(this.menuElement);\n positionMenu(this.menuElement, x, y);\n this.isOpen = true;\n }\n\n /**\n * Hide the context menu.\n */\n hideMenu(): void {\n if (this.menuElement) {\n this.menuElement.remove();\n this.menuElement = null;\n this.isOpen = false;\n }\n }\n\n /**\n * Check if the context menu is currently open.\n * @returns Whether the menu is open\n */\n isMenuOpen(): boolean {\n return this.isOpen;\n }\n // #endregion\n\n // Styles are injected globally via installGlobalHandlers() since menu renders in document.body\n}\n"],"names":["buildMenuItems","items","params","item","isItemDisabled","createMenuElement","onAction","submenuArrow","DEFAULT_GRID_ICONS","menu","separator","menuItem","disabled","icon","label","shortcut","arrow","subMenuItems","subMenu","e","positionMenu","x","y","menuRect","viewportWidth","viewportHeight","left","top","globalClickHandler","globalKeydownHandler","globalStyleSheet","globalHandlerRefCount","defaultItems","ContextMenuPlugin","BaseGridPlugin","grid","menuElement","gridEl","computed","styles","colorScheme","varName","value","existing","contextMenuStyles","container","event","target","cell","header","rowIndex","colIndex","column","row","fullParams"],"mappings":"gkEAiBO,SAASA,EACdC,EACAC,EACmB,CAGnB,OAFkB,OAAOD,GAAU,WAAaA,EAAMC,CAAM,EAAID,GAE/C,OAAQE,GACnB,EAAAA,EAAK,SAAW,IAChB,OAAOA,EAAK,QAAW,YAAcA,EAAK,OAAOD,CAAM,EAE5D,CACH,CASO,SAASE,EAAeD,EAAuBD,EAAoC,CACxF,OAAIC,EAAK,WAAa,GAAa,GAC/B,OAAOA,EAAK,UAAa,WAAmBA,EAAK,SAASD,CAAM,EAC7D,EACT,CAWO,SAASG,EACdJ,EACAC,EACAI,EACAC,EAA0BC,EAAAA,mBAAmB,aAChC,CACb,MAAMC,EAAO,SAAS,cAAc,KAAK,EACzCA,EAAK,UAAY,mBACjBA,EAAK,aAAa,OAAQ,MAAM,EAEhC,UAAWN,KAAQF,EAAO,CACxB,GAAIE,EAAK,UAAW,CAClB,MAAMO,EAAY,SAAS,cAAc,KAAK,EAC9CA,EAAU,UAAY,6BACtBA,EAAU,aAAa,OAAQ,WAAW,EAC1CD,EAAK,YAAYC,CAAS,EAC1B,QACF,CAEA,MAAMC,EAAW,SAAS,cAAc,KAAK,EAC7CA,EAAS,UAAY,wBACjBR,EAAK,UAAUQ,EAAS,UAAU,IAAIR,EAAK,QAAQ,EACvDQ,EAAS,aAAa,OAAQ,UAAU,EACxCA,EAAS,aAAa,UAAWR,EAAK,EAAE,EAExC,MAAMS,EAAWR,EAAeD,EAAMD,CAAM,EAM5C,GALIU,IACFD,EAAS,UAAU,IAAI,UA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,OAAOmD,CAAU,EACvC,KAAK,aAAa,OAAA,EAClB,KAAK,YAAc,KACnB,KAAK,OAAS,EAChB,EACA,KAAK,UAAU,YAAA,EAGjB,SAAS,KAAK,YAAY,KAAK,WAAW,EAC1C,KAAK,eAAe,KAAK,WAAW,EACpClC,EAAa,KAAK,YAAaC,EAAGC,CAAC,EACnC,KAAK,OAAS,EAChB,CAKA,UAAiB,CACX,KAAK,cACP,KAAK,YAAY,OAAA,EACjB,KAAK,YAAc,KACnB,KAAK,OAAS,GAElB,CAMA,YAAsB,CACpB,OAAO,KAAK,MACd,CAIF"}
|
|
1
|
+
{"version":3,"file":"context-menu.umd.js","sources":["../../../../../libs/grid/src/lib/plugins/context-menu/menu.ts","../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"sourcesContent":["/**\n * Context Menu Rendering Logic\n *\n * Pure functions for building and positioning context menus.\n */\n\nimport type { IconValue } from '../../core/types';\nimport { DEFAULT_GRID_ICONS } from '../../core/types';\nimport type { ContextMenuItem, ContextMenuParams } from './types';\n\n/**\n * Build the visible menu items by resolving dynamic items and filtering hidden ones.\n *\n * @param items - Menu items configuration (array or factory function)\n * @param params - Context menu parameters for evaluating dynamic properties\n * @returns Filtered array of visible menu items\n */\nexport function buildMenuItems(\n items: ContextMenuItem[] | ((params: ContextMenuParams) => ContextMenuItem[]),\n params: ContextMenuParams\n): ContextMenuItem[] {\n const menuItems = typeof items === 'function' ? items(params) : items;\n\n return menuItems.filter((item) => {\n if (item.hidden === true) return false;\n if (typeof item.hidden === 'function' && item.hidden(params)) return false;\n return true;\n });\n}\n\n/**\n * Check if a menu item is disabled.\n *\n * @param item - The menu item to check\n * @param params - Context menu parameters for evaluating dynamic disabled state\n * @returns True if the item is disabled\n */\nexport function isItemDisabled(item: ContextMenuItem, params: ContextMenuParams): boolean {\n if (item.disabled === true) return true;\n if (typeof item.disabled === 'function') return item.disabled(params);\n return false;\n}\n\n/**\n * Create the menu DOM element from a list of menu items.\n *\n * @param items - Array of menu items to render\n * @param params - Context menu parameters for evaluating dynamic properties\n * @param onAction - Callback when a menu item action is triggered\n * @param submenuArrow - Optional custom submenu arrow icon\n * @returns The created menu element\n */\nexport function createMenuElement(\n items: ContextMenuItem[],\n params: ContextMenuParams,\n onAction: (item: ContextMenuItem) => void,\n submenuArrow: IconValue = DEFAULT_GRID_ICONS.submenuArrow\n): HTMLElement {\n const menu = document.createElement('div');\n menu.className = 'tbw-context-menu';\n menu.setAttribute('role', 'menu');\n\n for (const item of items) {\n if (item.separator) {\n const separator = document.createElement('div');\n separator.className = 'tbw-context-menu-separator';\n separator.setAttribute('role', 'separator');\n menu.appendChild(separator);\n continue;\n }\n\n const menuItem = document.createElement('div');\n menuItem.className = 'tbw-context-menu-item';\n if (item.cssClass) menuItem.classList.add(item.cssClass);\n menuItem.setAttribute('role', 'menuitem');\n menuItem.setAttribute('data-id', item.id);\n\n const disabled = isItemDisabled(item, params);\n if (disabled) {\n menuItem.classList.add('disabled');\n menuItem.setAttribute('aria-disabled', 'true');\n }\n\n if (item.icon) {\n const icon = document.createElement('span');\n icon.className = 'tbw-context-menu-icon';\n icon.innerHTML = item.icon;\n menuItem.appendChild(icon);\n }\n\n const label = document.createElement('span');\n label.className = 'tbw-context-menu-label';\n label.textContent = item.name;\n menuItem.appendChild(label);\n\n if (item.shortcut) {\n const shortcut = document.createElement('span');\n shortcut.className = 'tbw-context-menu-shortcut';\n shortcut.textContent = item.shortcut;\n menuItem.appendChild(shortcut);\n }\n\n if (item.subMenu?.length) {\n const arrow = document.createElement('span');\n arrow.className = 'tbw-context-menu-arrow';\n // Use provided submenu arrow icon (string or HTMLElement)\n if (typeof submenuArrow === 'string') {\n arrow.innerHTML = submenuArrow;\n } else if (submenuArrow instanceof HTMLElement) {\n arrow.appendChild(submenuArrow.cloneNode(true));\n }\n menuItem.appendChild(arrow);\n\n // Add submenu on hover\n menuItem.addEventListener('mouseenter', () => {\n const existingSubMenu = menuItem.querySelector('.tbw-context-menu');\n if (existingSubMenu) return;\n if (!item.subMenu) return;\n\n const subMenuItems = buildMenuItems(item.subMenu, params);\n const subMenu = createMenuElement(subMenuItems, params, onAction, submenuArrow);\n subMenu.classList.add('tbw-context-submenu');\n subMenu.style.position = 'absolute';\n subMenu.style.left = '100%';\n subMenu.style.top = '0';\n menuItem.style.position = 'relative';\n menuItem.appendChild(subMenu);\n });\n\n menuItem.addEventListener('mouseleave', () => {\n const subMenu = menuItem.querySelector('.tbw-context-menu');\n if (subMenu) subMenu.remove();\n });\n }\n\n if (!disabled && item.action && !item.subMenu) {\n menuItem.addEventListener('click', (e) => {\n e.stopPropagation();\n onAction(item);\n });\n }\n\n menu.appendChild(menuItem);\n }\n\n return menu;\n}\n\n/**\n * Position the menu at the given viewport coordinates.\n * Menu is rendered in document.body with fixed positioning for top-layer behavior.\n *\n * @param menu - The menu element to position\n * @param x - Desired X coordinate (viewport)\n * @param y - Desired Y coordinate (viewport)\n */\nexport function positionMenu(menu: HTMLElement, x: number, y: number): void {\n // Use fixed positioning for top-layer behavior\n menu.style.position = 'fixed';\n menu.style.left = `${x}px`;\n menu.style.top = `${y}px`;\n menu.style.visibility = 'hidden';\n menu.style.zIndex = '10000';\n\n // Force layout to get dimensions\n const menuRect = menu.getBoundingClientRect();\n\n // Calculate visible area within viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n let left = x;\n let top = y;\n\n // Check if menu overflows right edge of viewport\n if (x + menuRect.width > viewportWidth) {\n left = x - menuRect.width;\n }\n // Check if menu overflows bottom edge of viewport\n if (y + menuRect.height > viewportHeight) {\n top = y - menuRect.height;\n }\n\n // Ensure we don't go negative\n left = Math.max(0, left);\n top = Math.max(0, top);\n\n menu.style.left = `${left}px`;\n menu.style.top = `${top}px`;\n menu.style.visibility = 'visible';\n}\n","/**\n * Context Menu Plugin (Class-based)\n *\n * Provides right-click context menu functionality for tbw-grid.\n * Supports custom menu items, submenus, icons, shortcuts, and dynamic item generation.\n */\n\nimport { BaseGridPlugin } from '../../core/plugin/base-plugin';\nimport contextMenuStyles from './context-menu.css?inline';\nimport { buildMenuItems, createMenuElement, positionMenu } from './menu';\nimport type { ContextMenuConfig, ContextMenuItem, ContextMenuParams } from './types';\n\n/** Global click handler reference for cleanup */\nlet globalClickHandler: ((e: Event) => void) | null = null;\n/** Global keydown handler reference for cleanup */\nlet globalKeydownHandler: ((e: KeyboardEvent) => void) | null = null;\n/** Global stylesheet for context menu (injected once) */\nlet globalStyleSheet: HTMLStyleElement | null = null;\n/** Reference count for instances using global handlers */\nlet globalHandlerRefCount = 0;\n\n/** Default menu items when none are configured */\nconst defaultItems: ContextMenuItem[] = [\n {\n id: 'copy',\n name: 'Copy',\n shortcut: 'Ctrl+C',\n action: (params) => {\n const grid = (params as ContextMenuParams & { grid?: { plugins?: { clipboard?: { copy?: () => void } } } }).grid;\n grid?.plugins?.clipboard?.copy?.();\n },\n },\n { separator: true, id: 'sep1', name: '' },\n {\n id: 'export-csv',\n name: 'Export CSV',\n action: (params) => {\n const grid = (params as ContextMenuParams & { grid?: { plugins?: { export?: { exportCsv?: () => void } } } })\n .grid;\n grid?.plugins?.export?.exportCsv?.();\n },\n },\n];\n\n/**\n * Context Menu Plugin for tbw-grid\n *\n * Adds a customizable right-click menu to grid cells. Build anything from simple\n * copy/paste actions to complex nested menus with conditional visibility, icons,\n * and keyboard shortcuts.\n *\n * ## Installation\n *\n * ```ts\n * import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';\n * ```\n *\n * ## Menu Item Structure\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `id` | `string` | Unique item identifier |\n * | `name` | `string` | Display label |\n * | `icon` | `string` | Icon class or HTML |\n * | `shortcut` | `string` | Keyboard shortcut hint |\n * | `action` | `(params) => void` | Click handler |\n * | `disabled` | `boolean \\| (params) => boolean` | Disable condition |\n * | `visible` | `boolean \\| (params) => boolean` | Visibility condition |\n * | `items` | `MenuItem[]` | Submenu items |\n * | `separator` | `boolean` | Create a divider line |\n *\n * ## Menu Context (params)\n *\n * | Property | Type | Description |\n * |----------|------|-------------|\n * | `rowIndex` | `number` | Clicked row index |\n * | `colIndex` | `number` | Clicked column index |\n * | `field` | `string` | Column field name |\n * | `value` | `any` | Cell value |\n * | `row` | `any` | Full row data |\n * | `column` | `ColumnConfig` | Column configuration |\n *\n * ## CSS Custom Properties\n *\n * | Property | Default | Description |\n * |----------|---------|-------------|\n * | `--tbw-context-menu-bg` | `var(--tbw-color-panel-bg)` | Menu background |\n * | `--tbw-context-menu-fg` | `var(--tbw-color-fg)` | Menu text color |\n * | `--tbw-context-menu-hover` | `var(--tbw-color-row-hover)` | Item hover background |\n *\n * @example Basic Context Menu\n * ```ts\n * import '@toolbox-web/grid';\n * import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';\n *\n * grid.gridConfig = {\n * plugins: [\n * new ContextMenuPlugin({\n * items: [\n * { id: 'copy', name: 'Copy', shortcut: 'Ctrl+C', action: (ctx) => navigator.clipboard.writeText(ctx.value) },\n * { separator: true, id: 'sep1', name: '' },\n * { id: 'delete', name: 'Delete', action: (ctx) => removeRow(ctx.rowIndex) },\n * ],\n * }),\n * ],\n * };\n * ```\n *\n * @example Conditional Menu Items\n * ```ts\n * new ContextMenuPlugin({\n * items: [\n * { id: 'edit', name: 'Edit', visible: (ctx) => ctx.column.editable === true },\n * { id: 'delete', name: 'Delete', disabled: (ctx) => ctx.row.locked === true },\n * ],\n * })\n * ```\n *\n * @see {@link ContextMenuConfig} for configuration options\n * @see {@link ContextMenuItem} for menu item structure\n * @see {@link ContextMenuParams} for action callback parameters\n *\n * @internal Extends BaseGridPlugin\n */\nexport class ContextMenuPlugin extends BaseGridPlugin<ContextMenuConfig> {\n /** @internal */\n readonly name = 'contextMenu';\n\n /** @internal */\n protected override get defaultConfig(): Partial<ContextMenuConfig> {\n return {\n items: defaultItems,\n };\n }\n\n // #region Internal State\n private isOpen = false;\n private position = { x: 0, y: 0 };\n private params: ContextMenuParams | null = null;\n private menuElement: HTMLElement | null = null;\n // #endregion\n\n // #region Lifecycle\n\n /** @internal */\n override attach(grid: import('../../core/plugin/base-plugin').GridElement): void {\n super.attach(grid);\n this.installGlobalHandlers();\n globalHandlerRefCount++;\n }\n\n /** @internal */\n override detach(): void {\n if (this.menuElement) {\n this.menuElement.remove();\n this.menuElement = null;\n }\n this.isOpen = false;\n this.params = null;\n this.uninstallGlobalHandlers();\n }\n // #endregion\n\n // #region Private Methods\n\n /**\n * CSS variables to copy from the grid element to the context menu.\n * Includes both base variables and context-menu specific overrides.\n */\n private static readonly CSS_VARS_TO_COPY = [\n // Base palette (for themes that only set base vars)\n '--tbw-color-panel-bg',\n '--tbw-color-fg',\n '--tbw-color-fg-muted',\n '--tbw-color-border',\n '--tbw-color-row-hover',\n '--tbw-color-shadow',\n '--tbw-color-danger',\n '--tbw-border-radius',\n '--tbw-font-family',\n '--tbw-font-size-sm',\n '--tbw-font-size-xs',\n '--tbw-font-size-2xs',\n '--tbw-spacing-xs',\n '--tbw-icon-size',\n '--tbw-menu-min-width',\n '--tbw-menu-item-padding',\n '--tbw-menu-item-gap',\n // Context menu specific overrides\n '--tbw-context-menu-bg',\n '--tbw-context-menu-fg',\n '--tbw-context-menu-border',\n '--tbw-context-menu-radius',\n '--tbw-context-menu-shadow',\n '--tbw-context-menu-hover',\n '--tbw-context-menu-danger',\n '--tbw-context-menu-muted',\n '--tbw-context-menu-min-width',\n '--tbw-context-menu-font-size',\n '--tbw-context-menu-font-family',\n '--tbw-context-menu-item-padding',\n '--tbw-context-menu-item-gap',\n '--tbw-context-menu-icon-size',\n '--tbw-context-menu-shortcut-size',\n '--tbw-context-menu-arrow-size',\n ];\n\n /**\n * Copy CSS custom properties from the grid element to the menu element.\n * This allows the context menu (appended to document.body) to inherit\n * theme variables set on tbw-grid.\n */\n private copyGridStyles(menuElement: HTMLElement): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n const computed = getComputedStyle(gridEl);\n const styles: string[] = [];\n\n // Copy color-scheme so light-dark() can resolve in the context menu\n const colorScheme = computed.getPropertyValue('color-scheme').trim();\n if (colorScheme) {\n styles.push(`color-scheme: ${colorScheme}`);\n }\n\n for (const varName of ContextMenuPlugin.CSS_VARS_TO_COPY) {\n const value = computed.getPropertyValue(varName).trim();\n if (value) {\n styles.push(`${varName}: ${value}`);\n }\n }\n\n if (styles.length > 0) {\n // Append to existing inline styles (don't overwrite)\n const existing = menuElement.getAttribute('style') || '';\n menuElement.setAttribute('style', existing + styles.join('; ') + ';');\n }\n }\n\n private installGlobalHandlers(): void {\n // Inject global stylesheet for context menu (once)\n // Only inject if we have valid CSS text (Vite's ?inline import)\n // When importing from source without Vite, the import is a module object, not a string\n if (\n !globalStyleSheet &&\n typeof document !== 'undefined' &&\n typeof contextMenuStyles === 'string' &&\n contextMenuStyles\n ) {\n globalStyleSheet = document.createElement('style');\n globalStyleSheet.id = 'tbw-context-menu-styles';\n globalStyleSheet.textContent = contextMenuStyles;\n document.head.appendChild(globalStyleSheet);\n }\n\n // Close menu on click outside\n if (!globalClickHandler) {\n globalClickHandler = () => {\n const menus = document.querySelectorAll('.tbw-context-menu');\n menus.forEach((menu) => menu.remove());\n };\n document.addEventListener('click', globalClickHandler);\n }\n\n // Close on escape\n if (!globalKeydownHandler) {\n globalKeydownHandler = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n const menus = document.querySelectorAll('.tbw-context-menu');\n menus.forEach((menu) => menu.remove());\n }\n };\n document.addEventListener('keydown', globalKeydownHandler);\n }\n }\n\n /**\n * Clean up global handlers when the last instance detaches.\n * Uses reference counting to ensure handlers persist while any grid uses the plugin.\n */\n private uninstallGlobalHandlers(): void {\n globalHandlerRefCount--;\n if (globalHandlerRefCount > 0) return;\n\n // Last instance - clean up all global resources\n if (globalClickHandler) {\n document.removeEventListener('click', globalClickHandler);\n globalClickHandler = null;\n }\n if (globalKeydownHandler) {\n document.removeEventListener('keydown', globalKeydownHandler);\n globalKeydownHandler = null;\n }\n if (globalStyleSheet) {\n globalStyleSheet.remove();\n globalStyleSheet = null;\n }\n }\n // #endregion\n\n // #region Hooks\n\n /** @internal */\n override afterRender(): void {\n const gridEl = this.gridElement;\n if (!gridEl) return;\n\n // Use querySelector instead of children[0] because light DOM children\n // (e.g. <tbw-grid-column>) are re-appended before .tbw-grid-root, making\n // children[0] point to a declarative element instead of the data container.\n const container = gridEl.querySelector('.tbw-grid-root');\n if (!container) return;\n\n // Check if handler already attached\n if (container.getAttribute('data-context-menu-bound') === 'true') return;\n container.setAttribute('data-context-menu-bound', 'true');\n\n container.addEventListener('contextmenu', (e: Event) => {\n const event = e as MouseEvent;\n event.preventDefault();\n\n const target = event.target as HTMLElement;\n const cell = target.closest('[data-row][data-col]');\n const header = target.closest('.header-cell');\n\n let params: ContextMenuParams;\n\n if (cell) {\n const rowIndex = parseInt(cell.getAttribute('data-row') ?? '-1', 10);\n const colIndex = parseInt(cell.getAttribute('data-col') ?? '-1', 10);\n const column = this.columns[colIndex];\n const row = this.rows[rowIndex];\n\n params = {\n row,\n rowIndex,\n column,\n columnIndex: colIndex,\n field: column?.field ?? '',\n value: row?.[column?.field as keyof typeof row] ?? null,\n isHeader: false,\n event,\n };\n } else if (header) {\n const colIndex = parseInt(header.getAttribute('data-col') ?? '-1', 10);\n const column = this.columns[colIndex];\n\n params = {\n row: null,\n rowIndex: -1,\n column,\n columnIndex: colIndex,\n field: column?.field ?? '',\n value: null,\n isHeader: true,\n event,\n };\n } else {\n return;\n }\n\n this.params = params;\n this.position = { x: event.clientX, y: event.clientY };\n\n const items = buildMenuItems(this.config.items ?? defaultItems, params);\n if (!items.length) return;\n\n if (this.menuElement) {\n this.menuElement.remove();\n }\n\n this.menuElement = createMenuElement(\n items,\n params,\n (item) => {\n if (item.action) {\n item.action(params);\n }\n this.menuElement?.remove();\n this.menuElement = null;\n this.isOpen = false;\n },\n this.gridIcons.submenuArrow,\n );\n\n document.body.appendChild(this.menuElement);\n this.copyGridStyles(this.menuElement);\n positionMenu(this.menuElement, event.clientX, event.clientY);\n this.isOpen = true;\n\n this.emit('context-menu-open', { params, items });\n });\n }\n // #endregion\n\n // #region Public API\n\n /**\n * Programmatically show the context menu at the specified position.\n * @param x - X coordinate\n * @param y - Y coordinate\n * @param params - Partial context menu parameters\n */\n showMenu(x: number, y: number, params: Partial<ContextMenuParams>): void {\n const fullParams: ContextMenuParams = {\n row: params.row ?? null,\n rowIndex: params.rowIndex ?? -1,\n column: params.column ?? null,\n columnIndex: params.columnIndex ?? -1,\n field: params.field ?? '',\n value: params.value ?? null,\n isHeader: params.isHeader ?? false,\n event: params.event ?? new MouseEvent('contextmenu'),\n };\n\n const items = buildMenuItems(this.config.items ?? defaultItems, fullParams);\n\n if (this.menuElement) {\n this.menuElement.remove();\n }\n\n this.menuElement = createMenuElement(\n items,\n fullParams,\n (item) => {\n if (item.action) item.action(fullParams);\n this.menuElement?.remove();\n this.menuElement = null;\n this.isOpen = false;\n },\n this.gridIcons.submenuArrow,\n );\n\n document.body.appendChild(this.menuElement);\n this.copyGridStyles(this.menuElement);\n positionMenu(this.menuElement, x, y);\n this.isOpen = true;\n }\n\n /**\n * Hide the context menu.\n */\n hideMenu(): void {\n if (this.menuElement) {\n this.menuElement.remove();\n this.menuElement = null;\n this.isOpen = false;\n }\n }\n\n /**\n * Check if the context menu is currently open.\n * @returns Whether the menu is open\n */\n isMenuOpen(): boolean {\n return this.isOpen;\n }\n // #endregion\n\n // Styles are injected globally via installGlobalHandlers() since menu renders in document.body\n}\n"],"names":["buildMenuItems","items","params","item","isItemDisabled","createMenuElement","onAction","submenuArrow","DEFAULT_GRID_ICONS","menu","separator","menuItem","disabled","icon","label","shortcut","arrow","subMenuItems","subMenu","e","positionMenu","x","y","menuRect","viewportWidth","viewportHeight","left","top","globalClickHandler","globalKeydownHandler","globalStyleSheet","globalHandlerRefCount","defaultItems","ContextMenuPlugin","BaseGridPlugin","grid","menuElement","gridEl","computed","styles","colorScheme","varName","value","existing","contextMenuStyles","container","event","target","cell","header","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,YAAY,OAAA,EACjB,KAAK,YAAc,KACnB,KAAK,OAAS,GAElB,CAMA,YAAsB,CACpB,OAAO,KAAK,MACd,CAIF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(v,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("../../core/internal/keyboard"),require("../../core/plugin/base-plugin")):typeof define=="function"&&define.amd?define(["exports","../../core/internal/keyboard","../../core/plugin/base-plugin"],E):(v=typeof globalThis<"u"?globalThis:v||self,E(v.TbwGridPlugin_editing={},v.TbwGrid,v.TbwGrid))})(this,(function(v,E,T){"use strict";const I="@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171)}tbw-grid .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}tbw-grid .data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}";function P(o){const e=o.options;return e?typeof e=="function"?e():e:[]}function q(o){return e=>{const t=o.editorParams,i=document.createElement("input");i.type="number",i.value=e.value!=null?String(e.value):"",t?.min!==void 0&&(i.min=String(t.min)),t?.max!==void 0&&(i.max=String(t.max)),t?.step!==void 0&&(i.step=String(t.step)),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>e.commit(i.value===""?null:Number(i.value));return i.addEventListener("blur",s),i.addEventListener("keydown",n=>{n.key==="Enter"&&s(),n.key==="Escape"&&e.cancel()}),i}}function O(){return o=>{const e=document.createElement("input");return e.type="checkbox",e.checked=!!o.value,e.addEventListener("change",()=>o.commit(e.checked)),e}}function B(o){return e=>{const t=o.editorParams,i=document.createElement("input");i.type="date",e.value instanceof Date?i.valueAsDate=e.value:typeof e.value=="string"&&e.value&&(i.value=e.value.split("T")[0]),t?.min&&(i.min=t.min),t?.max&&(i.max=t.max),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>{typeof e.value=="string"?e.commit(i.value):e.commit(i.valueAsDate)};return i.addEventListener("change",s),i.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),i}}function D(o){return e=>{const t=o.editorParams,i=document.createElement("select");if(o.multi&&(i.multiple=!0),t?.includeEmpty){const l=document.createElement("option");l.value="",l.textContent=t.emptyLabel??"",i.appendChild(l)}P(o).forEach(l=>{const r=document.createElement("option");r.value=String(l.value),r.textContent=l.label,(o.multi&&Array.isArray(e.value)&&e.value.includes(l.value)||!o.multi&&e.value===l.value)&&(r.selected=!0),i.appendChild(r)});const n=()=>{if(o.multi){const l=Array.from(i.selectedOptions).map(r=>r.value);e.commit(l)}else e.commit(i.value)};return i.addEventListener("change",n),i.addEventListener("blur",n),i.addEventListener("keydown",l=>{l.key==="Escape"&&e.cancel()}),i}}function M(o){return e=>{const t=o.editorParams,i=document.createElement("input");i.type="text",i.value=e.value!=null?String(e.value):"",t?.maxLength!==void 0&&(i.maxLength=t.maxLength),t?.pattern&&(i.pattern=t.pattern),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>{const n=i.value;typeof e.value=="number"&&n!==""?e.commit(Number(n)):e.commit(n)};return i.addEventListener("blur",s),i.addEventListener("keydown",n=>{n.key==="Enter"&&s(),n.key==="Escape"&&e.cancel()}),i}}function L(o){switch(o.type){case"number":return q(o);case"boolean":return O();case"date":return B(o);case"select":return D(o);default:return M(o)}}const _='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function x(o,e){if(e.editor)return e.editor;if(e.__editorTemplate)return"template";if(!e.type)return;const i=o.effectiveConfig?.typeDefaults;if(i?.[e.type]?.editor)return i[e.type].editor;const s=o.__frameworkAdapter;if(s?.getTypeDefault){const n=s.getTypeDefault(e.type);if(n?.editor)return n.editor}}function C(o){return!(typeof o!="string"||o==="__proto__"||o==="constructor"||o==="prototype")}function G(o){const e=(o.__editingCellCount??0)+1;o.__editingCellCount=e,o.setAttribute("data-has-editing","")}function H(o){o.__editingCellCount=0,o.removeAttribute("data-has-editing")}function R(o,e,t){return o instanceof HTMLInputElement?o.type==="checkbox"?o.checked:o.type==="number"?o.value===""?null:Number(o.value):o.type==="date"?typeof t=="string"?o.value:o.valueAsDate:typeof t=="number"?o.value===""?null:Number(o.value):t==null&&o.value===""?t:o.value:e?.type==="number"&&o.value!==""||typeof t=="number"&&o.value!==""?Number(o.value):t==null&&o.value===""?t:o.value}function A(o){}function N(o,e,t,i){const s=o.querySelector("input,textarea,select");s&&(s.addEventListener("blur",()=>{t(R(s,e,i))}),s instanceof HTMLInputElement&&s.type==="checkbox"?s.addEventListener("change",()=>t(s.checked)):s instanceof HTMLSelectElement&&s.addEventListener("change",()=>t(R(s,e,i))))}class $ extends T.BaseGridPlugin{static manifest={ownedProperties:[{property:"editable",level:"column",description:'the "editable" column property',isUsed:e=>e===!0},{property:"editor",level:"column",description:'the "editor" column property'},{property:"editorParams",level:"column",description:'the "editorParams" column property'}],events:[{type:"cell-edit-committed",description:"Emitted when a cell edit is committed (for plugin-to-plugin coordination)"}],queries:[{type:"isEditing",description:"Returns whether any cell is currently being edited"}]};name="editing";styles=I;get defaultConfig(){return{editOn:"click"}}#e=-1;#o=-1;#r=new Map;#i=new Set;#s=new Set;#l=!1;#a=-1;#t=new Map;attach(e){super.attach(e);const t=this.disconnectSignal,i=e;i._activeEditRows=-1,i._rowEditSnapshots=new Map,Object.defineProperty(e,"changedRows",{get:()=>this.changedRows,configurable:!0}),Object.defineProperty(e,"changedRowIds",{get:()=>this.changedRowIds,configurable:!0}),e.resetChangedRows=s=>this.resetChangedRows(s),e.beginBulkEdit=(s,n)=>{n&&this.beginCellEdit(s,n)},document.addEventListener("keydown",s=>{if(s.key==="Escape"&&this.#e!==-1){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(s)===!1)return;this.#n(this.#e,!0)}},{capture:!0,signal:t}),document.addEventListener("mousedown",s=>{if(this.#e===-1)return;const n=i.findRenderedRowElement?.(this.#e);!n||(s.composedPath&&s.composedPath()||[]).includes(n)||this.config.onBeforeEditClose&&this.config.onBeforeEditClose(s)===!1||queueMicrotask(()=>{this.#e!==-1&&this.#n(this.#e,!1)})},{signal:t})}detach(){this.#e=-1,this.#o=-1,this.#r.clear(),this.#i.clear(),this.#s.clear(),super.detach()}handleQuery(e){if(e.type==="isEditing")return this.#e!==-1}onCellClick(e){const t=this.grid,i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual"||i!=="click"&&i!=="dblclick")return!1;const s=e.originalEvent.type==="dblclick";if(i==="click"&&s||i==="dblclick"&&!s)return!1;const{rowIndex:n}=e;return t._columns?.some(r=>r.editable)?(e.originalEvent.stopPropagation(),this.beginBulkEdit(n),!0):!1}onKeyDown(e){const t=this.grid;if(e.key==="Escape"&&this.#e!==-1)return this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1||this.#n(this.#e,!0),!0;if((e.key==="ArrowUp"||e.key==="ArrowDown")&&this.#e!==-1){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1)return!0;const i=t._rows.length-1,s=this.#e;return this.#n(s,!1),e.key==="ArrowDown"?t._focusRow=Math.min(i,t._focusRow+1):t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault(),E.ensureCellVisible(t),this.requestAfterRender(),!0}if(e.key==="Tab"&&this.#e!==-1){e.preventDefault();const i=!e.shiftKey;return this.#m(i),!0}if(e.key===" "||e.key==="Spacebar"){if(this.#e!==-1)return!1;const i=t._focusRow,s=t._focusCol;if(i>=0&&s>=0){const n=t._visibleColumns[s],l=t._rows[i];if(n?.editable&&n.type==="boolean"&&l){const r=n.field;if(C(r)){const d=!l[r];return this.#u(i,n,d,l),e.preventDefault(),this.requestRender(),!0}}}return!1}if(e.key==="Enter"&&!e.shiftKey){if(this.#e!==-1)return!!(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1);const i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual")return!1;const s=t._focusRow,n=t._focusCol;if(s>=0&&t._columns?.some(r=>r.editable)){const r=t._visibleColumns[n],a=t._rows[s],d=r?.field??"",c=d&&a?a[d]:void 0,g=this.gridElement.querySelector(`[data-row="${s}"][data-col="${n}"]`),u=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,detail:{rowIndex:s,colIndex:n,field:d,value:c,row:a,cellEl:g,trigger:"keyboard",originalEvent:e}});this.gridElement.dispatchEvent(u);const m=new CustomEvent("activate-cell",{cancelable:!0,bubbles:!0,detail:{row:s,col:n}});return this.gridElement.dispatchEvent(m),u.defaultPrevented||m.defaultPrevented?(e.preventDefault(),!0):(this.beginBulkEdit(s),!0)}return!1}return!1}processColumns(e){const t=this.grid,i=t.effectiveConfig?.typeDefaults,s=t.__frameworkAdapter;return!i&&!s?.getTypeDefault?e:e.map(n=>{if(!n.type)return n;let l;if(i?.[n.type]?.editorParams&&(l=i[n.type].editorParams),!l&&s?.getTypeDefault){const r=s.getTypeDefault(n.type);r?.editorParams&&(l=r.editorParams)}return l?{...n,editorParams:{...l,...n.editorParams}}:n})}afterRender(){const e=this.grid;if(this.#l&&(this.#l=!1,this.#g(e)),this.#a!==-1){const t=this.#a;this.#a=-1,e.animateRow?.(t,"change")}if(this.#s.size!==0)for(const t of this.#s){const[i,s]=t.split(":"),n=parseInt(i,10),l=parseInt(s,10),r=e.findRenderedRowElement?.(n);if(!r)continue;const a=r.querySelector(`.cell[data-col="${l}"]`);if(!a||a.classList.contains("editing"))continue;const d=e._rows[n],c=e._visibleColumns[l];d&&c&&this.#f(d,n,c,l,a,!0)}}onScrollRender(){this.afterRender()}get changedRows(){const e=[];for(const t of this.#i){const i=this.grid.getRow(t);i&&e.push(i)}return e}get changedRowIds(){return Array.from(this.#i)}get activeEditRow(){return this.#e}get activeEditCol(){return this.#o}isRowEditing(e){return this.#e===e}isCellEditing(e,t){return this.#s.has(`${e}:${t}`)}isRowChanged(e){const t=this.grid,i=t._rows[e];if(!i)return!1;try{const s=t.getRowId?.(i);return s?this.#i.has(s):!1}catch{return!1}}isRowChangedById(e){return this.#i.has(e)}setInvalid(e,t,i=""){let s=this.#t.get(e);s||(s=new Map,this.#t.set(e,s)),s.set(t,i),this.#d(e,t,!0)}clearInvalid(e,t){const i=this.#t.get(e);i&&(i.delete(t),i.size===0&&this.#t.delete(e)),this.#d(e,t,!1)}clearRowInvalid(e){const t=this.#t.get(e);if(t){const i=Array.from(t.keys());this.#t.delete(e),i.forEach(s=>this.#d(e,s,!1))}}clearAllInvalid(){const e=Array.from(this.#t.entries());this.#t.clear(),e.forEach(([t,i])=>{i.forEach((s,n)=>this.#d(t,n,!1))})}isCellInvalid(e,t){return this.#t.get(e)?.has(t)??!1}getInvalidMessage(e,t){return this.#t.get(e)?.get(t)}hasInvalidCells(e){const t=this.#t.get(e);return t?t.size>0:!1}getInvalidFields(e){return new Map(this.#t.get(e)??[])}#d(e,t,i){const s=this.grid,n=s._visibleColumns?.findIndex(c=>c.field===t);if(n===-1||n===void 0)return;const r=s._rows?.findIndex(c=>{try{return s.getRowId?.(c)===e}catch{return!1}});if(r===-1||r===void 0)return;const d=s.findRenderedRowElement?.(r)?.querySelector(`.cell[data-col="${n}"]`);if(d)if(i){d.setAttribute("data-invalid","true");const c=this.#t.get(e)?.get(t);c&&d.setAttribute("title",c)}else d.removeAttribute("data-invalid"),d.removeAttribute("title")}resetChangedRows(e){const t=this.changedRows,i=this.changedRowIds;this.#i.clear(),this.#c(),e||this.emit("changed-rows-reset",{rows:t,ids:i}),this.grid._rowPool?.forEach(n=>n.classList.remove("changed"))}beginCellEdit(e,t){const i=this.grid,s=i._visibleColumns.findIndex(a=>a.field===t);if(s===-1||!i._visibleColumns[s]?.editable)return;const r=i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${s}"]`);r&&this.#p(e,s,r)}beginBulkEdit(e){const t=this.grid;if((this.config.editOn??t.effectiveConfig?.editOn)===!1||!t._columns?.some(r=>r.editable))return;const n=t.findRenderedRowElement?.(e);if(!n)return;const l=t._rows[e];this.#h(e,l),Array.from(n.children).forEach((r,a)=>{const d=t._visibleColumns[a];if(d?.editable){const c=r;c.classList.contains("editing")||this.#f(l,e,d,a,c,!0)}}),setTimeout(()=>{let r=n.querySelector(`.cell[data-col="${t._focusCol}"]`);if(r?.classList.contains("editing")||(r=n.querySelector(".cell.editing")),r?.classList.contains("editing")){const a=r.querySelector(_);try{a?.focus({preventScroll:!0})}catch{}}},0)}commitActiveRowEdit(){this.#e!==-1&&this.#n(this.#e,!1)}cancelActiveRowEdit(){this.#e!==-1&&this.#n(this.#e,!0)}#p(e,t,i){const s=this.grid,n=s._rows[e],l=s._visibleColumns[t];!n||!l?.editable||i.classList.contains("editing")||(this.#e!==e&&this.#h(e,n),this.#o=t,this.#f(n,e,l,t,i,!1))}#m(e){const t=this.grid,i=t._rows,s=this.#e,n=t._visibleColumns.map((d,c)=>d.editable?c:-1).filter(d=>d>=0);if(n.length===0)return;const r=n.indexOf(t._focusCol)+(e?1:-1);if(r>=0&&r<n.length){t._focusCol=n[r];const c=t.findRenderedRowElement?.(s)?.querySelector(`.cell[data-col="${n[r]}"]`);c?.classList.contains("editing")&&c.querySelector(_)?.focus({preventScroll:!0}),E.ensureCellVisible(t,{forceHorizontalScroll:!0});return}const a=s+(e?1:-1);a>=0&&a<i.length&&(this.#n(s,!1),t._focusRow=a,t._focusCol=e?n[0]:n[n.length-1],this.beginBulkEdit(a),E.ensureCellVisible(t,{forceHorizontalScroll:!0}))}#c(){const e=this.grid;e._activeEditRows=this.#e,e._rowEditSnapshots=this.#r}#h(e,t){this.#e!==e&&(this.#r.set(e,{...t}),this.#e=e,this.#c())}#n(e,t){if(this.#e!==e)return;const i=this.grid,s=this.#r.get(e),n=i._rows[e],l=i.findRenderedRowElement?.(e);let r;if(n)try{r=i.getRowId?.(n)}catch{}if(!t&&l&&n&&l.querySelectorAll(".cell.editing").forEach(d=>{const c=Number(d.getAttribute("data-col"));if(isNaN(c))return;const g=i._visibleColumns[c];if(!g||d.hasAttribute("data-editor-managed"))return;const u=d.querySelector("input,textarea,select");if(u){const m=g.field,p=n[m],h=R(u,g,p);p!==h&&this.#u(e,g,h,n)}}),t&&s&&n)Object.keys(s).forEach(a=>{n[a]=s[a]}),r&&(this.#i.delete(r),this.clearRowInvalid(r));else if(!t&&n){const a=this.#b(s,n),d=r?this.#i.has(r):a,c=this.emitCancelable("row-commit",{rowIndex:e,rowId:r??"",row:n,oldValue:s,newValue:n,changed:d,changedRows:this.changedRows,changedRowIds:this.changedRowIds});c&&s?(Object.keys(s).forEach(g=>{n[g]=s[g]}),r&&(this.#i.delete(r),this.clearRowInvalid(r))):!c&&a&&this.isAnimationEnabled&&(this.#a=e)}this.#r.delete(e),this.#e=-1,this.#o=-1,this.#c();for(const a of this.#s)a.startsWith(`${e}:`)&&this.#s.delete(a);l&&(l.querySelectorAll(".cell.editing").forEach(a=>{a.classList.remove("editing"),H(a.parentElement)}),this.requestRender()),this.#l=!0,l||(this.#g(i),this.#l=!1)}#u(e,t,i,s){const n=t.field;if(!C(n))return;const l=s[n];if(l===i)return;const r=this.grid;let a;try{a=this.grid.getRowId(s)}catch{}const d=a?!this.#i.has(a):!0,c=a?h=>this.grid.updateRow(a,h,"cascade"):A;let g=!1;const u=a?h=>{g=!0,this.setInvalid(a,n,h??"")}:()=>{};if(this.emitCancelable("cell-commit",{row:s,rowId:a??"",field:n,oldValue:l,value:i,rowIndex:e,changedRows:this.changedRows,changedRowIds:this.changedRowIds,firstTimeForRow:d,updateRow:c,setInvalid:u}))return;a&&!g&&this.isCellInvalid(a,n)&&this.clearInvalid(a,n),s[n]=i,a&&this.#i.add(a),this.#c(),this.emitPluginEvent("cell-edit-committed",{rowIndex:e,field:n,oldValue:l,newValue:i});const p=r.findRenderedRowElement?.(e);p&&p.classList.add("changed")}#f(e,t,i,s,n,l){if(!i.editable||n.classList.contains("editing"))return;let r;try{r=this.grid.getRowId(e)}catch{}const a=r?f=>this.grid.updateRow(r,f,"cascade"):A,d=C(i.field)?e[i.field]:void 0;n.classList.add("editing"),this.#s.add(`${t}:${s}`);const c=n.parentElement;c&&G(c);let g=!1;const u=f=>{g||this.#e===-1||this.#u(t,i,f,e)},m=()=>{g=!0,C(i.field)&&(e[i.field]=d)},p=document.createElement("div");p.className="tbw-editor-host",n.innerHTML="",n.appendChild(p),p.addEventListener("keydown",f=>{if(f.key==="Enter"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(f)===!1)return;f.stopPropagation(),f.preventDefault(),g=!0,this.#n(t,!1)}if(f.key==="Escape"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(f)===!1)return;f.stopPropagation(),f.preventDefault(),m(),this.#n(t,!0)}});const h=i,y=h.__editorTemplate,b=x(this.grid,h)??L(i),S=d;if(b==="template"&&y)this.#w(p,h,e,d,u,m,l,t);else if(typeof b=="string"){const f=document.createElement(b);f.value=S,f.addEventListener("change",()=>u(f.value)),p.appendChild(f),l||queueMicrotask(()=>{p.querySelector(_)?.focus({preventScroll:!0})})}else if(typeof b=="function"){const f={row:e,rowId:r??"",value:S,field:i.field,column:i,commit:u,cancel:m,updateRow:a},w=b(f);typeof w=="string"?(p.innerHTML=w,N(p,i,u,d)):w instanceof Node&&(p.appendChild(w),w instanceof HTMLInputElement||w instanceof HTMLSelectElement||w instanceof HTMLTextAreaElement||n.setAttribute("data-editor-managed","")),l||queueMicrotask(()=>{p.querySelector(_)?.focus({preventScroll:!0})})}else if(b&&typeof b=="object"){const f=document.createElement("div");f.setAttribute("data-external-editor",""),f.setAttribute("data-field",i.field),p.appendChild(f),n.setAttribute("data-editor-managed","");const w={row:e,rowId:r??"",value:S,field:i.field,column:i,commit:u,cancel:m,updateRow:a};if(b.mount)try{b.mount({placeholder:f,context:w,spec:b})}catch(k){console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,k)}else this.grid.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:f,spec:b,context:w}}))}}#w(e,t,i,s,n,l,r,a){const d=t.__editorTemplate;if(!d)return;const c=d.cloneNode(!0),g=t.__compiledEditor;g?c.innerHTML=g({row:i,value:s,field:t.field,column:t,commit:n,cancel:l}):c.querySelectorAll("*").forEach(m=>{m.childNodes.length===1&&m.firstChild?.nodeType===Node.TEXT_NODE&&(m.textContent=m.textContent?.replace(/{{\s*value\s*}}/g,s==null?"":String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(p,h)=>{if(!C(h))return"";const y=i[h];return y==null?"":String(y)})||"")});const u=c.querySelector("input,textarea,select");if(u){u instanceof HTMLInputElement&&u.type==="checkbox"?u.checked=!!s:u.value=String(s??"");let m=!1;u.addEventListener("blur",()=>{m||n(R(u,t,s))}),u.addEventListener("keydown",p=>{const h=p;if(h.key==="Enter"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(h)===!1)return;h.stopPropagation(),h.preventDefault(),m=!0,n(R(u,t,s)),this.#n(a,!1)}if(h.key==="Escape"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(h)===!1)return;h.stopPropagation(),h.preventDefault(),l(),this.#n(a,!0)}}),u instanceof HTMLInputElement&&u.type==="checkbox"&&u.addEventListener("change",()=>n(u.checked)),r||setTimeout(()=>u.focus({preventScroll:!0}),0)}e.appendChild(c)}#b(e,t){if(!e)return!1;const i=e,s=t,n=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of n)if(i[l]!==s[l])return!0;return!1}#g(e){queueMicrotask(()=>{try{const t=e._focusRow,i=e._focusCol,s=e.findRenderedRowElement?.(t);if(s){Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(l=>l.classList.remove("cell-focus"));const n=s.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);n&&(n.classList.add("cell-focus"),n.setAttribute("aria-selected","true"),n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0}))}}catch{}})}}v.EditingPlugin=$,v.defaultEditorFor=L,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(v,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("../../core/internal/keyboard"),require("../../core/internal/rows"),require("../../core/plugin/base-plugin")):typeof define=="function"&&define.amd?define(["exports","../../core/internal/keyboard","../../core/internal/rows","../../core/plugin/base-plugin"],y):(v=typeof globalThis<"u"?globalThis:v||self,y(v.TbwGridPlugin_editing={},v.TbwGrid,v.TbwGrid,v.TbwGrid))})(this,(function(v,y,b,A){"use strict";const I="@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171)}tbw-grid:not(.tbw-grid-mode) .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}tbw-grid .data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}";function O(l){const e=l.options;return e?typeof e=="function"?e():e:[]}function q(l){return e=>{const t=l.editorParams,i=document.createElement("input");i.type="number",i.value=e.value!=null?String(e.value):"",t?.min!==void 0&&(i.min=String(t.min)),t?.max!==void 0&&(i.max=String(t.max)),t?.step!==void 0&&(i.step=String(t.step)),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>e.commit(i.value===""?null:Number(i.value));return i.addEventListener("blur",s),i.addEventListener("keydown",n=>{n.key==="Enter"&&s(),n.key==="Escape"&&e.cancel()}),i}}function D(){return l=>{const e=document.createElement("input");return e.type="checkbox",e.checked=!!l.value,e.addEventListener("change",()=>l.commit(e.checked)),e}}function P(l){return e=>{const t=l.editorParams,i=document.createElement("input");i.type="date",e.value instanceof Date?i.valueAsDate=e.value:typeof e.value=="string"&&e.value&&(i.value=e.value.split("T")[0]),t?.min&&(i.min=t.min),t?.max&&(i.max=t.max),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>{typeof e.value=="string"?e.commit(i.value):e.commit(i.valueAsDate)};return i.addEventListener("change",s),i.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),i}}function B(l){return e=>{const t=l.editorParams,i=document.createElement("select");if(l.multi&&(i.multiple=!0),t?.includeEmpty){const r=document.createElement("option");r.value="",r.textContent=t.emptyLabel??"",i.appendChild(r)}O(l).forEach(r=>{const o=document.createElement("option");o.value=String(r.value),o.textContent=r.label,(l.multi&&Array.isArray(e.value)&&e.value.includes(r.value)||!l.multi&&e.value===r.value)&&(o.selected=!0),i.appendChild(o)});const n=()=>{if(l.multi){const r=Array.from(i.selectedOptions).map(o=>o.value);e.commit(r)}else e.commit(i.value)};return i.addEventListener("change",n),i.addEventListener("blur",n),i.addEventListener("keydown",r=>{r.key==="Escape"&&e.cancel()}),i}}function M(l){return e=>{const t=l.editorParams,i=document.createElement("input");i.type="text",i.value=e.value!=null?String(e.value):"",t?.maxLength!==void 0&&(i.maxLength=t.maxLength),t?.pattern&&(i.pattern=t.pattern),t?.placeholder&&(i.placeholder=t.placeholder);const s=()=>{const n=i.value;typeof e.value=="number"&&n!==""?e.commit(Number(n)):e.commit(n)};return i.addEventListener("blur",s),i.addEventListener("keydown",n=>{n.key==="Enter"&&s(),n.key==="Escape"&&e.cancel()}),i}}function k(l){switch(l.type){case"number":return q(l);case"boolean":return D();case"date":return P(l);case"select":return B(l);default:return M(l)}}function x(l,e){if(e.editor)return e.editor;if(e.__editorTemplate)return"template";if(!e.type)return;const i=l.effectiveConfig?.typeDefaults;if(i?.[e.type]?.editor)return i[e.type].editor;const s=l.__frameworkAdapter;if(s?.getTypeDefault){const n=s.getTypeDefault(e.type);if(n?.editor)return n.editor}}function _(l){return!(typeof l!="string"||l==="__proto__"||l==="constructor"||l==="prototype")}function G(l){const e=(l.__editingCellCount??0)+1;l.__editingCellCount=e,l.setAttribute("data-has-editing","")}function H(l){l.__editingCellCount=0,l.removeAttribute("data-has-editing")}function C(l,e,t){return l instanceof HTMLInputElement?l.type==="checkbox"?l.checked:l.type==="number"?l.value===""?null:Number(l.value):l.type==="date"?typeof t=="string"?l.value:l.valueAsDate:typeof t=="number"?l.value===""?null:Number(l.value):t==null&&l.value===""?t:l.value:e?.type==="number"&&l.value!==""||typeof t=="number"&&l.value!==""?Number(l.value):t==null&&l.value===""?t:l.value}function T(l){}function $(l,e,t,i){const s=l.querySelector("input,textarea,select");s&&(s.addEventListener("blur",()=>{t(C(s,e,i))}),s instanceof HTMLInputElement&&s.type==="checkbox"?s.addEventListener("change",()=>t(s.checked)):s instanceof HTMLSelectElement&&s.addEventListener("change",()=>t(C(s,e,i))))}class N extends A.BaseGridPlugin{static manifest={ownedProperties:[{property:"editable",level:"column",description:'the "editable" column property',isUsed:e=>e===!0},{property:"editor",level:"column",description:'the "editor" column property'},{property:"editorParams",level:"column",description:'the "editorParams" column property'}],events:[{type:"cell-edit-committed",description:"Emitted when a cell edit is committed (for plugin-to-plugin coordination)"}],queries:[{type:"isEditing",description:"Returns whether any cell is currently being edited"}]};name="editing";styles=I;get defaultConfig(){return{mode:"row",editOn:"click"}}get#t(){return this.config.mode==="grid"}#e=-1;#d=-1;#l=new Map;#n=new Set;#o=new Set;#c=!1;#u=-1;#i=new Map;#r=!1;#a=!1;attach(e){super.attach(e);const t=this.disconnectSignal,i=e;i._activeEditRows=-1,i._rowEditSnapshots=new Map,Object.defineProperty(e,"changedRows",{get:()=>this.changedRows,configurable:!0}),Object.defineProperty(e,"changedRowIds",{get:()=>this.changedRowIds,configurable:!0}),e.resetChangedRows=s=>this.resetChangedRows(s),e.beginBulkEdit=(s,n)=>{n&&this.beginCellEdit(s,n)},document.addEventListener("keydown",s=>{if(!this.#t&&s.key==="Escape"&&this.#e!==-1){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(s)===!1)return;this.#s(this.#e,!0)}},{capture:!0,signal:t}),document.addEventListener("mousedown",s=>{if(this.#t||this.#e===-1)return;const n=i.findRenderedRowElement?.(this.#e);!n||(s.composedPath&&s.composedPath()||[]).includes(n)||this.config.onBeforeEditClose&&this.config.onBeforeEditClose(s)===!1||queueMicrotask(()=>{this.#e!==-1&&this.#s(this.#e,!1)})},{signal:t}),this.#t&&(this.gridElement.classList.add("tbw-grid-mode"),this.requestRender(),this.gridElement.addEventListener("focusin",s=>{const n=s.target;if(n.matches(b.FOCUSABLE_EDITOR_SELECTOR)){if(this.#a){n.blur(),this.gridElement.focus();return}this.#r=!0}},{signal:t}),this.gridElement.addEventListener("focusout",s=>{const n=s.relatedTarget;(!n||!this.gridElement.contains(n)||!n.matches(b.FOCUSABLE_EDITOR_SELECTOR))&&(this.#r=!1)},{signal:t}),this.gridElement.addEventListener("keydown",s=>{if(s.key==="Escape"&&this.#r){const n=document.activeElement;n&&this.gridElement.contains(n)&&(n.blur(),this.gridElement.focus()),this.#r=!1,this.#a=!0,s.preventDefault(),s.stopPropagation()}},{capture:!0,signal:t}),this.gridElement.addEventListener("mousedown",s=>{s.target.matches(b.FOCUSABLE_EDITOR_SELECTOR)&&(this.#a=!1)},{signal:t}))}detach(){this.gridElement.classList.remove("tbw-grid-mode"),this.#e=-1,this.#d=-1,this.#l.clear(),this.#n.clear(),this.#o.clear(),this.#r=!1,this.#a=!1,super.detach()}handleQuery(e){if(e.type==="isEditing")return this.#t||this.#e!==-1}onCellClick(e){if(this.#t)return!1;const t=this.grid,i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual"||i!=="click"&&i!=="dblclick")return!1;const s=e.originalEvent.type==="dblclick";if(i==="click"&&s||i==="dblclick"&&!s)return!1;const{rowIndex:n}=e;return t._columns?.some(o=>o.editable)?(e.originalEvent.stopPropagation(),this.beginBulkEdit(n),!0):!1}onKeyDown(e){const t=this.grid;if(e.key==="Escape"){if(this.#t&&this.#r){const i=document.activeElement;return i&&this.gridElement.contains(i)&&i.blur(),this.#r=!1,this.requestAfterRender(),!0}if(this.#e!==-1&&!this.#t)return this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1||this.#s(this.#e,!0),!0}if(this.#t&&!this.#r&&(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"))return!1;if((e.key==="ArrowUp"||e.key==="ArrowDown")&&this.#e!==-1&&!this.#t){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1)return!0;const i=t._rows.length-1,s=this.#e;return this.#s(s,!1),e.key==="ArrowDown"?t._focusRow=Math.min(i,t._focusRow+1):t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault(),y.ensureCellVisible(t),this.requestAfterRender(),!0}if(e.key==="Tab"&&(this.#e!==-1||this.#t)){e.preventDefault();const i=!e.shiftKey;return this.#b(i),!0}if(e.key===" "||e.key==="Spacebar"){if(this.#e!==-1)return!1;const i=t._focusRow,s=t._focusCol;if(i>=0&&s>=0){const n=t._visibleColumns[s],r=t._rows[i];if(n?.editable&&n.type==="boolean"&&r){const o=n.field;if(_(o)){const d=!r[o];return this.#p(i,n,d,r),e.preventDefault(),this.requestRender(),!0}}}return!1}if(e.key==="Enter"&&!e.shiftKey){if(this.#t&&!this.#r)return this.#v(),!0;if(this.#e!==-1)return!!(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(e)===!1);const i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual")return!1;const s=t._focusRow,n=t._focusCol;if(s>=0&&t._columns?.some(o=>o.editable)){const o=t._visibleColumns[n],a=t._rows[s],d=o?.field??"",c=d&&a?a[d]:void 0,g=this.gridElement.querySelector(`[data-row="${s}"][data-col="${n}"]`),u=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,detail:{rowIndex:s,colIndex:n,field:d,value:c,row:a,cellEl:g,trigger:"keyboard",originalEvent:e}});this.gridElement.dispatchEvent(u);const E=new CustomEvent("activate-cell",{cancelable:!0,bubbles:!0,detail:{row:s,col:n}});return this.gridElement.dispatchEvent(E),u.defaultPrevented||E.defaultPrevented?(e.preventDefault(),!0):(this.beginBulkEdit(s),!0)}return!1}return!1}processColumns(e){const t=this.grid,i=t.effectiveConfig?.typeDefaults,s=t.__frameworkAdapter;return!i&&!s?.getTypeDefault?e:e.map(n=>{if(!n.type)return n;let r;if(i?.[n.type]?.editorParams&&(r=i[n.type].editorParams),!r&&s?.getTypeDefault){const o=s.getTypeDefault(n.type);o?.editorParams&&(r=o.editorParams)}return r?{...n,editorParams:{...r,...n.editorParams}}:n})}afterRender(){const e=this.grid;if(this.#c&&(this.#c=!1,this.#m(e)),this.#u!==-1){const t=this.#u;this.#u=-1,e.animateRow?.(t,"change")}if(!this.#t&&this.#o.size!==0)for(const t of this.#o){const[i,s]=t.split(":"),n=parseInt(i,10),r=parseInt(s,10),o=e.findRenderedRowElement?.(n);if(!o)continue;const a=o.querySelector(`.cell[data-col="${r}"]`);if(!a||a.classList.contains("editing"))continue;const d=e._rows[n],c=e._visibleColumns[r];d&&c&&this.#g(d,n,c,r,a,!0)}}afterCellRender(e){if(!this.#t)return;const{row:t,rowIndex:i,column:s,colIndex:n,cellElement:r}=e;s.editable&&(r.classList.contains("editing")||this.#g(t,i,s,n,r,!0))}onScrollRender(){this.afterRender()}get changedRows(){const e=[];for(const t of this.#n){const i=this.grid.getRow(t);i&&e.push(i)}return e}get changedRowIds(){return Array.from(this.#n)}get activeEditRow(){return this.#e}get activeEditCol(){return this.#d}isRowEditing(e){return this.#e===e}isCellEditing(e,t){return this.#o.has(`${e}:${t}`)}isRowChanged(e){const t=this.grid,i=t._rows[e];if(!i)return!1;try{const s=t.getRowId?.(i);return s?this.#n.has(s):!1}catch{return!1}}isRowChangedById(e){return this.#n.has(e)}setInvalid(e,t,i=""){let s=this.#i.get(e);s||(s=new Map,this.#i.set(e,s)),s.set(t,i),this.#f(e,t,!0)}clearInvalid(e,t){const i=this.#i.get(e);i&&(i.delete(t),i.size===0&&this.#i.delete(e)),this.#f(e,t,!1)}clearRowInvalid(e){const t=this.#i.get(e);if(t){const i=Array.from(t.keys());this.#i.delete(e),i.forEach(s=>this.#f(e,s,!1))}}clearAllInvalid(){const e=Array.from(this.#i.entries());this.#i.clear(),e.forEach(([t,i])=>{i.forEach((s,n)=>this.#f(t,n,!1))})}isCellInvalid(e,t){return this.#i.get(e)?.has(t)??!1}getInvalidMessage(e,t){return this.#i.get(e)?.get(t)}hasInvalidCells(e){const t=this.#i.get(e);return t?t.size>0:!1}getInvalidFields(e){return new Map(this.#i.get(e)??[])}#f(e,t,i){const s=this.grid,n=s._visibleColumns?.findIndex(c=>c.field===t);if(n===-1||n===void 0)return;const o=s._rows?.findIndex(c=>{try{return s.getRowId?.(c)===e}catch{return!1}});if(o===-1||o===void 0)return;const d=s.findRenderedRowElement?.(o)?.querySelector(`.cell[data-col="${n}"]`);if(d)if(i){d.setAttribute("data-invalid","true");const c=this.#i.get(e)?.get(t);c&&d.setAttribute("title",c)}else d.removeAttribute("data-invalid"),d.removeAttribute("title")}resetChangedRows(e){const t=this.changedRows,i=this.changedRowIds;this.#n.clear(),this.#h(),e||this.emit("changed-rows-reset",{rows:t,ids:i}),this.grid._rowPool?.forEach(n=>n.classList.remove("changed"))}beginCellEdit(e,t){const i=this.grid,s=i._visibleColumns.findIndex(a=>a.field===t);if(s===-1||!i._visibleColumns[s]?.editable)return;const o=i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${s}"]`);o&&this.#w(e,s,o)}beginBulkEdit(e){const t=this.grid;if((this.config.editOn??t.effectiveConfig?.editOn)===!1||!t._columns?.some(o=>o.editable))return;const n=t.findRenderedRowElement?.(e);if(!n)return;const r=t._rows[e];this.#E(e,r),Array.from(n.children).forEach((o,a)=>{const d=t._visibleColumns[a];if(d?.editable){const c=o;c.classList.contains("editing")||this.#g(r,e,d,a,c,!0)}}),setTimeout(()=>{let o=n.querySelector(`.cell[data-col="${t._focusCol}"]`);if(o?.classList.contains("editing")||(o=n.querySelector(".cell.editing")),o?.classList.contains("editing")){const a=o.querySelector(b.FOCUSABLE_EDITOR_SELECTOR);try{a?.focus({preventScroll:!0})}catch{}}},0)}commitActiveRowEdit(){this.#e!==-1&&this.#s(this.#e,!1)}cancelActiveRowEdit(){this.#e!==-1&&this.#s(this.#e,!0)}#w(e,t,i){const s=this.grid,n=s._rows[e],r=s._visibleColumns[t];!n||!r?.editable||i.classList.contains("editing")||(this.#e!==e&&this.#E(e,n),this.#d=t,this.#g(n,e,r,t,i,!1))}#v(){const e=this.grid,t=e._focusRow,i=e._focusCol;if(t<0||i<0)return;const n=e.findRenderedRowElement?.(t)?.querySelector(`.cell[data-col="${i}"]`);if(n?.classList.contains("editing")){const r=n.querySelector(b.FOCUSABLE_EDITOR_SELECTOR);r&&(this.#a=!1,r.focus(),this.#r=!0,r instanceof HTMLInputElement&&(r.type==="text"||r.type==="number")&&r.select())}}#b(e){const t=this.grid,i=t._rows,s=this.#t?t._focusRow:this.#e,n=t._visibleColumns.map((d,c)=>d.editable?c:-1).filter(d=>d>=0);if(n.length===0)return;const o=n.indexOf(t._focusCol)+(e?1:-1);if(o>=0&&o<n.length){t._focusCol=n[o];const c=t.findRenderedRowElement?.(s)?.querySelector(`.cell[data-col="${n[o]}"]`);c?.classList.contains("editing")&&c.querySelector(b.FOCUSABLE_EDITOR_SELECTOR)?.focus({preventScroll:!0}),y.ensureCellVisible(t,{forceHorizontalScroll:!0});return}const a=s+(e?1:-1);a>=0&&a<i.length&&(this.#t?(t._focusRow=a,t._focusCol=e?n[0]:n[n.length-1],y.ensureCellVisible(t,{forceHorizontalScroll:!0}),this.requestAfterRender(),setTimeout(()=>{const c=t.findRenderedRowElement?.(a)?.querySelector(`.cell[data-col="${t._focusCol}"]`);c?.classList.contains("editing")&&c.querySelector(b.FOCUSABLE_EDITOR_SELECTOR)?.focus({preventScroll:!0})},0)):(this.#s(s,!1),t._focusRow=a,t._focusCol=e?n[0]:n[n.length-1],this.beginBulkEdit(a),y.ensureCellVisible(t,{forceHorizontalScroll:!0})))}#h(){const e=this.grid;e._activeEditRows=this.#e,e._rowEditSnapshots=this.#l}#E(e,t){this.#e!==e&&(this.#l.set(e,{...t}),this.#e=e,this.#h())}#s(e,t){if(this.#e!==e)return;const i=this.grid,s=this.#l.get(e),n=i._rows[e],r=i.findRenderedRowElement?.(e);let o;if(n)try{o=i.getRowId?.(n)}catch{}if(!t&&r&&n&&r.querySelectorAll(".cell.editing").forEach(d=>{const c=Number(d.getAttribute("data-col"));if(isNaN(c))return;const g=i._visibleColumns[c];if(!g||d.hasAttribute("data-editor-managed"))return;const u=d.querySelector("input,textarea,select");if(u){const E=g.field,p=n[E],h=C(u,g,p);p!==h&&this.#p(e,g,h,n)}}),t&&s&&n)Object.keys(s).forEach(a=>{n[a]=s[a]}),o&&(this.#n.delete(o),this.clearRowInvalid(o));else if(!t&&n){const a=this.#C(s,n),d=o?this.#n.has(o):a,c=this.emitCancelable("row-commit",{rowIndex:e,rowId:o??"",row:n,oldValue:s,newValue:n,changed:d,changedRows:this.changedRows,changedRowIds:this.changedRowIds});c&&s?(Object.keys(s).forEach(g=>{n[g]=s[g]}),o&&(this.#n.delete(o),this.clearRowInvalid(o))):!c&&a&&this.isAnimationEnabled&&(this.#u=e)}this.#l.delete(e),this.#e=-1,this.#d=-1,this.#h();for(const a of this.#o)a.startsWith(`${e}:`)&&this.#o.delete(a);r&&(r.querySelectorAll(".cell.editing").forEach(a=>{a.classList.remove("editing"),H(a.parentElement)}),this.requestRender()),this.#c=!0,r||(this.#m(i),this.#c=!1)}#p(e,t,i,s){const n=t.field;if(!_(n))return;const r=s[n];if(r===i)return;const o=this.grid;let a;try{a=this.grid.getRowId(s)}catch{}const d=a?!this.#n.has(a):!0,c=a?h=>this.grid.updateRow(a,h,"cascade"):T;let g=!1;const u=a?h=>{g=!0,this.setInvalid(a,n,h??"")}:()=>{};if(this.emitCancelable("cell-commit",{row:s,rowId:a??"",field:n,oldValue:r,value:i,rowIndex:e,changedRows:this.changedRows,changedRowIds:this.changedRowIds,firstTimeForRow:d,updateRow:c,setInvalid:u}))return;a&&!g&&this.isCellInvalid(a,n)&&this.clearInvalid(a,n),s[n]=i,a&&this.#n.add(a),this.#h(),this.emitPluginEvent("cell-edit-committed",{rowIndex:e,field:n,oldValue:r,newValue:i});const p=o.findRenderedRowElement?.(e);p&&p.classList.add("changed")}#g(e,t,i,s,n,r){if(!i.editable||n.classList.contains("editing"))return;let o;try{o=this.grid.getRowId(e)}catch{}const a=o?f=>this.grid.updateRow(o,f,"cascade"):T,d=_(i.field)?e[i.field]:void 0;n.classList.add("editing"),this.#o.add(`${t}:${s}`);const c=n.parentElement;c&&G(c);let g=!1;const u=f=>{g||!this.#t&&this.#e===-1||this.#p(t,i,f,e)},E=()=>{g=!0,_(i.field)&&(e[i.field]=d)},p=document.createElement("div");p.className="tbw-editor-host",n.innerHTML="",n.appendChild(p),p.addEventListener("keydown",f=>{if(f.key==="Enter"){if(this.#t){f.stopPropagation(),f.preventDefault();const m=p.querySelector("input,textarea,select");m&&u(C(m,i,d));return}if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(f)===!1)return;f.stopPropagation(),f.preventDefault(),g=!0,this.#s(t,!1)}if(f.key==="Escape"){if(this.#t){f.stopPropagation(),f.preventDefault();return}if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(f)===!1)return;f.stopPropagation(),f.preventDefault(),E(),this.#s(t,!0)}});const h=i,R=h.__editorTemplate,w=x(this.grid,h)??k(i),S=d;if(w==="template"&&R)this.#y(p,h,e,d,u,E,r,t);else if(typeof w=="string"){const f=document.createElement(w);f.value=S,f.addEventListener("change",()=>u(f.value)),p.appendChild(f),r||queueMicrotask(()=>{p.querySelector(b.FOCUSABLE_EDITOR_SELECTOR)?.focus({preventScroll:!0})})}else if(typeof w=="function"){const f={row:e,rowId:o??"",value:S,field:i.field,column:i,commit:u,cancel:E,updateRow:a},m=w(f);typeof m=="string"?(p.innerHTML=m,$(p,i,u,d)):m instanceof Node&&(p.appendChild(m),m instanceof HTMLInputElement||m instanceof HTMLSelectElement||m instanceof HTMLTextAreaElement||n.setAttribute("data-editor-managed","")),r||queueMicrotask(()=>{p.querySelector(b.FOCUSABLE_EDITOR_SELECTOR)?.focus({preventScroll:!0})})}else if(w&&typeof w=="object"){const f=document.createElement("div");f.setAttribute("data-external-editor",""),f.setAttribute("data-field",i.field),p.appendChild(f),n.setAttribute("data-editor-managed","");const m={row:e,rowId:o??"",value:S,field:i.field,column:i,commit:u,cancel:E,updateRow:a};if(w.mount)try{w.mount({placeholder:f,context:m,spec:w})}catch(L){console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,L)}else this.grid.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:f,spec:w,context:m}}))}}#y(e,t,i,s,n,r,o,a){const d=t.__editorTemplate;if(!d)return;const c=d.cloneNode(!0),g=t.__compiledEditor;g?c.innerHTML=g({row:i,value:s,field:t.field,column:t,commit:n,cancel:r}):c.querySelectorAll("*").forEach(E=>{E.childNodes.length===1&&E.firstChild?.nodeType===Node.TEXT_NODE&&(E.textContent=E.textContent?.replace(/{{\s*value\s*}}/g,s==null?"":String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(p,h)=>{if(!_(h))return"";const R=i[h];return R==null?"":String(R)})||"")});const u=c.querySelector("input,textarea,select");if(u){u instanceof HTMLInputElement&&u.type==="checkbox"?u.checked=!!s:u.value=String(s??"");let E=!1;u.addEventListener("blur",()=>{E||n(C(u,t,s))}),u.addEventListener("keydown",p=>{const h=p;if(h.key==="Enter"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(h)===!1)return;h.stopPropagation(),h.preventDefault(),E=!0,n(C(u,t,s)),this.#s(a,!1)}if(h.key==="Escape"){if(this.config.onBeforeEditClose&&this.config.onBeforeEditClose(h)===!1)return;h.stopPropagation(),h.preventDefault(),r(),this.#s(a,!0)}}),u instanceof HTMLInputElement&&u.type==="checkbox"&&u.addEventListener("change",()=>n(u.checked)),o||setTimeout(()=>u.focus({preventScroll:!0}),0)}e.appendChild(c)}#C(e,t){if(!e)return!1;const i=e,s=t,n=new Set([...Object.keys(i),...Object.keys(s)]);for(const r of n)if(i[r]!==s[r])return!0;return!1}#m(e){queueMicrotask(()=>{try{const t=e._focusRow,i=e._focusCol,s=e.findRenderedRowElement?.(t);if(s){Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(r=>r.classList.remove("cell-focus"));const n=s.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);n&&(n.classList.add("cell-focus"),n.setAttribute("aria-selected","true"),n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0}))}}catch{}})}}v.EditingPlugin=N,v.defaultEditorFor=k,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=editing.umd.js.map
|