@webority/ui-react 0.176.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 +157 -14
- package/dist/canvas-kit/release.json +6 -6
- package/dist/components/AppButton.js +1 -1
- package/dist/components/AppColumnMenu.js +1 -1
- package/dist/components/AppDataTable.js +1 -1
- package/dist/components/AppEntryGrid.js +1 -1
- package/dist/components/AppFilePicker.js +1 -1
- package/dist/components/AppFileViewer.js +1 -1
- package/dist/components/AppInlineEdit.js +1 -1
- package/dist/components/AppMeter.js +1 -1
- package/dist/components/AppModal.js +1 -1
- package/dist/components/AppOrgTree.js +1 -1
- package/dist/components/AppShell.js +1 -1
- package/dist/components/AppSplitView.js +1 -1
- package/dist/components/AppTablePagination.js +1 -1
- package/dist/components/AppTabs.js +1 -1
- package/dist/components/AppTextarea.js +1 -1
- package/dist/guidance.json +2 -8
- package/dist/types/components/AppButton.d.ts +5 -5
- package/dist/types/components/AppCheckbox.d.ts +1 -2
- package/dist/types/components/AppDataTable.d.ts +5 -2
- package/dist/types/components/AppFilePicker.d.ts +2 -2
- package/dist/types/components/AppFileViewer.d.ts +1 -1
- package/dist/types/components/AppIcon.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/AppShell.d.ts +2 -0
- package/dist/types/components/AppTablePagination.d.ts +5 -0
- package/dist/types/components/AppTabs.d.ts +1 -0
- package/dist/types/components/AppTextarea.d.ts +1 -1
- package/dist/web-core/dist/api/idempotencyKey.js +1 -1
- package/dist/web-core/dist/errors/extractApiError.js +1 -1
- package/package.json +11 -11
|
@@ -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",
|
|
@@ -1860,14 +1860,14 @@
|
|
|
1860
1860
|
"twotone"
|
|
1861
1861
|
],
|
|
1862
1862
|
"required": false,
|
|
1863
|
-
"description": "The iconsax style of a named leftIcon / rightIcon
|
|
1863
|
+
"description": "The iconsax style of a named leftIcon / rightIcon.",
|
|
1864
1864
|
"default": "linear"
|
|
1865
1865
|
},
|
|
1866
1866
|
{
|
|
1867
1867
|
"name": "leftIcon",
|
|
1868
1868
|
"type": "icon",
|
|
1869
1869
|
"required": false,
|
|
1870
|
-
"description": "An icon name,
|
|
1870
|
+
"description": "An icon name, drawn in the icon set."
|
|
1871
1871
|
},
|
|
1872
1872
|
{
|
|
1873
1873
|
"name": "loading",
|
|
@@ -1887,7 +1887,7 @@
|
|
|
1887
1887
|
"name": "rightIcon",
|
|
1888
1888
|
"type": "icon",
|
|
1889
1889
|
"required": false,
|
|
1890
|
-
"description": "An icon name,
|
|
1890
|
+
"description": "An icon name, drawn in the icon set."
|
|
1891
1891
|
},
|
|
1892
1892
|
{
|
|
1893
1893
|
"name": "shape",
|
|
@@ -2071,13 +2071,7 @@
|
|
|
2071
2071
|
{
|
|
2072
2072
|
"component": "AppButton",
|
|
2073
2073
|
"props": {
|
|
2074
|
-
"leftIcon":
|
|
2075
|
-
"component": "AppIcon",
|
|
2076
|
-
"props": {
|
|
2077
|
-
"name": "plus",
|
|
2078
|
-
"size": 16
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2074
|
+
"leftIcon": "plus"
|
|
2081
2075
|
},
|
|
2082
2076
|
"children": "Add member"
|
|
2083
2077
|
}
|
|
@@ -7626,6 +7620,12 @@
|
|
|
7626
7620
|
"required": false,
|
|
7627
7621
|
"description": "Inline styles added to every cell in the column."
|
|
7628
7622
|
},
|
|
7623
|
+
{
|
|
7624
|
+
"name": "columnClassName",
|
|
7625
|
+
"type": "string",
|
|
7626
|
+
"required": false,
|
|
7627
|
+
"description": "added to the header cell and every body cell of the column; use it to target one column from CSS, for example to hide it in a container query"
|
|
7628
|
+
},
|
|
7629
7629
|
{
|
|
7630
7630
|
"name": "grow",
|
|
7631
7631
|
"type": "boolean",
|
|
@@ -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",
|
|
@@ -8020,8 +8026,8 @@
|
|
|
8020
8026
|
"name": "stackOnMobile",
|
|
8021
8027
|
"type": "boolean",
|
|
8022
8028
|
"required": false,
|
|
8023
|
-
"description": "
|
|
8024
|
-
"default":
|
|
8029
|
+
"description": "Stacks on phones by default: below 768px each row is a card, the first column on top, then label and value lines from the column labels, actions at the bottom. A virtual table defaults to false. Set false to keep the scrolling table.",
|
|
8030
|
+
"default": true
|
|
8025
8031
|
},
|
|
8026
8032
|
{
|
|
8027
8033
|
"name": "stickyActions",
|
|
@@ -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",
|
|
@@ -11302,7 +11314,7 @@
|
|
|
11302
11314
|
"sm"
|
|
11303
11315
|
],
|
|
11304
11316
|
"required": false,
|
|
11305
|
-
"description": "The control height: sm, md or lg. The button form takes it too
|
|
11317
|
+
"description": "The control height: sm, md or lg, md when unset. The button form takes it too.",
|
|
11306
11318
|
"default": "md"
|
|
11307
11319
|
},
|
|
11308
11320
|
{
|
|
@@ -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",
|
|
@@ -24840,6 +24872,12 @@
|
|
|
24840
24872
|
"nullable": true,
|
|
24841
24873
|
"description": "Suggestion groups, each with a label and its hits. Null hides the list."
|
|
24842
24874
|
},
|
|
24875
|
+
{
|
|
24876
|
+
"name": "shortcutKey",
|
|
24877
|
+
"type": "string",
|
|
24878
|
+
"required": false,
|
|
24879
|
+
"description": "One letter, a to z. Pressing Ctrl or Cmd with it focuses the field. The placeholder shows (Ctrl+K), or (⌘K) on a Mac, and aria-keyshortcuts names the chord."
|
|
24880
|
+
},
|
|
24843
24881
|
{
|
|
24844
24882
|
"name": "value",
|
|
24845
24883
|
"type": "string",
|
|
@@ -27847,6 +27885,13 @@
|
|
|
27847
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.",
|
|
27848
27886
|
"default": false
|
|
27849
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
|
+
},
|
|
27850
27895
|
{
|
|
27851
27896
|
"name": "total",
|
|
27852
27897
|
"type": "number",
|
|
@@ -28452,6 +28497,12 @@
|
|
|
28452
28497
|
"required": false,
|
|
28453
28498
|
"description": "Text shown in the count pill instead of count, such as 3 open."
|
|
28454
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
|
+
},
|
|
28455
28506
|
{
|
|
28456
28507
|
"name": "danger",
|
|
28457
28508
|
"type": "boolean",
|
|
@@ -34296,6 +34347,93 @@
|
|
|
34296
34347
|
{
|
|
34297
34348
|
"version": "0.130.0",
|
|
34298
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
|
+
},
|
|
34299
34437
|
{
|
|
34300
34438
|
"name": "AppCheckbox",
|
|
34301
34439
|
"props": {
|
|
@@ -34726,6 +34864,11 @@
|
|
|
34726
34864
|
"version": "0.172.0",
|
|
34727
34865
|
"components": [],
|
|
34728
34866
|
"values": {}
|
|
34867
|
+
},
|
|
34868
|
+
{
|
|
34869
|
+
"version": "0.177.0",
|
|
34870
|
+
"components": [],
|
|
34871
|
+
"values": {}
|
|
34729
34872
|
}
|
|
34730
34873
|
]
|
|
34731
34874
|
}
|
|
@@ -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{buttonClass as e}from"../lib/buttonClass.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{FILL_VARIANTS as r,TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import{FormSubmitContext as
|
|
1
|
+
import{buttonClass as e}from"../lib/buttonClass.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{FILL_VARIANTS as r,TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import{FormSubmitContext as te}from"./AppForm.js";import a from"./AppIcon.js";import o from"./assertValidValue.js";import ne from"./warnUnknownProps.js";import s from"./withTooltip.js";import{useContext as c,useRef as l,useState as re}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{Button as ie}from"react-bootstrap";var f={sm:14,md:16,lg:20,xl:20},p=[`sheen`,`fill`,`expand`,`glow`,`roll`,`none`],m=[`rounded`,`pill`,`sharp`],h=[`button`,`submit`,`reset`],ae=/* @__PURE__ */ new Set([!0,!1,...Array.from({length:100},(e,t)=>t+1)]),oe={variant:null},se=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],g=e=>e===`pill`||e===`sharp`?`wui-btn-shape-${e}`:``;function ce(e){return/* @__PURE__ */ d(`span`,{className:`wui-btn-roll`,children:[/* @__PURE__ */ u(`span`,{className:`wui-btn-roll__a`,children:e}),/* @__PURE__ */ u(`span`,{className:`wui-btn-roll__b`,"aria-hidden":`true`,children:e})]})}function le(e,t,n,r){if(!e)return null;let i=n=>/* @__PURE__ */ u(a,{name:e,size:f[t]??f.md,variant:r,className:n});return/* @__PURE__ */ d(`span`,{className:n?`wui-btn-roll-ico wui-btn-pin-icon`:`wui-btn-roll-ico ms-2`,"aria-hidden":`true`,children:[i(),i(`wui-btn-roll-ico__next`)]})}function _(e,t,n,r){if(!e)return null;let i=t===`left`?`me-2`:`ms-2`;return/* @__PURE__ */ u(a,{name:e,size:f[n]??f.md,variant:r,className:i})}function v(e,t,n){return e?/* @__PURE__ */ u(`span`,{className:`wui-btn-pin-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ u(a,{name:e,size:f[t]??f.md,variant:n})}):null}function y(a){let{marker:y,props:ue}=ee(`AppButton`,a),{children:b,tone:x=`primary`,variant:S=`solid`,size:C=`md`,type:w=`button`,loading:T=!1,disabled:E=!1,block:D=!1,leftIcon:O=null,rightIcon:k=null,href:A,static:j=!1,tooltip:M,tooltipPlacement:N,shortcut:P,animation:F,pinRightIcon:I=!1,shape:L=`rounded`,iconVariant:R,className:z=``,onClick:B,onClickCapture:V,vibrate:H,...U}=ue,[de,W]=re(!1),G=l(!1),K=c(te),fe=K!==null&&w===`submit`&&K.submitting,q=T||de||fe;ne(`AppButton`,U),o(`AppButton`,`vibrate`,H,ae);let J=H===!0?10:typeof H==`number`&&Number.isInteger(H)&&H>=1&&H<=100?H:0;F!==void 0&&o(`AppButton`,`animation`,F,p);let Y=F===`roll`&&!j,X=I&&k!=null&&k!==``&&!j&&!q;if(o(`AppButton`,`tone`,x,i),o(`AppButton`,`variant`,S,r),o(`AppButton`,`size`,C,Object.keys(f)),o(`AppButton`,`shape`,L,m),o(`AppButton`,`type`,w,h),R!==void 0&&o(`AppButton`,`iconVariant`,R,se),j){let t=[`btn`,e(x,S),C===`sm`?`btn-sm`:C===`lg`?`btn-lg`:C===`xl`?`btn-xl`:``,D?`w-100`:``,g(L),`btn-static`,z].filter(Boolean).join(` `);return s(/* @__PURE__ */ d(`span`,{className:t,...y,...U,children:[_(O,`left`,C,R),b,_(k,`right`,C,R)]}),M,N)}let pe=[D?`w-100`:``,q?`is-loading`:``,e(x,S),C===`xl`?`btn-xl`:``,F&&p.includes(F)?`btn-anim-${F}`:``,X?`wui-btn-pin-end`:``,g(L),z].filter(Boolean).join(` `),Z=(U.as===void 0||U.as===`button`)&&A===void 0&&U.to===void 0,me=Z?{}:{role:void 0,tabIndex:E||q?-1:void 0},{as:he,...ge}=U,_e={as:he},Q=M!=null&&M!==``,ve=e=>{if(G.current)return;J&&!E&&!q&&navigator.vibrate?.(J);let t=B?.(e);if(!(t instanceof Promise))return;G.current=!0,W(!0);let n=()=>{G.current=!1,W(!1)};t.then(n,e=>{throw n(),e})},$=/* @__PURE__ */ d(ie,{type:Z?w:void 0,href:A,...oe,...C===`sm`||C===`lg`?{size:C}:null,disabled:E||q,"aria-busy":q||void 0,"aria-keyshortcuts":t(P),"data-wui-vibrate":J||void 0,className:pe||void 0,onClick:ve,onClickCapture:E||q?void 0:V,...me,...y,..._e,...ge,children:[q&&/* @__PURE__ */ u(`span`,{className:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`}),!q&&_(O,`left`,C,R),Y?ce(b):b,!q&&(Y?le(k,C,X,R):X?v(k,C,R):_(k,`right`,C,R)),!Q&&n(P)]});return s(E&&Q?/* @__PURE__ */ u(`span`,{className:`d-inline-block`,tabIndex:0,children:$}):$,M,N,P)}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppDropdown.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{COLUMN_MENU_TEXT as a}from"@webority/ui-elements/text";function o(o){let{marker:s,props:c}=t(`AppColumnMenu`,o),l=e(`columnMenu`,a),{columns:u,hiddenColumns:d=[],onToggle:f,label:p=l.label,className:m=``,...h}=c,g=u.filter(e=>e.hideable);return/* @__PURE__ */ i(n,{icon:`layout-grid`,label:p,menuClassName:`wui-column-menu${m?` ${m}`:``}`,...s,...h,children:[/* @__PURE__ */ r(`div`,{className:`wui-column-menu-title`,children:p}),g.map(e=>/* @__PURE__ */ i(`label`,{className:`wui-column-menu-item`,children:[/* @__PURE__ */ r(`input`,{type:`checkbox`,className:`
|
|
1
|
+
import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppDropdown.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{COLUMN_MENU_TEXT as a}from"@webority/ui-elements/text";function o(o){let{marker:s,props:c}=t(`AppColumnMenu`,o),l=e(`columnMenu`,a),{columns:u,hiddenColumns:d=[],onToggle:f,label:p=l.label,className:m=``,...h}=c,g=u.filter(e=>e.hideable);return/* @__PURE__ */ i(n,{icon:`layout-grid`,label:p,menuClassName:`wui-column-menu${m?` ${m}`:``}`,...s,...h,children:[/* @__PURE__ */ r(`div`,{className:`wui-column-menu-title`,children:p}),g.map(e=>/* @__PURE__ */ i(`label`,{className:`wui-column-menu-item`,children:[/* @__PURE__ */ r(`input`,{type:`checkbox`,className:`form-check-input`,checked:!d.includes(e.key),onChange:()=>f(e.key)}),e.label]},e.key))]})}export{o as default};
|
|
@@ -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 c from"./AppRowActions.js";import l from"./AppSkeleton.js";import u from"./AppTablePagination.js";import d from"./assertValidValue.js";import f from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as p,COLUMN_MIN_WIDTH as te,PIN_AT_VAR as m,PIN_SIDES as ne,ROW_HEIGHTS as re,ROW_MOVE_LIMIT as ie,ROW_SAVE_ERROR_CLASS as ae,attachRowDrag as oe,attachScrollEdges as se,downloadTable as ce,groupCount as le,groupItems as ue,isImeSafeEnter as de,measureRows as fe,pinAtValue as pe,pinClasses as me,planPins as he,playRowMoves as ge,rowOrderChanged as _e,saveOutcomeText as ve,settledRows as ye,syncTargets as be,tableCsv as xe,tableXlsx as Se,virtualRange as Ce}from"@webority/ui-elements/helpers";import{Children as we,Fragment as Te,isValidElement as Ee,useCallback as De,useEffect as h,useLayoutEffect as Oe,useMemo as ke,useRef as g,useState as _}from"react";import{Fragment as Ae,jsx as v,jsxs as y}from"react/jsx-runtime";import{DATA_TABLE_TEXT as je,ROW_ACTIONS_TEXT as Me,fillText as Ne,pluralText as Pe}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Fe}from"@webority/theme/runtime";var Ie=()=>import(`@webority/ui-elements/elements/data-table`),Le=[`comfortable`,`cozy`,`compact`],Re=[`hover`,`hover-menu`,`column`],ze=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,Be=[`auto`,`fixed`],Ve=[`hover`,`always`],He=[`hide`,`show`],Ue=[1,2,3,4],We=e=>typeof e==`number`?`${e}px`:e;function Ge(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[We(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function b(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ke(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Ee(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function qe(e,t){return Ke(b(e,t),t)}var Je=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},x=/* @__PURE__ */ new Set;function S(t,n){!x.has(t)&&Je()&&(x.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Ye=100,Xe=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ze=()=>{},Qe=()=>({total:0,keys:[]}),$e=[],et=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function C(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function tt(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function nt(e){return e==null||e===``?t():Array.isArray(e)?we.toArray(e):typeof e==`boolean`?String(e):e}function rt(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function w(e){n(`wui-data-table`,Ie);let t=r(`dataTable`,je),we=r(`rowActions`,Me),Ee=e=>e?Ne(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:We,props:Je}=i(`AppDataTable`,e),{columns:x,rows:w=$e,rowKey:it=Xe,sort:at,onSort:ot,sortIcons:st=`hover`,emptyHeader:ct=`hide`,loading:T=!1,refreshing:lt=!1,skeletonRows:ut=5,empty:dt=t.empty,emptyFiltered:ft,error:pt,onRetry:mt,sourceCount:ht,rowActions:E,linkComponent:gt,rowActionsLabel:_t,pagination:D,ariaLabel:vt,className:yt=``,wrapperClassName:bt=``,selectable:O=!1,selectedIds:k,isRowSelectable:xt,onToggleRow:St,onToggleAll:Ct,onSelectRange:wt,renderExpanded:Tt,singleExpand:Et=!1,density:Dt=`cozy`,densitySwitch:Ot=!1,exportable:kt=!1,exportName:At=`table`,onExport:jt,tableLayout:Mt=`auto`,striped:Nt=!1,flush:Pt=!1,pad:Ft,nameLines:A,headerTone:It,rowDrag:j=!1,maxHeight:Lt,stickyFirstColumn:Rt=!1,stickyActions:zt=!1,equalActions:Bt=!1,linkFirstColumn:Vt=!1,stackOnMobile:M=!1,hiddenColumns:Ht,rowStatus:Ut,rowTone:Wt,rowActionsMode:Gt=`hover`,rowHref:N,onRowClick:Kt,activeRowKey:qt,hoverRowKey:Jt,resizableColumns:P=!1,viewKey:Yt,groupBy:F,groupLabel:Xt,virtual:I=!1,rowSaving:L,rowSaveError:Zt,...Qt}=Je;f(`AppDataTable`,Qt);let{style:$t,...en}=Qt,R=De((e,t)=>{let n=it(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[it]),tn=Ht?.length?new Set(Ht):null;x=tn?x.filter(e=>!(e.hideable&&tn.has(e.key))):x,d(`AppDataTable`,`density`,Dt,Le),d(`AppDataTable`,`rowActionsMode`,Gt,Re),d(`AppDataTable`,`tableLayout`,Mt,Be),d(`AppDataTable`,`sortIcons`,st,Ve),d(`AppDataTable`,`emptyHeader`,ct,He),d(`AppDataTable`,`nameLines`,A,Ue);for(let e of x)d(`AppDataTable`,`column.pin`,e.pin,ne);let z=typeof N==`function`||typeof Kt==`function`,[nn,rn]=_(null),B=Ot&&nn?nn:Dt,an=[`table table-ledger`,B===`cozy`||B===`compact`?`wui-table-${B}`:``,Gt===`hover-menu`?`wui-table-actions-menu`:``,Gt===`column`?`wui-table-actions-column`:``,Nt?`wui-table-striped`:``,Rt?`wui-table-sticky-first`:``,st===`always`?`wui-sort-icons-always`:``,ct===`show`?`wui-table-empty-header`:``,zt?`wui-table-sticky-actions`:``,Bt?`wui-table-equal-actions`:``,M?`wui-table-stack`:``,Vt&&z?`wui-table-link-first`:``,yt].filter(Boolean).join(` `),V=typeof Tt==`function`,[on,sn]=_(()=>/* @__PURE__ */ new Set),cn=e=>sn(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return Et?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),ln=x.some(e=>typeof e.footer==`function`),un=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),dn=(e,t)=>{if(un(t)||(Kt&&Kt(e),!N))return;let n=N(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},fn=Lt!==void 0,pn=lt&&!T&&w.length>0,mn=[`table-wrap`,fn?`wui-table-scroll`:``,Pt?`wui-table-flush`:``,pn?`wui-table-refreshing`:``,bt].filter(Boolean).join(` `),hn={maxHeight:fn?Lt:void 0,"--wui-table-pad":Ft!=null&&!Pt?`${Ft}px`:void 0,"--wui-name-lines":I?`1`:A?.toString(),"--wui-table-header-bg":It??void 0},gn=Object.values(hn).some(e=>e!==void 0)||$t!==void 0?{...hn,...$t}:void 0,_n=Math.max(1,x.length+ +!!E+ +!!O+ +!!V),vn=x.some(e=>e.pin===`start`||e.pin===`end`),yn=vn||P||!!F||I||kt||Ot,H=+!!V+ +!!O,bn=vn?he([...V?[`lead`]:[],...O?[`lead`]:[],...x.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...E?[null]:[]]):[],U=(e,t=``)=>{let n=bn[e];return n?{className:`${t.trim()} ${me(n)}`.trim(),style:{[m]:pe(n.side,n.ordinal)}}:{className:t,style:void 0}},xn=(e,t)=>bn[e]?{...t,...U(e).style}:t,Sn=x.length-1+ +!!E;Yt&&!P&&S(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),I&&!fn&&S(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),I&&(V||M)&&S(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),I&&A!==void 0&&A!==1&&S(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),Vt&&!z&&S(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),Et&&typeof Tt!=`function`&&S(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!I&&w?.length>500&&S(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=I&&fn&&!V&&!M&&!T&&w?.length>0,G=(e,t)=>!xt||!!xt(e,t),Cn=O&&w?w.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=O&&w?w.reduce((e,t,n)=>e+(G(t,n)&&k?.has(R(t,n))?1:0),0):0,wn=Cn>0&&K===Cn,Tn=K>0&&!wn,En=e=>{e&&(e.indeterminate=Tn)},Dn=g(null),On=(e,t)=>{let n=Dn.current;Dn.current=e;let r=t&&n!==null?w.findIndex((e,t)=>R(e,t)===n):-1,i=w.findIndex((t,n)=>R(t,n)===e);if(r<0||i<0||r===i){St?.(e);return}let a=!k?.has(e),o=Math.min(r,i),s=w.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>R(e,t)).filter(e=>(k?.has(e)||!1)!==a);if(wt)wt(s,a);else for(let e of s)St?.(e)},kn=e=>{xt?(w||[]).forEach((t,n)=>{let r=R(t,n);G(t,n)&&(k?.has(r)||!1)!==e&&St?.(r)}):Ct?.(e)},[An,jn]=_(()=>/* @__PURE__ */ new Set),Mn=e=>jn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=ke(()=>{let e=(w||[]).map((e,t)=>({row:e,i:t}));return F?ue(e,({row:e})=>String(b(e,F)??``)).flatMap(e=>[{group:e,open:!An.has(e.key)},...An.has(e.key)?[]:e.items]):e},[w,F,An]),Nn=g(null),[J,Pn]=_(null),Fn=De(e=>{Nn.current=e,Pn(e)},[]),In=g(null);h(()=>{let e=J;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;In.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(In.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=se(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[J]),h(()=>{if(!j||!J)return;let e=oe(J);return be(document),e},[j,J]);let Ln=g(Qe);Oe(()=>{Ln.current=()=>({total:w?.length??0,keys:w?w.flatMap((e,t)=>{let n=R(e,t);return G(e,t)&&k?.has(n)?[String(n)]:[]}):[]})});let Rn=g(!1);h(()=>{if(!Rn.current&&(Rn.current=!0,K===0))return;let{total:e,keys:t}=Ln.current();Nn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[zn,Bn]=_({top:0,height:0}),[Vn,Hn]=_(re[B]??re.cozy);h(()=>{let e=J;if(!W||!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};Bn(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)}},[W,J]);let Un=g(null);Oe(()=>{if(!W){Un.current=null;return}let e=`${B}:${w?.length??0}`;if(Un.current===e)return;Un.current=e;let t=(Nn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Vn)>.5&&Hn(t)});let Y={start:0,end:q.length,before:0,after:0};if(W){Y=Ce({scrollTop:zn.top,viewport:zn.height||Number.parseFloat(String(Lt))||0,rowHeight:Vn,count:q.length});let e=In.current;e!==null&&e>=0&&e<q.length&&(e<Y.start&&Y.start-e<=Ye&&(Y={...Y,start:e,before:e*Vn}),e>=Y.end&&e-Y.end<Ye&&(Y={...Y,end:e+1,after:(q.length-e-1)*Vn}))}let Wn=g(null),Gn=g(null),Kn=g(null),qn=!I&&!T&&w?.length>0&&w.length<=ie;Oe(()=>{let e=Wn.current;if(!qn||!e){Gn.current=null,Kn.current=null;return}let t=w.map((e,t)=>R(e,t));_e(Kn.current,t)&&ge(e.rows,Gn.current),Gn.current=fe(e.rows),Kn.current=t});let Jn=typeof L==`function`||typeof Zt==`function`,Yn=g(null),Xn=g(null),X=x[0]?.key;h(()=>{if(!Jn){Xn.current=null;return}let e=/* @__PURE__ */ new Map;(w||[]).forEach((t,n)=>{let r=X===void 0?void 0:b(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(R(t,n),{...et(t,L,Zt),label:i})});let t=ve(ye(Xn.current,e));Xn.current=e,t&&Yn.current&&(Yn.current.textContent=t)},[w,L,Zt,R,Jn,X]);let Zn=ft!==void 0&&(ht===void 0||ht>0)?ft:dt,Z=!T&&pt?pt:null,Qn=e=>{if(jt){jt(e);return}let t=x.map(e=>typeof e.label==`string`?e.label:e.key),n=w.map(e=>x.map(t=>{let n=t.exportValue?t.exportValue(e):b(e,t.key);return n==null?``:String(n)}));e===`csv`?ce([xe(t,n)],`text/csv;charset=utf-8`,`${At}.csv`):ce([Se(t,n)],ze,`${At}.xlsx`)},$n=({group:e,open:n},r)=>{let i=b(e.items[0]?.row,F??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ v(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ v(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:_n,children:/* @__PURE__ */ y(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>Mn(e.key),children:[/* @__PURE__ */ v(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ v(`span`,{className:`wui-group-label`,children:Xt?Xt(i,a):nt(Ke(i,F??``))}),/* @__PURE__ */ v(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:le(e.items.length)}),/* @__PURE__ */ v(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Pe(t,`groupRows`,e.items.length,{count:le(e.items.length)})}`})]})})},`group:${e.key}`)},er=({row:e,i:n},r)=>{let i=R(e,n),a=V&&on.has(i),o=qt!=null&&String(qt)===String(i),ee=Jt!=null&&String(Jt)===String(i),l=String(i).replace(/[^a-z0-9]/gi,`_`),u=U(0,`wui-expand-cell`),d=U(+!!V,`wui-select-cell`),f=Jn?et(e,L,Zt):null,p=G(e,n),te=E?.(e);if(E&&!Array.isArray(te))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.mjs --check.`);let m=X===void 0?void 0:b(e,X),ne=typeof m==`string`||typeof m==`number`?Ne(t.moreActionsForText,{firstValue:m}):we.menuLabel;return/* @__PURE__ */ y(Te,{children:[/* @__PURE__ */ y(`tr`,{className:[O&&p&&k?.has(i)?`is-selected`:``,z?`wui-row-link`:``,o?`wui-row-active`:``,ee?Fe.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":f?.state===`saving`?`true`:void 0,"data-wui-save-state":f?.state||void 0,"data-status":Ut?.(e)||void 0,"data-tone":Wt?.(e)||void 0,"data-href":N?.(e)||void 0,"data-row-key":j?String(i):void 0,tabIndex:z?0:void 0,onClick:z?t=>dn(e,t):void 0,onAuxClick:z&&N?t=>t.button===1&&dn(e,t):void 0,onKeyDown:z?t=>{de(t.nativeEvent)&&t.target===t.currentTarget&&dn(e,t)}:void 0,children:[V&&/* @__PURE__ */ v(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${l}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>cn(i),children:/* @__PURE__ */ v(s,{name:`chevron-down`,size:16})})}),O&&/* @__PURE__ */ v(`td`,{className:d.className,style:d.style,children:/* @__PURE__ */ v(`input`,{type:`checkbox`,className:`wui-check`,checked:p&&(k?.has(i)||!1),disabled:!p,onChange:e=>On(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),x.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ y(r,{scope:t.rowHeader?`row`:void 0,className:U(H+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+C(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:xn(H+n,t.cellStyle),"data-label":M&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):nt(qe(e,t.key)),n===0&&f?.state===`error`&&/* @__PURE__ */ v(`span`,{className:ae,children:f.message})]},t.key)}),E&&/* @__PURE__ */ v(`td`,{children:/* @__PURE__ */ v(c,{items:te??[],menuLabel:ne,linkComponent:gt})})]}),a&&/* @__PURE__ */ v(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ v(`td`,{id:`${l}-expanded`,colSpan:_n,children:Tt?.(e)})})]},i)},tr=(e,t)=>`group`in e?$n(e,t):er(e,t),nr=(e,t)=>W?/* @__PURE__ */ v(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ v(`td`,{colSpan:_n,style:{height:t}})},e):null,Q=U(0,`wui-expand-cell`),$=U(+!!V,`wui-select-cell`),rr=()=>Array.from({length:ut},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ y(`tr`,{children:[V&&/* @__PURE__ */ v(`td`,{className:Q.className,style:Q.style}),O&&/* @__PURE__ */ v(`td`,{className:$.className,style:$.style}),x.map((e,t)=>/* @__PURE__ */ v(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+C(e.align)).className,style:xn(H+t,void 0),"data-label":M&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ v(l,{width:tt(e.align),height:12,radius:6})},e.key)),E&&/* @__PURE__ */ v(`td`,{children:/* @__PURE__ */ v(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ v(l,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ y(Ae,{children:[/* @__PURE__ */ y(yn?`wui-data-table`:`div`,{ref:Fn,...yn?{class:mn,resizable:P?``:void 0,"view-key":Yt||void 0,"data-wui-row-drag":j?``:void 0,"aria-busy":pn||void 0}:{className:mn,"data-wui-row-drag":j?``:void 0,"aria-busy":pn||void 0},style:gn,tabIndex:0,...We,...en,children:[kt&&/* @__PURE__ */ y(`div`,{className:`wui-table-export`,children:[/* @__PURE__ */ v(a,{variant:`soft`,size:`sm`,onClick:()=>Qn(`csv`),children:t.exportCsvLabel}),/* @__PURE__ */ v(a,{variant:`soft`,size:`sm`,onClick:()=>Qn(`xlsx`),children:t.exportExcelLabel})]}),Ot&&/* @__PURE__ */ y(`div`,{className:`wui-table-density`,role:`group`,"aria-label":t.densityLabel,children:[/* @__PURE__ */ v(a,{variant:`soft`,size:`sm`,"aria-pressed":B===`comfortable`,"aria-label":t.densityComfortableLabel,onClick:()=>rn(`comfortable`),children:/* @__PURE__ */ v(s,{name:`list`,size:16})}),/* @__PURE__ */ v(a,{variant:`soft`,size:`sm`,"aria-pressed":B===`compact`,"aria-label":t.densityCompactLabel,onClick:()=>rn(`compact`),children:/* @__PURE__ */ v(s,{name:`grid`,size:16})})]}),/* @__PURE__ */ y(`table`,{className:an,"aria-label":vt,"aria-rowcount":W?q.length+1:void 0,style:Mt===`fixed`?{tableLayout:`fixed`,minWidth:Ge(x)}:void 0,children:[/* @__PURE__ */ v(`thead`,{children:/* @__PURE__ */ y(`tr`,{"aria-rowindex":W?1:void 0,children:[V&&/* @__PURE__ */ v(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ v(`span`,{className:`visually-hidden`,children:t.expandLabel})}),O&&/* @__PURE__ */ v(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ v(`input`,{ref:En,type:`checkbox`,className:`wui-check`,checked:wn,disabled:T,onChange:e=>kn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),x.map((e,t)=>{let n=e.sortable?ot:void 0,r=n!==void 0,i=at&&at.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ v(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ v(s,{name:`chevrons-up-down`,size:14})}),c=P&&t!==Sn,l=Mt===`fixed`&&!e.grow?e.minWidth:void 0,u=e.width||e.minWidth?{width:e.width??l,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ y(`th`,{className:U(H+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(c?`wui-col-resizable `:``)+C(e.align)).className,style:xn(H+t,u),"data-key":yn?e.key:void 0,"aria-label":c&&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?at?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||T||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(de(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),T||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ v(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,c&&/* @__PURE__ */ v(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":te,"aria-valuemax":p,tabIndex:0,"aria-label":Ee(typeof e.label==`string`?e.label:e.key)})]},e.key)}),E&&(_t?/* @__PURE__ */ v(`th`,{className:`wui-cell-end`,children:_t}):/* @__PURE__ */ v(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ v(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ v(`tbody`,{ref:Wn,children:T?rr():Z?null:w?.length?/* @__PURE__ */ y(Ae,{children:[nr(`before`,Y.before),q.slice(Y.start,Y.end).map((e,t)=>tr(e,Y.start+t)),nr(`after`,Y.after)]}):null}),ln&&!T&&!Z&&w?.length>0&&/* @__PURE__ */ v(`tfoot`,{children:/* @__PURE__ */ y(`tr`,{children:[V&&/* @__PURE__ */ v(`td`,{className:Q.className,style:Q.style}),O&&/* @__PURE__ */ v(`td`,{className:$.className,style:$.style}),x.map((e,t)=>/* @__PURE__ */ v(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+C(e.align)).className,style:xn(H+t,void 0),children:e.footer?e.footer(w):null},e.key)),E&&/* @__PURE__ */ v(`td`,{})]})})]}),!T&&(Z||!w?.length)&&/* @__PURE__ */ v(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ v(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:mt?/* @__PURE__ */ v(a,{variant:`soft`,size:`sm`,onClick:()=>mt(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Zn==`string`?/* @__PURE__ */ v(`div`,{className:`tbl-empty-plain`,children:Zn}):Zn})]}),rt(D)&&/* @__PURE__ */ v(u,{page:D.page,totalPages:D.totalPages,total:D.total,pageSize:D.pageSize,onPageChange:T?Ze:D.setPage,onPageSizeChange:T?Ze:D.setPageSize,pageSizes:D.pageSizes,mode:D.mode,summary:D.summary}),Jn&&/* @__PURE__ */ v(`div`,{ref:Yn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{w 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{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{BOX_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import{useFieldError as a}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import te from"../lib/useWuiText.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import re from"./AppInfoTip.js";import ie from"./AppRequiredMark.js";import ae from"./AppSpinner.js";import oe from"./assertValidValue.js";import se from"./warnUnknownProps.js";import ce from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as le,acceptDroppedFiles as ue,acceptLabel as s,isImageFile as c,isImageOnlyAccept as de,isPdfFile as fe}from"@webority/ui-elements/helpers";import{useEffect as l,useId as pe,useRef as me,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{FILE_PICKER_TEXT as he,fillText as p}from"@webority/ui-elements/text";var ge=[`dropzone`,`button`],_e={sm:` wui-input-sm`,md:``,lg:` wui-input-lg`}
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{BOX_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import{useFieldError as a}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import te from"../lib/useWuiText.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import re from"./AppInfoTip.js";import ie from"./AppRequiredMark.js";import ae from"./AppSpinner.js";import oe from"./assertValidValue.js";import se from"./warnUnknownProps.js";import ce from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as le,acceptDroppedFiles as ue,acceptLabel as s,isImageFile as c,isImageOnlyAccept as de,isPdfFile as fe}from"@webority/ui-elements/helpers";import{useEffect as l,useId as pe,useRef as me,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{FILE_PICKER_TEXT as he,fillText as p}from"@webority/ui-elements/text";var ge=[`dropzone`,`button`],_e={sm:` wui-input-sm`,md:``,lg:` wui-input-lg`};function m(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function h(h){let{marker:ve,props:ye}=ne(`AppFilePicker`,h),g=te(`filePicker`,he),{label:_,value:v,name:be,id:xe,onChange:Se,multiple:y=!1,variant:b=`dropzone`,buttonLabel:Ce=g.buttonLabel,browseLabel:we=g.browseLabel,dropLabel:Te=g.dropLabel,maxSizeText:Ee=g.maxSizeText,optionalLabel:De=g.optionalLabel,changeImageLabel:Oe=g.changeImageLabel,changeFileLabel:ke=g.changeFileLabel,maxFilesText:Ae=g.maxFilesText,removeFileLabel:je=g.removeFileLabel,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=le,required:w,optional:Me=!1,error:Ne,helperText:T,help:E,helpLabel:Pe=g.helpLabel,loading:D=!1,readOnly:O=!1,size:k,disabled:A=!1,className:j=``,fieldClassName:M=``,style:N,...P}=ye,Fe=a(be),Ie=Ne??Fe;if(se(`AppFilePicker`,P),oe(`AppFilePicker`,`variant`,b,ge),oe(`AppFilePicker`,`size`,k,r),!y&&Array.isArray(v))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let F=k===void 0?``:_e[k]??``,I=O?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Le,L]=u(null),[Re,R]=u(null),[z,ze]=u(null),[Be,B]=u(``),V=me(null),Ve=pe(),H=xe||Ve,U=A||D;l(()=>{if(!y&&v instanceof File&&c(v)){let e=URL.createObjectURL(v);return L(e),()=>URL.revokeObjectURL(e)}L(null)},[v,y]);let W=y||Array.isArray(v)?void 0:v,G=W&&!c(m(W))&&fe(m(W))?W instanceof File?W:W.url:null;l(()=>{if(!G){R(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof G==`string`?{url:G}:G)).then(e=>{t&&(n=URL.createObjectURL(e),R(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,R(null),n&&URL.revokeObjectURL(n)}},[G]);let K=y?Array.isArray(v)?v:v?[v]:[]:[],q=Ie||Be,He=q?`${H}-error`:void 0,Ue=T&&!q?`${H}-hint`:void 0,We=He||Ue,Ge=de(S),Ke=b===`button`,qe=`btn btn-outline-primary${k===`sm`?` btn-sm`:k===`lg`?` btn-lg`:``}`,Je=!y&&!!v,J=!!W&&(W instanceof File?c(W):Ge||c(m(W))),Ye=W?.name,Xe=W instanceof File?void 0:W?.url,Y=J?Xe||Le:Re,X=J?g.imageLabel:g.fileLabel,Ze=p(g.changeNamedText,{label:_||X}),Qe=p(g.removeNamedText,{label:_||X}),$e=_?p(g.previewAltText,{label:_}):p(g.selectedPreviewText,{noun:X}),et={accept:S,maxSizeMb:C,multiple:y},tt=e=>{h.multiple||h.onChange(e)},nt=e=>{h.multiple&&h.onChange(e)},rt=e=>{if(B(``),!y){tt(e[0]??null);return}let t=Array.isArray(v)?v:v?[v]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let a=t.concat(r);x&&a.length>x&&(a=a.slice(0,x),B(p(Ae,{count:x}))),nt(a)},Z=e=>B(e.message),{dragOver:it,dropProps:at}=ee({...et,disabled:U||O,onFiles:rt,onReject:Z}),ot=e=>{if(O)return;let{files:t,rejections:n}=ue(e,et);t.length&&rt(t);let[r]=n;r&&Z(r)},st=e=>ot(e.target.files),ct=e=>{O||(B(``),nt(K.filter((t,n)=>n!==e)))},lt=()=>{O||V.current?.click()},Q=D?/* @__PURE__ */ d(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ d(ae,{size:`sm`})}):null,$=/* @__PURE__ */ d(`input`,{id:H,name:be,ref:V,type:`file`,"aria-describedby":We,accept:S,multiple:y||void 0,disabled:U||void 0,className:`visually-hidden`,onClick:e=>{O?e.preventDefault():e.currentTarget.value=``},onChange:st,...P});return/* @__PURE__ */ f(`div`,{...ve,className:`field${M?` ${M}`:``}`,children:[_?/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:H,children:[_,Me&&!w&&/* @__PURE__ */ d(`span`,{className:`label-optional`,children:` ${De}`}),w&&/* @__PURE__ */ d(ie,{}),E&&/* @__PURE__ */ d(re,{label:Pe,children:E})]}):null,Ke?/* @__PURE__ */ f(`div`,{className:`file-input wui-file-input-button-field${F}${q?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ f(`label`,{htmlFor:H,className:qe,children:[/* @__PURE__ */ d(o,{name:`paperclip`,size:16}),Ce]}),$,Q]}):Je?/* @__PURE__ */ f(`div`,{className:`file-preview${F}${q?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Ze,onClick:lt,disabled:U||O,children:[Y?/* @__PURE__ */ d(`img`,{src:Y,alt:$e,className:`file-preview-img`,width:z?.src===Y?z.width:void 0,height:z?.src===Y?z.height:void 0,onLoad:e=>{let t=e.currentTarget;ze({src:Y,width:t.naturalWidth,height:t.naturalHeight})}}):/* @__PURE__ */ f(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ d(o,{name:`file-text`,size:28}),/* @__PURE__ */ d(`span`,{className:`file-preview-file-name`,children:Ye})]}),/* @__PURE__ */ d(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ f(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ d(o,{name:J?`image`:`file-text`,size:16}),` `,J?Oe:ke]})})]}),ce(/* @__PURE__ */ d(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":Qe,onClick:()=>tt(null),disabled:U||O,children:/* @__PURE__ */ d(o,{name:`x`,size:16})}),Qe),$,Q]}):/* @__PURE__ */ f(`div`,{className:`file-input file-input-tall${F}${it?` dragging`:``}${q?` error`:``}${y&&K.length>0?` has-files`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,"aria-disabled":A||void 0,...I,...at,children:[/* @__PURE__ */ f(`label`,{htmlFor:H,className:`file-input-zone-label`,children:[/* @__PURE__ */ d(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ d(o,{name:`upload`,size:24})}),/* @__PURE__ */ f(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ d(`span`,{className:`browse`,children:we}),` ${Te}`]}),/* @__PURE__ */ d(`span`,{className:`file-input-text`,children:C>0?`${s(S)}, ${p(Ee,{size:C})}`:s(S)})]}),$,Q,y&&K.length>0&&/* @__PURE__ */ d(`div`,{className:`attach-list`,children:K.map((e,t)=>/* @__PURE__ */ d(n,{item:e,isImage:e instanceof File?c(e):Ge||c(m(e)),noun:g.fileLabel,removeFileLabel:je,readOnly:O,onRemove:()=>ct(t)},i(e)))})]}),/* @__PURE__ */ d(t,{error:q,hint:T,errorId:He,hintId:Ue})]})}export{h 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{TONES as e}from"../lib/vocabulary.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./assertValidValue.js";import r from"./warnUnknownProps.js";import{cloneElement as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";var s=[`high`,`low`],c=[`sm`,`md`],l=e.filter(e=>e!==`primary`);function u(e,t,n){let r=n-t;if(!(r>0))return 0;let i=Math.min(100,Math.max(0,(e-t)/r*100));return Number(i.toFixed(2))}function d(e,t,n,r,i){if(t==null&&n==null)return i;let a=`mid`;return t!=null&&e<=t?a=`low`:n!=null&&e>=n&&(a=`high`),r===`low`?a===`low`?`success`:a===`high`?`danger`:`warning`:a===`high`?`success`:a===`low`?`danger`:`warning`}function f(e){let{marker:f,props:p}=t(`AppMeter`,e),{value:m=0,min:h=0,max:g=100,tone:_=`info`,optimum:v=`high`,low:y,high:b,size:x=`md`,label:S,showLabel:C=!1,className:w=``,...T}=p;r(`AppMeter`,T),n(`AppMeter`,`tone`,_,l),n(`AppMeter`,`optimum`,v,s),n(`AppMeter`,`size`,x,c);let E=d(m,y,b,v,
|
|
1
|
+
import{TONES as e}from"../lib/vocabulary.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./assertValidValue.js";import r from"./warnUnknownProps.js";import{cloneElement as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";var s=[`high`,`low`],c=[`sm`,`md`],l=e.filter(e=>e!==`primary`);function u(e,t,n){let r=n-t;if(!(r>0))return 0;let i=Math.min(100,Math.max(0,(e-t)/r*100));return Number(i.toFixed(2))}function d(e,t,n,r,i){if(t==null&&n==null)return i;let a=`mid`;return t!=null&&e<=t?a=`low`:n!=null&&e>=n&&(a=`high`),r===`low`?a===`low`?`success`:a===`high`?`danger`:`warning`:a===`high`?`success`:a===`low`?`danger`:`warning`}function f(e){let{marker:f,props:p}=t(`AppMeter`,e),{value:m=0,min:h=0,max:g=100,tone:_=`info`,optimum:v=`high`,low:y,high:b,size:x=`md`,label:S,showLabel:C=!1,className:w=``,...T}=p;r(`AppMeter`,T),n(`AppMeter`,`tone`,_,l),n(`AppMeter`,`optimum`,v,s),n(`AppMeter`,`size`,x,c);let E=d(m,y,b,v,_),D=u(m,h,g),O=C&&!!S,k=`progress${x===`sm`?` progress-sm`:``}${!O&&w?` ${w}`:``}`,A=/* @__PURE__ */ a(`div`,{className:k,role:`meter`,"aria-valuenow":m,"aria-valuemin":h,"aria-valuemax":g,"aria-label":S||void 0,...T,children:/* @__PURE__ */ a(`div`,{className:`progress-bar wui-progress-${E}`,style:{width:`${D}%`}})});return O?/* @__PURE__ */ o(`div`,{...f,className:`wui-progress-labelled${w?` ${w}`:``}`,children:[/* @__PURE__ */ a(`div`,{className:`wui-progress-label`,"aria-hidden":`true`,children:S}),A]}):i(A,f)}export{f as default};
|