@webority/ui-react 0.177.0 → 0.178.0
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/dist/canvas-kit/kit.js +96 -96
- package/dist/canvas-kit/manifest.json +133 -1
- package/dist/canvas-kit/release.json +6 -6
- package/dist/components/AppDataTable.js +1 -1
- package/dist/components/AppEntryGrid.js +1 -1
- package/dist/components/AppFileViewer.js +1 -1
- package/dist/components/AppInlineEdit.js +1 -1
- package/dist/components/AppModal.js +1 -1
- package/dist/components/AppOrgTree.js +1 -1
- package/dist/components/AppTablePagination.js +1 -1
- package/dist/components/AppTabs.js +1 -1
- package/dist/guidance.json +1 -1
- package/dist/types/components/AppDataTable.d.ts +1 -0
- package/dist/types/components/AppFileViewer.d.ts +1 -1
- package/dist/types/components/AppInlineEdit.d.ts +2 -0
- package/dist/types/components/AppModal.d.ts +3 -0
- package/dist/types/components/AppTablePagination.d.ts +5 -0
- package/dist/types/components/AppTabs.d.ts +1 -0
- package/package.json +10 -10
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"kind": "WeborityWeb",
|
|
3
3
|
"library": {
|
|
4
4
|
"name": "@webority/ui-react",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.178.0"
|
|
6
6
|
},
|
|
7
7
|
"rendererProtocolVersion": 14,
|
|
8
8
|
"platform": "Web",
|
|
@@ -7886,6 +7886,12 @@
|
|
|
7886
7886
|
"required": false,
|
|
7887
7887
|
"description": "Draws \"Showing x to y of z\" at the start of the footer."
|
|
7888
7888
|
},
|
|
7889
|
+
{
|
|
7890
|
+
"name": "summaryText",
|
|
7891
|
+
"type": "string",
|
|
7892
|
+
"required": false,
|
|
7893
|
+
"description": "Replaces the built-in \"Showing {first} to {last} of {total}\" text of the footer, for other languages. The tokens are {first}, {last} and {total}."
|
|
7894
|
+
},
|
|
7889
7895
|
{
|
|
7890
7896
|
"name": "total",
|
|
7891
7897
|
"type": "number",
|
|
@@ -10491,6 +10497,12 @@
|
|
|
10491
10497
|
"required": false,
|
|
10492
10498
|
"description": "Draws \"Showing x to y of z\" at the start of the footer."
|
|
10493
10499
|
},
|
|
10500
|
+
{
|
|
10501
|
+
"name": "summaryText",
|
|
10502
|
+
"type": "string",
|
|
10503
|
+
"required": false,
|
|
10504
|
+
"description": "Replaces the built-in \"Showing {first} to {last} of {total}\" text of the footer, for other languages. The tokens are {first}, {last} and {total}."
|
|
10505
|
+
},
|
|
10494
10506
|
{
|
|
10495
10507
|
"name": "total",
|
|
10496
10508
|
"type": "number",
|
|
@@ -13826,6 +13838,12 @@
|
|
|
13826
13838
|
"required": true,
|
|
13827
13839
|
"description": "What the value is, such as Owner: its accessible name and what screen readers announce, as in Owner saved."
|
|
13828
13840
|
},
|
|
13841
|
+
{
|
|
13842
|
+
"name": "loadUrl",
|
|
13843
|
+
"type": "string",
|
|
13844
|
+
"required": false,
|
|
13845
|
+
"description": "A select's choices, fetched as a JSON array of { value, label } on the first open. Only with type select, and instead of options."
|
|
13846
|
+
},
|
|
13829
13847
|
{
|
|
13830
13848
|
"name": "options",
|
|
13831
13849
|
"type": "array",
|
|
@@ -16362,6 +16380,20 @@
|
|
|
16362
16380
|
"required": true,
|
|
16363
16381
|
"description": "Whether the dialog is shown."
|
|
16364
16382
|
},
|
|
16383
|
+
{
|
|
16384
|
+
"name": "phoneSize",
|
|
16385
|
+
"type": "enum",
|
|
16386
|
+
"enum": [
|
|
16387
|
+
"fullscreen",
|
|
16388
|
+
"lg",
|
|
16389
|
+
"md",
|
|
16390
|
+
"sm",
|
|
16391
|
+
"wide",
|
|
16392
|
+
"xl"
|
|
16393
|
+
],
|
|
16394
|
+
"required": false,
|
|
16395
|
+
"description": "The card width below 576px, in place of size, which applies from 576px up. fullscreen covers the whole viewport on a phone. Unset, size applies at every width."
|
|
16396
|
+
},
|
|
16365
16397
|
{
|
|
16366
16398
|
"name": "placement",
|
|
16367
16399
|
"type": "enum",
|
|
@@ -27853,6 +27885,13 @@
|
|
|
27853
27885
|
"description": "Shows Showing x to y of z at the start of the pager. It needs total and pageSize; without both nothing is shown.",
|
|
27854
27886
|
"default": false
|
|
27855
27887
|
},
|
|
27888
|
+
{
|
|
27889
|
+
"name": "summaryText",
|
|
27890
|
+
"type": "string",
|
|
27891
|
+
"required": false,
|
|
27892
|
+
"description": "Replaces the built-in English text, for other languages. The tokens {first}, {last} and {total} are the first and last rows on the page and the row total. It shows with summary.",
|
|
27893
|
+
"default": "Showing {first} to {last} of {total}"
|
|
27894
|
+
},
|
|
27856
27895
|
{
|
|
27857
27896
|
"name": "total",
|
|
27858
27897
|
"type": "number",
|
|
@@ -28458,6 +28497,12 @@
|
|
|
28458
28497
|
"required": false,
|
|
28459
28498
|
"description": "Text shown in the count pill instead of count, such as 3 open."
|
|
28460
28499
|
},
|
|
28500
|
+
{
|
|
28501
|
+
"name": "countPending",
|
|
28502
|
+
"type": "boolean",
|
|
28503
|
+
"required": false,
|
|
28504
|
+
"description": "Shows an empty count pill that script fills in later, such as a count still loading. It takes no count or countLabel."
|
|
28505
|
+
},
|
|
28461
28506
|
{
|
|
28462
28507
|
"name": "danger",
|
|
28463
28508
|
"type": "boolean",
|
|
@@ -34302,6 +34347,93 @@
|
|
|
34302
34347
|
{
|
|
34303
34348
|
"version": "0.130.0",
|
|
34304
34349
|
"components": [
|
|
34350
|
+
{
|
|
34351
|
+
"name": "AppButton",
|
|
34352
|
+
"props": {},
|
|
34353
|
+
"values": {
|
|
34354
|
+
"variant": {
|
|
34355
|
+
"primary": "solid",
|
|
34356
|
+
"secondary": "soft",
|
|
34357
|
+
"success": "solid",
|
|
34358
|
+
"danger": "solid",
|
|
34359
|
+
"warning": "solid",
|
|
34360
|
+
"info": "solid",
|
|
34361
|
+
"light": "solid",
|
|
34362
|
+
"dark": "solid",
|
|
34363
|
+
"outline-primary": "outline",
|
|
34364
|
+
"outline-secondary": "outline",
|
|
34365
|
+
"outline-success": "outline",
|
|
34366
|
+
"outline-danger": "outline",
|
|
34367
|
+
"outline-warning": "outline",
|
|
34368
|
+
"outline-info": "outline",
|
|
34369
|
+
"outline-dark": "outline",
|
|
34370
|
+
"outline-light": "glass",
|
|
34371
|
+
"secondary-danger": "soft",
|
|
34372
|
+
"neutral": "soft",
|
|
34373
|
+
"text": "link"
|
|
34374
|
+
}
|
|
34375
|
+
},
|
|
34376
|
+
"added": {},
|
|
34377
|
+
"removed": {}
|
|
34378
|
+
},
|
|
34379
|
+
{
|
|
34380
|
+
"name": "AppCopyButton",
|
|
34381
|
+
"props": {},
|
|
34382
|
+
"values": {
|
|
34383
|
+
"variant": {
|
|
34384
|
+
"primary": "solid",
|
|
34385
|
+
"secondary": "soft",
|
|
34386
|
+
"success": "solid",
|
|
34387
|
+
"danger": "solid",
|
|
34388
|
+
"warning": "solid",
|
|
34389
|
+
"info": "solid",
|
|
34390
|
+
"light": "solid",
|
|
34391
|
+
"dark": "solid",
|
|
34392
|
+
"outline-primary": "outline",
|
|
34393
|
+
"outline-secondary": "outline",
|
|
34394
|
+
"outline-success": "outline",
|
|
34395
|
+
"outline-danger": "outline",
|
|
34396
|
+
"outline-warning": "outline",
|
|
34397
|
+
"outline-info": "outline",
|
|
34398
|
+
"outline-dark": "outline",
|
|
34399
|
+
"outline-light": "glass",
|
|
34400
|
+
"secondary-danger": "soft",
|
|
34401
|
+
"neutral": "soft",
|
|
34402
|
+
"text": "link"
|
|
34403
|
+
}
|
|
34404
|
+
},
|
|
34405
|
+
"added": {},
|
|
34406
|
+
"removed": {}
|
|
34407
|
+
},
|
|
34408
|
+
{
|
|
34409
|
+
"name": "AppSplitButton",
|
|
34410
|
+
"props": {},
|
|
34411
|
+
"values": {
|
|
34412
|
+
"variant": {
|
|
34413
|
+
"primary": "solid",
|
|
34414
|
+
"secondary": "soft",
|
|
34415
|
+
"success": "solid",
|
|
34416
|
+
"danger": "solid",
|
|
34417
|
+
"warning": "solid",
|
|
34418
|
+
"info": "solid",
|
|
34419
|
+
"light": "solid",
|
|
34420
|
+
"dark": "solid",
|
|
34421
|
+
"outline-primary": "outline",
|
|
34422
|
+
"outline-secondary": "outline",
|
|
34423
|
+
"outline-success": "outline",
|
|
34424
|
+
"outline-danger": "outline",
|
|
34425
|
+
"outline-warning": "outline",
|
|
34426
|
+
"outline-info": "outline",
|
|
34427
|
+
"outline-dark": "outline",
|
|
34428
|
+
"outline-light": "glass",
|
|
34429
|
+
"secondary-danger": "soft",
|
|
34430
|
+
"neutral": "soft",
|
|
34431
|
+
"text": "link"
|
|
34432
|
+
}
|
|
34433
|
+
},
|
|
34434
|
+
"added": {},
|
|
34435
|
+
"removed": {}
|
|
34436
|
+
},
|
|
34305
34437
|
{
|
|
34306
34438
|
"name": "AppCheckbox",
|
|
34307
34439
|
"props": {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.178.0",
|
|
4
4
|
"platform": "Web",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 14,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/ui-react",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.178.0"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
14
|
-
"bytes":
|
|
13
|
+
"sha256": "db7b5a8aa6befcc4461ef85ded21d870f758155a41419965573cec1bf7d8c636",
|
|
14
|
+
"bytes": 1141267
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "9f24e4bdaa269eb448342a80b007f8fbfdd01f71f19510ca71de9c67212a6f82",
|
|
18
|
+
"bytes": 10157396
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "13b14f71fb6ea024945f95cba617b4f1d49f44a65ba7c7ed05d2354805539ef6",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as p,PIN_SIDES as re,ROW_HEIGHTS as ie,ROW_MOVE_LIMIT as ae,ROW_SAVE_ERROR_CLASS as oe,attachRowDrag as se,attachScrollEdges as ce,downloadTable as le,groupCount as ue,groupItems as de,isImeSafeEnter as fe,measureRows as pe,pinAtValue as me,pinClasses as he,planPins as ge,playRowMoves as _e,rowOrderChanged as ve,saveOutcomeText as ye,settledRows as be,syncTargets as xe,tableCsv as Se,tableXlsx as Ce,virtualRange as we}from"@webority/ui-elements/helpers";import{Children as Te,Fragment as Ee,isValidElement as De,useCallback as Oe,useEffect as m,useLayoutEffect as ke,useMemo as Ae,useRef as h,useState as g}from"react";import{Fragment as je,jsx as _,jsxs as v}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Me,ROW_ACTIONS_TEXT as Ne,fillText as Pe,pluralText as Fe}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Ie}from"@webority/theme/runtime";var Le=()=>import(`@webority/ui-elements/elements/data-table`),Re=[`comfortable`,`cozy`,`compact`],ze=[`hover`,`hover-menu`,`column`],Be=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,Ve=[`auto`,`fixed`],He=[`hover`,`always`],Ue=[`hide`,`show`],We=[1,2,3,4],Ge=e=>typeof e==`number`?`${e}px`:e;function Ke(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[Ge(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function y(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function qe(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||De(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Je(e,t){return qe(y(e,t),t)}var Ye=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},b=/* @__PURE__ */ new Set;function x(t,n){!b.has(t)&&Ye()&&(b.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Xe=100,Ze=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Qe=()=>{},$e=()=>({total:0,keys:[]}),et=[],tt=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function S(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function nt(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function rt(e){return e==null||e===``?t():Array.isArray(e)?Te.toArray(e):typeof e==`boolean`?String(e):e}function it(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function C(e){n(`wui-data-table`,Le);let t=r(`dataTable`,Me),Te=r(`rowActions`,Ne),De=e=>e?Pe(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:Ge,props:Ye}=i(`AppDataTable`,e),{columns:b,rows:C=et,rowKey:at=Ze,sort:ot,onSort:st,sortIcons:ct=`hover`,emptyHeader:lt=`hide`,loading:w=!1,refreshing:ut=!1,skeletonRows:dt=5,empty:ft=t.empty,emptyFiltered:pt,error:mt,onRetry:ht,sourceCount:gt,rowActions:T,linkComponent:_t,rowActionsLabel:vt,pagination:E,ariaLabel:yt,className:bt=``,wrapperClassName:xt=``,selectable:D=!1,selectedIds:O,isRowSelectable:St,onToggleRow:Ct,onToggleAll:wt,onSelectRange:Tt,renderExpanded:Et,singleExpand:Dt=!1,density:Ot=`cozy`,densitySwitch:kt=!1,exportable:At=!1,exportName:jt=`table`,onExport:Mt,tableLayout:Nt=`auto`,striped:Pt=!1,flush:Ft=!1,pad:It,nameLines:Lt,headerTone:Rt,rowDrag:k=!1,maxHeight:zt,stickyFirstColumn:Bt=!1,stickyActions:Vt=!1,equalActions:Ht=!1,linkFirstColumn:Ut=!1,stackOnMobile:Wt,hiddenColumns:Gt,rowStatus:Kt,rowTone:qt,rowActionsMode:Jt=`hover`,rowHref:A,onRowClick:Yt,activeRowKey:Xt,hoverRowKey:Zt,resizableColumns:j=!1,viewKey:Qt,groupBy:M,groupLabel:$t,virtual:N=!1,rowSaving:P,rowSaveError:en,...tn}=Ye;d(`AppDataTable`,tn);let{style:nn,...rn}=tn,an=Wt??!N,F=Oe((e,t)=>{let n=at(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[at]),on=Gt?.length?new Set(Gt):null;b=on?b.filter(e=>!(e.hideable&&on.has(e.key))):b,u(`AppDataTable`,`density`,Ot,Re),u(`AppDataTable`,`rowActionsMode`,Jt,ze),u(`AppDataTable`,`tableLayout`,Nt,Ve),u(`AppDataTable`,`sortIcons`,ct,He),u(`AppDataTable`,`emptyHeader`,lt,Ue),u(`AppDataTable`,`nameLines`,Lt,We);for(let e of b)u(`AppDataTable`,`column.pin`,e.pin,re);let I=typeof A==`function`||typeof Yt==`function`,[sn,cn]=g(null),L=kt&&sn?sn:Ot,ln=[`table table-ledger`,L===`cozy`||L===`compact`?`wui-table-${L}`:``,Jt===`hover-menu`?`wui-table-actions-menu`:``,Jt===`column`?`wui-table-actions-column`:``,Pt?`wui-table-striped`:``,Bt?`wui-table-sticky-first`:``,ct===`always`?`wui-sort-icons-always`:``,lt===`show`?`wui-table-empty-header`:``,Vt?`wui-table-sticky-actions`:``,Ht?`wui-table-equal-actions`:``,an?`wui-table-stack`:``,Ut&&I?`wui-table-link-first`:``,bt].filter(Boolean).join(` `),R=typeof Et==`function`,[un,dn]=g(()=>/* @__PURE__ */ new Set),fn=e=>dn(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return Dt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),pn=b.some(e=>typeof e.footer==`function`),mn=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),hn=(e,t)=>{if(mn(t)||(Yt&&Yt(e),!A))return;let n=A(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},z=zt!==void 0,gn=ut&&!w&&C.length>0,_n=[`table-wrap`,z?`wui-table-scroll`:``,Ft?`wui-table-flush`:``,gn?`wui-table-refreshing`:``,xt].filter(Boolean).join(` `),vn={maxHeight:z?zt:void 0,"--wui-table-pad":It!=null&&!Ft?`${It}px`:void 0,"--wui-name-lines":N?`1`:Lt?.toString(),"--wui-table-header-bg":Rt??void 0},yn=Object.values(vn).some(e=>e!==void 0)||nn!==void 0?{...vn,...nn}:void 0,bn=Math.max(1,b.length+ +!!T+ +!!D+ +!!R),xn=b.some(e=>e.pin===`start`||e.pin===`end`),Sn=xn||j||!!M||N||At||kt,B=+!!R+ +!!D,Cn=xn?ge([...R?[`lead`]:[],...D?[`lead`]:[],...b.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...T?[null]:[]]):[],V=(e,t=``)=>{let n=Cn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[p]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},H=(e,t)=>Cn[e]?{...t,...V(e).style}:t,wn=b.length-1+ +!!T;Qt&&!j&&x(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),N&&!z&&x(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),N&&(R||Wt===!0)&&x(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),N&&Lt!==void 0&&Lt!==1&&x(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),Ut&&!I&&x(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),Dt&&typeof Et!=`function`&&x(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!N&&C?.length>500&&x(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let U=N&&z&&!R&&!an&&!w&&C?.length>0,W=(e,t)=>!St||!!St(e,t),Tn=D&&C?C.reduce((e,t,n)=>e+ +!!W(t,n),0):0,G=D&&C?C.reduce((e,t,n)=>e+(W(t,n)&&O?.has(F(t,n))?1:0),0):0,En=Tn>0&&G===Tn,Dn=G>0&&!En,On=e=>{e&&(e.indeterminate=Dn)},kn=h(null),An=(e,t)=>{let n=kn.current;kn.current=e;let r=t&&n!==null?C.findIndex((e,t)=>F(e,t)===n):-1,i=C.findIndex((t,n)=>F(t,n)===e);if(r<0||i<0||r===i){Ct?.(e);return}let a=!O?.has(e),o=Math.min(r,i),s=C.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>W(e,t)).map(([e,t])=>F(e,t)).filter(e=>(O?.has(e)||!1)!==a);if(Tt)Tt(s,a);else for(let e of s)Ct?.(e)},jn=e=>{St?(C||[]).forEach((t,n)=>{let r=F(t,n);W(t,n)&&(O?.has(r)||!1)!==e&&Ct?.(r)}):wt?.(e)},[Mn,Nn]=g(()=>/* @__PURE__ */ new Set),Pn=e=>Nn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),K=Ae(()=>{let e=(C||[]).map((e,t)=>({row:e,i:t}));return M?de(e,({row:e})=>String(y(e,M)??``)).flatMap(e=>[{group:e,open:!Mn.has(e.key)},...Mn.has(e.key)?[]:e.items]):e},[C,M,Mn]),Fn=h(null),[q,In]=g(null),Ln=Oe(e=>{Fn.current=e,In(e)},[]),Rn=h(null);m(()=>{let e=q;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;Rn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(Rn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=ce(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[q]),m(()=>{if(!k||!q)return;let e=se(q);return xe(document),e},[k,q]);let zn=h($e);ke(()=>{zn.current=()=>({total:C?.length??0,keys:C?C.flatMap((e,t)=>{let n=F(e,t);return W(e,t)&&O?.has(n)?[String(n)]:[]}):[]})});let Bn=h(!1);m(()=>{if(!Bn.current&&(Bn.current=!0,G===0))return;let{total:e,keys:t}=zn.current();Fn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:G,total:e,keys:t}}))},[G]);let[Vn,Hn]=g({top:0,height:0}),[J,Un]=g(ie[L]??ie.cozy);m(()=>{let e=q;if(!U||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Hn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[U,q]);let Wn=h(null);ke(()=>{if(!U){Wn.current=null;return}let e=`${L}:${C?.length??0}`;if(Wn.current===e)return;Wn.current=e;let t=(Fn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-J)>.5&&Un(t)});let Y={start:0,end:K.length,before:0,after:0};if(U){Y=we({scrollTop:Vn.top,viewport:Vn.height||Number.parseFloat(String(zt))||0,rowHeight:J,count:K.length});let e=Rn.current;e!==null&&e>=0&&e<K.length&&(e<Y.start&&Y.start-e<=Xe&&(Y={...Y,start:e,before:e*J}),e>=Y.end&&e-Y.end<Xe&&(Y={...Y,end:e+1,after:(K.length-e-1)*J}))}let Gn=h(null),Kn=h(null),qn=h(null),Jn=!N&&!w&&C?.length>0&&C.length<=ae;ke(()=>{let e=Gn.current;if(!Jn||!e){Kn.current=null,qn.current=null;return}let t=C.map((e,t)=>F(e,t));ve(qn.current,t)&&_e(e.rows,Kn.current),Kn.current=pe(e.rows),qn.current=t});let Yn=typeof P==`function`||typeof en==`function`,Xn=h(null),Zn=h(null),X=b[0]?.key;m(()=>{if(!Yn){Zn.current=null;return}let e=/* @__PURE__ */ new Map;(C||[]).forEach((t,n)=>{let r=X===void 0?void 0:y(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(F(t,n),{...tt(t,P,en),label:i})});let t=ye(be(Zn.current,e));Zn.current=e,t&&Xn.current&&(Xn.current.textContent=t)},[C,P,en,F,Yn,X]);let Qn=pt!==void 0&&(gt===void 0||gt>0)?pt:ft,Z=!w&&mt?mt:null,$n=e=>{if(Mt){Mt(e);return}let t=b.map(e=>typeof e.label==`string`?e.label:e.key),n=C.map(e=>b.map(t=>{let n=t.exportValue?t.exportValue(e):y(e,t.key);return n==null?``:String(n)}));e===`csv`?le([Se(t,n)],`text/csv;charset=utf-8`,`${jt}.csv`):le([Ce(t,n)],Be,`${jt}.xlsx`)},er=({group:e,open:n},r)=>{let i=y(e.items[0]?.row,M??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ _(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":U?r+2:void 0,children:/* @__PURE__ */ _(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:bn,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>Pn(e.key),children:[/* @__PURE__ */ _(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ _(`span`,{className:`wui-group-label`,children:$t?$t(i,a):rt(qe(i,M??``))}),/* @__PURE__ */ _(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Fe(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},tr=({row:e,i:n},r)=>{let i=F(e,n),a=R&&un.has(i),o=Xt!=null&&String(Xt)===String(i),ee=Zt!=null&&String(Zt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=V(0,`wui-expand-cell`),u=V(+!!R,`wui-select-cell`),d=Yn?tt(e,P,en):null,f=W(e,n),ne=T?.(e);if(T&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mts --check.`);let p=X===void 0?void 0:y(e,X),re=typeof p==`string`||typeof p==`number`?Pe(t.moreActionsForText,{firstValue:p}):Te.menuLabel;return/* @__PURE__ */ v(Ee,{children:[/* @__PURE__ */ v(`tr`,{className:[D&&f&&O?.has(i)?`is-selected`:``,I?`wui-row-link`:``,o?`wui-row-active`:``,ee?Ie.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":U?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Kt?.(e)||void 0,"data-tone":qt?.(e)||void 0,"data-href":A?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:I?0:void 0,onClick:I?t=>hn(e,t):void 0,onAuxClick:I&&A?t=>t.button===1&&hn(e,t):void 0,onKeyDown:I?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&hn(e,t)}:void 0,children:[R&&/* @__PURE__ */ _(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>fn(i),children:/* @__PURE__ */ _(s,{name:`chevron-down`,size:16})})}),D&&/* @__PURE__ */ _(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ _(`input`,{type:`checkbox`,className:`form-check-input`,checked:f&&(O?.has(i)||!1),disabled:!f,onChange:e=>An(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),b.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ v(r,{scope:t.rowHeader?`row`:void 0,className:V(B+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+S(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)+(t.columnClassName?` ${t.columnClassName}`:``)).className,style:H(B+n,t.cellStyle),"data-label":an&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):rt(Je(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ _(`span`,{className:oe,children:d.message})]},t.key)}),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(te,{items:ne??[],menuLabel:re,linkComponent:_t})})]}),a&&/* @__PURE__ */ _(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ _(`td`,{id:`${c}-expanded`,colSpan:bn,children:Et?.(e)})})]},i)},nr=(e,t)=>`group`in e?er(e,t):tr(e,t),rr=(e,t)=>U?/* @__PURE__ */ _(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ _(`td`,{colSpan:bn,style:{height:t}})},e):null,Q=V(0,`wui-expand-cell`),$=V(+!!R,`wui-select-cell`),ir=()=>Array.from({length:dt},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ v(`tr`,{children:[R&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,void 0),"data-label":an&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ _(c,{width:nt(e.align),height:12,radius:6})},e.key)),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ _(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ v(je,{children:[/* @__PURE__ */ v(Sn?`wui-data-table`:`div`,{ref:Ln,...Sn?{class:_n,resizable:j?``:void 0,"view-key":Qt||void 0,"data-wui-row-drag":k?``:void 0,"aria-busy":gn||void 0}:{className:_n,"data-wui-row-drag":k?``:void 0,"aria-busy":gn||void 0},style:yn,tabIndex:0,...Ge,...rn,children:[At&&/* @__PURE__ */ v(`div`,{className:`wui-table-export`,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>$n(`csv`),children:t.exportCsvLabel}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>$n(`xlsx`),children:t.exportExcelLabel})]}),kt&&/* @__PURE__ */ v(`div`,{className:`wui-table-density`,role:`group`,"aria-label":t.densityLabel,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`comfortable`,"aria-label":t.densityComfortableLabel,onClick:()=>cn(`comfortable`),children:/* @__PURE__ */ _(s,{name:`list`,size:16})}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`compact`,"aria-label":t.densityCompactLabel,onClick:()=>cn(`compact`),children:/* @__PURE__ */ _(s,{name:`grid`,size:16})})]}),/* @__PURE__ */ v(`table`,{className:ln,"aria-label":yt,"aria-rowcount":U?K.length+1:void 0,style:Nt===`fixed`?{tableLayout:`fixed`,minWidth:Ke(b)}:void 0,children:[/* @__PURE__ */ _(`thead`,{children:/* @__PURE__ */ v(`tr`,{"aria-rowindex":U?1:void 0,children:[R&&/* @__PURE__ */ _(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.expandLabel})}),D&&/* @__PURE__ */ _(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ _(`input`,{ref:On,type:`checkbox`,className:`form-check-input`,checked:En,disabled:w,onChange:e=>jn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),b.map((e,t)=>{let n=e.sortable?st:void 0,r=n!==void 0,i=ot&&ot.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ _(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ _(s,{name:`chevrons-up-down`,size:14})}),te=j&&t!==wn,c=Nt===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ v(`th`,{className:V(B+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,l),"data-key":Sn?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?ot?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||w||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(fe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),w||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ _(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ _(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":De(typeof e.label==`string`?e.label:e.key)})]},e.key)}),T&&(vt?/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:vt}):/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ _(`tbody`,{ref:Gn,children:w?ir():Z?null:C?.length?/* @__PURE__ */ v(je,{children:[rr(`before`,Y.before),K.slice(Y.start,Y.end).map((e,t)=>nr(e,Y.start+t)),rr(`after`,Y.after)]}):null}),pn&&!w&&!Z&&C?.length>0&&/* @__PURE__ */ _(`tfoot`,{children:/* @__PURE__ */ v(`tr`,{children:[R&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,void 0),children:e.footer?e.footer(C):null},e.key)),T&&/* @__PURE__ */ _(`td`,{})]})})]}),!w&&(Z||!C?.length)&&/* @__PURE__ */ _(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ _(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:ht?/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>ht(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Qn==`string`?/* @__PURE__ */ _(`div`,{className:`tbl-empty-plain`,children:Qn}):Qn})]}),it(E)&&/* @__PURE__ */ _(l,{page:E.page,totalPages:E.totalPages,total:E.total,pageSize:E.pageSize,onPageChange:w?Qe:E.setPage,onPageSizeChange:w?Qe:E.setPageSize,pageSizes:E.pageSizes,mode:E.mode,summary:E.summary}),Yn&&/* @__PURE__ */ _(`div`,{ref:Xn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{C as default};
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as p,PIN_SIDES as re,ROW_HEIGHTS as ie,ROW_MOVE_LIMIT as ae,ROW_SAVE_ERROR_CLASS as oe,attachRowDrag as se,attachScrollEdges as ce,downloadTable as le,groupCount as ue,groupItems as de,isImeSafeEnter as fe,measureRows as pe,pinAtValue as me,pinClasses as he,planPins as ge,playRowMoves as _e,rowOrderChanged as ve,saveOutcomeText as ye,settledRows as be,syncTargets as xe,tableCsv as Se,tableXlsx as Ce,virtualRange as we}from"@webority/ui-elements/helpers";import{Children as Te,Fragment as Ee,isValidElement as De,useCallback as Oe,useEffect as m,useLayoutEffect as ke,useMemo as Ae,useRef as h,useState as g}from"react";import{Fragment as je,jsx as _,jsxs as v}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Me,ROW_ACTIONS_TEXT as Ne,fillText as Pe,pluralText as Fe}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Ie}from"@webority/theme/runtime";var Le=()=>import(`@webority/ui-elements/elements/data-table`),Re=[`comfortable`,`cozy`,`compact`],ze=[`hover`,`hover-menu`,`column`],Be=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,Ve=[`auto`,`fixed`],He=[`hover`,`always`],Ue=[`hide`,`show`],We=[1,2,3,4],Ge=e=>typeof e==`number`?`${e}px`:e;function Ke(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[Ge(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function y(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function qe(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||De(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Je(e,t){return qe(y(e,t),t)}var Ye=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},b=/* @__PURE__ */ new Set;function x(t,n){!b.has(t)&&Ye()&&(b.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Xe=100,Ze=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Qe=()=>{},$e=()=>({total:0,keys:[]}),et=[],tt=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function S(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function nt(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function rt(e){return e==null||e===``?t():Array.isArray(e)?Te.toArray(e):typeof e==`boolean`?String(e):e}function it(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function C(e){n(`wui-data-table`,Le);let t=r(`dataTable`,Me),Te=r(`rowActions`,Ne),De=e=>e?Pe(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:Ge,props:Ye}=i(`AppDataTable`,e),{columns:b,rows:C=et,rowKey:at=Ze,sort:ot,onSort:st,sortIcons:ct=`hover`,emptyHeader:lt=`hide`,loading:w=!1,refreshing:ut=!1,skeletonRows:dt=5,empty:ft=t.empty,emptyFiltered:pt,error:mt,onRetry:ht,sourceCount:gt,rowActions:T,linkComponent:_t,rowActionsLabel:vt,pagination:E,ariaLabel:yt,className:bt=``,wrapperClassName:xt=``,selectable:D=!1,selectedIds:O,isRowSelectable:St,onToggleRow:Ct,onToggleAll:wt,onSelectRange:Tt,renderExpanded:Et,singleExpand:Dt=!1,density:Ot=`cozy`,densitySwitch:kt=!1,exportable:At=!1,exportName:jt=`table`,onExport:Mt,tableLayout:Nt=`auto`,striped:Pt=!1,flush:Ft=!1,pad:It,nameLines:Lt,headerTone:Rt,rowDrag:k=!1,maxHeight:zt,stickyFirstColumn:Bt=!1,stickyActions:Vt=!1,equalActions:Ht=!1,linkFirstColumn:Ut=!1,stackOnMobile:Wt,hiddenColumns:Gt,rowStatus:Kt,rowTone:qt,rowActionsMode:Jt=`hover`,rowHref:A,onRowClick:Yt,activeRowKey:Xt,hoverRowKey:Zt,resizableColumns:j=!1,viewKey:Qt,groupBy:M,groupLabel:$t,virtual:N=!1,rowSaving:P,rowSaveError:en,...tn}=Ye;d(`AppDataTable`,tn);let{style:nn,...rn}=tn,an=Wt??!N,F=Oe((e,t)=>{let n=at(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[at]),on=Gt?.length?new Set(Gt):null;b=on?b.filter(e=>!(e.hideable&&on.has(e.key))):b,u(`AppDataTable`,`density`,Ot,Re),u(`AppDataTable`,`rowActionsMode`,Jt,ze),u(`AppDataTable`,`tableLayout`,Nt,Ve),u(`AppDataTable`,`sortIcons`,ct,He),u(`AppDataTable`,`emptyHeader`,lt,Ue),u(`AppDataTable`,`nameLines`,Lt,We);for(let e of b)u(`AppDataTable`,`column.pin`,e.pin,re);let I=typeof A==`function`||typeof Yt==`function`,[sn,cn]=g(null),L=kt&&sn?sn:Ot,ln=[`table table-ledger`,L===`cozy`||L===`compact`?`wui-table-${L}`:``,Jt===`hover-menu`?`wui-table-actions-menu`:``,Jt===`column`?`wui-table-actions-column`:``,Pt?`wui-table-striped`:``,Bt?`wui-table-sticky-first`:``,ct===`always`?`wui-sort-icons-always`:``,lt===`show`?`wui-table-empty-header`:``,Vt?`wui-table-sticky-actions`:``,Ht?`wui-table-equal-actions`:``,an?`wui-table-stack`:``,Ut&&I?`wui-table-link-first`:``,bt].filter(Boolean).join(` `),R=typeof Et==`function`,[un,dn]=g(()=>/* @__PURE__ */ new Set),fn=e=>dn(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return Dt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),pn=b.some(e=>typeof e.footer==`function`),mn=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),hn=(e,t)=>{if(mn(t)||(Yt&&Yt(e),!A))return;let n=A(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},z=zt!==void 0,gn=ut&&!w&&C.length>0,_n=[`table-wrap`,z?`wui-table-scroll`:``,Ft?`wui-table-flush`:``,gn?`wui-table-refreshing`:``,xt].filter(Boolean).join(` `),vn={maxHeight:z?zt:void 0,"--wui-table-pad":It!=null&&!Ft?`${It}px`:void 0,"--wui-name-lines":N?`1`:Lt?.toString(),"--wui-table-header-bg":Rt??void 0},yn=Object.values(vn).some(e=>e!==void 0)||nn!==void 0?{...vn,...nn}:void 0,bn=Math.max(1,b.length+ +!!T+ +!!D+ +!!R),xn=b.some(e=>e.pin===`start`||e.pin===`end`),Sn=xn||j||!!M||N||At||kt,B=+!!R+ +!!D,Cn=xn?ge([...R?[`lead`]:[],...D?[`lead`]:[],...b.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...T?[null]:[]]):[],V=(e,t=``)=>{let n=Cn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[p]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},H=(e,t)=>Cn[e]?{...t,...V(e).style}:t,wn=b.length-1+ +!!T;Qt&&!j&&x(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),N&&!z&&x(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),N&&(R||Wt===!0)&&x(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),N&&Lt!==void 0&&Lt!==1&&x(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),Ut&&!I&&x(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),Dt&&typeof Et!=`function`&&x(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!N&&C?.length>500&&x(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let U=N&&z&&!R&&!an&&!w&&C?.length>0,W=(e,t)=>!St||!!St(e,t),Tn=D&&C?C.reduce((e,t,n)=>e+ +!!W(t,n),0):0,G=D&&C?C.reduce((e,t,n)=>e+(W(t,n)&&O?.has(F(t,n))?1:0),0):0,En=Tn>0&&G===Tn,Dn=G>0&&!En,On=e=>{e&&(e.indeterminate=Dn)},kn=h(null),An=(e,t)=>{let n=kn.current;kn.current=e;let r=t&&n!==null?C.findIndex((e,t)=>F(e,t)===n):-1,i=C.findIndex((t,n)=>F(t,n)===e);if(r<0||i<0||r===i){Ct?.(e);return}let a=!O?.has(e),o=Math.min(r,i),s=C.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>W(e,t)).map(([e,t])=>F(e,t)).filter(e=>(O?.has(e)||!1)!==a);if(Tt)Tt(s,a);else for(let e of s)Ct?.(e)},jn=e=>{St?(C||[]).forEach((t,n)=>{let r=F(t,n);W(t,n)&&(O?.has(r)||!1)!==e&&Ct?.(r)}):wt?.(e)},[Mn,Nn]=g(()=>/* @__PURE__ */ new Set),Pn=e=>Nn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),K=Ae(()=>{let e=(C||[]).map((e,t)=>({row:e,i:t}));return M?de(e,({row:e})=>String(y(e,M)??``)).flatMap(e=>[{group:e,open:!Mn.has(e.key)},...Mn.has(e.key)?[]:e.items]):e},[C,M,Mn]),Fn=h(null),[q,In]=g(null),Ln=Oe(e=>{Fn.current=e,In(e)},[]),Rn=h(null);m(()=>{let e=q;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;Rn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(Rn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=ce(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[q]),m(()=>{if(!k||!q)return;let e=se(q);return xe(document),e},[k,q]);let zn=h($e);ke(()=>{zn.current=()=>({total:C?.length??0,keys:C?C.flatMap((e,t)=>{let n=F(e,t);return W(e,t)&&O?.has(n)?[String(n)]:[]}):[]})});let Bn=h(!1);m(()=>{if(!Bn.current&&(Bn.current=!0,G===0))return;let{total:e,keys:t}=zn.current();Fn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:G,total:e,keys:t}}))},[G]);let[Vn,Hn]=g({top:0,height:0}),[J,Un]=g(ie[L]??ie.cozy);m(()=>{let e=q;if(!U||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Hn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[U,q]);let Wn=h(null);ke(()=>{if(!U){Wn.current=null;return}let e=`${L}:${C?.length??0}`;if(Wn.current===e)return;Wn.current=e;let t=(Fn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-J)>.5&&Un(t)});let Y={start:0,end:K.length,before:0,after:0};if(U){Y=we({scrollTop:Vn.top,viewport:Vn.height||Number.parseFloat(String(zt))||0,rowHeight:J,count:K.length});let e=Rn.current;e!==null&&e>=0&&e<K.length&&(e<Y.start&&Y.start-e<=Xe&&(Y={...Y,start:e,before:e*J}),e>=Y.end&&e-Y.end<Xe&&(Y={...Y,end:e+1,after:(K.length-e-1)*J}))}let Gn=h(null),Kn=h(null),qn=h(null),Jn=!N&&!w&&C?.length>0&&C.length<=ae;ke(()=>{let e=Gn.current;if(!Jn||!e){Kn.current=null,qn.current=null;return}let t=C.map((e,t)=>F(e,t));ve(qn.current,t)&&_e(e.rows,Kn.current),Kn.current=pe(e.rows),qn.current=t});let Yn=typeof P==`function`||typeof en==`function`,Xn=h(null),Zn=h(null),X=b[0]?.key;m(()=>{if(!Yn){Zn.current=null;return}let e=/* @__PURE__ */ new Map;(C||[]).forEach((t,n)=>{let r=X===void 0?void 0:y(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(F(t,n),{...tt(t,P,en),label:i})});let t=ye(be(Zn.current,e));Zn.current=e,t&&Xn.current&&(Xn.current.textContent=t)},[C,P,en,F,Yn,X]);let Qn=pt!==void 0&&(gt===void 0||gt>0)?pt:ft,Z=!w&&mt?mt:null,$n=e=>{if(Mt){Mt(e);return}let t=b.map(e=>typeof e.label==`string`?e.label:e.key),n=C.map(e=>b.map(t=>{let n=t.exportValue?t.exportValue(e):y(e,t.key);return n==null?``:String(n)}));e===`csv`?le([Se(t,n)],`text/csv;charset=utf-8`,`${jt}.csv`):le([Ce(t,n)],Be,`${jt}.xlsx`)},er=({group:e,open:n},r)=>{let i=y(e.items[0]?.row,M??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ _(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":U?r+2:void 0,children:/* @__PURE__ */ _(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:bn,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>Pn(e.key),children:[/* @__PURE__ */ _(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ _(`span`,{className:`wui-group-label`,children:$t?$t(i,a):rt(qe(i,M??``))}),/* @__PURE__ */ _(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Fe(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},tr=({row:e,i:n},r)=>{let i=F(e,n),a=R&&un.has(i),o=Xt!=null&&String(Xt)===String(i),ee=Zt!=null&&String(Zt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=V(0,`wui-expand-cell`),u=V(+!!R,`wui-select-cell`),d=Yn?tt(e,P,en):null,f=W(e,n),ne=T?.(e);if(T&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mts --check.`);let p=X===void 0?void 0:y(e,X),re=typeof p==`string`||typeof p==`number`?Pe(t.moreActionsForText,{firstValue:p}):Te.menuLabel;return/* @__PURE__ */ v(Ee,{children:[/* @__PURE__ */ v(`tr`,{className:[D&&f&&O?.has(i)?`is-selected`:``,I?`wui-row-link`:``,o?`wui-row-active`:``,ee?Ie.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":U?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Kt?.(e)||void 0,"data-tone":qt?.(e)||void 0,"data-href":A?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:I?0:void 0,onClick:I?t=>hn(e,t):void 0,onAuxClick:I&&A?t=>t.button===1&&hn(e,t):void 0,onKeyDown:I?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&hn(e,t)}:void 0,children:[R&&/* @__PURE__ */ _(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>fn(i),children:/* @__PURE__ */ _(s,{name:`chevron-down`,size:16})})}),D&&/* @__PURE__ */ _(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ _(`input`,{type:`checkbox`,className:`form-check-input`,checked:f&&(O?.has(i)||!1),disabled:!f,onChange:e=>An(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),b.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ v(r,{scope:t.rowHeader?`row`:void 0,className:V(B+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+S(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)+(t.columnClassName?` ${t.columnClassName}`:``)).className,style:H(B+n,t.cellStyle),"data-label":an&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):rt(Je(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ _(`span`,{className:oe,children:d.message})]},t.key)}),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(te,{items:ne??[],menuLabel:re,linkComponent:_t})})]}),a&&/* @__PURE__ */ _(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ _(`td`,{id:`${c}-expanded`,colSpan:bn,children:Et?.(e)})})]},i)},nr=(e,t)=>`group`in e?er(e,t):tr(e,t),rr=(e,t)=>U?/* @__PURE__ */ _(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ _(`td`,{colSpan:bn,style:{height:t}})},e):null,Q=V(0,`wui-expand-cell`),$=V(+!!R,`wui-select-cell`),ir=()=>Array.from({length:dt},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ v(`tr`,{children:[R&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,void 0),"data-label":an&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ _(c,{width:nt(e.align),height:12,radius:6})},e.key)),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ _(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ v(je,{children:[/* @__PURE__ */ v(Sn?`wui-data-table`:`div`,{ref:Ln,...Sn?{class:_n,resizable:j?``:void 0,"view-key":Qt||void 0,"data-wui-row-drag":k?``:void 0,"aria-busy":gn||void 0}:{className:_n,"data-wui-row-drag":k?``:void 0,"aria-busy":gn||void 0},style:yn,tabIndex:0,...Ge,...rn,children:[At&&/* @__PURE__ */ v(`div`,{className:`wui-table-export`,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>$n(`csv`),children:t.exportCsvLabel}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>$n(`xlsx`),children:t.exportExcelLabel})]}),kt&&/* @__PURE__ */ v(`div`,{className:`wui-table-density`,role:`group`,"aria-label":t.densityLabel,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`comfortable`,"aria-label":t.densityComfortableLabel,onClick:()=>cn(`comfortable`),children:/* @__PURE__ */ _(s,{name:`list`,size:16})}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`compact`,"aria-label":t.densityCompactLabel,onClick:()=>cn(`compact`),children:/* @__PURE__ */ _(s,{name:`grid`,size:16})})]}),/* @__PURE__ */ v(`table`,{className:ln,"aria-label":yt,"aria-rowcount":U?K.length+1:void 0,style:Nt===`fixed`?{tableLayout:`fixed`,minWidth:Ke(b)}:void 0,children:[/* @__PURE__ */ _(`thead`,{children:/* @__PURE__ */ v(`tr`,{"aria-rowindex":U?1:void 0,children:[R&&/* @__PURE__ */ _(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.expandLabel})}),D&&/* @__PURE__ */ _(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ _(`input`,{ref:On,type:`checkbox`,className:`form-check-input`,checked:En,disabled:w,onChange:e=>jn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),b.map((e,t)=>{let n=e.sortable?st:void 0,r=n!==void 0,i=ot&&ot.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ _(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ _(s,{name:`chevrons-up-down`,size:14})}),te=j&&t!==wn,c=Nt===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ v(`th`,{className:V(B+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,l),"data-key":Sn?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?ot?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||w||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(fe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),w||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ _(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ _(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":De(typeof e.label==`string`?e.label:e.key)})]},e.key)}),T&&(vt?/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:vt}):/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ _(`tbody`,{ref:Gn,children:w?ir():Z?null:C?.length?/* @__PURE__ */ v(je,{children:[rr(`before`,Y.before),K.slice(Y.start,Y.end).map((e,t)=>nr(e,Y.start+t)),rr(`after`,Y.after)]}):null}),pn&&!w&&!Z&&C?.length>0&&/* @__PURE__ */ _(`tfoot`,{children:/* @__PURE__ */ v(`tr`,{children:[R&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)+(e.columnClassName?` ${e.columnClassName}`:``)).className,style:H(B+t,void 0),children:e.footer?e.footer(C):null},e.key)),T&&/* @__PURE__ */ _(`td`,{})]})})]}),!w&&(Z||!C?.length)&&/* @__PURE__ */ _(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ _(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:ht?/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>ht(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Qn==`string`?/* @__PURE__ */ _(`div`,{className:`tbl-empty-plain`,children:Qn}):Qn})]}),it(E)&&/* @__PURE__ */ _(l,{page:E.page,totalPages:E.totalPages,total:E.total,pageSize:E.pageSize,onPageChange:w?Qe:E.setPage,onPageSizeChange:w?Qe:E.setPageSize,pageSizes:E.pageSizes,mode:E.mode,summary:E.summary,summaryText:E.summaryText}),Yn&&/* @__PURE__ */ _(`div`,{ref:Xn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppInfoTip.js";import a from"./AppKbd.js";import o from"./AppSkeleton.js";import s from"./AppSpinner.js";import c from"./AppTablePagination.js";import l from"./assertValidValue.js";import u from"./warnUnknownProps.js";import{memo as d,useEffect as f,useMemo as p,useRef as m,useState as ee}from"react";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";import{ENTRY_GRID_TEXT as v,KBD_TEXT as te}from"@webority/ui-elements/text";var ne=[`text`,`number`],re=[`start`],ie=3,ae=[`clean`,`dirty`,`saving`,`saved`,`failed`],oe=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)),se=()=>import(`@webority/ui-elements/elements/entry-grid`);function y(e,t){return e===`dirty`?/* @__PURE__ */ g(`span`,{className:`wui-entry-grid-dot`,role:`img`,"aria-label":t.dirty}):e===`saving`?/* @__PURE__ */ g(s,{size:`sm`,label:t.saving}):e===`saved`?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ g(r,{name:`tick-circle`,size:16}),/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.saved})]}):e===`failed`?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ g(r,{name:`danger`,size:16}),/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.failed})]}):null}function b(e){return e.kind===`number`?`text-end`:void 0}function x(e,t){let n=t?.(e)??{};for(let e of Object.keys(n))if(!e.startsWith(`data-`)||e===`data-row-key`)throw Error(`AppEntryGrid: rowProps can only return data-* attributes other than data-row-key, not "${e}".`);return n}function ce({row:e,rowKeyValue:t,status:n,isActive:r,columns:i,renderCell:a,rowError:o,renderRowDetail:s,rowProps:c,span:l,statusText:u}){let d=n===`failed`&&o!==void 0,f=r&&s!==void 0,p=[`wui-entry-grid-row`,r&&`is-active`,n!==`clean`&&`wui-entry-grid-row-${n}`].filter(Boolean).join(` `);return/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ _(`tr`,{...x(e,c),className:p,"data-row-key":t,"aria-current":r?`true`:void 0,children:[/* @__PURE__ */ g(`td`,{className:`wui-entry-grid-status`,children:y(n,u)}),i.map(t=>/* @__PURE__ */ g(`td`,{className:b(t),"data-kind":t.kind??`text`,"data-column-key":t.key,"data-pin":t.pin,children:a(e,t,r)},t.key))]}),d||f?/* @__PURE__ */ g(`tr`,{className:`wui-entry-grid-detail`,children:/* @__PURE__ */ _(`td`,{colSpan:l,children:[d?/* @__PURE__ */ g(`div`,{className:`wui-entry-grid-error`,role:`alert`,children:o(e)}):null,f?s(e):null]})}):null]})}function S(s){e(`wui-entry-grid`,se);let y=t(`entryGrid`,v),x=t(`kbd`,te),{marker:S,props:C}=n(`AppEntryGrid`,s),{columns:w,rows:T,rowKey:E,activeRowKey:D,onActiveRowChange:O,renderCell:le,rowState:k,rowError:ue,onCommitRow:A,onDiscardRow:j,onAddRow:M,sort:N,onSort:P,onPasteRows:F,onRemoveRow:I,loading:L=!1,skeletonRows:R=ie,emptyContent:z,rowProps:de,pagination:B,renderRowDetail:fe,hint:pe=!0,label:me=y.label,addLabel:he=y.addLabel,emptyLabel:ge=y.emptyLabel,statusLabel:V=y.statusLabel,dirtyLabel:H=y.dirtyLabel,savingLabel:U=y.savingLabel,savedLabel:W=y.savedLabel,failedLabel:G=y.failedLabel,commitNextLabel:_e=y.commitNextLabel,commitStayLabel:ve=y.commitStayLabel,discardLabel:ye=y.discardLabel,moveLabel:be=y.moveLabel,removeLineLabel:xe=y.removeLineLabel,maxHeight:K,className:Se=``,...q}=C;if(u(`AppEntryGrid`,q),w.forEach((e,t)=>{if(l(`AppEntryGrid`,`columns[].kind`,e.kind,ne),l(`AppEntryGrid`,`columns[].pin`,e.pin,re),e.pin!==void 0&&t!==0)throw Error(`AppEntryGrid: only the first column can be pinned, but "${e.key}" has pin.`);if(e.sortable&&P===void 0)throw Error(`AppEntryGrid: column "${e.key}" is sortable, so the grid needs onSort.`)}),!Number.isInteger(R)||R<1)throw Error(`AppEntryGrid: skeletonRows must be a whole number of 1 or more, not ${R}.`);if(z!==void 0&&C.emptyLabel!==void 0)throw Error(`AppEntryGrid: give emptyLabel or emptyContent, not both.`);let Ce=T.map(e=>{let t=k?k(e):`clean`;return l(`AppEntryGrid`,`rowState()`,t,ae),t}),J=m(null),Y=m({rows:T,rowKey:E,onCommitRow:A,onDiscardRow:j,onActiveRowChange:O,onAddRow:M,onSort:P,onPasteRows:F,onRemoveRow:I});Y.current={rows:T,rowKey:E,onCommitRow:A,onDiscardRow:j,onActiveRowChange:O,onAddRow:M,onSort:P,onPasteRows:F,onRemoveRow:I};let we=p(()=>({dirty:H,saving:U,saved:W,failed:G}),[H,U,W,G]),[X]=ee(()=>d(ce));f(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e instanceof CustomEvent?e.detail?.rowKey:void 0,{rows:n,rowKey:r}=Y.current;return typeof t==`string`?n.find(e=>r(e)===t):void 0},n=e=>{let n=t(e),r=e instanceof CustomEvent?e.detail?.move:void 0;n!==void 0&&(r===`next`||r===`stay`)&&Y.current.onCommitRow?.(n,r)},r=e=>{let n=t(e);n!==void 0&&Y.current.onDiscardRow?.(n)},i=e=>{let n=t(e);n!==void 0&&Y.current.onActiveRowChange?.(Y.current.rowKey(n))},a=()=>Y.current.onAddRow?.(),o=e=>{let t=e instanceof CustomEvent?e.detail?.columnKey:void 0;typeof t==`string`&&Y.current.onSort?.(t)},s=e=>{let n=e instanceof CustomEvent?e.detail:void 0,r=t(e);r!==void 0&&typeof n?.columnKey==`string`&&oe(n.rows)&&Y.current.onPasteRows?.({rowKey:Y.current.rowKey(r),columnKey:n.columnKey,rows:n.rows})},c=e=>{let n=t(e);n!==void 0&&Y.current.onRemoveRow?.(Y.current.rowKey(n))};return e.addEventListener(`wui-entry-grid:commit`,n),e.addEventListener(`wui-entry-grid:discard`,r),e.addEventListener(`wui-entry-grid:active`,i),e.addEventListener(`wui-entry-grid:add`,a),e.addEventListener(`wui-entry-grid:sort`,o),e.addEventListener(`wui-entry-grid:paste`,s),e.addEventListener(`wui-entry-grid:remove`,c),()=>{e.removeEventListener(`wui-entry-grid:commit`,n),e.removeEventListener(`wui-entry-grid:discard`,r),e.removeEventListener(`wui-entry-grid:active`,i),e.removeEventListener(`wui-entry-grid:add`,a),e.removeEventListener(`wui-entry-grid:sort`,o),e.removeEventListener(`wui-entry-grid:paste`,s),e.removeEventListener(`wui-entry-grid:remove`,c)}},[]);let Te=w.some(e=>e.footer),Z=w.length+1,Ee=e=>[e.sortable&&`sortable`,e.kind===`number`&&`text-end`].filter(Boolean).join(` `)||void 0,Q=w.some(e=>e.group!==void 0),$=[];for(let e of w){let t=$[$.length-1];e.group!==void 0&&t?.group===e.group?t.span+=1:$.push({key:e.key,group:e.group,span:1})}let De=e=>{if(e.sortable)return N?.key===e.key?N.dir===`asc`?`ascending`:`descending`:`none`};return/* @__PURE__ */ _(`wui-entry-grid`,{ref:J,class:[`wui-entry-grid`,Se].filter(Boolean).join(` `),"active-row":D??``,removable:I?``:void 0,...S,...q,children:[/* @__PURE__ */ g(`div`,{className:[`table-responsive wui-entry-grid-scroll`,K!==void 0&&`wui-entry-grid-scrolls`].filter(Boolean).join(` `),style:K===void 0?void 0:{maxHeight:K},children:/* @__PURE__ */ _(`table`,{className:`table wui-entry-grid-table`,"aria-label":me,children:[/* @__PURE__ */ _(`thead`,{children:[Q?/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`th`,{scope:`col`,className:`wui-entry-grid-status`,rowSpan:2,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:V})}),$.map(e=>/* @__PURE__ */ g(`th`,{className:`wui-entry-grid-group`,scope:e.span>1?`colgroup`:`col`,colSpan:e.span>1?e.span:void 0,"data-pin":e.span===1?w.find(t=>t.key===e.key)?.pin:void 0,children:e.group},e.key))]}):null,/* @__PURE__ */ _(`tr`,{children:[Q?null:/* @__PURE__ */ g(`th`,{scope:`col`,className:`wui-entry-grid-status`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:V})}),w.map(e=>{let t=e.sortable?/* @__PURE__ */ g(`span`,{className:`sort-icon${e.kind===`number`?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(r,{name:`chevrons-up-down`,size:14})}):null;return/* @__PURE__ */ _(`th`,{scope:`col`,className:Ee(e),style:e.width===void 0?void 0:{width:e.width},"data-column-key":e.key,"data-pin":e.pin,"data-sortable":e.sortable?`true`:void 0,tabIndex:e.sortable?0:void 0,"aria-sort":De(e),children:[e.kind===`number`?t:null,e.label,e.kind===`number`?null:t,e.help?/* @__PURE__ */ g(i,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null]},e.key)})]})]}),/* @__PURE__ */ _(`tbody`,{children:[L?Array.from({length:R},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`td`,{className:`wui-entry-grid-status`}),w.map(e=>/* @__PURE__ */ g(`td`,{className:b(e),"data-column-key":e.key,"data-pin":e.pin,children:/* @__PURE__ */ g(o,{width:e.kind===`number`?`56%`:`60%`,height:12,radius:6})},e.key))]},e)):T.map((e,t)=>{let n=E(e);return/* @__PURE__ */ g(X,{row:e,rowKeyValue:n,status:Ce[t]??`clean`,isActive:n===D,columns:w,renderCell:le,rowError:ue,renderRowDetail:fe,rowProps:de,span:Z,statusText:we},n)}),!L&&T.length===0?/* @__PURE__ */ g(`tr`,{className:`wui-entry-grid-empty`,children:/* @__PURE__ */ g(`td`,{colSpan:Z,children:z===void 0?ge:z})}):null]}),Te?/* @__PURE__ */ g(`tfoot`,{className:`wui-entry-grid-footer`,children:/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`td`,{}),w.map(e=>/* @__PURE__ */ g(`td`,{className:b(e),children:e.footer?.(T)},e.key))]})}):null]})}),B?/* @__PURE__ */ g(c,{page:B.page,totalPages:B.totalPages,total:B.total,pageSize:B.pageSize,onPageChange:L?void 0:B.setPage,onPageSizeChange:L?void 0:B.setPageSize,pageSizes:B.pageSizes,mode:B.mode,summary:B.summary}):null,/* @__PURE__ */ _(`div`,{className:`wui-entry-grid-bar`,children:[M?/* @__PURE__ */ g(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary wui-entry-grid-add`,children:he}):null,pe?/* @__PURE__ */ _(`ul`,{className:`wui-entry-grid-hint`,children:[A?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.enterLabel}),` ${_e}`]}),/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`S`}),` ${ve}`]})]}):null,/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.escLabel}),` ${ye}`]}),/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`↑`}),`/`,/* @__PURE__ */ g(a,{children:`↓`}),` ${be}`]}),I?/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`Delete`}),` ${xe}`]}):null]}):null]})]})}export{S as default};
|
|
1
|
+
import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppInfoTip.js";import a from"./AppKbd.js";import o from"./AppSkeleton.js";import s from"./AppSpinner.js";import c from"./AppTablePagination.js";import l from"./assertValidValue.js";import u from"./warnUnknownProps.js";import{memo as d,useEffect as f,useMemo as p,useRef as m,useState as ee}from"react";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";import{ENTRY_GRID_TEXT as v,KBD_TEXT as te}from"@webority/ui-elements/text";var ne=[`text`,`number`],re=[`start`],ie=3,ae=[`clean`,`dirty`,`saving`,`saved`,`failed`],oe=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)),se=()=>import(`@webority/ui-elements/elements/entry-grid`);function y(e,t){return e===`dirty`?/* @__PURE__ */ g(`span`,{className:`wui-entry-grid-dot`,role:`img`,"aria-label":t.dirty}):e===`saving`?/* @__PURE__ */ g(s,{size:`sm`,label:t.saving}):e===`saved`?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ g(r,{name:`tick-circle`,size:16}),/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.saved})]}):e===`failed`?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ g(r,{name:`danger`,size:16}),/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.failed})]}):null}function b(e){return e.kind===`number`?`text-end`:void 0}function x(e,t){let n=t?.(e)??{};for(let e of Object.keys(n))if(!e.startsWith(`data-`)||e===`data-row-key`)throw Error(`AppEntryGrid: rowProps can only return data-* attributes other than data-row-key, not "${e}".`);return n}function ce({row:e,rowKeyValue:t,status:n,isActive:r,columns:i,renderCell:a,rowError:o,renderRowDetail:s,rowProps:c,span:l,statusText:u}){let d=n===`failed`&&o!==void 0,f=r&&s!==void 0,p=[`wui-entry-grid-row`,r&&`is-active`,n!==`clean`&&`wui-entry-grid-row-${n}`].filter(Boolean).join(` `);return/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ _(`tr`,{...x(e,c),className:p,"data-row-key":t,"aria-current":r?`true`:void 0,children:[/* @__PURE__ */ g(`td`,{className:`wui-entry-grid-status`,children:y(n,u)}),i.map(t=>/* @__PURE__ */ g(`td`,{className:b(t),"data-kind":t.kind??`text`,"data-column-key":t.key,"data-pin":t.pin,children:a(e,t,r)},t.key))]}),d||f?/* @__PURE__ */ g(`tr`,{className:`wui-entry-grid-detail`,children:/* @__PURE__ */ _(`td`,{colSpan:l,children:[d?/* @__PURE__ */ g(`div`,{className:`wui-entry-grid-error`,role:`alert`,children:o(e)}):null,f?s(e):null]})}):null]})}function S(s){e(`wui-entry-grid`,se);let y=t(`entryGrid`,v),x=t(`kbd`,te),{marker:S,props:C}=n(`AppEntryGrid`,s),{columns:w,rows:T,rowKey:E,activeRowKey:D,onActiveRowChange:O,renderCell:le,rowState:k,rowError:ue,onCommitRow:A,onDiscardRow:j,onAddRow:M,sort:N,onSort:P,onPasteRows:F,onRemoveRow:I,loading:L=!1,skeletonRows:R=ie,emptyContent:z,rowProps:de,pagination:B,renderRowDetail:fe,hint:pe=!0,label:me=y.label,addLabel:he=y.addLabel,emptyLabel:ge=y.emptyLabel,statusLabel:V=y.statusLabel,dirtyLabel:H=y.dirtyLabel,savingLabel:U=y.savingLabel,savedLabel:W=y.savedLabel,failedLabel:G=y.failedLabel,commitNextLabel:_e=y.commitNextLabel,commitStayLabel:ve=y.commitStayLabel,discardLabel:ye=y.discardLabel,moveLabel:be=y.moveLabel,removeLineLabel:xe=y.removeLineLabel,maxHeight:K,className:Se=``,...q}=C;if(u(`AppEntryGrid`,q),w.forEach((e,t)=>{if(l(`AppEntryGrid`,`columns[].kind`,e.kind,ne),l(`AppEntryGrid`,`columns[].pin`,e.pin,re),e.pin!==void 0&&t!==0)throw Error(`AppEntryGrid: only the first column can be pinned, but "${e.key}" has pin.`);if(e.sortable&&P===void 0)throw Error(`AppEntryGrid: column "${e.key}" is sortable, so the grid needs onSort.`)}),!Number.isInteger(R)||R<1)throw Error(`AppEntryGrid: skeletonRows must be a whole number of 1 or more, not ${R}.`);if(z!==void 0&&C.emptyLabel!==void 0)throw Error(`AppEntryGrid: give emptyLabel or emptyContent, not both.`);let Ce=T.map(e=>{let t=k?k(e):`clean`;return l(`AppEntryGrid`,`rowState()`,t,ae),t}),J=m(null),Y=m({rows:T,rowKey:E,onCommitRow:A,onDiscardRow:j,onActiveRowChange:O,onAddRow:M,onSort:P,onPasteRows:F,onRemoveRow:I});Y.current={rows:T,rowKey:E,onCommitRow:A,onDiscardRow:j,onActiveRowChange:O,onAddRow:M,onSort:P,onPasteRows:F,onRemoveRow:I};let we=p(()=>({dirty:H,saving:U,saved:W,failed:G}),[H,U,W,G]),[X]=ee(()=>d(ce));f(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e instanceof CustomEvent?e.detail?.rowKey:void 0,{rows:n,rowKey:r}=Y.current;return typeof t==`string`?n.find(e=>r(e)===t):void 0},n=e=>{let n=t(e),r=e instanceof CustomEvent?e.detail?.move:void 0;n!==void 0&&(r===`next`||r===`stay`)&&Y.current.onCommitRow?.(n,r)},r=e=>{let n=t(e);n!==void 0&&Y.current.onDiscardRow?.(n)},i=e=>{let n=t(e);n!==void 0&&Y.current.onActiveRowChange?.(Y.current.rowKey(n))},a=()=>Y.current.onAddRow?.(),o=e=>{let t=e instanceof CustomEvent?e.detail?.columnKey:void 0;typeof t==`string`&&Y.current.onSort?.(t)},s=e=>{let n=e instanceof CustomEvent?e.detail:void 0,r=t(e);r!==void 0&&typeof n?.columnKey==`string`&&oe(n.rows)&&Y.current.onPasteRows?.({rowKey:Y.current.rowKey(r),columnKey:n.columnKey,rows:n.rows})},c=e=>{let n=t(e);n!==void 0&&Y.current.onRemoveRow?.(Y.current.rowKey(n))};return e.addEventListener(`wui-entry-grid:commit`,n),e.addEventListener(`wui-entry-grid:discard`,r),e.addEventListener(`wui-entry-grid:active`,i),e.addEventListener(`wui-entry-grid:add`,a),e.addEventListener(`wui-entry-grid:sort`,o),e.addEventListener(`wui-entry-grid:paste`,s),e.addEventListener(`wui-entry-grid:remove`,c),()=>{e.removeEventListener(`wui-entry-grid:commit`,n),e.removeEventListener(`wui-entry-grid:discard`,r),e.removeEventListener(`wui-entry-grid:active`,i),e.removeEventListener(`wui-entry-grid:add`,a),e.removeEventListener(`wui-entry-grid:sort`,o),e.removeEventListener(`wui-entry-grid:paste`,s),e.removeEventListener(`wui-entry-grid:remove`,c)}},[]);let Te=w.some(e=>e.footer),Z=w.length+1,Ee=e=>[e.sortable&&`sortable`,e.kind===`number`&&`text-end`].filter(Boolean).join(` `)||void 0,Q=w.some(e=>e.group!==void 0),$=[];for(let e of w){let t=$[$.length-1];e.group!==void 0&&t?.group===e.group?t.span+=1:$.push({key:e.key,group:e.group,span:1})}let De=e=>{if(e.sortable)return N?.key===e.key?N.dir===`asc`?`ascending`:`descending`:`none`};return/* @__PURE__ */ _(`wui-entry-grid`,{ref:J,class:[`wui-entry-grid`,Se].filter(Boolean).join(` `),"active-row":D??``,removable:I?``:void 0,...S,...q,children:[/* @__PURE__ */ g(`div`,{className:[`table-responsive wui-entry-grid-scroll`,K!==void 0&&`wui-entry-grid-scrolls`].filter(Boolean).join(` `),style:K===void 0?void 0:{maxHeight:K},children:/* @__PURE__ */ _(`table`,{className:`table wui-entry-grid-table`,"aria-label":me,children:[/* @__PURE__ */ _(`thead`,{children:[Q?/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`th`,{scope:`col`,className:`wui-entry-grid-status`,rowSpan:2,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:V})}),$.map(e=>/* @__PURE__ */ g(`th`,{className:`wui-entry-grid-group`,scope:e.span>1?`colgroup`:`col`,colSpan:e.span>1?e.span:void 0,"data-pin":e.span===1?w.find(t=>t.key===e.key)?.pin:void 0,children:e.group},e.key))]}):null,/* @__PURE__ */ _(`tr`,{children:[Q?null:/* @__PURE__ */ g(`th`,{scope:`col`,className:`wui-entry-grid-status`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:V})}),w.map(e=>{let t=e.sortable?/* @__PURE__ */ g(`span`,{className:`sort-icon${e.kind===`number`?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(r,{name:`chevrons-up-down`,size:14})}):null;return/* @__PURE__ */ _(`th`,{scope:`col`,className:Ee(e),style:e.width===void 0?void 0:{width:e.width},"data-column-key":e.key,"data-pin":e.pin,"data-sortable":e.sortable?`true`:void 0,tabIndex:e.sortable?0:void 0,"aria-sort":De(e),children:[e.kind===`number`?t:null,e.label,e.kind===`number`?null:t,e.help?/* @__PURE__ */ g(i,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null]},e.key)})]})]}),/* @__PURE__ */ _(`tbody`,{children:[L?Array.from({length:R},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`td`,{className:`wui-entry-grid-status`}),w.map(e=>/* @__PURE__ */ g(`td`,{className:b(e),"data-column-key":e.key,"data-pin":e.pin,children:/* @__PURE__ */ g(o,{width:e.kind===`number`?`56%`:`60%`,height:12,radius:6})},e.key))]},e)):T.map((e,t)=>{let n=E(e);return/* @__PURE__ */ g(X,{row:e,rowKeyValue:n,status:Ce[t]??`clean`,isActive:n===D,columns:w,renderCell:le,rowError:ue,renderRowDetail:fe,rowProps:de,span:Z,statusText:we},n)}),!L&&T.length===0?/* @__PURE__ */ g(`tr`,{className:`wui-entry-grid-empty`,children:/* @__PURE__ */ g(`td`,{colSpan:Z,children:z===void 0?ge:z})}):null]}),Te?/* @__PURE__ */ g(`tfoot`,{className:`wui-entry-grid-footer`,children:/* @__PURE__ */ _(`tr`,{children:[/* @__PURE__ */ g(`td`,{}),w.map(e=>/* @__PURE__ */ g(`td`,{className:b(e),children:e.footer?.(T)},e.key))]})}):null]})}),B?/* @__PURE__ */ g(c,{page:B.page,totalPages:B.totalPages,total:B.total,pageSize:B.pageSize,onPageChange:L?void 0:B.setPage,onPageSizeChange:L?void 0:B.setPageSize,pageSizes:B.pageSizes,mode:B.mode,summary:B.summary,summaryText:B.summaryText}):null,/* @__PURE__ */ _(`div`,{className:`wui-entry-grid-bar`,children:[M?/* @__PURE__ */ g(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary wui-entry-grid-add`,children:he}):null,pe?/* @__PURE__ */ _(`ul`,{className:`wui-entry-grid-hint`,children:[A?/* @__PURE__ */ _(h,{children:[/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.enterLabel}),` ${_e}`]}),/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`S`}),` ${ve}`]})]}):null,/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.escLabel}),` ${ye}`]}),/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`↑`}),`/`,/* @__PURE__ */ g(a,{children:`↓`}),` ${be}`]}),I?/* @__PURE__ */ _(`li`,{children:[/* @__PURE__ */ g(a,{children:x.ctrlLabel}),`+`,/* @__PURE__ */ g(a,{children:`Delete`}),` ${xe}`]}):null]}):null]})]})}export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{createElement as r,useCallback as i,useEffect as a,useLayoutEffect as o,useRef as s,useState as c}from"react";import{createPortal as l}from"react-dom";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";var p=`wui-file-viewer:load`,m=`wui-file-viewer:error`,h=`wui-file-viewer:prefs-change`,g=()=>import(`@webority/ui-elements/file-viewer`);function _({ref:_,...v}){let{marker:y,props:b}=t(`AppFileViewer`,v),{src:x,name:S,type:C,prefs:w,onPrefsChange:T,viewKey:E,download:D=!1,print:O=!0,workerSrc:k,assetBase:A,captions:j,actions:M,onLoad:N,onError:P,className:F=``,style:I,...L}=b;n(`AppFileViewer`,L);let R=e(`wui-file-viewer`,g),z=s(null),B=s(N),V=s(P),H=s(T),[U,W]=c(null),G=i(e=>{z.current=e,typeof _==`function`?_(e):_&&(_.current=e)},[_]);o(()=>{if(!R||w===void 0)return;let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);e.prefs=w},[w,R]),a(()=>{B.current=N,V.current=P,H.current=T}),a(()=>{let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);let t=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:load arrived without a CustomEvent`);B.current?.(e.detail)},n=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:error arrived without a CustomEvent`);V.current?.(e.detail)},r=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:prefs-change arrived without a CustomEvent`);H.current?.(e.detail)};return e.addEventListener(p,t),e.addEventListener(m,n),e.addEventListener(h,r),()=>{e.removeEventListener(p,t),e.removeEventListener(m,n),e.removeEventListener(h,r)}},[]),a(()=>{if(!R)return;let e=z.current;e?.isConnected&&W(e.actionsContainer)},[R])
|
|
1
|
+
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{createElement as r,useCallback as i,useEffect as a,useLayoutEffect as o,useRef as s,useState as c}from"react";import{createPortal as l}from"react-dom";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";var p=`wui-file-viewer:load`,m=`wui-file-viewer:error`,h=`wui-file-viewer:prefs-change`,g=()=>import(`@webority/ui-elements/file-viewer`);function _({ref:_,...v}){let{marker:y,props:b}=t(`AppFileViewer`,v),{src:x,name:S,type:C,prefs:w,onPrefsChange:T,viewKey:E,download:D=!1,print:O=!0,workerSrc:k,assetBase:A,captions:j,actions:M,onLoad:N,onError:P,className:F=``,style:I,...L}=b;n(`AppFileViewer`,L);let R=e(`wui-file-viewer`,g),z=s(null),B=s(N),V=s(P),H=s(T),[U,W]=c(null),G=i(e=>{z.current=e,typeof _==`function`?_(e):_&&(_.current=e)},[_]);return o(()=>{if(!R||w===void 0)return;let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);e.prefs=w},[w,R]),a(()=>{B.current=N,V.current=P,H.current=T}),a(()=>{let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);let t=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:load arrived without a CustomEvent`);B.current?.(e.detail)},n=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:error arrived without a CustomEvent`);V.current?.(e.detail)},r=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:prefs-change arrived without a CustomEvent`);H.current?.(e.detail)};return e.addEventListener(p,t),e.addEventListener(m,n),e.addEventListener(h,r),()=>{e.removeEventListener(p,t),e.removeEventListener(m,n),e.removeEventListener(h,r)}},[]),a(()=>{if(!R)return;let e=z.current;e?.isConnected&&W(e.actionsContainer)},[R]),/* @__PURE__ */ f(u,{children:[r(`wui-file-viewer`,{ref:G,src:x,name:S||void 0,type:C||void 0,"view-key":E||void 0,download:D?``:void 0,print:O?void 0:`false`,"worker-src":k||void 0,"asset-base":A||void 0,captions:j||void 0,className:F||void 0,style:I,...y,...L}),U&&M!=null&&l(/* @__PURE__ */ d(`div`,{slot:`actions`,className:`wui-file-viewer-slot`,children:M}),U)]})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{groupIndianText as e}from"../lib/indianGrouping.js";import t from"../lib/useElementEntry.js";import
|
|
1
|
+
import{groupIndianText as e}from"../lib/indianGrouping.js";import t from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import ee from"./AppSelect.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{INLINE_EDIT_TYPES as s,inlineEditText as c}from"@webority/ui-elements/helpers";import{useEffect as l,useId as te,useRef as u,useState as d}from"react";import{flushSync as f}from"react-dom";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{INLINE_EDIT_TEXT as ne,fillText as re}from"@webority/ui-elements/text";var ie=()=>import(`@webority/ui-elements/elements/datepicker`),ae=()=>import(`@webority/ui-elements/elements/inline-edit`),h=[`none`,`indian`],g=e=>e==null?``:String(e),_=(e,t)=>t===`number`?e===``?null:Number(e):e;function v(v){let y=t(`wui-inline-edit`,ae);t(`wui-datepicker`,ie);let{marker:b,props:x}=r(`AppInlineEdit`,v),S=n(`inlineEdit`,ne),{value:oe,onSave:C,type:w,options:T=[],loadUrl:E,label:D,placeholder:O,validate:k,renderValue:A,grouping:j=`none`,wrap:M=!0,disabled:N=!1,className:P=``,id:F,...I}=x;if(o(`AppInlineEdit`,I),a(`AppInlineEdit`,`type`,w,s),a(`AppInlineEdit`,`grouping`,j,h),E&&(w??`text`)!==`select`)throw RangeError(`[@webority/ui-react] <AppInlineEdit> received loadUrl with type="${w??`text`}"; loadUrl needs type="select".`);if(E&&T.length>0)throw RangeError(`[@webority/ui-react] <AppInlineEdit> received both loadUrl and options; pass one or the other.`);let L=w??`text`,R=te(),z=F||`inline-edit-${R.replace(/[^a-zA-Z0-9_-]/g,``)}`,B=`${z}-error`,V=`${z}-control`,H=u(null),U=g(oe),[W,G]=d(U),[K,q]=d(U);W!==U&&(G(U),q(U));let[se,J]=d(null),Y=u({onSave:C,validate:k,kind:L});Y.current={onSave:C,validate:k,kind:L},l(()=>{let e=H.current;if(e&&y)return e.save=async e=>{J(e);let t=!1;try{await Y.current.onSave?.(_(e,Y.current.kind)),t=!0}finally{f(()=>{t&&q(e),J(null)})}},e.validate=e=>Y.current.validate?.(_(e,Y.current.kind))||null,()=>{e.save=void 0,e.validate=void 0}},[y]);let X=se??K,Z=c(X,{type:L,options:T,...O===void 0?null:{placeholder:O}}),ce=L===`number`&&j===`indian`?e(Z.text):Z.text,le=A&&!Z.empty?A(_(X,L)):ce,Q={id:V,"data-wui-control":``,"aria-label":D},$;if(L===`select`){let e=T.map(e=>({value:String(e.value),label:g(e.label??e.value)}));$=/* @__PURE__ */ p(ee,{id:V,"data-wui-control":``,"aria-label":D,size:`sm`,placeholder:O||void 0,options:e})}else $=L===`date`?/* @__PURE__ */ p(`wui-datepicker`,{...Q,size:`sm`,"aria-describedby":B,placeholder:O||void 0}):L===`textarea`?/* @__PURE__ */ p(`textarea`,{...Q,className:`form-control`,rows:3,"aria-describedby":B,placeholder:O||void 0}):/* @__PURE__ */ p(`input`,{...Q,type:L===`number`?`number`:`text`,inputMode:L===`number`?`decimal`:void 0,className:`form-control input wui-input-sm`,"aria-describedby":B,placeholder:O||void 0});let ue=[`wui-inline-edit`,M===!1?`wui-inline-edit--nowrap`:``,P].filter(Boolean).join(` `);return/* @__PURE__ */ m(`wui-inline-edit`,{ref:H,id:z,class:ue,type:L,label:D,value:K,placeholder:O||void 0,disabled:N?``:void 0,controlled:``,"load-url":E||void 0,...b,...I,children:[/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-inline-edit-display`,"data-wui-display":``,"aria-describedby":B,disabled:N,children:[/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:re(N?S.readOnlyText:S.editText,{label:D})}),/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-value`,"data-wui-value":``,"data-wui-empty":Z.empty?``:void 0,children:le}),/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ p(i,{name:`edit`,size:14})})]}),/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-editor`,"data-wui-editor":``,hidden:!0,children:$}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-status`,"aria-hidden":`true`,children:[/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-spinner spinner-border spinner-border-sm`}),/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-saved`,children:/* @__PURE__ */ p(i,{name:`tick-circle`,size:16})})]}),/* @__PURE__ */ p(`span`,{className:`wui-inline-edit-error`,id:B,"data-wui-error":``,hidden:!0}),/* @__PURE__ */ p(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import te from"./warnUnknownProps.js";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{createPortal as
|
|
1
|
+
import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import te from"./warnUnknownProps.js";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{createPortal as ne}from"react-dom";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{MODAL_TEXT as re}from"@webority/ui-elements/text";var ie=[`neutral`,`danger`,`success`,`warning`],ae=[`center`,`top`],oe=[`sans`,`serif`],se=()=>import(`@webority/ui-elements/elements/modal`),f={sm:380,md:440,lg:640,xl:880,wide:1080},ce=`wui-modal-fullscreen`,p=`wui-modal-wide`,le=e=>typeof e==`number`?e:e===`fullscreen`?f.md:f[e],m=!1;function h(){let e=!0;try{e=process.env.NODE_ENV!==`production`}catch{e=!0}e&&!m&&(m=!0,t("[@webority/ui-react] <AppModal hideHeader> has no accessible name: pass `ariaLabel` (or a string `title`)."))}function g(t){n(`wui-modal`,se);let m=r(`modal`,re),{marker:g,props:_}=ee(`AppModal`,t),{open:v,eyebrow:y,title:b,subtitle:x,headerIcon:S,tone:C=`neutral`,dismissible:ue=!0,onClose:w,onBack:T,backLabel:E=m.backLabel,headerActions:D,footer:O,size:k=`md`,phoneSize:A,placement:j=`center`,titleFont:M=`sans`,hideHeader:N=!1,staticBackdrop:de=!0,closeOnEscape:fe=!0,confirmDiscard:P,dirty:F=!1,ariaLabel:I,closeLabel:L=m.closeLabel,className:R=``,children:z,...B}=_;te(`AppModal`,B),a(`AppModal`,`tone`,C,ie),a(`AppModal`,`placement`,j,ae),a(`AppModal`,`titleFont`,M,oe),a(`AppModal`,`size`,typeof k==`string`?k:null,[...Object.keys(f),`fullscreen`]),a(`AppModal`,`phoneSize`,A,[...Object.keys(f),`fullscreen`]);let{style:V,ref:H,onExited:U,"data-wui":W,"data-wui-props":pe,...me}=B,G=W?{"data-wui":W,"data-wui-props":pe}:g,he=G[`data-wui`],ge=G[`data-wui-props`];N&&!I&&typeof b!=`string`&&h();let K=c(null),q=c(null),[_e,J]=l(v),ve=v||_e;s(()=>{v&&J(!0)},[v]);let Y=c(null),[X,Z]=l(!1);s(()=>{v||Z(!1)},[v]),s(()=>{X&&Y.current?.focus()},[X]);let ye=o(e=>{q.current=e,typeof H==`function`?H(e):H&&(H.current=e)},[H]),be=()=>{P&&F?Z(!0):w?.()},Q=c({open:v,requestClose:()=>{},onExited:U});Q.current={open:v,requestClose:be,onExited:U};let xe=o(e=>{if(!e)return;let t=t=>t.target instanceof Element&&t.target.closest(`wui-modal`)===e,n=e=>{t(e)&&(e.preventDefault(),Q.current.requestClose())},r=e=>{if(!t(e))return;Q.current.open||J(!1);let n=q.current;if(!n)throw TypeError(`<wui-modal> closed without its dialog.`);Q.current.onExited?.(n)};return e.addEventListener(`wui-modal-close`,n),e.addEventListener(`wui-modal-closed`,r),()=>{e.removeEventListener(`wui-modal-close`,n),e.removeEventListener(`wui-modal-closed`,r)}},[]),Se=()=>{Z(!1),w?.()},Ce=()=>{Z(!1),(K.current?.querySelector(`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled])`))?.focus()},$=k===`fullscreen`,we=le(k),Te=[`modal-content`,`wui-modal`,C===`neutral`?``:`tone-${C}`,R].filter(Boolean).join(` `),Ee=[`modal`,`wui-modal-shell`,$&&ce,k===`wide`&&p,A&&`wui-modal-phone-${A}`].filter(Boolean).join(` `),De=[`modal-dialog`,j!==`top`&&`modal-dialog-centered`,`wui-rb-dialog`].filter(Boolean).join(` `),Oe=$?V:{"--wui-modal-max-width":`${we}px`,...V};return!ve||typeof document>`u`?null:ne(/* @__PURE__ */ u(`wui-modal`,{ref:xe,"data-wui":he,"data-wui-props":ge,open:v?``:void 0,static:de?``:void 0,"no-escape":fe&&!X?void 0:``,"confirm-discard":P||void 0,children:/* @__PURE__ */ u(`dialog`,{...me,ref:ye,className:Ee,"aria-label":I||(typeof b==`string`?b:void 0),style:Oe,children:/* @__PURE__ */ u(`div`,{className:De,children:/* @__PURE__ */ d(`div`,{className:Te,children:[!N&&/* @__PURE__ */ d(`div`,{className:`wui-modal-header`,children:[T&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-modal-back`,onClick:T,"aria-label":E,children:/* @__PURE__ */ u(i,{name:`arrow-left`,size:18})}),/* @__PURE__ */ d(`div`,{className:`wui-modal-heading`,children:[S&&/* @__PURE__ */ u(`span`,{className:`wui-modal-headicon`,children:/* @__PURE__ */ u(i,{name:S,size:18})}),/* @__PURE__ */ d(`div`,{className:`wui-modal-headtext`,children:[y&&/* @__PURE__ */ u(`div`,{className:`wui-modal-eyebrow`,children:y}),/* @__PURE__ */ u(`div`,{className:M===`serif`?`wui-modal-title wui-modal-title-serif`:`wui-modal-title`,children:b}),x&&/* @__PURE__ */ u(`div`,{className:`wui-modal-subtitle`,children:x})]})]}),D&&/* @__PURE__ */ u(`div`,{className:`wui-modal-header-actions`,children:D}),ue&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-modal-close`,"data-wui-dismiss":``,"aria-label":L,children:/* @__PURE__ */ u(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ u(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),/* @__PURE__ */ u(`div`,{className:`wui-modal-body`,ref:K,children:z}),(O||X)&&/* @__PURE__ */ d(`div`,{className:X?`wui-modal-footer wui-drawer-discarding`:`wui-modal-footer`,children:[X&&/* @__PURE__ */ u(e,{text:P,confirmRef:Y,onDiscard:Se,onKeep:Ce}),O]})]})})})}),document.body)}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppAvatar.js";import i from"./AppIcon.js";import a from"./useWuiControl.js";import o from"./warnUnknownProps.js";import{useEffect as s,useId as c,useMemo as l,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{ORG_TREE_TEXT as p,fillText as m}from"@webority/ui-elements/text";function h(e){return`selected`in e}var g=()=>import(`@webority/ui-elements/elements/org-tree`);function _(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(t.has(n.id))throw Error(`OrgTree node id "${n.id}" is used twice: every id must be unique.`);t.set(n.id,n)}let n=/* @__PURE__ */ new Map,r=[];for(let i of e){if(!i.parentId){r.push(i);continue}if(!t.has(i.parentId))throw Error(`OrgTree node "${i.id}" names parent "${i.parentId}", which is not in the list.`);let e=n.get(i.parentId);e||(e=[],n.set(i.parentId,e)),e.push(i)}for(let n of e){let r=n.parentId;for(let i=0;r&&i<=e.length;i+=1){if(r===n.id)throw Error(`OrgTree node "${n.id}" is its own ancestor: the reporting lines form a loop.`);r=t.get(r)?.parentId}}return{byId:t,childrenOf:n,roots:r}}function v(e,t){let n=/* @__PURE__ */ new Set;for(let r of e){let e=t.has(r)?r:null;for(;e&&!n.has(e);)n.add(e),e=t.get(e)?.parentId||null}return n}function y(e,t,n,a,o){let s=o.childrenOf.get(e.id)??[],c=s.length>0,l=c&&o.expandDepth!=null&&t>=o.expandDepth,u=o.renderOverlay?.(e),p;return o.highlightChain&&(p=o.highlightChain.has(e.id)?`highlight`:`dim`),/* @__PURE__ */ f(`li`,{className:`wui-org-tree-item`,role:`treeitem`,"data-wui-org-node":e.id,"aria-level":t,"aria-setsize":n,"aria-posinset":a+1,tabIndex:t===1&&a===0?0:-1,"aria-expanded":c?l?`false`:`true`:void 0,"aria-selected":o.selectable?o.selected===e.id?`true`:`false`:void 0,"data-wui-org-state":p,children:[/* @__PURE__ */ f(`div`,{className:`wui-org-tree-node`,children:[/* @__PURE__ */ d(r,{name:e.name,src:e.avatarUrl,size:`md`}),/* @__PURE__ */ f(`div`,{className:`wui-org-tree-text`,children:[/* @__PURE__ */ d(`span`,{className:`wui-org-tree-name`,children:e.name}),e.role?/* @__PURE__ */ d(`span`,{className:`wui-org-tree-role`,children:e.role}):null,e.team?/* @__PURE__ */ d(`span`,{className:`wui-org-tree-team`,children:e.team}):null]}),u==null?null:/* @__PURE__ */ d(`div`,{className:`wui-org-tree-overlay`,children:u}),c?/* @__PURE__ */ f(`button`,{type:`button`,className:`wui-org-tree-toggle`,"data-wui-org-toggle":``,tabIndex:-1,"aria-label":m(l?o.expandLabel:o.collapseLabel,{name:e.name}),children:[/* @__PURE__ */ d(i,{name:`chevron-down`,size:16}),/* @__PURE__ */ d(`span`,{className:`wui-org-tree-count`,children:s.length})]}):null]}),c?/* @__PURE__ */ d(`ul`,{className:`wui-org-tree-children`,role:`group`,hidden:l,children:b(s,t+1,o)}):null]},e.id)}function b(e,t,n){return e.map((r,i)=>y(r,t,e.length,i,n))}function x(r){let i=e(`wui-org-tree`,g),{marker:m,props:y}=n(`AppOrgTree`,r),x=t(`orgTree`,p),{nodes:S,renderOverlay:C,highlightIds:w,selectable:T=!1,selected:E,onSelect:D,expandDepth:O,searchable:k=!0,searchLabel:A=x.searchLabel,resultsText:j=x.resultsText,noResultsText:M=x.noResultsText,expandLabel:N=x.expandLabel,collapseLabel:P=x.collapseLabel,helpText:F=x.helpText,ariaLabel:I=x.ariaLabel,id:L,className:R=``,ref:z,...B}=y;if(!Array.isArray(S))throw Error(`<AppOrgTree> nodes is required: pass the flat list of people.`);o(`AppOrgTree`,B);let V=c(),H=L||`org-tree-${V.replace(/[^a-zA-Z0-9_-]/g,``)}`,U=`${H}-help`,W=l(()=>_(S),[S]),G=l(()=>Array.isArray(w)&&w.length>0?v(w,W.byId):null,[w,W]),{setRef:K,innerRef:q}=a({ready:i,ref:z,on:{"wui-org-tree:select":e=>{if(!(e instanceof CustomEvent))throw Error(`wui-org-tree:select must be a CustomEvent.`);let{id:t}=e.detail,n=e.currentTarget;D?.(t,W.byId.get(t)),n instanceof HTMLElement&&h(n)&&E!==void 0&&n.selected!==E&&(n.selected=E)}}}),J=u(!1);s(()=>{let e=q.current;e&&i&&h(e)&&(E===void 0?(J.current&&(e.selected=null),J.current=!1):(J.current=!0,e.selected!==E&&(e.selected=E)))},[E,q,i]);let Y={childrenOf:W.childrenOf,renderOverlay:C,highlightChain:G,selectable:T,selected:E,expandDepth:O,expandLabel:N,collapseLabel:P};return/* @__PURE__ */ f(`wui-org-tree`,{ref:K,id:H,class:R||void 0,selectable:T||void 0,selected:E??void 0,"search-results-text":j,"search-empty-text":M,"expand-label":N,"collapse-label":P,...m,...B,children:[k?/* @__PURE__ */ d(`div`,{className:`wui-org-tree-toolbar`,children:/* @__PURE__ */ d(`input`,{type:`search`,className:`form-control
|
|
1
|
+
import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppAvatar.js";import i from"./AppIcon.js";import a from"./useWuiControl.js";import o from"./warnUnknownProps.js";import{useEffect as s,useId as c,useMemo as l,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{ORG_TREE_TEXT as p,fillText as m}from"@webority/ui-elements/text";function h(e){return`selected`in e}var g=()=>import(`@webority/ui-elements/elements/org-tree`);function _(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(t.has(n.id))throw Error(`OrgTree node id "${n.id}" is used twice: every id must be unique.`);t.set(n.id,n)}let n=/* @__PURE__ */ new Map,r=[];for(let i of e){if(!i.parentId){r.push(i);continue}if(!t.has(i.parentId))throw Error(`OrgTree node "${i.id}" names parent "${i.parentId}", which is not in the list.`);let e=n.get(i.parentId);e||(e=[],n.set(i.parentId,e)),e.push(i)}for(let n of e){let r=n.parentId;for(let i=0;r&&i<=e.length;i+=1){if(r===n.id)throw Error(`OrgTree node "${n.id}" is its own ancestor: the reporting lines form a loop.`);r=t.get(r)?.parentId}}return{byId:t,childrenOf:n,roots:r}}function v(e,t){let n=/* @__PURE__ */ new Set;for(let r of e){let e=t.has(r)?r:null;for(;e&&!n.has(e);)n.add(e),e=t.get(e)?.parentId||null}return n}function y(e,t,n,a,o){let s=o.childrenOf.get(e.id)??[],c=s.length>0,l=c&&o.expandDepth!=null&&t>=o.expandDepth,u=o.renderOverlay?.(e),p;return o.highlightChain&&(p=o.highlightChain.has(e.id)?`highlight`:`dim`),/* @__PURE__ */ f(`li`,{className:`wui-org-tree-item`,role:`treeitem`,"data-wui-org-node":e.id,"aria-level":t,"aria-setsize":n,"aria-posinset":a+1,tabIndex:t===1&&a===0?0:-1,"aria-expanded":c?l?`false`:`true`:void 0,"aria-selected":o.selectable?o.selected===e.id?`true`:`false`:void 0,"data-wui-org-state":p,children:[/* @__PURE__ */ f(`div`,{className:`wui-org-tree-node`,children:[/* @__PURE__ */ d(r,{name:e.name,src:e.avatarUrl,size:`md`}),/* @__PURE__ */ f(`div`,{className:`wui-org-tree-text`,children:[/* @__PURE__ */ d(`span`,{className:`wui-org-tree-name`,children:e.name}),e.role?/* @__PURE__ */ d(`span`,{className:`wui-org-tree-role`,children:e.role}):null,e.team?/* @__PURE__ */ d(`span`,{className:`wui-org-tree-team`,children:e.team}):null]}),u==null?null:/* @__PURE__ */ d(`div`,{className:`wui-org-tree-overlay`,children:u}),c?/* @__PURE__ */ f(`button`,{type:`button`,className:`wui-org-tree-toggle`,"data-wui-org-toggle":``,tabIndex:-1,"aria-label":m(l?o.expandLabel:o.collapseLabel,{name:e.name}),children:[/* @__PURE__ */ d(i,{name:`chevron-down`,size:16}),/* @__PURE__ */ d(`span`,{className:`wui-org-tree-count`,children:s.length})]}):null]}),c?/* @__PURE__ */ d(`ul`,{className:`wui-org-tree-children`,role:`group`,hidden:l,children:b(s,t+1,o)}):null]},e.id)}function b(e,t,n){return e.map((r,i)=>y(r,t,e.length,i,n))}function x(r){let i=e(`wui-org-tree`,g),{marker:m,props:y}=n(`AppOrgTree`,r),x=t(`orgTree`,p),{nodes:S,renderOverlay:C,highlightIds:w,selectable:T=!1,selected:E,onSelect:D,expandDepth:O,searchable:k=!0,searchLabel:A=x.searchLabel,resultsText:j=x.resultsText,noResultsText:M=x.noResultsText,expandLabel:N=x.expandLabel,collapseLabel:P=x.collapseLabel,helpText:F=x.helpText,ariaLabel:I=x.ariaLabel,id:L,className:R=``,ref:z,...B}=y;if(!Array.isArray(S))throw Error(`<AppOrgTree> nodes is required: pass the flat list of people.`);o(`AppOrgTree`,B);let V=c(),H=L||`org-tree-${V.replace(/[^a-zA-Z0-9_-]/g,``)}`,U=`${H}-help`,W=l(()=>_(S),[S]),G=l(()=>Array.isArray(w)&&w.length>0?v(w,W.byId):null,[w,W]),{setRef:K,innerRef:q}=a({ready:i,ref:z,on:{"wui-org-tree:select":e=>{if(!(e instanceof CustomEvent))throw Error(`wui-org-tree:select must be a CustomEvent.`);let{id:t}=e.detail,n=e.currentTarget;D?.(t,W.byId.get(t)),n instanceof HTMLElement&&h(n)&&E!==void 0&&n.selected!==E&&(n.selected=E)}}}),J=u(!1);s(()=>{let e=q.current;e&&i&&h(e)&&(E===void 0?(J.current&&(e.selected=null),J.current=!1):(J.current=!0,e.selected!==E&&(e.selected=E)))},[E,q,i]);let Y={childrenOf:W.childrenOf,renderOverlay:C,highlightChain:G,selectable:T,selected:E,expandDepth:O,expandLabel:N,collapseLabel:P};return/* @__PURE__ */ f(`wui-org-tree`,{ref:K,id:H,class:R||void 0,selectable:T||void 0,selected:E??void 0,"search-results-text":j,"search-empty-text":M,"expand-label":N,"collapse-label":P,...m,...B,children:[k?/* @__PURE__ */ d(`div`,{className:`wui-org-tree-toolbar`,children:/* @__PURE__ */ d(`input`,{type:`search`,className:`form-control wui-input-sm wui-org-tree-search`,"data-wui-org-search":``,"aria-label":A,placeholder:A,autoComplete:`off`})}):null,/* @__PURE__ */ d(`div`,{className:`wui-org-tree-canvas`,"data-wui-org-canvas":``,children:/* @__PURE__ */ d(`ul`,{className:`wui-org-tree`,role:`tree`,"aria-label":I,"aria-describedby":U,children:b(W.roots,1,Y)})}),/* @__PURE__ */ d(`p`,{className:`visually-hidden`,id:U,"data-wui-org-help":``,children:F}),/* @__PURE__ */ d(`div`,{className:`visually-hidden`,"data-wui-org-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pageWindow as e}from"../lib/pageWindow.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppSelect.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{TABLE_PAGINATION_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=[`numbered`,`prev-next`],f=[`sm`,`md`],p=[`footer`,`standalone`],m=[5,10,25,50];function h(e,t,n,r){let i=Math.min((t-1)*n+1,r),a=Math.min(t*n,r);return u(e,{first:i,last:a,total:r})}function g(g){let{marker:_,props:v}=n(`AppTablePagination`,g),y=t(`tablePagination`,l),{page:b,totalPages:x,total:S,hasNext:C,pageSize:w,onPageChange:T,onPageSizeChange:E,pageSizes:D=m,mode:O=`numbered`,showPageSize:k=!0,siblings:A=2,summary:j=!1,size:M=`md`,variant:N=`footer`,ariaLabel:P=y.ariaLabel,rowsPerPageLabel:F=y.rowsPerPageLabel,pageSizeLabel:I=y.pageSizeLabel,previousLabel:L=y.previousLabel,nextLabel:R=y.nextLabel,pageLabel:z=y.pageLabel,rangeText:B=y.rangeText,className:
|
|
1
|
+
import{pageWindow as e}from"../lib/pageWindow.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppSelect.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{TABLE_PAGINATION_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=[`numbered`,`prev-next`],f=[`sm`,`md`],p=[`footer`,`standalone`],m=[5,10,25,50];function h(e,t,n,r){let i=Math.min((t-1)*n+1,r),a=Math.min(t*n,r);return u(e,{first:i,last:a,total:r})}function g(g){let{marker:_,props:v}=n(`AppTablePagination`,g),y=t(`tablePagination`,l),{page:b,totalPages:x,total:S,hasNext:C,pageSize:w,onPageChange:T,onPageSizeChange:E,pageSizes:D=m,mode:O=`numbered`,showPageSize:k=!0,siblings:A=2,summary:j=!1,size:M=`md`,variant:N=`footer`,ariaLabel:P=y.ariaLabel,rowsPerPageLabel:F=y.rowsPerPageLabel,pageSizeLabel:I=y.pageSizeLabel,previousLabel:L=y.previousLabel,nextLabel:R=y.nextLabel,pageLabel:z=y.pageLabel,rangeText:B=y.rangeText,summaryText:V=y.summaryText,className:H=``,...U}=v;o(`AppTablePagination`,U),a(`AppTablePagination`,`mode`,O,d),a(`AppTablePagination`,`size`,M,f),a(`AppTablePagination`,`variant`,N,p);let W=Number(w)||0,G=Number(S)||0;if(C!==void 0&&(x!==void 0||G>0))throw Error(`AppTablePagination hasNext is for an unknown total: leave total and totalPages unset.`);let K=C!==void 0,q=!K&&(x===void 0?G<=0:x<=0),J=Math.max(1,x??Math.ceil(G/(W>0?W:10))),Y=K?Math.max(1,Number(b)||1):Math.min(Math.max(1,Number(b)||1),J),X=W>0&&!!E&&k!==!1,Z=j===!0&&G>0&&W>0;if(q||!K&&J<=1&&!X)return null;let Q=W>0&&!D.includes(W)?[...D,W].sort((e,t)=>e-t):D,$=!K&&O===`numbered`,ee=$?e(Y,J,{siblingCount:A}):null,te=[`table-pagination`,N===`standalone`&&`wui-table-pagination-standalone`,M===`sm`&&`wui-table-pagination-sm`,H].filter(Boolean).join(` `);return/* @__PURE__ */ c(`nav`,{className:te,"aria-label":P,..._,...U,children:[Z&&/* @__PURE__ */ s(`span`,{className:`wui-pager-summary`,children:h(V,Y,W,G)}),X&&/* @__PURE__ */ s(`span`,{className:`tpg-rows`,children:/* @__PURE__ */ s(i,{density:`compact`,size:`sm`,"aria-label":F,value:String(W),onChange:e=>E?.(Number(e)),options:Q.map(e=>({value:String(e),label:u(I,{count:e})}))})}),!$&&!K&&/* @__PURE__ */ s(`span`,{className:`tpg-range`,children:u(B,{page:Y,pages:J})}),/* @__PURE__ */ c(`div`,{className:`tpg-nav`,children:[/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>T?.(Math.max(1,Y-1)),disabled:Y<=1,"aria-label":L,children:/* @__PURE__ */ s(r,{name:`arrow-left`,size:18})}),ee?.map(e=>typeof e==`number`?/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-page${e===Y?` is-active`:``}`,onClick:()=>T?.(e),"aria-current":e===Y?`page`:void 0,"aria-label":u(z,{page:e}),children:e},e):/* @__PURE__ */ s(`span`,{className:`tpg-ellipsis`,"aria-hidden":`true`,children:`…`},e)),/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>T?.(K?Y+1:Math.min(J,Y+1)),disabled:K?!C:Y>=J,"aria-label":R,children:/* @__PURE__ */ s(r,{name:`arrow-right`,size:18})})]})]})}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import s from"./AppTooltip.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import u from"./warnUnknownProps.js";import{formatNumber as ee}from"@webority/ui-elements/helpers";import{cloneElement as te,useCallback as d,useEffect as f,useLayoutEffect as p,useRef as m,useState as ne}from"react";import{Fragment as re,jsx as h,jsxs as g}from"react/jsx-runtime";import{TABS_TEXT as ie}from"@webority/ui-elements/text";var _=[`underline`,`pills`],v=[`horizontal`,`vertical`],y=[`sm`,`md`,`lg`],ae={sm:16,md:18,lg:20},oe=[`automatic`,`manual`],se=[`scroll`,`menu`],ce=i.filter(e=>e!==`primary`&&e!==`neutral`),le=()=>import(`@webority/ui-elements/elements/overflow`),b=1,ue=28,de=.7;function x(i){let{marker:x,props:fe}=a(`AppTabs`,i),S=r(`tabs`,ie),{tabs:C,value:w,onChange:T,linkComponent:E,variant:D=`underline`,orientation:O=`horizontal`,size:k=`md`,fitted:pe=!1,overflow:A=`scroll`,moreLabel:me=S.moreLabel,maxVisible:he,activation:j=`automatic`,ariaLabel:M,className:N=``,style:P,...F}=fe;n(`wui-overflow`,le),u(`AppTabs`,F),c(`AppTabs`,`variant`,D,_),c(`AppTabs`,`orientation`,O,v),c(`AppTabs`,`size`,k,y),c(`AppTabs`,`activation`,j,oe),c(`AppTabs`,`overflow`,A,se);for(let e of C)c(`AppTabs`,`tabs[].tone`,e.tone,ce);let I=m(null),L=m(null),R=O===`vertical`,z=(A===`menu`||he!=null)&&!R,B=ae[k],[V,H]=ne(w);f(()=>{H(w)},[w]);let ge=C.find(e=>!e.disabled)?.key,_e=C.some(e=>e.key===V&&!e.disabled)?V:void 0,ve=C.some(e=>e.key===w&&!e.disabled)?w:void 0,ye=_e??ve??ge,be=e=>{I.current?.querySelector(`[data-key="${CSS.escape(String(e))}"]`)?.focus()},U=d(()=>{let e=I.current,t=L.current;if(!e||!t||R||z)return;let n=e.scrollWidth-e.clientWidth;t.classList.toggle(`is-overflow-start`,e.scrollLeft>b),t.classList.toggle(`is-overflow-end`,n>b&&e.scrollLeft<n-b)},[R,z]),W=d(()=>{let e=I.current;if(!e)return;let t=e.querySelector(`.app-tab.active`);t?(R?(e.style.setProperty(`--wui-tab-y`,`${t.offsetTop}px`),e.style.setProperty(`--wui-tab-h`,`${t.offsetHeight}px`)):(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.toggleAttribute(`data-active-danger`,!!C.find(e=>e.key===w)?.danger)):e.style.setProperty(R?`--wui-tab-h`:`--wui-tab-w`,`0px`),e.setAttribute(`data-wui-tabs`,``),U()},[R,C,w,U]),G=e=>!z||!I.current?.querySelector(`[data-key="${CSS.escape(String(e))}"][data-wui-overflow-hidden]`),K=d(e=>{let t=I.current;if(!t||R)return;let n=t.querySelector(`.app-tab[data-key="${CSS.escape(e)}"]`);if(!n)return;let r=ue,i=n.offsetLeft,a=i+n.offsetWidth;i-r<t.scrollLeft?t.scrollLeft=Math.max(0,i-r):a+r>t.scrollLeft+t.clientWidth&&(t.scrollLeft=a+r-t.clientWidth)},[R]);p(()=>{W()},[W]),p(()=>{K(w)},[w,K]);let q=m(W);f(()=>{q.current=W},[W]),f(()=>{if(!document.fonts)return;let e=!0;return document.fonts.ready.then(()=>{e&&q.current()}),()=>{e=!1}},[]);let J=m(null),Y=d(e=>{if(typeof ResizeObserver>`u`)return;let t=J.current??{ro:new ResizeObserver(()=>q.current()),count:0};return J.current=t,t.ro.observe(e),t.count+=1,()=>{t.ro.unobserve(e),--t.count,t.count===0&&(t.ro.disconnect(),J.current===t&&(J.current=null))}},[]),X=d(e=>{I.current=e;let t=e?Y(e):void 0;return()=>{I.current=null,t?.()}},[Y]),Z=d(e=>{L.current=e;let t=e?Y(e):void 0;return()=>{L.current=null,t?.()}},[Y]);f(()=>{let e=L.current;if(!z||!e)return;let t=()=>q.current();return e.addEventListener(`wui-overflow-change`,t),()=>e.removeEventListener(`wui-overflow-change`,t)},[z]);function xe(e){let t=e.target instanceof HTMLElement?e.target.dataset.key:void 0;if(t==null)return;let n=C.findIndex(e=>e.key===t);if(n<0)return;let r=C.length,i=(e,t)=>{for(let n=1;n<=r;n++){let i=C[((e+t*n)%r+r)%r];if(i&&!i.disabled&&G(i.key))return i}return null},a=getComputedStyle(e.currentTarget).direction===`rtl`,o=R?`ArrowDown`:a?`ArrowLeft`:`ArrowRight`,s=R?`ArrowUp`:a?`ArrowRight`:`ArrowLeft`,c=null;if(e.key===o?c=i(n,1):e.key===s?c=i(n,-1):e.key===`Home`?c=C.find(e=>!e.disabled&&G(e.key))??null:e.key===`End`&&(c=[...C].reverse().find(e=>!e.disabled&&G(e.key))??null),!c)return;e.preventDefault(),H(c.key),be(c.key);let l=c.href!=null||c.to!=null;j===`automatic`&&!l&&T?.(c.key)}let Q=e=>{let t=I.current;t&&t.scrollBy({left:e*t.clientWidth*de})},Se=[`app-tabs`,D===`pills`?`app-tabs-pills`:``,R?`app-tabs-vertical`:``,k===`sm`?`app-tabs-sm`:``,k===`lg`?`app-tabs-lg`:``,pe?`app-tabs-fitted`:``,N].filter(Boolean).join(` `),$=/* @__PURE__ */ g(`div`,{ref:X,role:`tablist`,"aria-orientation":R?`vertical`:void 0,"aria-label":M,className:Se,style:P,"data-wui-overflow-list":z?``:void 0,...F,onKeyDown:xe,onScroll:U,children:[C.map(n=>{let r=n.key===w,i=n.href!=null||n.to!=null,a={role:`tab`,"data-key":n.key,"aria-selected":r,tabIndex:n.key===ye?0:-1,className:`app-tab${r?` active`:``}${n.danger?` danger`:``}${i&&n.disabled?` disabled`:``}`},o=/* @__PURE__ */ g(re,{children:[n.image?/* @__PURE__ */ h(`img`,{className:`app-tab-img`,src:n.image,alt:n.imageAlt??``,width:B,height:B}):l(n.icon,{size:16,className:`app-tab-icon`}),/* @__PURE__ */ h(`span`,{className:`wui-tab-label`,children:n.label}),(n.countLabel||n.count!=null)&&/* @__PURE__ */ h(`span`,{className:`app-tab-count${n.tone?` ${n.tone}`:``}`,children:n.countLabel||ee(n.count,{decimals:0})})]}),c;if(i){let r=n.disabled||n.to==null||E==null||E===`a`?e(void 0,{href:n.disabled?void 0:n.href??n.to}):e(E,{to:n.to}),i=n.rel??(n.target===`_blank`?`noopener noreferrer`:void 0),s=n.disabled?{"aria-disabled":!0}:{target:n.target,rel:i},l=e=>{n.disabled?e.preventDefault():e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(H(n.key),T?.(n.key))};c=/* @__PURE__ */ h(t,{link:r,...a,...s,onClick:l,children:o},n.key)}else c=/* @__PURE__ */ h(`button`,{type:`button`,...a,disabled:n.disabled,onClick:()=>{n.disabled||(H(n.key),T?.(n.key))},children:o},n.key);return n.tooltip?/* @__PURE__ */ h(s,{content:n.tooltip,children:c},n.key):c}),/* @__PURE__ */ h(`span`,{className:`app-tab-indicator`,"aria-hidden":`true`,"data-wui-overflow-skip":``})]});return R?te($,x):z?/* @__PURE__ */ h(`wui-overflow`,{...x,ref:Z,class:`app-tabs-wrap`,label:me,children:$}):/* @__PURE__ */ g(`div`,{...x,ref:Z,className:`app-tabs-wrap`,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`app-tabs-scroll-btn prev`,"aria-label":S.scrollTabsBackwardLabel,tabIndex:-1,onClick:()=>Q(-1),children:/* @__PURE__ */ h(o,{name:`chevron-left`,size:16})}),$,/* @__PURE__ */ h(`button`,{type:`button`,className:`app-tabs-scroll-btn next`,"aria-label":S.scrollTabsForwardLabel,tabIndex:-1,onClick:()=>Q(1),children:/* @__PURE__ */ h(o,{name:`chevron-right`,size:16})})]})}export{x as default};
|
|
1
|
+
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import s from"./AppTooltip.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import u from"./warnUnknownProps.js";import{formatNumber as ee}from"@webority/ui-elements/helpers";import{cloneElement as te,useCallback as d,useEffect as f,useLayoutEffect as p,useRef as m,useState as ne}from"react";import{Fragment as re,jsx as h,jsxs as g}from"react/jsx-runtime";import{TABS_TEXT as ie}from"@webority/ui-elements/text";var _=[`underline`,`pills`],v=[`horizontal`,`vertical`],y=[`sm`,`md`,`lg`],ae={sm:16,md:18,lg:20},oe=[`automatic`,`manual`],se=[`scroll`,`menu`],ce=i.filter(e=>e!==`primary`&&e!==`neutral`),le=()=>import(`@webority/ui-elements/elements/overflow`),b=1,ue=28,de=.7;function x(i){let{marker:x,props:fe}=a(`AppTabs`,i),S=r(`tabs`,ie),{tabs:C,value:w,onChange:T,linkComponent:E,variant:D=`underline`,orientation:O=`horizontal`,size:k=`md`,fitted:pe=!1,overflow:A=`scroll`,moreLabel:me=S.moreLabel,maxVisible:he,activation:j=`automatic`,ariaLabel:M,className:N=``,style:P,...F}=fe;n(`wui-overflow`,le),u(`AppTabs`,F),c(`AppTabs`,`variant`,D,_),c(`AppTabs`,`orientation`,O,v),c(`AppTabs`,`size`,k,y),c(`AppTabs`,`activation`,j,oe),c(`AppTabs`,`overflow`,A,se);for(let e of C)if(c(`AppTabs`,`tabs[].tone`,e.tone,ce),e.countPending&&(e.count!=null||e.countLabel))throw Error(`<AppTabs> tab "${e.key}" sets countPending with count or countLabel: a pending badge is empty, so it takes neither.`);let I=m(null),L=m(null),R=O===`vertical`,z=(A===`menu`||he!=null)&&!R,B=ae[k],[V,H]=ne(w);f(()=>{H(w)},[w]);let ge=C.find(e=>!e.disabled)?.key,_e=C.some(e=>e.key===V&&!e.disabled)?V:void 0,ve=C.some(e=>e.key===w&&!e.disabled)?w:void 0,ye=_e??ve??ge,be=e=>{I.current?.querySelector(`[data-key="${CSS.escape(String(e))}"]`)?.focus()},U=d(()=>{let e=I.current,t=L.current;if(!e||!t||R||z)return;let n=e.scrollWidth-e.clientWidth;t.classList.toggle(`is-overflow-start`,e.scrollLeft>b),t.classList.toggle(`is-overflow-end`,n>b&&e.scrollLeft<n-b)},[R,z]),W=d(()=>{let e=I.current;if(!e)return;let t=e.querySelector(`.app-tab.active`);t?(R?(e.style.setProperty(`--wui-tab-y`,`${t.offsetTop}px`),e.style.setProperty(`--wui-tab-h`,`${t.offsetHeight}px`)):(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.toggleAttribute(`data-active-danger`,!!C.find(e=>e.key===w)?.danger)):e.style.setProperty(R?`--wui-tab-h`:`--wui-tab-w`,`0px`),e.setAttribute(`data-wui-tabs`,``),U()},[R,C,w,U]),G=e=>!z||!I.current?.querySelector(`[data-key="${CSS.escape(String(e))}"][data-wui-overflow-hidden]`),K=d(e=>{let t=I.current;if(!t||R)return;let n=t.querySelector(`.app-tab[data-key="${CSS.escape(e)}"]`);if(!n)return;let r=ue,i=n.offsetLeft,a=i+n.offsetWidth;i-r<t.scrollLeft?t.scrollLeft=Math.max(0,i-r):a+r>t.scrollLeft+t.clientWidth&&(t.scrollLeft=a+r-t.clientWidth)},[R]);p(()=>{W()},[W]),p(()=>{K(w)},[w,K]);let q=m(W);f(()=>{q.current=W},[W]),f(()=>{if(!document.fonts)return;let e=!0;return document.fonts.ready.then(()=>{e&&q.current()}),()=>{e=!1}},[]);let J=m(null),Y=d(e=>{if(typeof ResizeObserver>`u`)return;let t=J.current??{ro:new ResizeObserver(()=>q.current()),count:0};return J.current=t,t.ro.observe(e),t.count+=1,()=>{t.ro.unobserve(e),--t.count,t.count===0&&(t.ro.disconnect(),J.current===t&&(J.current=null))}},[]),X=d(e=>{I.current=e;let t=e?Y(e):void 0;return()=>{I.current=null,t?.()}},[Y]),Z=d(e=>{L.current=e;let t=e?Y(e):void 0;return()=>{L.current=null,t?.()}},[Y]);f(()=>{let e=L.current;if(!z||!e)return;let t=()=>q.current();return e.addEventListener(`wui-overflow-change`,t),()=>e.removeEventListener(`wui-overflow-change`,t)},[z]);function xe(e){let t=e.target instanceof HTMLElement?e.target.dataset.key:void 0;if(t==null)return;let n=C.findIndex(e=>e.key===t);if(n<0)return;let r=C.length,i=(e,t)=>{for(let n=1;n<=r;n++){let i=C[((e+t*n)%r+r)%r];if(i&&!i.disabled&&G(i.key))return i}return null},a=getComputedStyle(e.currentTarget).direction===`rtl`,o=R?`ArrowDown`:a?`ArrowLeft`:`ArrowRight`,s=R?`ArrowUp`:a?`ArrowRight`:`ArrowLeft`,c=null;if(e.key===o?c=i(n,1):e.key===s?c=i(n,-1):e.key===`Home`?c=C.find(e=>!e.disabled&&G(e.key))??null:e.key===`End`&&(c=[...C].reverse().find(e=>!e.disabled&&G(e.key))??null),!c)return;e.preventDefault(),H(c.key),be(c.key);let l=c.href!=null||c.to!=null;j===`automatic`&&!l&&T?.(c.key)}let Q=e=>{let t=I.current;t&&t.scrollBy({left:e*t.clientWidth*de})},Se=[`app-tabs`,D===`pills`?`app-tabs-pills`:``,R?`app-tabs-vertical`:``,k===`sm`?`app-tabs-sm`:``,k===`lg`?`app-tabs-lg`:``,pe?`app-tabs-fitted`:``,N].filter(Boolean).join(` `),$=/* @__PURE__ */ g(`div`,{ref:X,role:`tablist`,"aria-orientation":R?`vertical`:void 0,"aria-label":M,className:Se,style:P,"data-wui-overflow-list":z?``:void 0,...F,onKeyDown:xe,onScroll:U,children:[C.map(n=>{let r=n.key===w,i=n.href!=null||n.to!=null,a={role:`tab`,"data-key":n.key,"aria-selected":r,tabIndex:n.key===ye?0:-1,className:`app-tab${r?` active`:``}${n.danger?` danger`:``}${i&&n.disabled?` disabled`:``}`},o=/* @__PURE__ */ g(re,{children:[n.image?/* @__PURE__ */ h(`img`,{className:`app-tab-img`,src:n.image,alt:n.imageAlt??``,width:B,height:B}):l(n.icon,{size:16,className:`app-tab-icon`}),/* @__PURE__ */ h(`span`,{className:`wui-tab-label`,children:n.label}),n.countPending?/* @__PURE__ */ h(`span`,{className:`app-tab-count${n.tone?` ${n.tone}`:``}`,"data-count-pending":``}):(n.countLabel||n.count!=null)&&/* @__PURE__ */ h(`span`,{className:`app-tab-count${n.tone?` ${n.tone}`:``}`,children:n.countLabel||ee(n.count,{decimals:0})})]}),c;if(i){let r=n.disabled||n.to==null||E==null||E===`a`?e(void 0,{href:n.disabled?void 0:n.href??n.to}):e(E,{to:n.to}),i=n.rel??(n.target===`_blank`?`noopener noreferrer`:void 0),s=n.disabled?{"aria-disabled":!0}:{target:n.target,rel:i},l=e=>{n.disabled?e.preventDefault():e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(H(n.key),T?.(n.key))};c=/* @__PURE__ */ h(t,{link:r,...a,...s,onClick:l,children:o},n.key)}else c=/* @__PURE__ */ h(`button`,{type:`button`,...a,disabled:n.disabled,onClick:()=>{n.disabled||(H(n.key),T?.(n.key))},children:o},n.key);return n.tooltip?/* @__PURE__ */ h(s,{content:n.tooltip,children:c},n.key):c}),/* @__PURE__ */ h(`span`,{className:`app-tab-indicator`,"aria-hidden":`true`,"data-wui-overflow-skip":``})]});return R?te($,x):z?/* @__PURE__ */ h(`wui-overflow`,{...x,ref:Z,class:`app-tabs-wrap`,label:me,children:$}):/* @__PURE__ */ g(`div`,{...x,ref:Z,className:`app-tabs-wrap`,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`app-tabs-scroll-btn prev`,"aria-label":S.scrollTabsBackwardLabel,tabIndex:-1,onClick:()=>Q(-1),children:/* @__PURE__ */ h(o,{name:`chevron-left`,size:16})}),$,/* @__PURE__ */ h(`button`,{type:`button`,className:`app-tabs-scroll-btn next`,"aria-label":S.scrollTabsForwardLabel,tabIndex:-1,onClick:()=>Q(1),children:/* @__PURE__ */ h(o,{name:`chevron-right`,size:16})})]})}export{x as default};
|
package/dist/guidance.json
CHANGED
|
@@ -29,6 +29,7 @@ export interface AppDataTablePagination {
|
|
|
29
29
|
pageSizes?: number[] | undefined;
|
|
30
30
|
mode?: "numbered" | "prev-next" | undefined;
|
|
31
31
|
summary?: boolean | undefined;
|
|
32
|
+
summaryText?: string | undefined;
|
|
32
33
|
}
|
|
33
34
|
export interface AppDataTableColumn<Row> {
|
|
34
35
|
key: string;
|
|
@@ -90,7 +90,7 @@ export interface AppFileViewerProps extends Omit<ComponentPropsWithoutRef<"div">
|
|
|
90
90
|
* @param [props.onLoad] Called once the file shows, with its kind and page count.
|
|
91
91
|
* @param [props.onError] Called when the file cannot be opened.
|
|
92
92
|
* @param [props.className]
|
|
93
|
-
* @param [props.style] Inline style; lands on the element with `className`. Set a height here to size the viewer
|
|
93
|
+
* @param [props.style] Inline style; lands on the element with `className`. Set a height here to size the viewer.
|
|
94
94
|
* @param [ref] The `<wui-file-viewer>` element. For a video or audio file,
|
|
95
95
|
* `ref.current.seekTo(seconds)` moves the player to that point, kept within the file's length, and returns
|
|
96
96
|
* true; with no video or audio open (another kind of file, or before `onLoad`) it does nothing and returns
|
|
@@ -21,6 +21,8 @@ export interface AppInlineEditProps {
|
|
|
21
21
|
value: string | number;
|
|
22
22
|
label: string;
|
|
23
23
|
}[] | undefined;
|
|
24
|
+
/** A select's choices, fetched as a JSON array of { value, label } on the first open. Only with type select, and instead of options. */
|
|
25
|
+
loadUrl?: string | undefined;
|
|
24
26
|
/** What the value is, such as Owner: its accessible name and what screen readers announce, as in Owner saved. */
|
|
25
27
|
label: string;
|
|
26
28
|
/** Shown, muted, when there is no value, and in the empty control. Without it an empty value shows a hyphen. */
|